Path: blob/master/editor/scene/2d/tiles/tile_set_editor.h
21733 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 "editor/docks/editor_dock.h"34#include "scene/gui/tab_bar.h"35#include "scene/resources/2d/tile_set.h"36#include "tile_proxies_manager_dialog.h"37#include "tile_set_atlas_source_editor.h"38#include "tile_set_scenes_collection_source_editor.h"3940class AcceptDialog;41class SpinBox;42class HBoxContainer;43class SplitContainer;44class EditorFileDialog;45class EditorInspectorPlugin;46class TileSetSourceItemList;4748class TileSetEditor : public EditorDock {49GDCLASS(TileSetEditor, EditorDock);5051static TileSetEditor *singleton;5253private:54bool read_only = false;5556Ref<TileSet> tile_set;57bool tile_set_changed_needs_update = false;58HSplitContainer *split_container = nullptr;5960// TabBar.61HBoxContainer *tile_set_toolbar = nullptr;62TabBar *tabs_bar = nullptr;6364// Tiles.65Label *no_source_selected_label = nullptr;66TileSetAtlasSourceEditor *tile_set_atlas_source_editor = nullptr;67TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr;6869void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);70bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;71void _load_texture_files(const Vector<String> &p_paths);7273void _update_sources_list(int force_selected_id = -1);7475// Sources management.76Button *sources_delete_button = nullptr;77MenuButton *sources_add_button = nullptr;78MenuButton *source_sort_button = nullptr;79MenuButton *sources_advanced_menu_button = nullptr;80TileSetSourceItemList *sources_list = nullptr;81Ref<Texture2D> missing_texture_texture;82void _source_selected(int p_source_index);83void _source_delete_pressed();84void _source_add_id_pressed(int p_id_pressed);85void _sources_advanced_menu_id_pressed(int p_id_pressed);86void _set_source_sort(int p_sort);8788EditorFileDialog *texture_file_dialog = nullptr;89AtlasMergingDialog *atlas_merging_dialog = nullptr;90TileProxiesManagerDialog *tile_proxies_manager_dialog = nullptr;9192bool first_edit = true;9394// Patterns.95MarginContainer *patterns_mc = nullptr;96ItemList *patterns_item_list = nullptr;97Label *patterns_help_label = nullptr;98void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event);99void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture);100void _update_patterns_list();101102// Expanded editor.103PanelContainer *expanded_area = nullptr;104Control *expanded_editor = nullptr;105ObjectID expanded_editor_parent;106LocalVector<SplitContainer *> disable_on_expand;107108void _tile_set_changed();109void _tab_changed(int p_tab_changed);110111void _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);112void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value);113114protected:115void _notification(int p_what);116117public:118_FORCE_INLINE_ static TileSetEditor *get_singleton() { return singleton; }119120void edit(Ref<TileSet> p_tile_set);121122void add_expanded_editor(Control *p_editor);123void remove_expanded_editor();124void register_split(SplitContainer *p_split);125126TileSetEditor();127};128129class TileSourceInspectorPlugin : public EditorInspectorPlugin {130GDCLASS(TileSourceInspectorPlugin, EditorInspectorPlugin);131132AcceptDialog *id_edit_dialog = nullptr;133Label *id_label = nullptr;134SpinBox *id_input = nullptr;135Object *edited_source = nullptr;136137void _show_id_edit_dialog(Object *p_for_source);138void _confirm_change_id();139140public:141virtual bool can_handle(Object *p_object) override;142virtual 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;143};144145146