Path: blob/master/editor/scene/2d/tiles/tile_set_editor.h
9906 views
/**************************************************************************/1/* tile_set_editor.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "atlas_merging_dialog.h"33#include "scene/gui/tab_bar.h"34#include "scene/resources/2d/tile_set.h"35#include "tile_proxies_manager_dialog.h"36#include "tile_set_atlas_source_editor.h"37#include "tile_set_scenes_collection_source_editor.h"3839class AcceptDialog;40class SpinBox;41class HBoxContainer;42class SplitContainer;43class EditorFileDialog;44class EditorInspectorPlugin;4546class TileSetEditor : public MarginContainer {47GDCLASS(TileSetEditor, MarginContainer);4849static TileSetEditor *singleton;5051private:52bool read_only = false;5354Ref<TileSet> tile_set;55bool tile_set_changed_needs_update = false;56HSplitContainer *split_container = nullptr;5758// TabBar.59HBoxContainer *tile_set_toolbar = nullptr;60TabBar *tabs_bar = nullptr;6162// Tiles.63Label *no_source_selected_label = nullptr;64TileSetAtlasSourceEditor *tile_set_atlas_source_editor = nullptr;65TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr;6667void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);68bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;69void _load_texture_files(const Vector<String> &p_paths);7071void _update_sources_list(int force_selected_id = -1);7273// Sources management.74Button *sources_delete_button = nullptr;75MenuButton *sources_add_button = nullptr;76MenuButton *source_sort_button = nullptr;77MenuButton *sources_advanced_menu_button = nullptr;78ItemList *sources_list = nullptr;79Ref<Texture2D> missing_texture_texture;80void _source_selected(int p_source_index);81void _source_delete_pressed();82void _source_add_id_pressed(int p_id_pressed);83void _sources_advanced_menu_id_pressed(int p_id_pressed);84void _set_source_sort(int p_sort);8586EditorFileDialog *texture_file_dialog = nullptr;87AtlasMergingDialog *atlas_merging_dialog = nullptr;88TileProxiesManagerDialog *tile_proxies_manager_dialog = nullptr;8990bool first_edit = true;9192// Patterns.93ItemList *patterns_item_list = nullptr;94Label *patterns_help_label = nullptr;95void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event);96void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture);97bool select_last_pattern = false;98void _update_patterns_list();99100// Expanded editor.101PanelContainer *expanded_area = nullptr;102Control *expanded_editor = nullptr;103ObjectID expanded_editor_parent;104LocalVector<SplitContainer *> disable_on_expand;105106void _tile_set_changed();107void _tab_changed(int p_tab_changed);108109void _move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos);110void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value);111112protected:113void _notification(int p_what);114115public:116_FORCE_INLINE_ static TileSetEditor *get_singleton() { return singleton; }117118void edit(Ref<TileSet> p_tile_set);119120void add_expanded_editor(Control *p_editor);121void remove_expanded_editor();122void register_split(SplitContainer *p_split);123124TileSetEditor();125};126127class TileSourceInspectorPlugin : public EditorInspectorPlugin {128GDCLASS(TileSourceInspectorPlugin, EditorInspectorPlugin);129130AcceptDialog *id_edit_dialog = nullptr;131Label *id_label = nullptr;132SpinBox *id_input = nullptr;133Object *edited_source = nullptr;134135void _show_id_edit_dialog(Object *p_for_source);136void _confirm_change_id();137138public:139virtual bool can_handle(Object *p_object) override;140virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;141};142143144