mirror of
https://github.com/Relintai/tile_map_backport.git
synced 2024-11-09 03:12:09 +01:00
Prefix every editor plugin class With R, and add them to the build.
This commit is contained in:
parent
96f4de946d
commit
8ab8064f1b
7
SCsub
7
SCsub
@ -8,9 +8,6 @@ env.add_source_files(env.modules_sources,"array_lt_op.cpp")
|
||||
env.add_source_files(env.modules_sources,"rtile_set.cpp")
|
||||
env.add_source_files(env.modules_sources,"rtile_map.cpp")
|
||||
|
||||
#if env["tools"]:
|
||||
# env.add_source_files(env.modules_sources, "skeleton_editor_plugin_remover.cpp")
|
||||
# env.add_source_files(env.modules_sources, "skeleton_editor_plugin.cpp")
|
||||
# env.add_source_files(env.modules_sources, "spatial_editor_gizmos.cpp")
|
||||
# env.add_source_files(env.modules_sources, "skeleton_editor_module_plugin.cpp")
|
||||
if env["tools"]:
|
||||
env.add_source_files(env.modules_sources, "tile_editor/*.cpp")
|
||||
|
||||
|
@ -35,11 +35,11 @@
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/gui/split_container.h"
|
||||
|
||||
void AtlasMergingDialog::_property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) {
|
||||
void RAtlasMergingDialog::_property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) {
|
||||
_set(p_property, p_value);
|
||||
}
|
||||
|
||||
void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns) {
|
||||
void RAtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns) {
|
||||
merged.instantiate();
|
||||
merged_mapping.clear();
|
||||
|
||||
@ -124,7 +124,7 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla
|
||||
}
|
||||
}
|
||||
|
||||
void AtlasMergingDialog::_update_texture() {
|
||||
void RAtlasMergingDialog::_update_texture() {
|
||||
Vector<int> selected = atlas_merging_atlases_list->get_selected_items();
|
||||
if (selected.size() >= 2) {
|
||||
Vector<Ref<TileSetAtlasSource>> to_merge;
|
||||
@ -148,7 +148,7 @@ void AtlasMergingDialog::_update_texture() {
|
||||
}
|
||||
}
|
||||
|
||||
void AtlasMergingDialog::_merge_confirmed(String p_path) {
|
||||
void RAtlasMergingDialog::_merge_confirmed(String p_path) {
|
||||
ERR_FAIL_COND(!merged.is_valid());
|
||||
|
||||
Ref<ImageTexture> output_image_texture = merged->get_texture();
|
||||
@ -190,26 +190,26 @@ void AtlasMergingDialog::_merge_confirmed(String p_path) {
|
||||
hide();
|
||||
}
|
||||
|
||||
void AtlasMergingDialog::ok_pressed() {
|
||||
void RAtlasMergingDialog::ok_pressed() {
|
||||
delete_original_atlases = false;
|
||||
editor_file_dialog->popup_file_dialog();
|
||||
}
|
||||
|
||||
void AtlasMergingDialog::cancel_pressed() {
|
||||
void RAtlasMergingDialog::cancel_pressed() {
|
||||
for (int i = 0; i < commited_actions_count; i++) {
|
||||
undo_redo->undo();
|
||||
}
|
||||
commited_actions_count = 0;
|
||||
}
|
||||
|
||||
void AtlasMergingDialog::custom_action(const String &p_action) {
|
||||
void RAtlasMergingDialog::custom_action(const String &p_action) {
|
||||
if (p_action == "merge") {
|
||||
delete_original_atlases = true;
|
||||
editor_file_dialog->popup_file_dialog();
|
||||
}
|
||||
}
|
||||
|
||||
bool AtlasMergingDialog::_set(const StringName &p_name, const Variant &p_value) {
|
||||
bool RAtlasMergingDialog::_set(const StringName &p_name, const Variant &p_value) {
|
||||
if (p_name == "next_line_after_column" && p_value.get_type() == Variant::INT) {
|
||||
next_line_after_column = p_value;
|
||||
_update_texture();
|
||||
@ -218,7 +218,7 @@ bool AtlasMergingDialog::_set(const StringName &p_name, const Variant &p_value)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtlasMergingDialog::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
bool RAtlasMergingDialog::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (p_name == "next_line_after_column") {
|
||||
r_ret = next_line_after_column;
|
||||
return true;
|
||||
@ -226,7 +226,7 @@ bool AtlasMergingDialog::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void AtlasMergingDialog::update_tile_set(Ref<TileSet> p_tile_set) {
|
||||
void RAtlasMergingDialog::update_tile_set(Ref<TileSet> p_tile_set) {
|
||||
ERR_FAIL_COND(!p_tile_set.is_valid());
|
||||
tile_set = p_tile_set;
|
||||
|
||||
@ -250,7 +250,7 @@ void AtlasMergingDialog::update_tile_set(Ref<TileSet> p_tile_set) {
|
||||
commited_actions_count = 0;
|
||||
}
|
||||
|
||||
AtlasMergingDialog::AtlasMergingDialog() {
|
||||
RAtlasMergingDialog::RAtlasMergingDialog() {
|
||||
// Atlas merging window.
|
||||
set_title(TTR("Atlas Merging"));
|
||||
set_hide_on_ok(false);
|
||||
@ -274,7 +274,7 @@ AtlasMergingDialog::AtlasMergingDialog() {
|
||||
atlas_merging_atlases_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
|
||||
atlas_merging_atlases_list->set_custom_minimum_size(Size2(100, 200));
|
||||
atlas_merging_atlases_list->set_select_mode(ItemList::SELECT_MULTI);
|
||||
atlas_merging_atlases_list->connect("multi_selected", callable_mp(this, &AtlasMergingDialog::_update_texture).unbind(2));
|
||||
atlas_merging_atlases_list->connect("multi_selected", callable_mp(this, &RAtlasMergingDialog::_update_texture).unbind(2));
|
||||
atlas_merging_h_split_container->add_child(atlas_merging_atlases_list);
|
||||
|
||||
VBoxContainer *atlas_merging_right_panel = memnew(VBoxContainer);
|
||||
@ -290,7 +290,7 @@ AtlasMergingDialog::AtlasMergingDialog() {
|
||||
columns_editor_property->set_label(TTR("Next Line After Column"));
|
||||
columns_editor_property->set_object_and_property(this, "next_line_after_column");
|
||||
columns_editor_property->update_property();
|
||||
columns_editor_property->connect("property_changed", callable_mp(this, &AtlasMergingDialog::_property_changed));
|
||||
columns_editor_property->connect("property_changed", callable_mp(this, &RAtlasMergingDialog::_property_changed));
|
||||
atlas_merging_right_panel->add_child(columns_editor_property);
|
||||
|
||||
// Preview.
|
||||
@ -318,6 +318,6 @@ AtlasMergingDialog::AtlasMergingDialog() {
|
||||
editor_file_dialog = memnew(EditorFileDialog);
|
||||
editor_file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
|
||||
editor_file_dialog->add_filter("*.png");
|
||||
editor_file_dialog->connect("file_selected", callable_mp(this, &AtlasMergingDialog::_merge_confirmed));
|
||||
editor_file_dialog->connect("file_selected", callable_mp(this, &RAtlasMergingDialog::_merge_confirmed));
|
||||
add_child(editor_file_dialog);
|
||||
}
|
||||
|
@ -28,8 +28,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef ATLAS_MERGING_DIALOG_H
|
||||
#define ATLAS_MERGING_DIALOG_H
|
||||
#ifndef RATLAS_MERGING_DIALOG_H
|
||||
#define RATLAS_MERGING_DIALOG_H
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_properties.h"
|
||||
@ -39,8 +39,8 @@
|
||||
#include "scene/gui/texture_rect.h"
|
||||
#include "scene/resources/tile_set.h"
|
||||
|
||||
class AtlasMergingDialog : public ConfirmationDialog {
|
||||
GDCLASS(AtlasMergingDialog, ConfirmationDialog);
|
||||
class RAtlasMergingDialog : public ConfirmationDialog {
|
||||
GDCLASS(RAtlasMergingDialog, ConfirmationDialog);
|
||||
|
||||
private:
|
||||
int commited_actions_count = 0;
|
||||
@ -80,7 +80,7 @@ protected:
|
||||
public:
|
||||
void update_tile_set(Ref<TileSet> p_tile_set);
|
||||
|
||||
AtlasMergingDialog();
|
||||
RAtlasMergingDialog();
|
||||
};
|
||||
|
||||
#endif // ATLAS_MERGING_DIALOG_H
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "editor/editor_scale.h"
|
||||
#include "editor/editor_settings.h"
|
||||
|
||||
void TileAtlasView::gui_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileAtlasView::gui_input(const Ref<InputEvent> &p_event) {
|
||||
Ref<InputEventMouseButton> mb = p_event;
|
||||
if (mb.is_valid()) {
|
||||
drag_type = DRAG_TYPE_NONE;
|
||||
@ -90,7 +90,7 @@ void TileAtlasView::gui_input(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
}
|
||||
|
||||
Size2i TileAtlasView::_compute_base_tiles_control_size() {
|
||||
Size2i RTileAtlasView::_compute_base_tiles_control_size() {
|
||||
// Update the texture.
|
||||
Vector2i size;
|
||||
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
|
||||
@ -100,7 +100,7 @@ Size2i TileAtlasView::_compute_base_tiles_control_size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
Size2i TileAtlasView::_compute_alternative_tiles_control_size() {
|
||||
Size2i RTileAtlasView::_compute_alternative_tiles_control_size() {
|
||||
Vector2i size;
|
||||
for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) {
|
||||
Vector2i tile_id = tile_set_atlas_source->get_tile_id(i);
|
||||
@ -120,7 +120,7 @@ Size2i TileAtlasView::_compute_alternative_tiles_control_size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
void TileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) {
|
||||
void RTileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) {
|
||||
float zoom = zoom_widget->get_zoom();
|
||||
|
||||
// Compute the minimum sizes.
|
||||
@ -172,19 +172,19 @@ void TileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) {
|
||||
center_container->set_size(center_container->get_minimum_size());
|
||||
}
|
||||
|
||||
void TileAtlasView::_zoom_widget_changed() {
|
||||
void RTileAtlasView::_zoom_widget_changed() {
|
||||
_update_zoom_and_panning();
|
||||
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
|
||||
}
|
||||
|
||||
void TileAtlasView::_center_view() {
|
||||
void RTileAtlasView::_center_view() {
|
||||
panning = Vector2();
|
||||
button_center_view->set_disabled(true);
|
||||
_update_zoom_and_panning();
|
||||
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
|
||||
}
|
||||
|
||||
void TileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
base_tiles_root_control->set_tooltip("");
|
||||
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
@ -200,7 +200,7 @@ void TileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &p_
|
||||
}
|
||||
}
|
||||
|
||||
void TileAtlasView::_draw_base_tiles() {
|
||||
void RTileAtlasView::_draw_base_tiles() {
|
||||
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
|
||||
if (texture.is_valid()) {
|
||||
Vector2i margins = tile_set_atlas_source->get_margins();
|
||||
@ -291,7 +291,7 @@ void TileAtlasView::_draw_base_tiles() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileAtlasView::_draw_base_tiles_texture_grid() {
|
||||
void RTileAtlasView::_draw_base_tiles_texture_grid() {
|
||||
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
|
||||
if (texture.is_valid()) {
|
||||
Vector2i margins = tile_set_atlas_source->get_margins();
|
||||
@ -321,7 +321,7 @@ void TileAtlasView::_draw_base_tiles_texture_grid() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileAtlasView::_draw_base_tiles_shape_grid() {
|
||||
void RTileAtlasView::_draw_base_tiles_shape_grid() {
|
||||
// Draw the shapes.
|
||||
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||
Vector2i tile_shape_size = tile_set->get_tile_size();
|
||||
@ -343,7 +343,7 @@ void TileAtlasView::_draw_base_tiles_shape_grid() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileAtlasView::_alternative_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileAtlasView::_alternative_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
alternative_tiles_root_control->set_tooltip("");
|
||||
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
@ -358,7 +358,7 @@ void TileAtlasView::_alternative_tiles_root_control_gui_input(const Ref<InputEve
|
||||
}
|
||||
}
|
||||
|
||||
void TileAtlasView::_draw_alternatives() {
|
||||
void RTileAtlasView::_draw_alternatives() {
|
||||
// Draw the alternative tiles.
|
||||
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
|
||||
if (texture.is_valid()) {
|
||||
@ -397,19 +397,19 @@ void TileAtlasView::_draw_alternatives() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileAtlasView::_draw_background_left() {
|
||||
void RTileAtlasView::_draw_background_left() {
|
||||
Ref<Texture2D> texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"));
|
||||
background_left->set_size(base_tiles_root_control->get_custom_minimum_size());
|
||||
background_left->draw_texture_rect(texture, Rect2(Vector2(), background_left->get_size()), true);
|
||||
}
|
||||
|
||||
void TileAtlasView::_draw_background_right() {
|
||||
void RTileAtlasView::_draw_background_right() {
|
||||
Ref<Texture2D> texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"));
|
||||
background_right->set_size(alternative_tiles_root_control->get_custom_minimum_size());
|
||||
background_right->draw_texture_rect(texture, Rect2(Vector2(), background_right->get_size()), true);
|
||||
}
|
||||
|
||||
void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
|
||||
void RTileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
|
||||
ERR_FAIL_COND(!p_tile_set);
|
||||
ERR_FAIL_COND(!p_tile_set_atlas_source);
|
||||
ERR_FAIL_COND(p_source_id < 0);
|
||||
@ -456,22 +456,22 @@ void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_
|
||||
background_right->update();
|
||||
}
|
||||
|
||||
float TileAtlasView::get_zoom() const {
|
||||
float RTileAtlasView::get_zoom() const {
|
||||
return zoom_widget->get_zoom();
|
||||
};
|
||||
|
||||
void TileAtlasView::set_transform(float p_zoom, Vector2i p_panning) {
|
||||
void RTileAtlasView::set_transform(float p_zoom, Vector2i p_panning) {
|
||||
zoom_widget->set_zoom(p_zoom);
|
||||
panning = p_panning;
|
||||
_update_zoom_and_panning();
|
||||
};
|
||||
|
||||
void TileAtlasView::set_padding(Side p_side, int p_padding) {
|
||||
void RTileAtlasView::set_padding(Side p_side, int p_padding) {
|
||||
ERR_FAIL_COND(p_padding < 0);
|
||||
margin_container_paddings[p_side] = p_padding;
|
||||
}
|
||||
|
||||
Vector2i TileAtlasView::get_atlas_tile_coords_at_pos(const Vector2 p_pos) const {
|
||||
Vector2i RTileAtlasView::get_atlas_tile_coords_at_pos(const Vector2 p_pos) const {
|
||||
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
|
||||
if (texture.is_valid()) {
|
||||
Vector2i margins = tile_set_atlas_source->get_margins();
|
||||
@ -488,7 +488,7 @@ Vector2i TileAtlasView::get_atlas_tile_coords_at_pos(const Vector2 p_pos) const
|
||||
return TileSetSource::INVALID_ATLAS_COORDS;
|
||||
}
|
||||
|
||||
void TileAtlasView::_update_alternative_tiles_rect_cache() {
|
||||
void RTileAtlasView::_update_alternative_tiles_rect_cache() {
|
||||
alternative_tiles_rect_cache.clear();
|
||||
|
||||
Rect2i current;
|
||||
@ -518,7 +518,7 @@ void TileAtlasView::_update_alternative_tiles_rect_cache() {
|
||||
}
|
||||
}
|
||||
|
||||
Vector3i TileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const {
|
||||
Vector3i RTileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const {
|
||||
for (const KeyValue<Vector2, Map<int, Rect2i>> &E_coords : alternative_tiles_rect_cache) {
|
||||
for (const KeyValue<int, Rect2i> &E_alternative : E_coords.value) {
|
||||
if (E_alternative.value.has_point(p_pos)) {
|
||||
@ -530,14 +530,14 @@ Vector3i TileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const {
|
||||
return Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE);
|
||||
}
|
||||
|
||||
Rect2i TileAtlasView::get_alternative_tile_rect(const Vector2i p_coords, int p_alternative_tile) {
|
||||
Rect2i RTileAtlasView::get_alternative_tile_rect(const Vector2i p_coords, int p_alternative_tile) {
|
||||
ERR_FAIL_COND_V_MSG(!alternative_tiles_rect_cache.has(p_coords), Rect2i(), vformat("No cached rect for tile coords:%s", p_coords));
|
||||
ERR_FAIL_COND_V_MSG(!alternative_tiles_rect_cache[p_coords].has(p_alternative_tile), Rect2i(), vformat("No cached rect for tile coords:%s alternative_id:%d", p_coords, p_alternative_tile));
|
||||
|
||||
return alternative_tiles_rect_cache[p_coords][p_alternative_tile];
|
||||
}
|
||||
|
||||
void TileAtlasView::update() {
|
||||
void RTileAtlasView::update() {
|
||||
base_tiles_draw->update();
|
||||
base_tiles_texture_grid->update();
|
||||
base_tiles_shape_grid->update();
|
||||
@ -546,7 +546,7 @@ void TileAtlasView::update() {
|
||||
background_right->update();
|
||||
}
|
||||
|
||||
void TileAtlasView::_notification(int p_what) {
|
||||
void RTileAtlasView::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_READY:
|
||||
button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons")));
|
||||
@ -554,11 +554,11 @@ void TileAtlasView::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileAtlasView::_bind_methods() {
|
||||
void RTileAtlasView::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("transform_changed", PropertyInfo(Variant::FLOAT, "zoom"), PropertyInfo(Variant::VECTOR2, "scroll")));
|
||||
}
|
||||
|
||||
TileAtlasView::TileAtlasView() {
|
||||
RTileAtlasView::RTileAtlasView() {
|
||||
set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
|
||||
|
||||
Panel *panel = memnew(Panel);
|
||||
@ -573,12 +573,12 @@ TileAtlasView::TileAtlasView() {
|
||||
zoom_widget = memnew(EditorZoomWidget);
|
||||
add_child(zoom_widget);
|
||||
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
|
||||
zoom_widget->connect("zoom_changed", callable_mp(this, &TileAtlasView::_zoom_widget_changed).unbind(1));
|
||||
zoom_widget->connect("zoom_changed", callable_mp(this, &RTileAtlasView::_zoom_widget_changed).unbind(1));
|
||||
|
||||
button_center_view = memnew(Button);
|
||||
button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons")));
|
||||
button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5);
|
||||
button_center_view->connect("pressed", callable_mp(this, &TileAtlasView::_center_view));
|
||||
button_center_view->connect("pressed", callable_mp(this, &RTileAtlasView::_center_view));
|
||||
button_center_view->set_flat(true);
|
||||
button_center_view->set_disabled(true);
|
||||
button_center_view->set_tooltip(TTR("Center View"));
|
||||
@ -587,7 +587,7 @@ TileAtlasView::TileAtlasView() {
|
||||
center_container = memnew(CenterContainer);
|
||||
center_container->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
|
||||
center_container->set_anchors_preset(Control::PRESET_CENTER);
|
||||
center_container->connect("gui_input", callable_mp(this, &TileAtlasView::gui_input));
|
||||
center_container->connect("gui_input", callable_mp(this, &RTileAtlasView::gui_input));
|
||||
panel->add_child(center_container);
|
||||
|
||||
missing_source_label = memnew(Label);
|
||||
@ -622,14 +622,14 @@ TileAtlasView::TileAtlasView() {
|
||||
base_tiles_root_control = memnew(Control);
|
||||
base_tiles_root_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
|
||||
base_tiles_root_control->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
base_tiles_root_control->connect("gui_input", callable_mp(this, &TileAtlasView::_base_tiles_root_control_gui_input));
|
||||
base_tiles_root_control->connect("gui_input", callable_mp(this, &RTileAtlasView::_base_tiles_root_control_gui_input));
|
||||
left_vbox->add_child(base_tiles_root_control);
|
||||
|
||||
background_left = memnew(Control);
|
||||
background_left->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
|
||||
background_left->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
|
||||
background_left->set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
|
||||
background_left->connect("draw", callable_mp(this, &TileAtlasView::_draw_background_left));
|
||||
background_left->connect("draw", callable_mp(this, &RTileAtlasView::_draw_background_left));
|
||||
base_tiles_root_control->add_child(background_left);
|
||||
|
||||
base_tiles_drawing_root = memnew(Control);
|
||||
@ -641,19 +641,19 @@ TileAtlasView::TileAtlasView() {
|
||||
base_tiles_draw = memnew(Control);
|
||||
base_tiles_draw->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
|
||||
base_tiles_draw->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
|
||||
base_tiles_draw->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles));
|
||||
base_tiles_draw->connect("draw", callable_mp(this, &RTileAtlasView::_draw_base_tiles));
|
||||
base_tiles_drawing_root->add_child(base_tiles_draw);
|
||||
|
||||
base_tiles_texture_grid = memnew(Control);
|
||||
base_tiles_texture_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
|
||||
base_tiles_texture_grid->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
|
||||
base_tiles_texture_grid->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles_texture_grid));
|
||||
base_tiles_texture_grid->connect("draw", callable_mp(this, &RTileAtlasView::_draw_base_tiles_texture_grid));
|
||||
base_tiles_drawing_root->add_child(base_tiles_texture_grid);
|
||||
|
||||
base_tiles_shape_grid = memnew(Control);
|
||||
base_tiles_shape_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
|
||||
base_tiles_shape_grid->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
|
||||
base_tiles_shape_grid->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles_shape_grid));
|
||||
base_tiles_shape_grid->connect("draw", callable_mp(this, &RTileAtlasView::_draw_base_tiles_shape_grid));
|
||||
base_tiles_drawing_root->add_child(base_tiles_shape_grid);
|
||||
|
||||
// Alternative tiles.
|
||||
@ -665,13 +665,13 @@ TileAtlasView::TileAtlasView() {
|
||||
|
||||
alternative_tiles_root_control = memnew(Control);
|
||||
alternative_tiles_root_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
|
||||
alternative_tiles_root_control->connect("gui_input", callable_mp(this, &TileAtlasView::_alternative_tiles_root_control_gui_input));
|
||||
alternative_tiles_root_control->connect("gui_input", callable_mp(this, &RTileAtlasView::_alternative_tiles_root_control_gui_input));
|
||||
right_vbox->add_child(alternative_tiles_root_control);
|
||||
|
||||
background_right = memnew(Control);
|
||||
background_right->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
|
||||
background_right->set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
|
||||
background_right->connect("draw", callable_mp(this, &TileAtlasView::_draw_background_right));
|
||||
background_right->connect("draw", callable_mp(this, &RTileAtlasView::_draw_background_right));
|
||||
|
||||
alternative_tiles_root_control->add_child(background_right);
|
||||
|
||||
@ -682,6 +682,6 @@ TileAtlasView::TileAtlasView() {
|
||||
|
||||
alternatives_draw = memnew(Control);
|
||||
alternatives_draw->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
|
||||
alternatives_draw->connect("draw", callable_mp(this, &TileAtlasView::_draw_alternatives));
|
||||
alternatives_draw->connect("draw", callable_mp(this, &RTileAtlasView::_draw_alternatives));
|
||||
alternative_tiles_drawing_root->add_child(alternatives_draw);
|
||||
}
|
||||
|
@ -28,8 +28,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TILE_ATLAS_VIEW_H
|
||||
#define TILE_ATLAS_VIEW_H
|
||||
#ifndef RTILE_ATLAS_VIEW_H
|
||||
#define RTILE_ATLAS_VIEW_H
|
||||
|
||||
#include "editor/editor_zoom_widget.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
@ -41,8 +41,8 @@
|
||||
#include "scene/gui/texture_rect.h"
|
||||
#include "scene/resources/tile_set.h"
|
||||
|
||||
class TileAtlasView : public Control {
|
||||
GDCLASS(TileAtlasView, Control);
|
||||
class RTileAtlasView : public Control {
|
||||
GDCLASS(RTileAtlasView, Control);
|
||||
|
||||
private:
|
||||
TileSet *tile_set;
|
||||
@ -150,7 +150,7 @@ public:
|
||||
// Update everything.
|
||||
void update();
|
||||
|
||||
TileAtlasView();
|
||||
RTileAtlasView();
|
||||
};
|
||||
|
||||
#endif // TILE_ATLAS_VIEW
|
||||
|
@ -38,19 +38,19 @@
|
||||
#include "editor/editor_properties.h"
|
||||
#include "editor/editor_scale.h"
|
||||
|
||||
void TileDataEditor::_tile_set_changed_plan_update() {
|
||||
void RTileDataEditor::_tile_set_changed_plan_update() {
|
||||
_tile_set_changed_update_needed = true;
|
||||
call_deferred("_tile_set_changed_deferred_update");
|
||||
}
|
||||
|
||||
void TileDataEditor::_tile_set_changed_deferred_update() {
|
||||
void RTileDataEditor::_tile_set_changed_deferred_update() {
|
||||
if (_tile_set_changed_update_needed) {
|
||||
_tile_set_changed();
|
||||
_tile_set_changed_update_needed = false;
|
||||
}
|
||||
}
|
||||
|
||||
TileData *TileDataEditor::_get_tile_data(TileMapCell p_cell) {
|
||||
TileData *RTileDataEditor::_get_tile_data(TileMapCell p_cell) {
|
||||
ERR_FAIL_COND_V(!tile_set.is_valid(), nullptr);
|
||||
ERR_FAIL_COND_V(!tile_set->has_source(p_cell.source_id), nullptr);
|
||||
|
||||
@ -66,19 +66,19 @@ TileData *TileDataEditor::_get_tile_data(TileMapCell p_cell) {
|
||||
return td;
|
||||
}
|
||||
|
||||
void TileDataEditor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_tile_set_changed_deferred_update"), &TileDataEditor::_tile_set_changed_deferred_update);
|
||||
void RTileDataEditor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_tile_set_changed_deferred_update"), &RTileDataEditor::_tile_set_changed_deferred_update);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("needs_redraw"));
|
||||
}
|
||||
|
||||
void TileDataEditor::set_tile_set(Ref<TileSet> p_tile_set) {
|
||||
void RTileDataEditor::set_tile_set(Ref<TileSet> p_tile_set) {
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect("changed", callable_mp(this, &TileDataEditor::_tile_set_changed_plan_update));
|
||||
tile_set->disconnect("changed", callable_mp(this, &RTileDataEditor::_tile_set_changed_plan_update));
|
||||
}
|
||||
tile_set = p_tile_set;
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->connect("changed", callable_mp(this, &TileDataEditor::_tile_set_changed_plan_update));
|
||||
tile_set->connect("changed", callable_mp(this, &RTileDataEditor::_tile_set_changed_plan_update));
|
||||
}
|
||||
_tile_set_changed_plan_update();
|
||||
}
|
||||
@ -866,7 +866,7 @@ void TileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_s
|
||||
}
|
||||
}
|
||||
|
||||
void TileDataDefaultEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {
|
||||
void TileDataDefaultEditor::forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {
|
||||
if (drag_type == DRAG_TYPE_PAINT_RECT) {
|
||||
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
|
||||
@ -901,11 +901,11 @@ void TileDataDefaultEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_
|
||||
}
|
||||
};
|
||||
|
||||
void TileDataDefaultEditor::forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){
|
||||
void TileDataDefaultEditor::forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){
|
||||
|
||||
};
|
||||
|
||||
void TileDataDefaultEditor::forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
|
||||
void TileDataDefaultEditor::forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
if (mm.is_valid()) {
|
||||
if (drag_type == DRAG_TYPE_PAINT) {
|
||||
@ -995,7 +995,7 @@ void TileDataDefaultEditor::forward_painting_atlas_gui_input(TileAtlasView *p_ti
|
||||
}
|
||||
}
|
||||
|
||||
void TileDataDefaultEditor::forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
|
||||
void TileDataDefaultEditor::forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
if (mm.is_valid()) {
|
||||
if (drag_type == DRAG_TYPE_PAINT) {
|
||||
@ -1079,8 +1079,8 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2
|
||||
Rect2 rect = p_transform.xform(Rect2(Vector2(-size / 2, -size / 2), Vector2(size, size)));
|
||||
p_canvas_item->draw_rect(rect, value);
|
||||
} else {
|
||||
Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
||||
int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
||||
Ref<Font> font = RTileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
||||
int font_size = RTileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
||||
String text;
|
||||
switch (value.get_type()) {
|
||||
case Variant::INT:
|
||||
@ -1217,7 +1217,7 @@ void TileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform
|
||||
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
|
||||
color = selection_color;
|
||||
}
|
||||
Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons"));
|
||||
Ref<Texture2D> position_icon = RTileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons"));
|
||||
p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(value)) - position_icon->get_size() / 2, color);
|
||||
}
|
||||
|
||||
@ -1231,7 +1231,7 @@ void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D
|
||||
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
|
||||
color = selection_color;
|
||||
}
|
||||
Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons"));
|
||||
Ref<Texture2D> position_icon = RTileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons"));
|
||||
p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(0, tile_data->get_y_sort_origin())) - position_icon->get_size() / 2, color);
|
||||
}
|
||||
|
||||
@ -1631,7 +1631,7 @@ void TileDataTerrainsEditor::_tile_set_changed() {
|
||||
_update_terrain_selector();
|
||||
}
|
||||
|
||||
void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {
|
||||
void TileDataTerrainsEditor::forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
// Draw the hovered terrain bit, or the whole tile if it has the wrong terrain set.
|
||||
@ -1675,8 +1675,8 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas
|
||||
}
|
||||
|
||||
// Dim terrains with wrong terrain set.
|
||||
Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
||||
int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
||||
Ref<Font> font = RTileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
||||
int font_size = RTileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
||||
for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) {
|
||||
Vector2i coords = p_tile_set_atlas_source->get_tile_id(i);
|
||||
if (coords != hovered_coords) {
|
||||
@ -1803,7 +1803,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas
|
||||
}
|
||||
}
|
||||
|
||||
void TileDataTerrainsEditor::forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {
|
||||
void TileDataTerrainsEditor::forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
// Draw the hovered terrain bit, or the whole tile if it has the wrong terrain set.
|
||||
@ -1849,8 +1849,8 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(TileAtlasView *p_til
|
||||
}
|
||||
|
||||
// Dim terrains with wrong terrain set.
|
||||
Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
||||
int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
||||
Ref<Font> font = RTileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
||||
int font_size = RTileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
||||
for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) {
|
||||
Vector2i coords = p_tile_set_atlas_source->get_tile_id(i);
|
||||
for (int j = 1; j < p_tile_set_atlas_source->get_alternative_tiles_count(coords); j++) {
|
||||
@ -1885,7 +1885,7 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(TileAtlasView *p_til
|
||||
p_canvas_item->draw_set_transform_matrix(Transform2D());
|
||||
}
|
||||
|
||||
void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
|
||||
void TileDataTerrainsEditor::forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
if (mm.is_valid()) {
|
||||
if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) {
|
||||
@ -2228,7 +2228,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t
|
||||
}
|
||||
}
|
||||
|
||||
void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
|
||||
void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
if (mm.is_valid()) {
|
||||
if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) {
|
||||
|
@ -28,8 +28,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TILE_DATA_EDITORS_H
|
||||
#define TILE_DATA_EDITORS_H
|
||||
#ifndef RTILE_DATA_EDITORS_H
|
||||
#define RTILE_DATA_EDITORS_H
|
||||
|
||||
#include "tile_atlas_view.h"
|
||||
|
||||
@ -41,8 +41,8 @@
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/gui/label.h"
|
||||
|
||||
class TileDataEditor : public VBoxContainer {
|
||||
GDCLASS(TileDataEditor, VBoxContainer);
|
||||
class RTileDataEditor : public VBoxContainer {
|
||||
GDCLASS(RTileDataEditor, VBoxContainer);
|
||||
|
||||
private:
|
||||
bool _tile_set_changed_update_needed = false;
|
||||
@ -61,10 +61,10 @@ public:
|
||||
|
||||
// Input to handle painting.
|
||||
virtual Control *get_toolbar() { return nullptr; };
|
||||
virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
|
||||
virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
|
||||
virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
|
||||
virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
|
||||
virtual void forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
|
||||
virtual void forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
|
||||
virtual void forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
|
||||
virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
|
||||
|
||||
// Used to draw the tile data property value over a tile.
|
||||
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false){};
|
||||
@ -184,8 +184,8 @@ public:
|
||||
GenericTilePolygonEditor();
|
||||
};
|
||||
|
||||
class TileDataDefaultEditor : public TileDataEditor {
|
||||
GDCLASS(TileDataDefaultEditor, TileDataEditor);
|
||||
class TileDataDefaultEditor : public RTileDataEditor {
|
||||
GDCLASS(TileDataDefaultEditor, RTileDataEditor);
|
||||
|
||||
private:
|
||||
// Toolbar
|
||||
@ -230,10 +230,10 @@ protected:
|
||||
|
||||
public:
|
||||
virtual Control *get_toolbar() override { return toolbar; };
|
||||
virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
|
||||
virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
|
||||
virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
|
||||
virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
|
||||
virtual void forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
|
||||
virtual void forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
|
||||
virtual void forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
|
||||
virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
|
||||
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
|
||||
|
||||
void setup_property_editor(Variant::Type p_type, String p_property, String p_label = "", Variant p_default_value = Variant());
|
||||
@ -330,8 +330,8 @@ public:
|
||||
~TileDataCollisionEditor();
|
||||
};
|
||||
|
||||
class TileDataTerrainsEditor : public TileDataEditor {
|
||||
GDCLASS(TileDataTerrainsEditor, TileDataEditor);
|
||||
class TileDataTerrainsEditor : public RTileDataEditor {
|
||||
GDCLASS(TileDataTerrainsEditor, RTileDataEditor);
|
||||
|
||||
private:
|
||||
// Toolbar
|
||||
@ -371,10 +371,10 @@ protected:
|
||||
|
||||
public:
|
||||
virtual Control *get_toolbar() override { return toolbar; };
|
||||
virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
|
||||
virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
|
||||
virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
|
||||
virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
|
||||
virtual void forward_draw_over_atlas(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
|
||||
virtual void forward_draw_over_alternatives(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
|
||||
virtual void forward_painting_atlas_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
|
||||
virtual void forward_painting_alternatives_gui_input(RTileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
|
||||
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
|
||||
|
||||
TileDataTerrainsEditor();
|
||||
|
@ -44,22 +44,22 @@
|
||||
#include "core/math/geometry_2d.h"
|
||||
#include "core/os/keyboard.h"
|
||||
|
||||
void TileMapEditorTilesPlugin::tile_set_changed() {
|
||||
void RTileMapEditorTilesPlugin::tile_set_changed() {
|
||||
_update_fix_selected_and_hovered();
|
||||
_update_tile_set_sources_list();
|
||||
_update_source_display();
|
||||
_update_patterns_list();
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_on_random_tile_checkbox_toggled(bool p_pressed) {
|
||||
void RTileMapEditorTilesPlugin::_on_random_tile_checkbox_toggled(bool p_pressed) {
|
||||
scatter_spinbox->set_editable(p_pressed);
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_on_scattering_spinbox_changed(double p_value) {
|
||||
void RTileMapEditorTilesPlugin::_on_scattering_spinbox_changed(double p_value) {
|
||||
scattering = p_value;
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_toolbar() {
|
||||
void RTileMapEditorTilesPlugin::_update_toolbar() {
|
||||
// Stop draggig if needed.
|
||||
_stop_dragging();
|
||||
|
||||
@ -106,14 +106,14 @@ void TileMapEditorTilesPlugin::_update_toolbar() {
|
||||
}
|
||||
}
|
||||
|
||||
Vector<TileMapEditorPlugin::TabData> TileMapEditorTilesPlugin::get_tabs() const {
|
||||
Vector<TileMapEditorPlugin::TabData> tabs;
|
||||
Vector<RTileMapEditorPlugin::TabData> RTileMapEditorTilesPlugin::get_tabs() const {
|
||||
Vector<RTileMapEditorPlugin::TabData> tabs;
|
||||
tabs.push_back({ toolbar, tiles_bottom_panel });
|
||||
tabs.push_back({ toolbar, patterns_bottom_panel });
|
||||
return tabs;
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_tab_changed() {
|
||||
void RTileMapEditorTilesPlugin::_tab_changed() {
|
||||
if (tiles_bottom_panel->is_visible_in_tree()) {
|
||||
_update_selection_pattern_from_tileset_tiles_selection();
|
||||
} else if (patterns_bottom_panel->is_visible_in_tree()) {
|
||||
@ -121,7 +121,7 @@ void TileMapEditorTilesPlugin::_tab_changed() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_tile_set_sources_list() {
|
||||
void RTileMapEditorTilesPlugin::_update_tile_set_sources_list() {
|
||||
// Update the sources.
|
||||
int old_current = sources_list->get_current();
|
||||
sources_list->clear();
|
||||
@ -194,10 +194,10 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() {
|
||||
}
|
||||
|
||||
// Synchronize
|
||||
TilesEditorPlugin::get_singleton()->set_sources_lists_current(sources_list->get_current());
|
||||
RTilesEditorPlugin::get_singleton()->set_sources_lists_current(sources_list->get_current());
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_source_display() {
|
||||
void RTileMapEditorTilesPlugin::_update_source_display() {
|
||||
// Update the atlas display.
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
@ -244,7 +244,7 @@ void TileMapEditorTilesPlugin::_update_source_display() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_patterns_item_list_gui_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileMapEditorTilesPlugin::_patterns_item_list_gui_input(const Ref<InputEvent> &p_event) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -278,7 +278,7 @@ void TileMapEditorTilesPlugin::_patterns_item_list_gui_input(const Ref<InputEven
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture) {
|
||||
void RTileMapEditorTilesPlugin::_pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture) {
|
||||
// TODO optimize ?
|
||||
for (int i = 0; i < patterns_item_list->get_item_count(); i++) {
|
||||
if (patterns_item_list->get_item_metadata(i) == p_pattern) {
|
||||
@ -288,7 +288,7 @@ void TileMapEditorTilesPlugin::_pattern_preview_done(Ref<TileMapPattern> p_patte
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_patterns_list() {
|
||||
void RTileMapEditorTilesPlugin::_update_patterns_list() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -304,7 +304,7 @@ void TileMapEditorTilesPlugin::_update_patterns_list() {
|
||||
for (int i = 0; i < tile_set->get_patterns_count(); i++) {
|
||||
int id = patterns_item_list->add_item("");
|
||||
patterns_item_list->set_item_metadata(id, tile_set->get_pattern(i));
|
||||
TilesEditorPlugin::get_singleton()->queue_pattern_preview(tile_set, tile_set->get_pattern(i), callable_mp(this, &TileMapEditorTilesPlugin::_pattern_preview_done));
|
||||
RTilesEditorPlugin::get_singleton()->queue_pattern_preview(tile_set, tile_set->get_pattern(i), callable_mp(this, &RTileMapEditorTilesPlugin::_pattern_preview_done));
|
||||
}
|
||||
|
||||
// Update the label visibility.
|
||||
@ -319,7 +319,7 @@ void TileMapEditorTilesPlugin::_update_patterns_list() {
|
||||
select_last_pattern = false;
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_atlas_view() {
|
||||
void RTileMapEditorTilesPlugin::_update_atlas_view() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -336,11 +336,11 @@ void TileMapEditorTilesPlugin::_update_atlas_view() {
|
||||
ERR_FAIL_COND(!atlas_source);
|
||||
|
||||
tile_atlas_view->set_atlas_source(*tile_map->get_tileset(), atlas_source, source_id);
|
||||
TilesEditorPlugin::get_singleton()->synchronize_atlas_view(tile_atlas_view);
|
||||
RTilesEditorPlugin::get_singleton()->synchronize_atlas_view(tile_atlas_view);
|
||||
tile_atlas_control->update();
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_scenes_collection_view() {
|
||||
void RTileMapEditorTilesPlugin::_update_scenes_collection_view() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -386,7 +386,7 @@ void TileMapEditorTilesPlugin::_update_scenes_collection_view() {
|
||||
scene_tiles_list->set_fixed_icon_size(Vector2(int_size, int_size));
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) {
|
||||
void RTileMapEditorTilesPlugin::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) {
|
||||
int index = p_ud;
|
||||
|
||||
if (index >= 0 && index < scene_tiles_list->get_item_count()) {
|
||||
@ -394,7 +394,7 @@ void TileMapEditorTilesPlugin::_scene_thumbnail_done(const String &p_path, const
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_scenes_list_multi_selected(int p_index, bool p_selected) {
|
||||
void RTileMapEditorTilesPlugin::_scenes_list_multi_selected(int p_index, bool p_selected) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -430,7 +430,7 @@ void TileMapEditorTilesPlugin::_scenes_list_multi_selected(int p_index, bool p_s
|
||||
_update_selection_pattern_from_tileset_tiles_selection();
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_scenes_list_nothing_selected() {
|
||||
void RTileMapEditorTilesPlugin::_scenes_list_nothing_selected() {
|
||||
scene_tiles_list->deselect_all();
|
||||
tile_set_selection.clear();
|
||||
tile_map_selection.clear();
|
||||
@ -438,7 +438,7 @@ void TileMapEditorTilesPlugin::_scenes_list_nothing_selected() {
|
||||
_update_selection_pattern_from_tileset_tiles_selection();
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_theme() {
|
||||
void RTileMapEditorTilesPlugin::_update_theme() {
|
||||
select_tool_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
|
||||
paint_tool_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
|
||||
line_tool_button->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("CurveLinear"), SNAME("EditorIcons")));
|
||||
@ -451,7 +451,7 @@ void TileMapEditorTilesPlugin::_update_theme() {
|
||||
missing_atlas_texture_icon = tiles_bottom_panel->get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons"));
|
||||
}
|
||||
|
||||
bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||
bool RTileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||
if (!(tiles_bottom_panel->is_visible_in_tree() || patterns_bottom_panel->is_visible_in_tree())) {
|
||||
// If the bottom editor is not visible, we ignore inputs.
|
||||
return false;
|
||||
@ -557,7 +557,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
|
||||
_fix_invalid_tiles_in_tile_map_selection();
|
||||
} break;
|
||||
case DRAG_TYPE_BUCKET: {
|
||||
Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos));
|
||||
Vector<Vector2i> line = RTileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos));
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
if (!drag_modified.has(line[i])) {
|
||||
Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing);
|
||||
@ -653,7 +653,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
|
||||
drag_type = DRAG_TYPE_BUCKET;
|
||||
drag_start_mouse_pos = mpos;
|
||||
drag_modified.clear();
|
||||
Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos));
|
||||
Vector<Vector2i> line = RTileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos));
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
if (!drag_modified.has(line[i])) {
|
||||
Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing);
|
||||
@ -690,7 +690,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
|
||||
return false;
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
void RTileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -910,12 +910,12 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_mouse_exited_viewport() {
|
||||
void RTileMapEditorTilesPlugin::_mouse_exited_viewport() {
|
||||
has_mouse = false;
|
||||
CanvasItemEditor::get_singleton()->update_viewport();
|
||||
}
|
||||
|
||||
TileMapCell TileMapEditorTilesPlugin::_pick_random_tile(Ref<TileMapPattern> p_pattern) {
|
||||
TileMapCell RTileMapEditorTilesPlugin::_pick_random_tile(Ref<TileMapPattern> p_pattern) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return TileMapCell();
|
||||
@ -967,7 +967,7 @@ TileMapCell TileMapEditorTilesPlugin::_pick_random_tile(Ref<TileMapPattern> p_pa
|
||||
return TileMapCell();
|
||||
}
|
||||
|
||||
Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase) {
|
||||
Map<Vector2i, TileMapCell> RTileMapEditorTilesPlugin::_draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return Map<Vector2i, TileMapCell>();
|
||||
@ -989,7 +989,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_
|
||||
// Paint the tiles on the tile map.
|
||||
if (!p_erase && random_tile_checkbox->is_pressed()) {
|
||||
// Paint a random tile.
|
||||
Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(p_from_mouse_pos), tile_map->world_to_map(p_to_mouse_pos));
|
||||
Vector<Vector2i> line = RTileMapEditor::get_line(tile_map, tile_map->world_to_map(p_from_mouse_pos), tile_map->world_to_map(p_to_mouse_pos));
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
output.insert(line[i], _pick_random_tile(pattern));
|
||||
}
|
||||
@ -1003,7 +1003,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_
|
||||
|
||||
TypedArray<Vector2i> used_cells = pattern->get_used_cells();
|
||||
Vector2i offset = Vector2i(Math::posmod(drag_start_cell.x, pattern->get_size().x), Math::posmod(drag_start_cell.y, pattern->get_size().y)); // Note: no posmodv for Vector2i for now. Meh.s
|
||||
Vector<Vector2i> line = TileMapEditor::get_line(tile_map, (last_hovered_cell - offset) / pattern->get_size(), (new_hovered_cell - offset) / pattern->get_size());
|
||||
Vector<Vector2i> line = RTileMapEditor::get_line(tile_map, (last_hovered_cell - offset) / pattern->get_size(), (new_hovered_cell - offset) / pattern->get_size());
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
Vector2i top_left = line[i] * pattern->get_size() + offset;
|
||||
for (int j = 0; j < used_cells.size(); j++) {
|
||||
@ -1016,7 +1016,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_
|
||||
return output;
|
||||
}
|
||||
|
||||
Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) {
|
||||
Map<Vector2i, TileMapCell> RTileMapEditorTilesPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return Map<Vector2i, TileMapCell>();
|
||||
@ -1075,7 +1075,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_rect(Vector2i p_start
|
||||
return output;
|
||||
}
|
||||
|
||||
Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) {
|
||||
Map<Vector2i, TileMapCell> RTileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return Map<Vector2i, TileMapCell>();
|
||||
@ -1187,7 +1187,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i
|
||||
return output;
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_stop_dragging() {
|
||||
void RTileMapEditorTilesPlugin::_stop_dragging() {
|
||||
if (drag_type == DRAG_TYPE_NONE) {
|
||||
return;
|
||||
}
|
||||
@ -1387,7 +1387,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() {
|
||||
drag_type = DRAG_TYPE_NONE;
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() {
|
||||
void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
hovered_tile.source_id = TileSet::INVALID_SOURCE;
|
||||
@ -1455,7 +1455,7 @@ void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_fix_invalid_tiles_in_tile_map_selection() {
|
||||
void RTileMapEditorTilesPlugin::_fix_invalid_tiles_in_tile_map_selection() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -1474,7 +1474,7 @@ void TileMapEditorTilesPlugin::_fix_invalid_tiles_in_tile_map_selection() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection() {
|
||||
void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -1496,7 +1496,7 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tilemap_selection(
|
||||
selection_pattern = tile_map->get_pattern(tile_map_layer, coords_array);
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_selection() {
|
||||
void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_selection() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -1569,7 +1569,7 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_tiles_sele
|
||||
CanvasItemEditor::get_singleton()->update_viewport();
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_selection() {
|
||||
void RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_selection() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -1593,7 +1593,7 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_se
|
||||
CanvasItemEditor::get_singleton()->update_viewport();
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern() {
|
||||
void RTileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern() {
|
||||
tile_set_selection.clear();
|
||||
TypedArray<Vector2i> used_cells = selection_pattern->get_used_cells();
|
||||
for (int i = 0; i < used_cells.size(); i++) {
|
||||
@ -1607,7 +1607,7 @@ void TileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern(
|
||||
alternative_tiles_control->update();
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_tile_atlas_control_draw() {
|
||||
void RTileMapEditorTilesPlugin::_tile_atlas_control_draw() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -1683,7 +1683,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited() {
|
||||
void RTileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited() {
|
||||
hovered_tile.source_id = TileSet::INVALID_SOURCE;
|
||||
hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS);
|
||||
hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
|
||||
@ -1691,7 +1691,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited() {
|
||||
tile_atlas_control->update();
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -1797,7 +1797,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEven
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_tile_alternatives_control_draw() {
|
||||
void RTileMapEditorTilesPlugin::_tile_alternatives_control_draw() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -1842,7 +1842,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited() {
|
||||
void RTileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited() {
|
||||
hovered_tile.source_id = TileSet::INVALID_SOURCE;
|
||||
hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS);
|
||||
hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
|
||||
@ -1850,7 +1850,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited() {
|
||||
alternative_tiles_control->update();
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -1916,7 +1916,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<In
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_set_tile_map_selection(const TypedArray<Vector2i> &p_selection) {
|
||||
void RTileMapEditorTilesPlugin::_set_tile_map_selection(const TypedArray<Vector2i> &p_selection) {
|
||||
tile_map_selection.clear();
|
||||
for (int i = 0; i < p_selection.size(); i++) {
|
||||
tile_map_selection.insert(p_selection[i]);
|
||||
@ -1926,7 +1926,7 @@ void TileMapEditorTilesPlugin::_set_tile_map_selection(const TypedArray<Vector2i
|
||||
CanvasItemEditor::get_singleton()->update_viewport();
|
||||
}
|
||||
|
||||
TypedArray<Vector2i> TileMapEditorTilesPlugin::_get_tile_map_selection() const {
|
||||
TypedArray<Vector2i> RTileMapEditorTilesPlugin::_get_tile_map_selection() const {
|
||||
TypedArray<Vector2i> output;
|
||||
for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) {
|
||||
output.push_back(E->get());
|
||||
@ -1934,7 +1934,7 @@ TypedArray<Vector2i> TileMapEditorTilesPlugin::_get_tile_map_selection() const {
|
||||
return output;
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::edit(ObjectID p_tile_map_id, int p_tile_map_layer) {
|
||||
void RTileMapEditorTilesPlugin::edit(ObjectID p_tile_map_id, int p_tile_map_layer) {
|
||||
_stop_dragging(); // Avoids staying in a wrong drag state.
|
||||
|
||||
if (tile_map_id != p_tile_map_id) {
|
||||
@ -1950,14 +1950,14 @@ void TileMapEditorTilesPlugin::edit(ObjectID p_tile_map_id, int p_tile_map_layer
|
||||
tile_map_layer = p_tile_map_layer;
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_scene_thumbnail_done"), &TileMapEditorTilesPlugin::_scene_thumbnail_done);
|
||||
ClassDB::bind_method(D_METHOD("_set_tile_map_selection", "selection"), &TileMapEditorTilesPlugin::_set_tile_map_selection);
|
||||
ClassDB::bind_method(D_METHOD("_get_tile_map_selection"), &TileMapEditorTilesPlugin::_get_tile_map_selection);
|
||||
void RTileMapEditorTilesPlugin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_scene_thumbnail_done"), &RTileMapEditorTilesPlugin::_scene_thumbnail_done);
|
||||
ClassDB::bind_method(D_METHOD("_set_tile_map_selection", "selection"), &RTileMapEditorTilesPlugin::_set_tile_map_selection);
|
||||
ClassDB::bind_method(D_METHOD("_get_tile_map_selection"), &RTileMapEditorTilesPlugin::_get_tile_map_selection);
|
||||
}
|
||||
|
||||
TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
CanvasItemEditor::get_singleton()->get_viewport_control()->connect("mouse_exited", callable_mp(this, &TileMapEditorTilesPlugin::_mouse_exited_viewport));
|
||||
RTileMapEditorTilesPlugin::RTileMapEditorTilesPlugin() {
|
||||
CanvasItemEditor::get_singleton()->get_viewport_control()->connect("mouse_exited", callable_mp(this, &RTileMapEditorTilesPlugin::_mouse_exited_viewport));
|
||||
|
||||
// --- Shortcuts ---
|
||||
ED_SHORTCUT("tiles_editor/cut", TTR("Cut"), KeyModifierMask::CMD | Key::X);
|
||||
@ -1983,7 +1983,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
select_tool_button->set_toggle_mode(true);
|
||||
select_tool_button->set_button_group(tool_buttons_group);
|
||||
select_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/selection_tool", "Selection", Key::S));
|
||||
select_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTilesPlugin::_update_toolbar));
|
||||
select_tool_button->connect("pressed", callable_mp(this, &RTileMapEditorTilesPlugin::_update_toolbar));
|
||||
tilemap_tiles_tools_buttons->add_child(select_tool_button);
|
||||
|
||||
paint_tool_button = memnew(Button);
|
||||
@ -1992,7 +1992,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
paint_tool_button->set_button_group(tool_buttons_group);
|
||||
paint_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/paint_tool", "Paint", Key::D));
|
||||
paint_tool_button->set_tooltip(TTR("Shift: Draw line.") + "\n" + TTR("Shift+Ctrl: Draw rectangle."));
|
||||
paint_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTilesPlugin::_update_toolbar));
|
||||
paint_tool_button->connect("pressed", callable_mp(this, &RTileMapEditorTilesPlugin::_update_toolbar));
|
||||
tilemap_tiles_tools_buttons->add_child(paint_tool_button);
|
||||
|
||||
line_tool_button = memnew(Button);
|
||||
@ -2000,7 +2000,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
line_tool_button->set_toggle_mode(true);
|
||||
line_tool_button->set_button_group(tool_buttons_group);
|
||||
line_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/line_tool", "Line", Key::L));
|
||||
line_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTilesPlugin::_update_toolbar));
|
||||
line_tool_button->connect("pressed", callable_mp(this, &RTileMapEditorTilesPlugin::_update_toolbar));
|
||||
tilemap_tiles_tools_buttons->add_child(line_tool_button);
|
||||
|
||||
rect_tool_button = memnew(Button);
|
||||
@ -2008,7 +2008,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
rect_tool_button->set_toggle_mode(true);
|
||||
rect_tool_button->set_button_group(tool_buttons_group);
|
||||
rect_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/rect_tool", "Rect", Key::R));
|
||||
rect_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTilesPlugin::_update_toolbar));
|
||||
rect_tool_button->connect("pressed", callable_mp(this, &RTileMapEditorTilesPlugin::_update_toolbar));
|
||||
tilemap_tiles_tools_buttons->add_child(rect_tool_button);
|
||||
|
||||
bucket_tool_button = memnew(Button);
|
||||
@ -2016,7 +2016,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
bucket_tool_button->set_toggle_mode(true);
|
||||
bucket_tool_button->set_button_group(tool_buttons_group);
|
||||
bucket_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/bucket_tool", "Bucket", Key::B));
|
||||
bucket_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTilesPlugin::_update_toolbar));
|
||||
bucket_tool_button->connect("pressed", callable_mp(this, &RTileMapEditorTilesPlugin::_update_toolbar));
|
||||
tilemap_tiles_tools_buttons->add_child(bucket_tool_button);
|
||||
toolbar->add_child(tilemap_tiles_tools_buttons);
|
||||
|
||||
@ -2060,7 +2060,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
random_tile_checkbox = memnew(CheckBox);
|
||||
random_tile_checkbox->set_flat(true);
|
||||
random_tile_checkbox->set_text(TTR("Place Random Tile"));
|
||||
random_tile_checkbox->connect("toggled", callable_mp(this, &TileMapEditorTilesPlugin::_on_random_tile_checkbox_toggled));
|
||||
random_tile_checkbox->connect("toggled", callable_mp(this, &RTileMapEditorTilesPlugin::_on_random_tile_checkbox_toggled));
|
||||
tools_settings->add_child(random_tile_checkbox);
|
||||
|
||||
// Random tile scattering.
|
||||
@ -2075,7 +2075,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
scatter_spinbox->set_step(0.001);
|
||||
scatter_spinbox->set_tooltip(TTR("Defines the probability of painting nothing instead of a randomly selected tile."));
|
||||
scatter_spinbox->get_line_edit()->add_theme_constant_override("minimum_character_width", 4);
|
||||
scatter_spinbox->connect("value_changed", callable_mp(this, &TileMapEditorTilesPlugin::_on_scattering_spinbox_changed));
|
||||
scatter_spinbox->connect("value_changed", callable_mp(this, &RTileMapEditorTilesPlugin::_on_scattering_spinbox_changed));
|
||||
tools_settings->add_child(scatter_spinbox);
|
||||
|
||||
_on_random_tile_checkbox_toggled(false);
|
||||
@ -2086,10 +2086,10 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
|
||||
// --- Bottom panel tiles ---
|
||||
tiles_bottom_panel = memnew(VBoxContainer);
|
||||
tiles_bottom_panel->connect("tree_entered", callable_mp(this, &TileMapEditorTilesPlugin::_update_theme));
|
||||
tiles_bottom_panel->connect("theme_changed", callable_mp(this, &TileMapEditorTilesPlugin::_update_theme));
|
||||
tiles_bottom_panel->connect("visibility_changed", callable_mp(this, &TileMapEditorTilesPlugin::_stop_dragging));
|
||||
tiles_bottom_panel->connect("visibility_changed", callable_mp(this, &TileMapEditorTilesPlugin::_tab_changed));
|
||||
tiles_bottom_panel->connect("tree_entered", callable_mp(this, &RTileMapEditorTilesPlugin::_update_theme));
|
||||
tiles_bottom_panel->connect("theme_changed", callable_mp(this, &RTileMapEditorTilesPlugin::_update_theme));
|
||||
tiles_bottom_panel->connect("visibility_changed", callable_mp(this, &RTileMapEditorTilesPlugin::_stop_dragging));
|
||||
tiles_bottom_panel->connect("visibility_changed", callable_mp(this, &RTileMapEditorTilesPlugin::_tab_changed));
|
||||
tiles_bottom_panel->set_name(TTR("Tiles"));
|
||||
|
||||
missing_source_label = memnew(Label);
|
||||
@ -2112,31 +2112,31 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
sources_list->set_stretch_ratio(0.25);
|
||||
sources_list->set_custom_minimum_size(Size2i(70, 0) * EDSCALE);
|
||||
sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
|
||||
sources_list->connect("item_selected", callable_mp(this, &TileMapEditorTilesPlugin::_update_fix_selected_and_hovered).unbind(1));
|
||||
sources_list->connect("item_selected", callable_mp(this, &TileMapEditorTilesPlugin::_update_source_display).unbind(1));
|
||||
sources_list->connect("item_selected", callable_mp(TilesEditorPlugin::get_singleton(), &TilesEditorPlugin::set_sources_lists_current));
|
||||
sources_list->connect("visibility_changed", callable_mp(TilesEditorPlugin::get_singleton(), &TilesEditorPlugin::synchronize_sources_list), varray(sources_list));
|
||||
sources_list->connect("item_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered).unbind(1));
|
||||
sources_list->connect("item_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_update_source_display).unbind(1));
|
||||
sources_list->connect("item_selected", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::set_sources_lists_current));
|
||||
sources_list->connect("visibility_changed", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::synchronize_sources_list), varray(sources_list));
|
||||
atlas_sources_split_container->add_child(sources_list);
|
||||
|
||||
// Tile atlas source.
|
||||
tile_atlas_view = memnew(TileAtlasView);
|
||||
tile_atlas_view = memnew(RTileAtlasView);
|
||||
tile_atlas_view->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
tile_atlas_view->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
tile_atlas_view->set_texture_grid_visible(false);
|
||||
tile_atlas_view->set_tile_shape_grid_visible(false);
|
||||
tile_atlas_view->connect("transform_changed", callable_mp(TilesEditorPlugin::get_singleton(), &TilesEditorPlugin::set_atlas_view_transform));
|
||||
tile_atlas_view->connect("transform_changed", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::set_atlas_view_transform));
|
||||
atlas_sources_split_container->add_child(tile_atlas_view);
|
||||
|
||||
tile_atlas_control = memnew(Control);
|
||||
tile_atlas_control->connect("draw", callable_mp(this, &TileMapEditorTilesPlugin::_tile_atlas_control_draw));
|
||||
tile_atlas_control->connect("mouse_exited", callable_mp(this, &TileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited));
|
||||
tile_atlas_control->connect("gui_input", callable_mp(this, &TileMapEditorTilesPlugin::_tile_atlas_control_gui_input));
|
||||
tile_atlas_control->connect("draw", callable_mp(this, &RTileMapEditorTilesPlugin::_tile_atlas_control_draw));
|
||||
tile_atlas_control->connect("mouse_exited", callable_mp(this, &RTileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited));
|
||||
tile_atlas_control->connect("gui_input", callable_mp(this, &RTileMapEditorTilesPlugin::_tile_atlas_control_gui_input));
|
||||
tile_atlas_view->add_control_over_atlas_tiles(tile_atlas_control);
|
||||
|
||||
alternative_tiles_control = memnew(Control);
|
||||
alternative_tiles_control->connect("draw", callable_mp(this, &TileMapEditorTilesPlugin::_tile_alternatives_control_draw));
|
||||
alternative_tiles_control->connect("mouse_exited", callable_mp(this, &TileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited));
|
||||
alternative_tiles_control->connect("gui_input", callable_mp(this, &TileMapEditorTilesPlugin::_tile_alternatives_control_gui_input));
|
||||
alternative_tiles_control->connect("draw", callable_mp(this, &RTileMapEditorTilesPlugin::_tile_alternatives_control_draw));
|
||||
alternative_tiles_control->connect("mouse_exited", callable_mp(this, &RTileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited));
|
||||
alternative_tiles_control->connect("gui_input", callable_mp(this, &RTileMapEditorTilesPlugin::_tile_alternatives_control_gui_input));
|
||||
tile_atlas_view->add_control_over_alternative_tiles(alternative_tiles_control);
|
||||
|
||||
// Scenes collection source.
|
||||
@ -2145,8 +2145,8 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
scene_tiles_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
scene_tiles_list->set_drag_forwarding(this);
|
||||
scene_tiles_list->set_select_mode(ItemList::SELECT_MULTI);
|
||||
scene_tiles_list->connect("multi_selected", callable_mp(this, &TileMapEditorTilesPlugin::_scenes_list_multi_selected));
|
||||
scene_tiles_list->connect("nothing_selected", callable_mp(this, &TileMapEditorTilesPlugin::_scenes_list_nothing_selected));
|
||||
scene_tiles_list->connect("multi_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_scenes_list_multi_selected));
|
||||
scene_tiles_list->connect("nothing_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_scenes_list_nothing_selected));
|
||||
scene_tiles_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
|
||||
atlas_sources_split_container->add_child(scene_tiles_list);
|
||||
|
||||
@ -2163,7 +2163,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
// --- Bottom panel patterns ---
|
||||
patterns_bottom_panel = memnew(VBoxContainer);
|
||||
patterns_bottom_panel->set_name(TTR("Patterns"));
|
||||
patterns_bottom_panel->connect("visibility_changed", callable_mp(this, &TileMapEditorTilesPlugin::_tab_changed));
|
||||
patterns_bottom_panel->connect("visibility_changed", callable_mp(this, &RTileMapEditorTilesPlugin::_tab_changed));
|
||||
|
||||
int thumbnail_size = 64;
|
||||
patterns_item_list = memnew(ItemList);
|
||||
@ -2173,10 +2173,10 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
patterns_item_list->set_max_text_lines(2);
|
||||
patterns_item_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
|
||||
patterns_item_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
patterns_item_list->connect("gui_input", callable_mp(this, &TileMapEditorTilesPlugin::_patterns_item_list_gui_input));
|
||||
patterns_item_list->connect("item_selected", callable_mp(this, &TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_selection).unbind(1));
|
||||
patterns_item_list->connect("item_activated", callable_mp(this, &TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_selection));
|
||||
patterns_item_list->connect("nothing_selected", callable_mp(this, &TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_selection));
|
||||
patterns_item_list->connect("gui_input", callable_mp(this, &RTileMapEditorTilesPlugin::_patterns_item_list_gui_input));
|
||||
patterns_item_list->connect("item_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_selection).unbind(1));
|
||||
patterns_item_list->connect("item_activated", callable_mp(this, &RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_selection));
|
||||
patterns_item_list->connect("nothing_selected", callable_mp(this, &RTileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_pattern_selection));
|
||||
patterns_bottom_panel->add_child(patterns_item_list);
|
||||
|
||||
patterns_help_label = memnew(Label);
|
||||
@ -2188,16 +2188,16 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||
_update_source_display();
|
||||
}
|
||||
|
||||
TileMapEditorTilesPlugin::~TileMapEditorTilesPlugin() {
|
||||
RTileMapEditorTilesPlugin::~RTileMapEditorTilesPlugin() {
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::tile_set_changed() {
|
||||
void RTileMapEditorTerrainsPlugin::tile_set_changed() {
|
||||
_update_terrains_cache();
|
||||
_update_terrains_tree();
|
||||
_update_tiles_list();
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::_update_toolbar() {
|
||||
void RTileMapEditorTerrainsPlugin::_update_toolbar() {
|
||||
// Hide all settings.
|
||||
for (int i = 0; i < tools_settings->get_child_count(); i++) {
|
||||
Object::cast_to<CanvasItem>(tools_settings->get_child(i))->hide();
|
||||
@ -2231,13 +2231,13 @@ void TileMapEditorTerrainsPlugin::_update_toolbar() {
|
||||
}
|
||||
}
|
||||
|
||||
Vector<TileMapEditorPlugin::TabData> TileMapEditorTerrainsPlugin::get_tabs() const {
|
||||
Vector<TileMapEditorPlugin::TabData> tabs;
|
||||
Vector<RTileMapEditorPlugin::TabData> RTileMapEditorTerrainsPlugin::get_tabs() const {
|
||||
Vector<RTileMapEditorPlugin::TabData> tabs;
|
||||
tabs.push_back({ toolbar, main_vbox_container });
|
||||
return tabs;
|
||||
}
|
||||
|
||||
Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map<Vector2i, TileSet::TerrainsPattern> &p_to_paint, int p_terrain_set) const {
|
||||
Map<Vector2i, TileMapCell> RTileMapEditorTerrainsPlugin::_draw_terrains(const Map<Vector2i, TileSet::TerrainsPattern> &p_to_paint, int p_terrain_set) const {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return Map<Vector2i, TileMapCell>();
|
||||
@ -2350,7 +2350,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_terrains(const Map
|
||||
return output;
|
||||
}
|
||||
|
||||
Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) {
|
||||
Map<Vector2i, TileMapCell> RTileMapEditorTerrainsPlugin::_draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return Map<Vector2i, TileMapCell>();
|
||||
@ -2368,7 +2368,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_line(Vector2i p_st
|
||||
terrains_pattern = selected_terrains_pattern;
|
||||
}
|
||||
|
||||
Vector<Vector2i> line = TileMapEditor::get_line(tile_map, p_start_cell, p_end_cell);
|
||||
Vector<Vector2i> line = RTileMapEditor::get_line(tile_map, p_start_cell, p_end_cell);
|
||||
Map<Vector2i, TileSet::TerrainsPattern> to_draw;
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
to_draw[line[i]] = terrains_pattern;
|
||||
@ -2376,7 +2376,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_line(Vector2i p_st
|
||||
return _draw_terrains(to_draw, selected_terrain_set);
|
||||
}
|
||||
|
||||
Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) {
|
||||
Map<Vector2i, TileMapCell> RTileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return Map<Vector2i, TileMapCell>();
|
||||
@ -2408,7 +2408,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_rect(Vector2i p_st
|
||||
return _draw_terrains(to_draw, selected_terrain_set);
|
||||
}
|
||||
|
||||
Set<Vector2i> TileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i p_coords, bool p_contiguous) {
|
||||
Set<Vector2i> RTileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i p_coords, bool p_contiguous) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return Set<Vector2i>();
|
||||
@ -2519,7 +2519,7 @@ Set<Vector2i> TileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i p
|
||||
return output;
|
||||
}
|
||||
|
||||
Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) {
|
||||
Map<Vector2i, TileMapCell> RTileMapEditorTerrainsPlugin::_draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return Map<Vector2i, TileMapCell>();
|
||||
@ -2546,7 +2546,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTerrainsPlugin::_draw_bucket_fill(Vector
|
||||
return _draw_terrains(to_draw, selected_terrain_set);
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::_stop_dragging() {
|
||||
void RTileMapEditorTerrainsPlugin::_stop_dragging() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -2672,12 +2672,12 @@ void TileMapEditorTerrainsPlugin::_stop_dragging() {
|
||||
drag_type = DRAG_TYPE_NONE;
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::_mouse_exited_viewport() {
|
||||
void RTileMapEditorTerrainsPlugin::_mouse_exited_viewport() {
|
||||
has_mouse = false;
|
||||
CanvasItemEditor::get_singleton()->update_viewport();
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::_update_selection() {
|
||||
void RTileMapEditorTerrainsPlugin::_update_selection() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -2709,7 +2709,7 @@ void TileMapEditorTerrainsPlugin::_update_selection() {
|
||||
}
|
||||
}
|
||||
|
||||
bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||
bool RTileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||
if (!main_vbox_container->is_visible_in_tree()) {
|
||||
// If the bottom editor is not visible, we ignore inputs.
|
||||
return false;
|
||||
@ -2816,7 +2816,7 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent>
|
||||
drag_type = DRAG_TYPE_BUCKET;
|
||||
drag_start_mouse_pos = mpos;
|
||||
drag_modified.clear();
|
||||
Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos));
|
||||
Vector<Vector2i> line = RTileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos));
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
if (!drag_modified.has(line[i])) {
|
||||
Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing);
|
||||
@ -2850,7 +2850,7 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent>
|
||||
return false;
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
void RTileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -2899,7 +2899,7 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o
|
||||
preview.insert(tile_map->world_to_map(drag_last_mouse_pos));
|
||||
} else if (drag_type == DRAG_TYPE_LINE) {
|
||||
// Preview for a line.
|
||||
Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(drag_last_mouse_pos));
|
||||
Vector<Vector2i> line = RTileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(drag_last_mouse_pos));
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
preview.insert(line[i]);
|
||||
}
|
||||
@ -2979,7 +2979,7 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::_update_terrains_cache() {
|
||||
void RTileMapEditorTerrainsPlugin::_update_terrains_cache() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -3038,7 +3038,7 @@ void TileMapEditorTerrainsPlugin::_update_terrains_cache() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::_update_terrains_tree() {
|
||||
void RTileMapEditorTerrainsPlugin::_update_terrains_tree() {
|
||||
terrains_tree->clear();
|
||||
terrains_tree->create_item();
|
||||
|
||||
@ -3086,7 +3086,7 @@ void TileMapEditorTerrainsPlugin::_update_terrains_tree() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::_update_tiles_list() {
|
||||
void RTileMapEditorTerrainsPlugin::_update_tiles_list() {
|
||||
terrains_tile_list->clear();
|
||||
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
@ -3172,7 +3172,7 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::_update_theme() {
|
||||
void RTileMapEditorTerrainsPlugin::_update_theme() {
|
||||
paint_tool_button->set_icon(main_vbox_container->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
|
||||
line_tool_button->set_icon(main_vbox_container->get_theme_icon(SNAME("CurveLinear"), SNAME("EditorIcons")));
|
||||
rect_tool_button->set_icon(main_vbox_container->get_theme_icon(SNAME("Rectangle"), SNAME("EditorIcons")));
|
||||
@ -3182,7 +3182,7 @@ void TileMapEditorTerrainsPlugin::_update_theme() {
|
||||
erase_button->set_icon(main_vbox_container->get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons")));
|
||||
}
|
||||
|
||||
void TileMapEditorTerrainsPlugin::edit(ObjectID p_tile_map_id, int p_tile_map_layer) {
|
||||
void RTileMapEditorTerrainsPlugin::edit(ObjectID p_tile_map_id, int p_tile_map_layer) {
|
||||
_stop_dragging(); // Avoids staying in a wrong drag state.
|
||||
|
||||
tile_map_id = p_tile_map_id;
|
||||
@ -3193,10 +3193,10 @@ void TileMapEditorTerrainsPlugin::edit(ObjectID p_tile_map_id, int p_tile_map_la
|
||||
_update_tiles_list();
|
||||
}
|
||||
|
||||
TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() {
|
||||
RTileMapEditorTerrainsPlugin::RTileMapEditorTerrainsPlugin() {
|
||||
main_vbox_container = memnew(VBoxContainer);
|
||||
main_vbox_container->connect("tree_entered", callable_mp(this, &TileMapEditorTerrainsPlugin::_update_theme));
|
||||
main_vbox_container->connect("theme_changed", callable_mp(this, &TileMapEditorTerrainsPlugin::_update_theme));
|
||||
main_vbox_container->connect("tree_entered", callable_mp(this, &RTileMapEditorTerrainsPlugin::_update_theme));
|
||||
main_vbox_container->connect("theme_changed", callable_mp(this, &RTileMapEditorTerrainsPlugin::_update_theme));
|
||||
main_vbox_container->set_name("Terrains");
|
||||
|
||||
HSplitContainer *tilemap_tab_terrains = memnew(HSplitContainer);
|
||||
@ -3210,7 +3210,7 @@ TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() {
|
||||
terrains_tree->set_custom_minimum_size(Size2i(70, 0) * EDSCALE);
|
||||
terrains_tree->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
|
||||
terrains_tree->set_hide_root(true);
|
||||
terrains_tree->connect("item_selected", callable_mp(this, &TileMapEditorTerrainsPlugin::_update_tiles_list));
|
||||
terrains_tree->connect("item_selected", callable_mp(this, &RTileMapEditorTerrainsPlugin::_update_tiles_list));
|
||||
tilemap_tab_terrains->add_child(terrains_tree);
|
||||
|
||||
terrains_tile_list = memnew(ItemList);
|
||||
@ -3234,7 +3234,7 @@ TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() {
|
||||
paint_tool_button->set_button_group(tool_buttons_group);
|
||||
paint_tool_button->set_pressed(true);
|
||||
paint_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/paint_tool", "Paint", Key::D));
|
||||
paint_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTerrainsPlugin::_update_toolbar));
|
||||
paint_tool_button->connect("pressed", callable_mp(this, &RTileMapEditorTerrainsPlugin::_update_toolbar));
|
||||
tilemap_tiles_tools_buttons->add_child(paint_tool_button);
|
||||
|
||||
line_tool_button = memnew(Button);
|
||||
@ -3242,7 +3242,7 @@ TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() {
|
||||
line_tool_button->set_toggle_mode(true);
|
||||
line_tool_button->set_button_group(tool_buttons_group);
|
||||
line_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/line_tool", "Line", Key::L));
|
||||
line_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTerrainsPlugin::_update_toolbar));
|
||||
line_tool_button->connect("pressed", callable_mp(this, &RTileMapEditorTerrainsPlugin::_update_toolbar));
|
||||
tilemap_tiles_tools_buttons->add_child(line_tool_button);
|
||||
|
||||
rect_tool_button = memnew(Button);
|
||||
@ -3250,7 +3250,7 @@ TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() {
|
||||
rect_tool_button->set_toggle_mode(true);
|
||||
rect_tool_button->set_button_group(tool_buttons_group);
|
||||
rect_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/rect_tool", "Rect", Key::R));
|
||||
rect_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTerrainsPlugin::_update_toolbar));
|
||||
rect_tool_button->connect("pressed", callable_mp(this, &RTileMapEditorTerrainsPlugin::_update_toolbar));
|
||||
tilemap_tiles_tools_buttons->add_child(rect_tool_button);
|
||||
|
||||
bucket_tool_button = memnew(Button);
|
||||
@ -3258,7 +3258,7 @@ TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() {
|
||||
bucket_tool_button->set_toggle_mode(true);
|
||||
bucket_tool_button->set_button_group(tool_buttons_group);
|
||||
bucket_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/bucket_tool", "Bucket", Key::B));
|
||||
bucket_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTerrainsPlugin::_update_toolbar));
|
||||
bucket_tool_button->connect("pressed", callable_mp(this, &RTileMapEditorTerrainsPlugin::_update_toolbar));
|
||||
tilemap_tiles_tools_buttons->add_child(bucket_tool_button);
|
||||
|
||||
toolbar->add_child(tilemap_tiles_tools_buttons);
|
||||
@ -3298,10 +3298,10 @@ TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() {
|
||||
tools_settings->add_child(bucket_contiguous_checkbox);
|
||||
}
|
||||
|
||||
TileMapEditorTerrainsPlugin::~TileMapEditorTerrainsPlugin() {
|
||||
RTileMapEditorTerrainsPlugin::~RTileMapEditorTerrainsPlugin() {
|
||||
}
|
||||
|
||||
void TileMapEditor::_notification(int p_what) {
|
||||
void RTileMapEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_THEME_CHANGED:
|
||||
@ -3337,11 +3337,11 @@ void TileMapEditor::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditor::_on_grid_toggled(bool p_pressed) {
|
||||
void RTileMapEditor::_on_grid_toggled(bool p_pressed) {
|
||||
EditorSettings::get_singleton()->set("editors/tiles_editor/display_grid", p_pressed);
|
||||
}
|
||||
|
||||
void TileMapEditor::_layers_selection_button_draw() {
|
||||
void RTileMapEditor::_layers_selection_button_draw() {
|
||||
if (!has_theme_icon(SNAME("arrow"), SNAME("OptionButton"))) {
|
||||
return;
|
||||
}
|
||||
@ -3385,7 +3385,7 @@ void TileMapEditor::_layers_selection_button_draw() {
|
||||
arrow->draw_rect(ci, dst_rect, false, clr);
|
||||
}
|
||||
|
||||
void TileMapEditor::_layers_selection_button_pressed() {
|
||||
void RTileMapEditor::_layers_selection_button_pressed() {
|
||||
if (!layers_selection_popup->is_visible()) {
|
||||
Size2 size = layers_selection_popup->get_contents_minimum_size();
|
||||
size.x = MAX(size.x, layers_selection_button->get_size().x);
|
||||
@ -3397,12 +3397,12 @@ void TileMapEditor::_layers_selection_button_pressed() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditor::_layers_selection_id_pressed(int p_id) {
|
||||
void RTileMapEditor::_layers_selection_id_pressed(int p_id) {
|
||||
tile_map_layer = p_id;
|
||||
_update_layers_selection();
|
||||
}
|
||||
|
||||
void TileMapEditor::_advanced_menu_button_id_pressed(int p_id) {
|
||||
void RTileMapEditor::_advanced_menu_button_id_pressed(int p_id) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -3435,7 +3435,7 @@ void TileMapEditor::_advanced_menu_button_id_pressed(int p_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditor::_update_bottom_panel() {
|
||||
void RTileMapEditor::_update_bottom_panel() {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -3452,7 +3452,7 @@ void TileMapEditor::_update_bottom_panel() {
|
||||
}
|
||||
}
|
||||
|
||||
Vector<Vector2i> TileMapEditor::get_line(TileMap *p_tile_map, Vector2i p_from_cell, Vector2i p_to_cell) {
|
||||
Vector<Vector2i> RTileMapEditor::get_line(TileMap *p_tile_map, Vector2i p_from_cell, Vector2i p_to_cell) {
|
||||
ERR_FAIL_COND_V(!p_tile_map, Vector<Vector2i>());
|
||||
|
||||
Ref<TileSet> tile_set = p_tile_map->get_tileset();
|
||||
@ -3525,11 +3525,11 @@ Vector<Vector2i> TileMapEditor::get_line(TileMap *p_tile_map, Vector2i p_from_ce
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditor::_tile_map_changed() {
|
||||
void RTileMapEditor::_tile_map_changed() {
|
||||
tileset_changed_needs_update = true;
|
||||
}
|
||||
|
||||
void TileMapEditor::_tab_changed(int p_tab_id) {
|
||||
void RTileMapEditor::_tab_changed(int p_tab_id) {
|
||||
// Make the plugin edit the correct tilemap.
|
||||
tabs_plugins[tabs_bar->get_current_tab()]->edit(tile_map_id, tile_map_layer);
|
||||
|
||||
@ -3553,7 +3553,7 @@ void TileMapEditor::_tab_changed(int p_tab_id) {
|
||||
CanvasItemEditor::get_singleton()->update_viewport();
|
||||
}
|
||||
|
||||
void TileMapEditor::_layers_select_next_or_previous(bool p_next) {
|
||||
void RTileMapEditor::_layers_select_next_or_previous(bool p_next) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -3580,7 +3580,7 @@ void TileMapEditor::_layers_select_next_or_previous(bool p_next) {
|
||||
_update_layers_selection();
|
||||
}
|
||||
|
||||
void TileMapEditor::_update_layers_selection() {
|
||||
void RTileMapEditor::_update_layers_selection() {
|
||||
layers_selection_popup->clear();
|
||||
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
@ -3639,7 +3639,7 @@ void TileMapEditor::_update_layers_selection() {
|
||||
tabs_plugins[tabs_bar->get_current_tab()]->edit(tile_map_id, tile_map_layer);
|
||||
}
|
||||
|
||||
void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
|
||||
void RTileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
|
||||
UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
|
||||
ERR_FAIL_COND(!undo_redo);
|
||||
|
||||
@ -3711,7 +3711,7 @@ void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_
|
||||
}
|
||||
}
|
||||
|
||||
bool TileMapEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||
bool RTileMapEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||
if (ED_IS_SHORTCUT("tiles_editor/select_next_layer", p_event) && p_event->is_pressed()) {
|
||||
_layers_select_next_or_previous(true);
|
||||
return true;
|
||||
@ -3725,7 +3725,7 @@ bool TileMapEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||
return tabs_plugins[tabs_bar->get_current_tab()]->forward_canvas_gui_input(p_event);
|
||||
}
|
||||
|
||||
void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
void RTileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (!tile_map) {
|
||||
return;
|
||||
@ -3860,7 +3860,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
tabs_plugins[tabs_bar->get_current_tab()]->forward_canvas_draw_over_viewport(p_overlay);
|
||||
}
|
||||
|
||||
void TileMapEditor::edit(TileMap *p_tile_map) {
|
||||
void RTileMapEditor::edit(TileMap *p_tile_map) {
|
||||
if (p_tile_map && p_tile_map->get_instance_id() == tile_map_id) {
|
||||
return;
|
||||
}
|
||||
@ -3873,7 +3873,7 @@ void TileMapEditor::edit(TileMap *p_tile_map) {
|
||||
}
|
||||
|
||||
// Disconnect to changes.
|
||||
tile_map->disconnect("changed", callable_mp(this, &TileMapEditor::_tile_map_changed));
|
||||
tile_map->disconnect("changed", callable_mp(this, &RTileMapEditor::_tile_map_changed));
|
||||
}
|
||||
|
||||
if (p_tile_map) {
|
||||
@ -3881,8 +3881,8 @@ void TileMapEditor::edit(TileMap *p_tile_map) {
|
||||
tile_map_id = p_tile_map->get_instance_id();
|
||||
tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
// Connect to changes.
|
||||
if (!tile_map->is_connected("changed", callable_mp(this, &TileMapEditor::_tile_map_changed))) {
|
||||
tile_map->connect("changed", callable_mp(this, &TileMapEditor::_tile_map_changed));
|
||||
if (!tile_map->is_connected("changed", callable_mp(this, &RTileMapEditor::_tile_map_changed))) {
|
||||
tile_map->connect("changed", callable_mp(this, &RTileMapEditor::_tile_map_changed));
|
||||
}
|
||||
} else {
|
||||
tile_map_id = ObjectID();
|
||||
@ -3896,7 +3896,7 @@ void TileMapEditor::edit(TileMap *p_tile_map) {
|
||||
_tile_map_changed();
|
||||
}
|
||||
|
||||
TileMapEditor::TileMapEditor() {
|
||||
RTileMapEditor::RTileMapEditor() {
|
||||
set_process_internal(true);
|
||||
|
||||
// Shortcuts.
|
||||
@ -3904,21 +3904,21 @@ TileMapEditor::TileMapEditor() {
|
||||
ED_SHORTCUT("tiles_editor/select_previous_layer", TTR("Select Previous Tile Map Layer"), Key::PAGEDOWN);
|
||||
|
||||
// TileMap editor plugins
|
||||
tile_map_editor_plugins.push_back(memnew(TileMapEditorTilesPlugin));
|
||||
tile_map_editor_plugins.push_back(memnew(TileMapEditorTerrainsPlugin));
|
||||
tile_map_editor_plugins.push_back(memnew(RTileMapEditorTilesPlugin));
|
||||
tile_map_editor_plugins.push_back(memnew(RTileMapEditorTerrainsPlugin));
|
||||
|
||||
// TabBar.
|
||||
tabs_bar = memnew(TabBar);
|
||||
tabs_bar->set_clip_tabs(false);
|
||||
for (int plugin_index = 0; plugin_index < tile_map_editor_plugins.size(); plugin_index++) {
|
||||
Vector<TileMapEditorPlugin::TabData> tabs_vector = tile_map_editor_plugins[plugin_index]->get_tabs();
|
||||
Vector<RTileMapEditorPlugin::TabData> tabs_vector = tile_map_editor_plugins[plugin_index]->get_tabs();
|
||||
for (int tab_index = 0; tab_index < tabs_vector.size(); tab_index++) {
|
||||
tabs_bar->add_tab(tabs_vector[tab_index].panel->get_name());
|
||||
tabs_data.push_back(tabs_vector[tab_index]);
|
||||
tabs_plugins.push_back(tile_map_editor_plugins[plugin_index]);
|
||||
}
|
||||
}
|
||||
tabs_bar->connect("tab_changed", callable_mp(this, &TileMapEditor::_tab_changed));
|
||||
tabs_bar->connect("tab_changed", callable_mp(this, &RTileMapEditor::_tab_changed));
|
||||
|
||||
// --- TileMap toolbar ---
|
||||
tile_map_toolbar = memnew(HBoxContainer);
|
||||
@ -3943,13 +3943,13 @@ TileMapEditor::TileMapEditor() {
|
||||
|
||||
// Layer selector.
|
||||
layers_selection_popup = memnew(PopupMenu);
|
||||
layers_selection_popup->connect("id_pressed", callable_mp(this, &TileMapEditor::_layers_selection_id_pressed));
|
||||
layers_selection_popup->connect("id_pressed", callable_mp(this, &RTileMapEditor::_layers_selection_id_pressed));
|
||||
layers_selection_popup->set_close_on_parent_focus(false);
|
||||
|
||||
layers_selection_button = memnew(Button);
|
||||
layers_selection_button->set_toggle_mode(true);
|
||||
layers_selection_button->connect("draw", callable_mp(this, &TileMapEditor::_layers_selection_button_draw));
|
||||
layers_selection_button->connect("pressed", callable_mp(this, &TileMapEditor::_layers_selection_button_pressed));
|
||||
layers_selection_button->connect("draw", callable_mp(this, &RTileMapEditor::_layers_selection_button_draw));
|
||||
layers_selection_button->connect("pressed", callable_mp(this, &RTileMapEditor::_layers_selection_button_pressed));
|
||||
layers_selection_button->connect("hidden", callable_mp((Window *)layers_selection_popup, &Popup::hide));
|
||||
layers_selection_button->set_tooltip(TTR("Tile Map Layer"));
|
||||
layers_selection_button->add_child(layers_selection_popup);
|
||||
@ -3959,7 +3959,7 @@ TileMapEditor::TileMapEditor() {
|
||||
toogle_highlight_selected_layer_button->set_flat(true);
|
||||
toogle_highlight_selected_layer_button->set_toggle_mode(true);
|
||||
toogle_highlight_selected_layer_button->set_pressed(true);
|
||||
toogle_highlight_selected_layer_button->connect("pressed", callable_mp(this, &TileMapEditor::_update_layers_selection));
|
||||
toogle_highlight_selected_layer_button->connect("pressed", callable_mp(this, &RTileMapEditor::_update_layers_selection));
|
||||
toogle_highlight_selected_layer_button->set_tooltip(TTR("Highlight Selected TileMap Layer"));
|
||||
tile_map_toolbar->add_child(toogle_highlight_selected_layer_button);
|
||||
|
||||
@ -3970,14 +3970,14 @@ TileMapEditor::TileMapEditor() {
|
||||
toggle_grid_button->set_flat(true);
|
||||
toggle_grid_button->set_toggle_mode(true);
|
||||
toggle_grid_button->set_tooltip(TTR("Toggle grid visibility."));
|
||||
toggle_grid_button->connect("toggled", callable_mp(this, &TileMapEditor::_on_grid_toggled));
|
||||
toggle_grid_button->connect("toggled", callable_mp(this, &RTileMapEditor::_on_grid_toggled));
|
||||
tile_map_toolbar->add_child(toggle_grid_button);
|
||||
|
||||
// Advanced settings menu button.
|
||||
advanced_menu_button = memnew(MenuButton);
|
||||
advanced_menu_button->set_flat(true);
|
||||
advanced_menu_button->get_popup()->add_item(TTR("Automatically Replace Tiles with Proxies"));
|
||||
advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &TileMapEditor::_advanced_menu_button_id_pressed));
|
||||
advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &RTileMapEditor::_advanced_menu_button_id_pressed));
|
||||
tile_map_toolbar->add_child(advanced_menu_button);
|
||||
|
||||
missing_tileset_label = memnew(Label);
|
||||
@ -3999,10 +3999,10 @@ TileMapEditor::TileMapEditor() {
|
||||
_tab_changed(0);
|
||||
|
||||
// Registers UndoRedo inspector callback.
|
||||
EditorNode::get_singleton()->get_editor_data().add_move_array_element_function(SNAME("TileMap"), callable_mp(this, &TileMapEditor::_move_tile_map_array_element));
|
||||
EditorNode::get_singleton()->get_editor_data().add_move_array_element_function(SNAME("TileMap"), callable_mp(this, &RTileMapEditor::_move_tile_map_array_element));
|
||||
}
|
||||
|
||||
TileMapEditor::~TileMapEditor() {
|
||||
RTileMapEditor::~RTileMapEditor() {
|
||||
for (int i = 0; i < tile_map_editor_plugins.size(); i++) {
|
||||
memdelete(tile_map_editor_plugins[i]);
|
||||
}
|
||||
|
@ -28,8 +28,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TILE_MAP_EDITOR_H
|
||||
#define TILE_MAP_EDITOR_H
|
||||
#ifndef RTILE_MAP_EDITOR_H
|
||||
#define RTILE_MAP_EDITOR_H
|
||||
|
||||
#include "tile_atlas_view.h"
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/tab_bar.h"
|
||||
|
||||
class TileMapEditorPlugin : public Object {
|
||||
class RTileMapEditorPlugin : public Object {
|
||||
public:
|
||||
struct TabData {
|
||||
Control *toolbar;
|
||||
@ -57,8 +57,8 @@ public:
|
||||
virtual void edit(ObjectID p_tile_map_id, int p_tile_map_layer){};
|
||||
};
|
||||
|
||||
class TileMapEditorTilesPlugin : public TileMapEditorPlugin {
|
||||
GDCLASS(TileMapEditorTilesPlugin, TileMapEditorPlugin);
|
||||
class RTileMapEditorTilesPlugin : public RTileMapEditorPlugin {
|
||||
GDCLASS(RTileMapEditorTilesPlugin, RTileMapEditorPlugin);
|
||||
|
||||
private:
|
||||
UndoRedo *undo_redo = EditorNode::get_undo_redo();
|
||||
@ -153,7 +153,7 @@ private:
|
||||
|
||||
// Atlas sources.
|
||||
TileMapCell hovered_tile;
|
||||
TileAtlasView *tile_atlas_view;
|
||||
RTileAtlasView *tile_atlas_view;
|
||||
HSplitContainer *atlas_sources_split_container;
|
||||
|
||||
bool tile_set_dragging_selection = false;
|
||||
@ -202,12 +202,12 @@ public:
|
||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override;
|
||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override;
|
||||
|
||||
TileMapEditorTilesPlugin();
|
||||
~TileMapEditorTilesPlugin();
|
||||
RTileMapEditorTilesPlugin();
|
||||
~RTileMapEditorTilesPlugin();
|
||||
};
|
||||
|
||||
class TileMapEditorTerrainsPlugin : public TileMapEditorPlugin {
|
||||
GDCLASS(TileMapEditorTerrainsPlugin, TileMapEditorPlugin);
|
||||
class RTileMapEditorTerrainsPlugin : public RTileMapEditorPlugin {
|
||||
GDCLASS(RTileMapEditorTerrainsPlugin, RTileMapEditorPlugin);
|
||||
|
||||
private:
|
||||
UndoRedo *undo_redo = EditorNode::get_undo_redo();
|
||||
@ -288,12 +288,12 @@ public:
|
||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override;
|
||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override;
|
||||
|
||||
TileMapEditorTerrainsPlugin();
|
||||
~TileMapEditorTerrainsPlugin();
|
||||
RTileMapEditorTerrainsPlugin();
|
||||
~RTileMapEditorTerrainsPlugin();
|
||||
};
|
||||
|
||||
class TileMapEditor : public VBoxContainer {
|
||||
GDCLASS(TileMapEditor, VBoxContainer);
|
||||
class RTileMapEditor : public VBoxContainer {
|
||||
GDCLASS(RTileMapEditor, VBoxContainer);
|
||||
|
||||
private:
|
||||
UndoRedo *undo_redo = EditorNode::get_undo_redo();
|
||||
@ -302,7 +302,7 @@ private:
|
||||
int tile_map_layer = -1;
|
||||
|
||||
// Vector to keep plugins.
|
||||
Vector<TileMapEditorPlugin *> tile_map_editor_plugins;
|
||||
Vector<RTileMapEditorPlugin *> tile_map_editor_plugins;
|
||||
|
||||
// Toolbar.
|
||||
HBoxContainer *tile_map_toolbar;
|
||||
@ -323,8 +323,8 @@ private:
|
||||
// Bottom panel.
|
||||
Label *missing_tileset_label;
|
||||
TabBar *tabs_bar;
|
||||
LocalVector<TileMapEditorPlugin::TabData> tabs_data;
|
||||
LocalVector<TileMapEditorPlugin *> tabs_plugins;
|
||||
LocalVector<RTileMapEditorPlugin::TabData> tabs_data;
|
||||
LocalVector<RTileMapEditorPlugin *> tabs_plugins;
|
||||
void _update_bottom_panel();
|
||||
|
||||
// TileMap.
|
||||
@ -352,8 +352,8 @@ public:
|
||||
|
||||
void edit(TileMap *p_tile_map);
|
||||
|
||||
TileMapEditor();
|
||||
~TileMapEditor();
|
||||
RTileMapEditor();
|
||||
~RTileMapEditor();
|
||||
|
||||
// Static functions.
|
||||
static Vector<Vector2i> get_line(TileMap *p_tile_map, Vector2i p_from_cell, Vector2i p_to_cell);
|
||||
|
@ -32,21 +32,21 @@
|
||||
|
||||
#include "editor/editor_scale.h"
|
||||
|
||||
void TileProxiesManagerDialog::_right_clicked(int p_item, Vector2 p_local_mouse_pos, Object *p_item_list) {
|
||||
void RTileProxiesManagerDialog::_right_clicked(int p_item, Vector2 p_local_mouse_pos, Object *p_item_list) {
|
||||
ItemList *item_list = Object::cast_to<ItemList>(p_item_list);
|
||||
popup_menu->reset_size();
|
||||
popup_menu->set_position(get_position() + item_list->get_global_mouse_position());
|
||||
popup_menu->popup();
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_menu_id_pressed(int p_id) {
|
||||
void RTileProxiesManagerDialog::_menu_id_pressed(int p_id) {
|
||||
if (p_id == 0) {
|
||||
// Delete.
|
||||
_delete_selected_bindings();
|
||||
}
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_delete_selected_bindings() {
|
||||
void RTileProxiesManagerDialog::_delete_selected_bindings() {
|
||||
undo_redo->create_action(TTR("Remove Tile Proxies"));
|
||||
|
||||
Vector<int> source_level_selected = source_level_list->get_selected_items();
|
||||
@ -79,7 +79,7 @@ void TileProxiesManagerDialog::_delete_selected_bindings() {
|
||||
commited_actions_count += 1;
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_update_lists() {
|
||||
void RTileProxiesManagerDialog::_update_lists() {
|
||||
source_level_list->clear();
|
||||
coords_level_list->clear();
|
||||
alternative_level_list->clear();
|
||||
@ -109,7 +109,7 @@ void TileProxiesManagerDialog::_update_lists() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_update_enabled_property_editors() {
|
||||
void RTileProxiesManagerDialog::_update_enabled_property_editors() {
|
||||
if (from.source_id == TileSet::INVALID_SOURCE) {
|
||||
from.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS);
|
||||
to.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS);
|
||||
@ -141,11 +141,11 @@ void TileProxiesManagerDialog::_update_enabled_property_editors() {
|
||||
alternative_to_property_editor->update_property();
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
|
||||
void RTileProxiesManagerDialog::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
|
||||
_set(p_path, p_value);
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_add_button_pressed() {
|
||||
void RTileProxiesManagerDialog::_add_button_pressed() {
|
||||
if (from.source_id != TileSet::INVALID_SOURCE && to.source_id != TileSet::INVALID_SOURCE) {
|
||||
Vector2i from_coords = from.get_atlas_coords();
|
||||
Vector2i to_coords = to.get_atlas_coords();
|
||||
@ -185,7 +185,7 @@ void TileProxiesManagerDialog::_add_button_pressed() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_clear_invalid_button_pressed() {
|
||||
void RTileProxiesManagerDialog::_clear_invalid_button_pressed() {
|
||||
undo_redo->create_action(TTR("Delete All Invalid Tile Proxies"));
|
||||
|
||||
undo_redo->add_do_method(*tile_set, "cleanup_invalid_tile_proxies");
|
||||
@ -212,7 +212,7 @@ void TileProxiesManagerDialog::_clear_invalid_button_pressed() {
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_clear_all_button_pressed() {
|
||||
void RTileProxiesManagerDialog::_clear_all_button_pressed() {
|
||||
undo_redo->create_action(TTR("Delete All Tile Proxies"));
|
||||
|
||||
undo_redo->add_do_method(*tile_set, "clear_tile_proxies");
|
||||
@ -239,7 +239,7 @@ void TileProxiesManagerDialog::_clear_all_button_pressed() {
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
bool TileProxiesManagerDialog::_set(const StringName &p_name, const Variant &p_value) {
|
||||
bool RTileProxiesManagerDialog::_set(const StringName &p_name, const Variant &p_value) {
|
||||
if (p_name == "from_source") {
|
||||
from.source_id = MAX(int(p_value), -1);
|
||||
} else if (p_name == "from_coords") {
|
||||
@ -259,7 +259,7 @@ bool TileProxiesManagerDialog::_set(const StringName &p_name, const Variant &p_v
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TileProxiesManagerDialog::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
bool RTileProxiesManagerDialog::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (p_name == "from_source") {
|
||||
r_ret = from.source_id;
|
||||
} else if (p_name == "from_coords") {
|
||||
@ -278,7 +278,7 @@ bool TileProxiesManagerDialog::_get(const StringName &p_name, Variant &r_ret) co
|
||||
return true;
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_unhandled_key_input(Ref<InputEvent> p_event) {
|
||||
void RTileProxiesManagerDialog::_unhandled_key_input(Ref<InputEvent> p_event) {
|
||||
ERR_FAIL_COND(p_event.is_null());
|
||||
|
||||
if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) {
|
||||
@ -292,26 +292,26 @@ void TileProxiesManagerDialog::_unhandled_key_input(Ref<InputEvent> p_event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::cancel_pressed() {
|
||||
void RTileProxiesManagerDialog::cancel_pressed() {
|
||||
for (int i = 0; i < commited_actions_count; i++) {
|
||||
undo_redo->undo();
|
||||
}
|
||||
commited_actions_count = 0;
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_update_lists"), &TileProxiesManagerDialog::_update_lists);
|
||||
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &TileProxiesManagerDialog::_unhandled_key_input);
|
||||
void RTileProxiesManagerDialog::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_update_lists"), &RTileProxiesManagerDialog::_update_lists);
|
||||
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &RTileProxiesManagerDialog::_unhandled_key_input);
|
||||
}
|
||||
|
||||
void TileProxiesManagerDialog::update_tile_set(Ref<TileSet> p_tile_set) {
|
||||
void RTileProxiesManagerDialog::update_tile_set(Ref<TileSet> p_tile_set) {
|
||||
ERR_FAIL_COND(!p_tile_set.is_valid());
|
||||
tile_set = p_tile_set;
|
||||
commited_actions_count = 0;
|
||||
_update_lists();
|
||||
}
|
||||
|
||||
TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
RTileProxiesManagerDialog::RTileProxiesManagerDialog() {
|
||||
// Tile proxy management window.
|
||||
set_title(TTR("Tile Proxies Management"));
|
||||
set_process_unhandled_key_input(true);
|
||||
@ -333,7 +333,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
source_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
source_level_list->set_select_mode(ItemList::SELECT_MULTI);
|
||||
source_level_list->set_allow_rmb_select(true);
|
||||
source_level_list->connect("item_rmb_selected", callable_mp(this, &TileProxiesManagerDialog::_right_clicked), varray(source_level_list));
|
||||
source_level_list->connect("item_rmb_selected", callable_mp(this, &RTileProxiesManagerDialog::_right_clicked), varray(source_level_list));
|
||||
vbox_container->add_child(source_level_list);
|
||||
|
||||
Label *coords_level_label = memnew(Label);
|
||||
@ -344,7 +344,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
coords_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
coords_level_list->set_select_mode(ItemList::SELECT_MULTI);
|
||||
coords_level_list->set_allow_rmb_select(true);
|
||||
coords_level_list->connect("item_rmb_selected", callable_mp(this, &TileProxiesManagerDialog::_right_clicked), varray(coords_level_list));
|
||||
coords_level_list->connect("item_rmb_selected", callable_mp(this, &RTileProxiesManagerDialog::_right_clicked), varray(coords_level_list));
|
||||
vbox_container->add_child(coords_level_list);
|
||||
|
||||
Label *alternative_level_label = memnew(Label);
|
||||
@ -355,12 +355,12 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
alternative_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
alternative_level_list->set_select_mode(ItemList::SELECT_MULTI);
|
||||
alternative_level_list->set_allow_rmb_select(true);
|
||||
alternative_level_list->connect("item_rmb_selected", callable_mp(this, &TileProxiesManagerDialog::_right_clicked), varray(alternative_level_list));
|
||||
alternative_level_list->connect("item_rmb_selected", callable_mp(this, &RTileProxiesManagerDialog::_right_clicked), varray(alternative_level_list));
|
||||
vbox_container->add_child(alternative_level_list);
|
||||
|
||||
popup_menu = memnew(PopupMenu);
|
||||
popup_menu->add_shortcut(ED_GET_SHORTCUT("ui_text_delete"));
|
||||
popup_menu->connect("id_pressed", callable_mp(this, &TileProxiesManagerDialog::_menu_id_pressed));
|
||||
popup_menu->connect("id_pressed", callable_mp(this, &RTileProxiesManagerDialog::_menu_id_pressed));
|
||||
add_child(popup_menu);
|
||||
|
||||
// Add proxy panel.
|
||||
@ -382,7 +382,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
source_from_property_editor = memnew(EditorPropertyInteger);
|
||||
source_from_property_editor->set_label(TTR("From Source"));
|
||||
source_from_property_editor->set_object_and_property(this, "from_source");
|
||||
source_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
|
||||
source_from_property_editor->connect("property_changed", callable_mp(this, &RTileProxiesManagerDialog::_property_changed));
|
||||
source_from_property_editor->set_selectable(false);
|
||||
source_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
source_from_property_editor->setup(-1, 99999, 1, true, false);
|
||||
@ -391,7 +391,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
coords_from_property_editor = memnew(EditorPropertyVector2i);
|
||||
coords_from_property_editor->set_label(TTR("From Coords"));
|
||||
coords_from_property_editor->set_object_and_property(this, "from_coords");
|
||||
coords_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
|
||||
coords_from_property_editor->connect("property_changed", callable_mp(this, &RTileProxiesManagerDialog::_property_changed));
|
||||
coords_from_property_editor->set_selectable(false);
|
||||
coords_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
coords_from_property_editor->setup(-1, 99999, true);
|
||||
@ -401,7 +401,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
alternative_from_property_editor = memnew(EditorPropertyInteger);
|
||||
alternative_from_property_editor->set_label(TTR("From Alternative"));
|
||||
alternative_from_property_editor->set_object_and_property(this, "from_alternative");
|
||||
alternative_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
|
||||
alternative_from_property_editor->connect("property_changed", callable_mp(this, &RTileProxiesManagerDialog::_property_changed));
|
||||
alternative_from_property_editor->set_selectable(false);
|
||||
alternative_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
alternative_from_property_editor->setup(-1, 99999, 1, true, false);
|
||||
@ -416,7 +416,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
source_to_property_editor = memnew(EditorPropertyInteger);
|
||||
source_to_property_editor->set_label(TTR("To Source"));
|
||||
source_to_property_editor->set_object_and_property(this, "to_source");
|
||||
source_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
|
||||
source_to_property_editor->connect("property_changed", callable_mp(this, &RTileProxiesManagerDialog::_property_changed));
|
||||
source_to_property_editor->set_selectable(false);
|
||||
source_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
source_to_property_editor->setup(-1, 99999, 1, true, false);
|
||||
@ -425,7 +425,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
coords_to_property_editor = memnew(EditorPropertyVector2i);
|
||||
coords_to_property_editor->set_label(TTR("To Coords"));
|
||||
coords_to_property_editor->set_object_and_property(this, "to_coords");
|
||||
coords_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
|
||||
coords_to_property_editor->connect("property_changed", callable_mp(this, &RTileProxiesManagerDialog::_property_changed));
|
||||
coords_to_property_editor->set_selectable(false);
|
||||
coords_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
coords_to_property_editor->setup(-1, 99999, true);
|
||||
@ -435,7 +435,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
alternative_to_property_editor = memnew(EditorPropertyInteger);
|
||||
alternative_to_property_editor->set_label(TTR("To Alternative"));
|
||||
alternative_to_property_editor->set_object_and_property(this, "to_alternative");
|
||||
alternative_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
|
||||
alternative_to_property_editor->connect("property_changed", callable_mp(this, &RTileProxiesManagerDialog::_property_changed));
|
||||
alternative_to_property_editor->set_selectable(false);
|
||||
alternative_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
alternative_to_property_editor->setup(-1, 99999, 1, true, false);
|
||||
@ -445,7 +445,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
Button *add_button = memnew(Button);
|
||||
add_button->set_text(TTR("Add"));
|
||||
add_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
|
||||
add_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_add_button_pressed));
|
||||
add_button->connect("pressed", callable_mp(this, &RTileProxiesManagerDialog::_add_button_pressed));
|
||||
vbox_container->add_child(add_button);
|
||||
|
||||
h_separator = memnew(HSeparator);
|
||||
@ -462,13 +462,13 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
|
||||
Button *clear_invalid_button = memnew(Button);
|
||||
clear_invalid_button->set_text(TTR("Clear Invalid"));
|
||||
clear_invalid_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
|
||||
clear_invalid_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_clear_invalid_button_pressed));
|
||||
clear_invalid_button->connect("pressed", callable_mp(this, &RTileProxiesManagerDialog::_clear_invalid_button_pressed));
|
||||
hboxcontainer->add_child(clear_invalid_button);
|
||||
|
||||
Button *clear_all_button = memnew(Button);
|
||||
clear_all_button->set_text(TTR("Clear All"));
|
||||
clear_all_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
|
||||
clear_all_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_clear_all_button_pressed));
|
||||
clear_all_button->connect("pressed", callable_mp(this, &RTileProxiesManagerDialog::_clear_all_button_pressed));
|
||||
hboxcontainer->add_child(clear_all_button);
|
||||
|
||||
h_separator = memnew(HSeparator);
|
||||
|
@ -28,8 +28,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TILE_PROXIES_MANAGER_DIALOG_H
|
||||
#define TILE_PROXIES_MANAGER_DIALOG_H
|
||||
#ifndef RTILE_PROXIES_MANAGER_DIALOG_H
|
||||
#define RTILE_PROXIES_MANAGER_DIALOG_H
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_properties.h"
|
||||
@ -38,8 +38,8 @@
|
||||
#include "scene/gui/dialogs.h"
|
||||
#include "scene/gui/item_list.h"
|
||||
|
||||
class TileProxiesManagerDialog : public ConfirmationDialog {
|
||||
GDCLASS(TileProxiesManagerDialog, ConfirmationDialog);
|
||||
class RTileProxiesManagerDialog : public ConfirmationDialog {
|
||||
GDCLASS(RTileProxiesManagerDialog, ConfirmationDialog);
|
||||
|
||||
private:
|
||||
int commited_actions_count = 0;
|
||||
@ -84,7 +84,7 @@ protected:
|
||||
public:
|
||||
void update_tile_set(Ref<TileSet> p_tile_set);
|
||||
|
||||
TileProxiesManagerDialog();
|
||||
RTileProxiesManagerDialog();
|
||||
};
|
||||
|
||||
#endif // TILE_PROXIES_MANAGER_DIALOG_H
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "core/math/geometry_2d.h"
|
||||
#include "core/os/keyboard.h"
|
||||
|
||||
void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id(int p_id) {
|
||||
void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id(int p_id) {
|
||||
ERR_FAIL_COND(p_id < 0);
|
||||
if (source_id == p_id) {
|
||||
return;
|
||||
@ -61,11 +61,11 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id(int p_id) {
|
||||
emit_signal(SNAME("changed"), "id");
|
||||
}
|
||||
|
||||
int TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id() {
|
||||
int RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id() {
|
||||
return source_id;
|
||||
}
|
||||
|
||||
bool TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_set(const StringName &p_name, const Variant &p_value) {
|
||||
bool RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_set(const StringName &p_name, const Variant &p_value) {
|
||||
String name = p_name;
|
||||
if (name == "name") {
|
||||
// Use the resource_name property to store the source's name.
|
||||
@ -79,7 +79,7 @@ bool TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_set(const StringN
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
bool RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (!tile_set_atlas_source) {
|
||||
return false;
|
||||
}
|
||||
@ -93,7 +93,7 @@ bool TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get(const StringN
|
||||
return valid;
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::STRING, "name", PROPERTY_HINT_NONE, ""));
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"));
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "margins", PROPERTY_HINT_NONE, ""));
|
||||
@ -102,17 +102,17 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get_property_list
|
||||
p_list->push_back(PropertyInfo(Variant::BOOL, "use_texture_padding", PROPERTY_HINT_NONE, ""));
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_bind_methods() {
|
||||
void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_bind_methods() {
|
||||
// -- Shape and layout --
|
||||
ClassDB::bind_method(D_METHOD("set_id", "id"), &TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id);
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id);
|
||||
ClassDB::bind_method(D_METHOD("set_id", "id"), &RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id);
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
||||
|
||||
ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what")));
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
|
||||
void RTileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
|
||||
ERR_FAIL_COND(!p_tile_set.is_valid());
|
||||
ERR_FAIL_COND(!p_tile_set_atlas_source);
|
||||
ERR_FAIL_COND(p_source_id < 0);
|
||||
@ -142,7 +142,7 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::edit(Ref<TileSet>
|
||||
}
|
||||
|
||||
// -- Proxy object used by the tile inspector --
|
||||
bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_name, const Variant &p_value) {
|
||||
bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_name, const Variant &p_value) {
|
||||
if (!tile_set_atlas_source) {
|
||||
return false;
|
||||
}
|
||||
@ -288,7 +288,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na
|
||||
return any_valid;
|
||||
}
|
||||
|
||||
bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (!tile_set_atlas_source) {
|
||||
return false;
|
||||
}
|
||||
@ -372,7 +372,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_na
|
||||
return false;
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
if (!tile_set_atlas_source) {
|
||||
return;
|
||||
}
|
||||
@ -472,7 +472,7 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles) {
|
||||
void RTileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles) {
|
||||
ERR_FAIL_COND(!p_tile_set_atlas_source);
|
||||
ERR_FAIL_COND(p_tiles.is_empty());
|
||||
for (Set<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) {
|
||||
@ -512,17 +512,17 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::edit(TileSetAtlasSource *p_
|
||||
notify_property_list_changed();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::AtlasTileProxyObject::_bind_methods() {
|
||||
void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what")));
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_inspector_property_selected(String p_property) {
|
||||
void RTileSetAtlasSourceEditor::_inspector_property_selected(String p_property) {
|
||||
selected_property = p_property;
|
||||
_update_atlas_view();
|
||||
_update_current_tile_data_editor();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_update_tile_id_label() {
|
||||
void RTileSetAtlasSourceEditor::_update_tile_id_label() {
|
||||
if (selection.size() == 1) {
|
||||
TileSelection selected = selection.front()->get();
|
||||
tool_tile_id_label->set_text(vformat("%d, %s, %d", tile_set_atlas_source_id, selected.tile, selected.alternative));
|
||||
@ -533,12 +533,12 @@ void TileSetAtlasSourceEditor::_update_tile_id_label() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_update_source_inspector() {
|
||||
void RTileSetAtlasSourceEditor::_update_source_inspector() {
|
||||
// Update the proxy object.
|
||||
atlas_source_proxy_object->edit(tile_set, tile_set_atlas_source, tile_set_atlas_source_id);
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() {
|
||||
void RTileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() {
|
||||
// Fix selected.
|
||||
for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
|
||||
TileSelection selected = E->get();
|
||||
@ -558,14 +558,14 @@ void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_update_atlas_source_inspector() {
|
||||
void RTileSetAtlasSourceEditor::_update_atlas_source_inspector() {
|
||||
// Update visibility.
|
||||
bool visible = tools_button_group->get_pressed_button() == tool_setup_atlas_source_button;
|
||||
atlas_source_inspector_label->set_visible(visible);
|
||||
atlas_source_inspector->set_visible(visible);
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_update_tile_inspector() {
|
||||
void RTileSetAtlasSourceEditor::_update_tile_inspector() {
|
||||
// Update visibility.
|
||||
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
||||
if (!selection.is_empty()) {
|
||||
@ -581,7 +581,7 @@ void TileSetAtlasSourceEditor::_update_tile_inspector() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_update_tile_data_editors() {
|
||||
void RTileSetAtlasSourceEditor::_update_tile_data_editors() {
|
||||
String previously_selected;
|
||||
if (tile_data_editors_tree && tile_data_editors_tree->get_selected()) {
|
||||
previously_selected = tile_data_editors_tree->get_selected()->get_metadata(0);
|
||||
@ -757,9 +757,9 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() {
|
||||
#undef ADD_TILE_DATA_EDITOR
|
||||
|
||||
// Add tile data editors as children.
|
||||
for (KeyValue<String, TileDataEditor *> &E : tile_data_editors) {
|
||||
for (KeyValue<String, RTileDataEditor *> &E : tile_data_editors) {
|
||||
// Tile Data Editor.
|
||||
TileDataEditor *tile_data_editor = E.value;
|
||||
RTileDataEditor *tile_data_editor = E.value;
|
||||
if (!tile_data_editor->is_inside_tree()) {
|
||||
tile_data_painting_editor_container->add_child(tile_data_editor);
|
||||
}
|
||||
@ -784,7 +784,7 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() {
|
||||
tile_data_editors_label->set_visible(is_visible);
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_update_current_tile_data_editor() {
|
||||
void RTileSetAtlasSourceEditor::_update_current_tile_data_editor() {
|
||||
// Find the property to use.
|
||||
String property;
|
||||
if (tools_button_group->get_pressed_button() == tool_select_button && tile_inspector->is_visible() && !tile_inspector->get_selected_path().is_empty()) {
|
||||
@ -803,7 +803,7 @@ void TileSetAtlasSourceEditor::_update_current_tile_data_editor() {
|
||||
}
|
||||
|
||||
// Hide all editors but the current one.
|
||||
for (const KeyValue<String, TileDataEditor *> &E : tile_data_editors) {
|
||||
for (const KeyValue<String, RTileDataEditor *> &E : tile_data_editors) {
|
||||
E.value->hide();
|
||||
E.value->get_toolbar()->hide();
|
||||
}
|
||||
@ -822,7 +822,7 @@ void TileSetAtlasSourceEditor::_update_current_tile_data_editor() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() {
|
||||
void RTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() {
|
||||
if (!has_theme_icon(SNAME("arrow"), SNAME("OptionButton"))) {
|
||||
return;
|
||||
}
|
||||
@ -861,14 +861,14 @@ void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() {
|
||||
arrow->draw(ci, ofs, clr);
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed() {
|
||||
void RTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed() {
|
||||
Size2 size = tile_data_editor_dropdown_button->get_size();
|
||||
tile_data_editors_popup->set_position(tile_data_editor_dropdown_button->get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
|
||||
tile_data_editors_popup->set_size(Size2(size.width, 0));
|
||||
tile_data_editors_popup->popup();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_data_editors_tree_selected() {
|
||||
void RTileSetAtlasSourceEditor::_tile_data_editors_tree_selected() {
|
||||
tile_data_editors_popup->call_deferred(SNAME("hide"));
|
||||
_update_current_tile_data_editor();
|
||||
tile_atlas_control->update();
|
||||
@ -877,7 +877,7 @@ void TileSetAtlasSourceEditor::_tile_data_editors_tree_selected() {
|
||||
alternative_tiles_control_unscaled->update();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_update_atlas_view() {
|
||||
void RTileSetAtlasSourceEditor::_update_atlas_view() {
|
||||
// Update the atlas display.
|
||||
tile_atlas_view->set_atlas_source(*tile_set, tile_set_atlas_source, tile_set_atlas_source_id);
|
||||
|
||||
@ -929,10 +929,10 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
|
||||
tile_atlas_view->update();
|
||||
|
||||
// Synchronize atlas view.
|
||||
TilesEditorPlugin::get_singleton()->synchronize_atlas_view(tile_atlas_view);
|
||||
RTilesEditorPlugin::get_singleton()->synchronize_atlas_view(tile_atlas_view);
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_update_toolbar() {
|
||||
void RTileSetAtlasSourceEditor::_update_toolbar() {
|
||||
// Show the tools and settings.
|
||||
if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) {
|
||||
if (current_tile_data_editor_toolbar) {
|
||||
@ -958,19 +958,19 @@ void TileSetAtlasSourceEditor::_update_toolbar() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_atlas_control_mouse_exited() {
|
||||
void RTileSetAtlasSourceEditor::_tile_atlas_control_mouse_exited() {
|
||||
hovered_base_tile_coords = TileSetSource::INVALID_ATLAS_COORDS;
|
||||
tile_atlas_control->update();
|
||||
tile_atlas_control_unscaled->update();
|
||||
tile_atlas_view->update();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_atlas_view_transform_changed() {
|
||||
void RTileSetAtlasSourceEditor::_tile_atlas_view_transform_changed() {
|
||||
tile_atlas_control->update();
|
||||
tile_atlas_control_unscaled->update();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
// Update the hovered coords.
|
||||
hovered_base_tile_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(tile_atlas_control->get_local_mouse_position());
|
||||
|
||||
@ -1308,7 +1308,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_end_dragging() {
|
||||
void RTileSetAtlasSourceEditor::_end_dragging() {
|
||||
switch (drag_type) {
|
||||
case DRAG_TYPE_CREATE_TILES:
|
||||
undo_redo->create_action(TTR("Create tiles"));
|
||||
@ -1522,7 +1522,7 @@ void TileSetAtlasSourceEditor::_end_dragging() {
|
||||
tile_atlas_control->set_default_cursor_shape(CURSOR_ARROW);
|
||||
}
|
||||
|
||||
Map<Vector2i, List<const PropertyInfo *>> TileSetAtlasSourceEditor::_group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas) {
|
||||
Map<Vector2i, List<const PropertyInfo *>> RTileSetAtlasSourceEditor::_group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas) {
|
||||
// Group properties per tile.
|
||||
Map<Vector2i, List<const PropertyInfo *>> per_tile;
|
||||
for (const List<PropertyInfo>::Element *E_property = r_list.front(); E_property; E_property = E_property->next()) {
|
||||
@ -1538,7 +1538,7 @@ Map<Vector2i, List<const PropertyInfo *>> TileSetAtlasSourceEditor::_group_prope
|
||||
return per_tile;
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_menu_option(int p_option) {
|
||||
void RTileSetAtlasSourceEditor::_menu_option(int p_option) {
|
||||
switch (p_option) {
|
||||
case TILE_DELETE: {
|
||||
List<PropertyInfo> list;
|
||||
@ -1630,7 +1630,7 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_unhandled_key_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileSetAtlasSourceEditor::_unhandled_key_input(const Ref<InputEvent> &p_event) {
|
||||
// Check for shortcuts.
|
||||
if (ED_IS_SHORTCUT("tiles_editor/delete_tile", p_event)) {
|
||||
if (tools_button_group->get_pressed_button() == tool_select_button && !selection.is_empty()) {
|
||||
@ -1640,7 +1640,7 @@ void TileSetAtlasSourceEditor::_unhandled_key_input(const Ref<InputEvent> &p_eve
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) {
|
||||
void RTileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) {
|
||||
ERR_FAIL_COND((p_selection.size() % 2) != 0);
|
||||
selection.clear();
|
||||
for (int i = 0; i < p_selection.size() / 2; i++) {
|
||||
@ -1655,7 +1655,7 @@ void TileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) {
|
||||
_update_current_tile_data_editor();
|
||||
}
|
||||
|
||||
Array TileSetAtlasSourceEditor::_get_selection_as_array() {
|
||||
Array RTileSetAtlasSourceEditor::_get_selection_as_array() {
|
||||
Array output;
|
||||
for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
|
||||
output.push_back(E->get().tile);
|
||||
@ -1664,7 +1664,7 @@ Array TileSetAtlasSourceEditor::_get_selection_as_array() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
|
||||
void RTileSetAtlasSourceEditor::_tile_atlas_control_draw() {
|
||||
// Colors.
|
||||
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
|
||||
@ -1812,7 +1812,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
|
||||
void RTileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
|
||||
if (current_tile_data_editor) {
|
||||
// Draw the preview of the selected property.
|
||||
for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) {
|
||||
@ -1862,7 +1862,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<InputEvent> &p_event) {
|
||||
// Update the hovered alternative tile.
|
||||
hovered_alternative_tile_coords = tile_atlas_view->get_alternative_tile_at_pos(alternative_tiles_control->get_local_mouse_position());
|
||||
|
||||
@ -1937,7 +1937,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<In
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() {
|
||||
void RTileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() {
|
||||
hovered_alternative_tile_coords = Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE);
|
||||
tile_atlas_control->update();
|
||||
tile_atlas_control_unscaled->update();
|
||||
@ -1945,7 +1945,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() {
|
||||
alternative_tiles_control_unscaled->update();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
|
||||
void RTileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
|
||||
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
|
||||
|
||||
@ -1973,7 +1973,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
|
||||
void RTileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
|
||||
// Draw the preview of the selected property.
|
||||
if (current_tile_data_editor) {
|
||||
// Draw the preview of the currently selected property.
|
||||
@ -2030,16 +2030,16 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_set_changed() {
|
||||
void RTileSetAtlasSourceEditor::_tile_set_changed() {
|
||||
tile_set_changed_needs_update = true;
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_proxy_object_changed(String p_what) {
|
||||
void RTileSetAtlasSourceEditor::_tile_proxy_object_changed(String p_what) {
|
||||
tile_set_changed_needs_update = false; // Avoid updating too many things.
|
||||
_update_atlas_view();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what) {
|
||||
void RTileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what) {
|
||||
if (p_what == "texture" && !atlas_source_proxy_object->get("texture").is_null()) {
|
||||
confirm_auto_create_tiles->popup_centered();
|
||||
} else if (p_what == "id") {
|
||||
@ -2047,7 +2047,7 @@ void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what)
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) {
|
||||
void RTileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) {
|
||||
UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
|
||||
ERR_FAIL_COND(!undo_redo);
|
||||
|
||||
@ -2116,7 +2116,7 @@ void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo
|
||||
#undef ADD_UNDO
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
|
||||
void RTileSetAtlasSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
|
||||
ERR_FAIL_COND(!p_tile_set.is_valid());
|
||||
ERR_FAIL_COND(!p_tile_set_atlas_source);
|
||||
ERR_FAIL_COND(p_source_id < 0);
|
||||
@ -2128,7 +2128,7 @@ void TileSetAtlasSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource
|
||||
|
||||
// Remove listener for old objects.
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_set_changed));
|
||||
tile_set->disconnect("changed", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
}
|
||||
|
||||
// Clear the selection.
|
||||
@ -2141,7 +2141,7 @@ void TileSetAtlasSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource
|
||||
|
||||
// Add the listener again.
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->connect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_set_changed));
|
||||
tile_set->connect("changed", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
}
|
||||
|
||||
// Update everything.
|
||||
@ -2157,11 +2157,11 @@ void TileSetAtlasSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource
|
||||
_update_current_tile_data_editor();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::init_source() {
|
||||
void RTileSetAtlasSourceEditor::init_source() {
|
||||
confirm_auto_create_tiles->popup_centered();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_auto_create_tiles() {
|
||||
void RTileSetAtlasSourceEditor::_auto_create_tiles() {
|
||||
if (!tile_set_atlas_source) {
|
||||
return;
|
||||
}
|
||||
@ -2205,7 +2205,7 @@ void TileSetAtlasSourceEditor::_auto_create_tiles() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_auto_remove_tiles() {
|
||||
void RTileSetAtlasSourceEditor::_auto_remove_tiles() {
|
||||
if (!tile_set_atlas_source) {
|
||||
return;
|
||||
}
|
||||
@ -2266,7 +2266,7 @@ void TileSetAtlasSourceEditor::_auto_remove_tiles() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_notification(int p_what) {
|
||||
void RTileSetAtlasSourceEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_THEME_CHANGED:
|
||||
@ -2303,14 +2303,14 @@ void TileSetAtlasSourceEditor::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &TileSetAtlasSourceEditor::_unhandled_key_input);
|
||||
ClassDB::bind_method(D_METHOD("_set_selection_from_array"), &TileSetAtlasSourceEditor::_set_selection_from_array);
|
||||
void RTileSetAtlasSourceEditor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &RTileSetAtlasSourceEditor::_unhandled_key_input);
|
||||
ClassDB::bind_method(D_METHOD("_set_selection_from_array"), &RTileSetAtlasSourceEditor::_set_selection_from_array);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("source_id_changed", PropertyInfo(Variant::INT, "source_id")));
|
||||
}
|
||||
|
||||
TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
|
||||
RTileSetAtlasSourceEditor::RTileSetAtlasSourceEditor() {
|
||||
set_process_unhandled_key_input(true);
|
||||
set_process_internal(true);
|
||||
|
||||
@ -2335,14 +2335,14 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
|
||||
middle_vbox_container->add_child(tile_inspector_label);
|
||||
|
||||
tile_proxy_object = memnew(AtlasTileProxyObject(this));
|
||||
tile_proxy_object->connect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_proxy_object_changed));
|
||||
tile_proxy_object->connect("changed", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_proxy_object_changed));
|
||||
|
||||
tile_inspector = memnew(EditorInspector);
|
||||
tile_inspector->set_undo_redo(undo_redo);
|
||||
tile_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
|
||||
tile_inspector->edit(tile_proxy_object);
|
||||
tile_inspector->set_use_folding(true);
|
||||
tile_inspector->connect("property_selected", callable_mp(this, &TileSetAtlasSourceEditor::_inspector_property_selected));
|
||||
tile_inspector->connect("property_selected", callable_mp(this, &RTileSetAtlasSourceEditor::_inspector_property_selected));
|
||||
middle_vbox_container->add_child(tile_inspector);
|
||||
|
||||
tile_inspector_no_tile_selected_label = memnew(Label);
|
||||
@ -2358,8 +2358,8 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
|
||||
middle_vbox_container->add_child(tile_data_editors_label);
|
||||
|
||||
tile_data_editor_dropdown_button = memnew(Button);
|
||||
tile_data_editor_dropdown_button->connect("draw", callable_mp(this, &TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw));
|
||||
tile_data_editor_dropdown_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed));
|
||||
tile_data_editor_dropdown_button->connect("draw", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw));
|
||||
tile_data_editor_dropdown_button->connect("pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed));
|
||||
middle_vbox_container->add_child(tile_data_editor_dropdown_button);
|
||||
tile_data_editor_dropdown_button->add_child(tile_data_editors_popup);
|
||||
|
||||
@ -2368,7 +2368,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
|
||||
tile_data_editors_tree->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
|
||||
tile_data_editors_tree->set_h_scroll_enabled(false);
|
||||
tile_data_editors_tree->set_v_scroll_enabled(false);
|
||||
tile_data_editors_tree->connect("item_selected", callable_mp(this, &TileSetAtlasSourceEditor::_tile_data_editors_tree_selected));
|
||||
tile_data_editors_tree->connect("item_selected", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_data_editors_tree_selected));
|
||||
tile_data_editors_popup->add_child(tile_data_editors_tree);
|
||||
|
||||
tile_data_painting_editor_container = memnew(VBoxContainer);
|
||||
@ -2381,7 +2381,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
|
||||
middle_vbox_container->add_child(atlas_source_inspector_label);
|
||||
|
||||
atlas_source_proxy_object = memnew(TileSetAtlasSourceProxyObject());
|
||||
atlas_source_proxy_object->connect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed));
|
||||
atlas_source_proxy_object->connect("changed", callable_mp(this, &RTileSetAtlasSourceEditor::_atlas_source_proxy_object_changed));
|
||||
|
||||
atlas_source_inspector = memnew(EditorInspector);
|
||||
atlas_source_inspector->set_undo_redo(undo_redo);
|
||||
@ -2401,19 +2401,19 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
|
||||
confirm_auto_create_tiles->set_text(TTR("The atlas's texture was modified.\nWould you like to automatically create tiles in the atlas?"));
|
||||
confirm_auto_create_tiles->get_ok_button()->set_text(TTR("Yes"));
|
||||
confirm_auto_create_tiles->add_cancel_button()->set_text(TTR("No"));
|
||||
confirm_auto_create_tiles->connect("confirmed", callable_mp(this, &TileSetAtlasSourceEditor::_auto_create_tiles));
|
||||
confirm_auto_create_tiles->connect("confirmed", callable_mp(this, &RTileSetAtlasSourceEditor::_auto_create_tiles));
|
||||
add_child(confirm_auto_create_tiles);
|
||||
|
||||
// -- Toolbox --
|
||||
tools_button_group.instantiate();
|
||||
tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_id_label).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_source_inspector).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_inspector).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_data_editors).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_current_tile_data_editor).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_view).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_toolbar).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_update_tile_id_label).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_update_atlas_source_inspector).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_update_tile_inspector).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_update_tile_data_editors).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_update_current_tile_data_editor).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_update_atlas_view).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_update_toolbar).unbind(1));
|
||||
|
||||
toolbox = memnew(HBoxContainer);
|
||||
right_panel->add_child(toolbox);
|
||||
@ -2462,7 +2462,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
|
||||
tool_advanced_menu_buttom->set_flat(true);
|
||||
tool_advanced_menu_buttom->get_popup()->add_item(TTR("Create Tiles in Non-Transparent Texture Regions"), ADVANCED_AUTO_CREATE_TILES);
|
||||
tool_advanced_menu_buttom->get_popup()->add_item(TTR("Remove Tiles in Fully Transparent Texture Regions"), ADVANCED_AUTO_REMOVE_TILES);
|
||||
tool_advanced_menu_buttom->get_popup()->connect("id_pressed", callable_mp(this, &TileSetAtlasSourceEditor::_menu_option));
|
||||
tool_advanced_menu_buttom->get_popup()->connect("id_pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_menu_option));
|
||||
toolbox->add_child(tool_advanced_menu_buttom);
|
||||
|
||||
_update_toolbar();
|
||||
@ -2478,50 +2478,50 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
|
||||
_update_tile_id_label();
|
||||
|
||||
// Tile atlas view.
|
||||
tile_atlas_view = memnew(TileAtlasView);
|
||||
tile_atlas_view = memnew(RTileAtlasView);
|
||||
tile_atlas_view->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
tile_atlas_view->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
tile_atlas_view->connect("transform_changed", callable_mp(TilesEditorPlugin::get_singleton(), &TilesEditorPlugin::set_atlas_view_transform));
|
||||
tile_atlas_view->connect("transform_changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_atlas_view_transform_changed).unbind(2));
|
||||
tile_atlas_view->connect("transform_changed", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::set_atlas_view_transform));
|
||||
tile_atlas_view->connect("transform_changed", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_atlas_view_transform_changed).unbind(2));
|
||||
right_panel->add_child(tile_atlas_view);
|
||||
|
||||
base_tile_popup_menu = memnew(PopupMenu);
|
||||
base_tile_popup_menu->add_shortcut(ED_SHORTCUT("tiles_editor/delete", TTR("Delete"), Key::KEY_DELETE), TILE_DELETE);
|
||||
base_tile_popup_menu->add_item(TTR("Create an Alternative Tile"), TILE_CREATE_ALTERNATIVE);
|
||||
base_tile_popup_menu->connect("id_pressed", callable_mp(this, &TileSetAtlasSourceEditor::_menu_option));
|
||||
base_tile_popup_menu->connect("id_pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_menu_option));
|
||||
tile_atlas_view->add_child(base_tile_popup_menu);
|
||||
|
||||
empty_base_tile_popup_menu = memnew(PopupMenu);
|
||||
empty_base_tile_popup_menu->add_item(TTR("Create a Tile"), TILE_CREATE);
|
||||
empty_base_tile_popup_menu->connect("id_pressed", callable_mp(this, &TileSetAtlasSourceEditor::_menu_option));
|
||||
empty_base_tile_popup_menu->connect("id_pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_menu_option));
|
||||
tile_atlas_view->add_child(empty_base_tile_popup_menu);
|
||||
|
||||
tile_atlas_control = memnew(Control);
|
||||
tile_atlas_control->connect("draw", callable_mp(this, &TileSetAtlasSourceEditor::_tile_atlas_control_draw));
|
||||
tile_atlas_control->connect("mouse_exited", callable_mp(this, &TileSetAtlasSourceEditor::_tile_atlas_control_mouse_exited));
|
||||
tile_atlas_control->connect("gui_input", callable_mp(this, &TileSetAtlasSourceEditor::_tile_atlas_control_gui_input));
|
||||
tile_atlas_control->connect("draw", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_atlas_control_draw));
|
||||
tile_atlas_control->connect("mouse_exited", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_atlas_control_mouse_exited));
|
||||
tile_atlas_control->connect("gui_input", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input));
|
||||
tile_atlas_view->add_control_over_atlas_tiles(tile_atlas_control);
|
||||
|
||||
tile_atlas_control_unscaled = memnew(Control);
|
||||
tile_atlas_control_unscaled->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
|
||||
tile_atlas_control_unscaled->connect("draw", callable_mp(this, &TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw));
|
||||
tile_atlas_control_unscaled->connect("draw", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw));
|
||||
tile_atlas_view->add_control_over_atlas_tiles(tile_atlas_control_unscaled, false);
|
||||
tile_atlas_control_unscaled->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
|
||||
|
||||
alternative_tile_popup_menu = memnew(PopupMenu);
|
||||
alternative_tile_popup_menu->add_shortcut(ED_SHORTCUT("tiles_editor/delete_tile", TTR("Delete"), Key::KEY_DELETE), TILE_DELETE);
|
||||
alternative_tile_popup_menu->connect("id_pressed", callable_mp(this, &TileSetAtlasSourceEditor::_menu_option));
|
||||
alternative_tile_popup_menu->connect("id_pressed", callable_mp(this, &RTileSetAtlasSourceEditor::_menu_option));
|
||||
tile_atlas_view->add_child(alternative_tile_popup_menu);
|
||||
|
||||
alternative_tiles_control = memnew(Control);
|
||||
alternative_tiles_control->connect("draw", callable_mp(this, &TileSetAtlasSourceEditor::_tile_alternatives_control_draw));
|
||||
alternative_tiles_control->connect("mouse_exited", callable_mp(this, &TileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited));
|
||||
alternative_tiles_control->connect("gui_input", callable_mp(this, &TileSetAtlasSourceEditor::_tile_alternatives_control_gui_input));
|
||||
alternative_tiles_control->connect("draw", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_alternatives_control_draw));
|
||||
alternative_tiles_control->connect("mouse_exited", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited));
|
||||
alternative_tiles_control->connect("gui_input", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_alternatives_control_gui_input));
|
||||
tile_atlas_view->add_control_over_alternative_tiles(alternative_tiles_control);
|
||||
|
||||
alternative_tiles_control_unscaled = memnew(Control);
|
||||
alternative_tiles_control_unscaled->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
|
||||
alternative_tiles_control_unscaled->connect("draw", callable_mp(this, &TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw));
|
||||
alternative_tiles_control_unscaled->connect("draw", callable_mp(this, &RTileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw));
|
||||
tile_atlas_view->add_control_over_alternative_tiles(alternative_tiles_control_unscaled, false);
|
||||
alternative_tiles_control_unscaled->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
|
||||
|
||||
@ -2534,22 +2534,22 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
|
||||
tile_atlas_view_missing_source_label->hide();
|
||||
right_panel->add_child(tile_atlas_view_missing_source_label);
|
||||
|
||||
EditorNode::get_singleton()->get_editor_data().add_undo_redo_inspector_hook_callback(callable_mp(this, &TileSetAtlasSourceEditor::_undo_redo_inspector_callback));
|
||||
EditorNode::get_singleton()->get_editor_data().add_undo_redo_inspector_hook_callback(callable_mp(this, &RTileSetAtlasSourceEditor::_undo_redo_inspector_callback));
|
||||
|
||||
// Inspector plugin.
|
||||
Ref<EditorInspectorPluginTileData> tile_data_inspector_plugin;
|
||||
Ref<REditorInspectorPluginTileData> tile_data_inspector_plugin;
|
||||
tile_data_inspector_plugin.instantiate();
|
||||
EditorInspector::add_inspector_plugin(tile_data_inspector_plugin);
|
||||
}
|
||||
|
||||
TileSetAtlasSourceEditor::~TileSetAtlasSourceEditor() {
|
||||
RTileSetAtlasSourceEditor::~RTileSetAtlasSourceEditor() {
|
||||
memdelete(tile_proxy_object);
|
||||
memdelete(atlas_source_proxy_object);
|
||||
}
|
||||
|
||||
////// EditorPropertyTilePolygon //////
|
||||
////// REditorPropertyTilePolygon //////
|
||||
|
||||
void EditorPropertyTilePolygon::_add_focusable_children(Node *p_node) {
|
||||
void REditorPropertyTilePolygon::_add_focusable_children(Node *p_node) {
|
||||
Control *control = Object::cast_to<Control>(p_node);
|
||||
if (control && control->get_focus_mode() != Control::FOCUS_NONE) {
|
||||
add_focusable(control);
|
||||
@ -2559,7 +2559,7 @@ void EditorPropertyTilePolygon::_add_focusable_children(Node *p_node) {
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPropertyTilePolygon::_polygons_changed() {
|
||||
void REditorPropertyTilePolygon::_polygons_changed() {
|
||||
if (String(count_property).is_empty()) {
|
||||
if (base_type == "OccluderPolygon2D") {
|
||||
// Single OccluderPolygon2D.
|
||||
@ -2598,8 +2598,8 @@ void EditorPropertyTilePolygon::_polygons_changed() {
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPropertyTilePolygon::update_property() {
|
||||
TileSetAtlasSourceEditor::AtlasTileProxyObject *atlas_tile_proxy_object = Object::cast_to<TileSetAtlasSourceEditor::AtlasTileProxyObject>(get_edited_object());
|
||||
void REditorPropertyTilePolygon::update_property() {
|
||||
RTileSetAtlasSourceEditor::AtlasTileProxyObject *atlas_tile_proxy_object = Object::cast_to<RTileSetAtlasSourceEditor::AtlasTileProxyObject>(get_edited_object());
|
||||
ERR_FAIL_COND(!atlas_tile_proxy_object);
|
||||
ERR_FAIL_COND(atlas_tile_proxy_object->get_edited_tiles().is_empty());
|
||||
|
||||
@ -2645,14 +2645,14 @@ void EditorPropertyTilePolygon::update_property() {
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPropertyTilePolygon::setup_single_mode(const StringName &p_property, const String &p_base_type) {
|
||||
void REditorPropertyTilePolygon::setup_single_mode(const StringName &p_property, const String &p_base_type) {
|
||||
set_object_and_property(nullptr, p_property);
|
||||
base_type = p_base_type;
|
||||
|
||||
generic_tile_polygon_editor->set_multiple_polygon_mode(false);
|
||||
}
|
||||
|
||||
void EditorPropertyTilePolygon::setup_multiple_mode(const StringName &p_property, const StringName &p_count_property, const String &p_element_pattern, const String &p_base_type) {
|
||||
void REditorPropertyTilePolygon::setup_multiple_mode(const StringName &p_property, const StringName &p_count_property, const String &p_element_pattern, const String &p_base_type) {
|
||||
set_object_and_property(nullptr, p_property);
|
||||
count_property = p_count_property;
|
||||
element_pattern = p_element_pattern;
|
||||
@ -2661,32 +2661,32 @@ void EditorPropertyTilePolygon::setup_multiple_mode(const StringName &p_property
|
||||
generic_tile_polygon_editor->set_multiple_polygon_mode(true);
|
||||
}
|
||||
|
||||
EditorPropertyTilePolygon::EditorPropertyTilePolygon() {
|
||||
REditorPropertyTilePolygon::REditorPropertyTilePolygon() {
|
||||
// Setup the polygon editor.
|
||||
generic_tile_polygon_editor = memnew(GenericTilePolygonEditor);
|
||||
generic_tile_polygon_editor->set_use_undo_redo(false);
|
||||
generic_tile_polygon_editor->clear_polygons();
|
||||
add_child(generic_tile_polygon_editor);
|
||||
generic_tile_polygon_editor->connect("polygons_changed", callable_mp(this, &EditorPropertyTilePolygon::_polygons_changed));
|
||||
generic_tile_polygon_editor->connect("polygons_changed", callable_mp(this, &REditorPropertyTilePolygon::_polygons_changed));
|
||||
|
||||
// Add all focussable children of generic_tile_polygon_editor as focussable.
|
||||
_add_focusable_children(generic_tile_polygon_editor);
|
||||
}
|
||||
|
||||
////// EditorInspectorPluginTileData //////
|
||||
////// REditorInspectorPluginTileData //////
|
||||
|
||||
bool EditorInspectorPluginTileData::can_handle(Object *p_object) {
|
||||
return Object::cast_to<TileSetAtlasSourceEditor::AtlasTileProxyObject>(p_object) != nullptr;
|
||||
bool REditorInspectorPluginTileData::can_handle(Object *p_object) {
|
||||
return Object::cast_to<RTileSetAtlasSourceEditor::AtlasTileProxyObject>(p_object) != nullptr;
|
||||
}
|
||||
|
||||
bool EditorInspectorPluginTileData::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
|
||||
bool REditorInspectorPluginTileData::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
|
||||
Vector<String> components = String(p_path).split("/", true, 2);
|
||||
if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) {
|
||||
// Occlusion layers.
|
||||
int layer_index = components[0].trim_prefix("occlusion_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
if (components[1] == "polygon") {
|
||||
EditorPropertyTilePolygon *ep = memnew(EditorPropertyTilePolygon);
|
||||
REditorPropertyTilePolygon *ep = memnew(REditorPropertyTilePolygon);
|
||||
ep->setup_single_mode(p_path, "OccluderPolygon2D");
|
||||
add_property_editor(p_path, ep);
|
||||
return true;
|
||||
@ -2696,7 +2696,7 @@ bool EditorInspectorPluginTileData::parse_property(Object *p_object, const Varia
|
||||
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
if (components[1] == "polygons_count") {
|
||||
EditorPropertyTilePolygon *ep = memnew(EditorPropertyTilePolygon);
|
||||
REditorPropertyTilePolygon *ep = memnew(REditorPropertyTilePolygon);
|
||||
ep->setup_multiple_mode(vformat("physics_layer_%d/polygons", layer_index), vformat("physics_layer_%d/polygons_count", layer_index), vformat("physics_layer_%d/polygon_%%d/points", layer_index), "");
|
||||
Vector<String> properties;
|
||||
properties.push_back(p_path);
|
||||
@ -2718,7 +2718,7 @@ bool EditorInspectorPluginTileData::parse_property(Object *p_object, const Varia
|
||||
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
if (components[1] == "polygon") {
|
||||
EditorPropertyTilePolygon *ep = memnew(EditorPropertyTilePolygon);
|
||||
REditorPropertyTilePolygon *ep = memnew(REditorPropertyTilePolygon);
|
||||
ep->setup_single_mode(p_path, "NavigationPolygon");
|
||||
add_property_editor(p_path, ep);
|
||||
return true;
|
||||
|
@ -28,8 +28,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TILE_SET_ATLAS_SOURCE_EDITOR_H
|
||||
#define TILE_SET_ATLAS_SOURCE_EDITOR_H
|
||||
#ifndef RTILE_SET_ATLAS_SOURCE_EDITOR_H
|
||||
#define RTILE_SET_ATLAS_SOURCE_EDITOR_H
|
||||
|
||||
#include "tile_atlas_view.h"
|
||||
#include "tile_data_editors.h"
|
||||
@ -40,8 +40,8 @@
|
||||
|
||||
class TileSet;
|
||||
|
||||
class TileSetAtlasSourceEditor : public HBoxContainer {
|
||||
GDCLASS(TileSetAtlasSourceEditor, HBoxContainer);
|
||||
class RTileSetAtlasSourceEditor : public HBoxContainer {
|
||||
GDCLASS(RTileSetAtlasSourceEditor, HBoxContainer);
|
||||
|
||||
public:
|
||||
// A class to store which tiles are selected.
|
||||
@ -86,7 +86,7 @@ public:
|
||||
GDCLASS(AtlasTileProxyObject, Object);
|
||||
|
||||
private:
|
||||
TileSetAtlasSourceEditor *tiles_set_atlas_source_editor;
|
||||
RTileSetAtlasSourceEditor *tiles_set_atlas_source_editor;
|
||||
|
||||
TileSetAtlasSource *tile_set_atlas_source = nullptr;
|
||||
Set<TileSelection> tiles = Set<TileSelection>();
|
||||
@ -105,7 +105,7 @@ public:
|
||||
// Update the proxyed object.
|
||||
void edit(TileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles = Set<TileSelection>());
|
||||
|
||||
AtlasTileProxyObject(TileSetAtlasSourceEditor *p_tiles_set_atlas_source_editor) {
|
||||
AtlasTileProxyObject(RTileSetAtlasSourceEditor *p_tiles_set_atlas_source_editor) {
|
||||
tiles_set_atlas_source_editor = p_tiles_set_atlas_source_editor;
|
||||
}
|
||||
};
|
||||
@ -131,8 +131,8 @@ private:
|
||||
// -- Tile data editors --
|
||||
String current_property;
|
||||
Control *current_tile_data_editor_toolbar = nullptr;
|
||||
Map<String, TileDataEditor *> tile_data_editors;
|
||||
TileDataEditor *current_tile_data_editor = nullptr;
|
||||
Map<String, RTileDataEditor *> tile_data_editors;
|
||||
RTileDataEditor *current_tile_data_editor = nullptr;
|
||||
void _tile_data_editors_tree_selected();
|
||||
|
||||
// -- Inspector --
|
||||
@ -150,7 +150,7 @@ private:
|
||||
// -- Atlas view --
|
||||
HBoxContainer *toolbox;
|
||||
Label *tile_atlas_view_missing_source_label;
|
||||
TileAtlasView *tile_atlas_view;
|
||||
RTileAtlasView *tile_atlas_view;
|
||||
|
||||
// Dragging
|
||||
enum DragType {
|
||||
@ -281,12 +281,12 @@ public:
|
||||
void edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_source, int p_source_id);
|
||||
void init_source();
|
||||
|
||||
TileSetAtlasSourceEditor();
|
||||
~TileSetAtlasSourceEditor();
|
||||
RTileSetAtlasSourceEditor();
|
||||
~RTileSetAtlasSourceEditor();
|
||||
};
|
||||
|
||||
class EditorPropertyTilePolygon : public EditorProperty {
|
||||
GDCLASS(EditorPropertyTilePolygon, EditorProperty);
|
||||
class REditorPropertyTilePolygon : public EditorProperty {
|
||||
GDCLASS(REditorPropertyTilePolygon, EditorProperty);
|
||||
|
||||
StringName count_property;
|
||||
String element_pattern;
|
||||
@ -301,11 +301,11 @@ public:
|
||||
virtual void update_property() override;
|
||||
void setup_single_mode(const StringName &p_property, const String &p_base_type);
|
||||
void setup_multiple_mode(const StringName &p_property, const StringName &p_count_property, const String &p_element_pattern, const String &p_base_type);
|
||||
EditorPropertyTilePolygon();
|
||||
REditorPropertyTilePolygon();
|
||||
};
|
||||
|
||||
class EditorInspectorPluginTileData : public EditorInspectorPlugin {
|
||||
GDCLASS(EditorInspectorPluginTileData, EditorInspectorPlugin);
|
||||
class REditorInspectorPluginTileData : public EditorInspectorPlugin {
|
||||
GDCLASS(REditorInspectorPluginTileData, EditorInspectorPlugin);
|
||||
|
||||
void _occlusion_polygon_set_callback();
|
||||
void _polygons_changed(Object *p_generic_tile_polygon_editor, Object *p_object, const String &p_path);
|
||||
|
@ -39,9 +39,9 @@
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/gui/tab_container.h"
|
||||
|
||||
TileSetEditor *TileSetEditor::singleton = nullptr;
|
||||
RTileSetEditor *RTileSetEditor::singleton = nullptr;
|
||||
|
||||
void TileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
void RTileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
if (!_can_drop_data_fw(p_point, p_data, p_from)) {
|
||||
@ -81,7 +81,7 @@ void TileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
||||
}
|
||||
}
|
||||
|
||||
bool TileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
bool RTileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
ERR_FAIL_COND_V(!tile_set.is_valid(), false);
|
||||
|
||||
if (p_from == sources_list) {
|
||||
@ -114,7 +114,7 @@ bool TileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_da
|
||||
return false;
|
||||
}
|
||||
|
||||
void TileSetEditor::_update_sources_list(int force_selected_id) {
|
||||
void RTileSetEditor::_update_sources_list(int force_selected_id) {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
// Get the previously selected id.
|
||||
@ -209,10 +209,10 @@ void TileSetEditor::_update_sources_list(int force_selected_id) {
|
||||
_source_selected(sources_list->get_current());
|
||||
|
||||
// Synchronize the lists.
|
||||
TilesEditorPlugin::get_singleton()->set_sources_lists_current(sources_list->get_current());
|
||||
RTilesEditorPlugin::get_singleton()->set_sources_lists_current(sources_list->get_current());
|
||||
}
|
||||
|
||||
void TileSetEditor::_source_selected(int p_source_index) {
|
||||
void RTileSetEditor::_source_selected(int p_source_index) {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
// Update the selected source.
|
||||
@ -244,7 +244,7 @@ void TileSetEditor::_source_selected(int p_source_index) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetEditor::_source_delete_pressed() {
|
||||
void RTileSetEditor::_source_delete_pressed() {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
// Update the selected source.
|
||||
@ -261,7 +261,7 @@ void TileSetEditor::_source_delete_pressed() {
|
||||
_update_sources_list();
|
||||
}
|
||||
|
||||
void TileSetEditor::_source_add_id_pressed(int p_id_pressed) {
|
||||
void RTileSetEditor::_source_add_id_pressed(int p_id_pressed) {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
switch (p_id_pressed) {
|
||||
@ -297,7 +297,7 @@ void TileSetEditor::_source_add_id_pressed(int p_id_pressed) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetEditor::_sources_advanced_menu_id_pressed(int p_id_pressed) {
|
||||
void RTileSetEditor::_sources_advanced_menu_id_pressed(int p_id_pressed) {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
switch (p_id_pressed) {
|
||||
@ -312,7 +312,7 @@ void TileSetEditor::_sources_advanced_menu_id_pressed(int p_id_pressed) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetEditor::_notification(int p_what) {
|
||||
void RTileSetEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_THEME_CHANGED:
|
||||
@ -336,7 +336,7 @@ void TileSetEditor::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetEditor::_patterns_item_list_gui_input(const Ref<InputEvent> &p_event) {
|
||||
void RTileSetEditor::_patterns_item_list_gui_input(const Ref<InputEvent> &p_event) {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
if (ED_IS_SHORTCUT("tiles_editor/delete", p_event) && p_event->is_pressed() && !p_event->is_echo()) {
|
||||
@ -352,7 +352,7 @@ void TileSetEditor::_patterns_item_list_gui_input(const Ref<InputEvent> &p_event
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetEditor::_pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture) {
|
||||
void RTileSetEditor::_pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture) {
|
||||
// TODO optimize ?
|
||||
for (int i = 0; i < patterns_item_list->get_item_count(); i++) {
|
||||
if (patterns_item_list->get_item_metadata(i) == p_pattern) {
|
||||
@ -362,7 +362,7 @@ void TileSetEditor::_pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Tex
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetEditor::_update_patterns_list() {
|
||||
void RTileSetEditor::_update_patterns_list() {
|
||||
ERR_FAIL_COND(!tile_set.is_valid());
|
||||
|
||||
// Recreate the items.
|
||||
@ -370,23 +370,23 @@ void TileSetEditor::_update_patterns_list() {
|
||||
for (int i = 0; i < tile_set->get_patterns_count(); i++) {
|
||||
int id = patterns_item_list->add_item("");
|
||||
patterns_item_list->set_item_metadata(id, tile_set->get_pattern(i));
|
||||
TilesEditorPlugin::get_singleton()->queue_pattern_preview(tile_set, tile_set->get_pattern(i), callable_mp(this, &TileSetEditor::_pattern_preview_done));
|
||||
RTilesEditorPlugin::get_singleton()->queue_pattern_preview(tile_set, tile_set->get_pattern(i), callable_mp(this, &RTileSetEditor::_pattern_preview_done));
|
||||
}
|
||||
|
||||
// Update the label visibility.
|
||||
patterns_help_label->set_visible(patterns_item_list->get_item_count() == 0);
|
||||
}
|
||||
|
||||
void TileSetEditor::_tile_set_changed() {
|
||||
void RTileSetEditor::_tile_set_changed() {
|
||||
tile_set_changed_needs_update = true;
|
||||
}
|
||||
|
||||
void TileSetEditor::_tab_changed(int p_tab_changed) {
|
||||
void RTileSetEditor::_tab_changed(int p_tab_changed) {
|
||||
split_container->set_visible(p_tab_changed == 0);
|
||||
patterns_item_list->set_visible(p_tab_changed == 1);
|
||||
}
|
||||
|
||||
void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
|
||||
void RTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
|
||||
UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
|
||||
ERR_FAIL_COND(!undo_redo);
|
||||
|
||||
@ -567,7 +567,7 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) {
|
||||
void RTileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) {
|
||||
UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
|
||||
ERR_FAIL_COND(!undo_redo);
|
||||
|
||||
@ -607,19 +607,19 @@ void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p
|
||||
#undef ADD_UNDO
|
||||
}
|
||||
|
||||
void TileSetEditor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &TileSetEditor::_can_drop_data_fw);
|
||||
ClassDB::bind_method(D_METHOD("_drop_data_fw"), &TileSetEditor::_drop_data_fw);
|
||||
void RTileSetEditor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &RTileSetEditor::_can_drop_data_fw);
|
||||
ClassDB::bind_method(D_METHOD("_drop_data_fw"), &RTileSetEditor::_drop_data_fw);
|
||||
}
|
||||
|
||||
void TileSetEditor::edit(Ref<TileSet> p_tile_set) {
|
||||
void RTileSetEditor::edit(Ref<TileSet> p_tile_set) {
|
||||
if (p_tile_set == tile_set) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove listener.
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect("changed", callable_mp(this, &TileSetEditor::_tile_set_changed));
|
||||
tile_set->disconnect("changed", callable_mp(this, &RTileSetEditor::_tile_set_changed));
|
||||
}
|
||||
|
||||
// Change the edited object.
|
||||
@ -627,7 +627,7 @@ void TileSetEditor::edit(Ref<TileSet> p_tile_set) {
|
||||
|
||||
// Add the listener again.
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->connect("changed", callable_mp(this, &TileSetEditor::_tile_set_changed));
|
||||
tile_set->connect("changed", callable_mp(this, &RTileSetEditor::_tile_set_changed));
|
||||
_update_sources_list();
|
||||
_update_patterns_list();
|
||||
}
|
||||
@ -637,7 +637,7 @@ void TileSetEditor::edit(Ref<TileSet> p_tile_set) {
|
||||
no_source_selected_label->show();
|
||||
}
|
||||
|
||||
TileSetEditor::TileSetEditor() {
|
||||
RTileSetEditor::RTileSetEditor() {
|
||||
singleton = this;
|
||||
|
||||
set_process_internal(true);
|
||||
@ -647,7 +647,7 @@ TileSetEditor::TileSetEditor() {
|
||||
tabs_bar->set_clip_tabs(false);
|
||||
tabs_bar->add_tab(TTR("Tiles"));
|
||||
tabs_bar->add_tab(TTR("Patterns"));
|
||||
tabs_bar->connect("tab_changed", callable_mp(this, &TileSetEditor::_tab_changed));
|
||||
tabs_bar->connect("tab_changed", callable_mp(this, &RTileSetEditor::_tab_changed));
|
||||
|
||||
tile_set_toolbar = memnew(HBoxContainer);
|
||||
tile_set_toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
@ -674,9 +674,9 @@ TileSetEditor::TileSetEditor() {
|
||||
sources_list->set_fixed_icon_size(Size2i(60, 60) * EDSCALE);
|
||||
sources_list->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
sources_list->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
sources_list->connect("item_selected", callable_mp(this, &TileSetEditor::_source_selected));
|
||||
sources_list->connect("item_selected", callable_mp(TilesEditorPlugin::get_singleton(), &TilesEditorPlugin::set_sources_lists_current));
|
||||
sources_list->connect("visibility_changed", callable_mp(TilesEditorPlugin::get_singleton(), &TilesEditorPlugin::synchronize_sources_list), varray(sources_list));
|
||||
sources_list->connect("item_selected", callable_mp(this, &RTileSetEditor::_source_selected));
|
||||
sources_list->connect("item_selected", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::set_sources_lists_current));
|
||||
sources_list->connect("visibility_changed", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::synchronize_sources_list), varray(sources_list));
|
||||
sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
|
||||
sources_list->set_drag_forwarding(this);
|
||||
split_container_left_side->add_child(sources_list);
|
||||
@ -688,27 +688,27 @@ TileSetEditor::TileSetEditor() {
|
||||
sources_delete_button = memnew(Button);
|
||||
sources_delete_button->set_flat(true);
|
||||
sources_delete_button->set_disabled(true);
|
||||
sources_delete_button->connect("pressed", callable_mp(this, &TileSetEditor::_source_delete_pressed));
|
||||
sources_delete_button->connect("pressed", callable_mp(this, &RTileSetEditor::_source_delete_pressed));
|
||||
sources_bottom_actions->add_child(sources_delete_button);
|
||||
|
||||
sources_add_button = memnew(MenuButton);
|
||||
sources_add_button->set_flat(true);
|
||||
sources_add_button->get_popup()->add_item(TTR("Atlas"));
|
||||
sources_add_button->get_popup()->add_item(TTR("Scenes Collection"));
|
||||
sources_add_button->get_popup()->connect("id_pressed", callable_mp(this, &TileSetEditor::_source_add_id_pressed));
|
||||
sources_add_button->get_popup()->connect("id_pressed", callable_mp(this, &RTileSetEditor::_source_add_id_pressed));
|
||||
sources_bottom_actions->add_child(sources_add_button);
|
||||
|
||||
sources_advanced_menu_button = memnew(MenuButton);
|
||||
sources_advanced_menu_button->set_flat(true);
|
||||
sources_advanced_menu_button->get_popup()->add_item(TTR("Open Atlas Merging Tool"));
|
||||
sources_advanced_menu_button->get_popup()->add_item(TTR("Manage Tile Proxies"));
|
||||
sources_advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &TileSetEditor::_sources_advanced_menu_id_pressed));
|
||||
sources_advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &RTileSetEditor::_sources_advanced_menu_id_pressed));
|
||||
sources_bottom_actions->add_child(sources_advanced_menu_button);
|
||||
|
||||
atlas_merging_dialog = memnew(AtlasMergingDialog);
|
||||
atlas_merging_dialog = memnew(RAtlasMergingDialog);
|
||||
add_child(atlas_merging_dialog);
|
||||
|
||||
tile_proxies_manager_dialog = memnew(TileProxiesManagerDialog);
|
||||
tile_proxies_manager_dialog = memnew(RTileProxiesManagerDialog);
|
||||
add_child(tile_proxies_manager_dialog);
|
||||
|
||||
// Right side container.
|
||||
@ -727,18 +727,18 @@ TileSetEditor::TileSetEditor() {
|
||||
split_container_right_side->add_child(no_source_selected_label);
|
||||
|
||||
// Atlases editor.
|
||||
tile_set_atlas_source_editor = memnew(TileSetAtlasSourceEditor);
|
||||
tile_set_atlas_source_editor = memnew(RTileSetAtlasSourceEditor);
|
||||
tile_set_atlas_source_editor->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
tile_set_atlas_source_editor->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
tile_set_atlas_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_sources_list));
|
||||
tile_set_atlas_source_editor->connect("source_id_changed", callable_mp(this, &RTileSetEditor::_update_sources_list));
|
||||
split_container_right_side->add_child(tile_set_atlas_source_editor);
|
||||
tile_set_atlas_source_editor->hide();
|
||||
|
||||
// Scenes collection editor.
|
||||
tile_set_scenes_collection_source_editor = memnew(TileSetScenesCollectionSourceEditor);
|
||||
tile_set_scenes_collection_source_editor = memnew(RTileSetScenesCollectionSourceEditor);
|
||||
tile_set_scenes_collection_source_editor->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
tile_set_scenes_collection_source_editor->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
tile_set_scenes_collection_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_sources_list));
|
||||
tile_set_scenes_collection_source_editor->connect("source_id_changed", callable_mp(this, &RTileSetEditor::_update_sources_list));
|
||||
split_container_right_side->add_child(tile_set_scenes_collection_source_editor);
|
||||
tile_set_scenes_collection_source_editor->hide();
|
||||
|
||||
@ -751,7 +751,7 @@ TileSetEditor::TileSetEditor() {
|
||||
patterns_item_list->set_max_text_lines(2);
|
||||
patterns_item_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
|
||||
patterns_item_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
patterns_item_list->connect("gui_input", callable_mp(this, &TileSetEditor::_patterns_item_list_gui_input));
|
||||
patterns_item_list->connect("gui_input", callable_mp(this, &RTileSetEditor::_patterns_item_list_gui_input));
|
||||
add_child(patterns_item_list);
|
||||
patterns_item_list->hide();
|
||||
|
||||
@ -761,12 +761,12 @@ TileSetEditor::TileSetEditor() {
|
||||
patterns_item_list->add_child(patterns_help_label);
|
||||
|
||||
// Registers UndoRedo inspector callback.
|
||||
EditorNode::get_singleton()->get_editor_data().add_move_array_element_function(SNAME("TileSet"), callable_mp(this, &TileSetEditor::_move_tile_set_array_element));
|
||||
EditorNode::get_singleton()->get_editor_data().add_undo_redo_inspector_hook_callback(callable_mp(this, &TileSetEditor::_undo_redo_inspector_callback));
|
||||
EditorNode::get_singleton()->get_editor_data().add_move_array_element_function(SNAME("TileSet"), callable_mp(this, &RTileSetEditor::_move_tile_set_array_element));
|
||||
EditorNode::get_singleton()->get_editor_data().add_undo_redo_inspector_hook_callback(callable_mp(this, &RTileSetEditor::_undo_redo_inspector_callback));
|
||||
}
|
||||
|
||||
TileSetEditor::~TileSetEditor() {
|
||||
RTileSetEditor::~RTileSetEditor() {
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect("changed", callable_mp(this, &TileSetEditor::_tile_set_changed));
|
||||
tile_set->disconnect("changed", callable_mp(this, &RTileSetEditor::_tile_set_changed));
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TILE_SET_EDITOR_H
|
||||
#define TILE_SET_EDITOR_H
|
||||
#ifndef RTILE_SET_EDITOR_H
|
||||
#define RTILE_SET_EDITOR_H
|
||||
|
||||
#include "atlas_merging_dialog.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
@ -38,10 +38,10 @@
|
||||
#include "tile_set_atlas_source_editor.h"
|
||||
#include "tile_set_scenes_collection_source_editor.h"
|
||||
|
||||
class TileSetEditor : public VBoxContainer {
|
||||
GDCLASS(TileSetEditor, VBoxContainer);
|
||||
class RTileSetEditor : public VBoxContainer {
|
||||
GDCLASS(RTileSetEditor, VBoxContainer);
|
||||
|
||||
static TileSetEditor *singleton;
|
||||
static RTileSetEditor *singleton;
|
||||
|
||||
private:
|
||||
Ref<TileSet> tile_set;
|
||||
@ -54,8 +54,8 @@ private:
|
||||
|
||||
// Tiles.
|
||||
Label *no_source_selected_label;
|
||||
TileSetAtlasSourceEditor *tile_set_atlas_source_editor;
|
||||
TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor;
|
||||
RTileSetAtlasSourceEditor *tile_set_atlas_source_editor;
|
||||
RTileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor;
|
||||
|
||||
UndoRedo *undo_redo = EditorNode::get_undo_redo();
|
||||
|
||||
@ -75,8 +75,8 @@ private:
|
||||
void _source_add_id_pressed(int p_id_pressed);
|
||||
void _sources_advanced_menu_id_pressed(int p_id_pressed);
|
||||
|
||||
AtlasMergingDialog *atlas_merging_dialog;
|
||||
TileProxiesManagerDialog *tile_proxies_manager_dialog;
|
||||
RAtlasMergingDialog *atlas_merging_dialog;
|
||||
RTileProxiesManagerDialog *tile_proxies_manager_dialog;
|
||||
|
||||
// Patterns.
|
||||
ItemList *patterns_item_list;
|
||||
@ -97,12 +97,12 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
_FORCE_INLINE_ static TileSetEditor *get_singleton() { return singleton; }
|
||||
_FORCE_INLINE_ static RTileSetEditor *get_singleton() { return singleton; }
|
||||
|
||||
void edit(Ref<TileSet> p_tile_set);
|
||||
|
||||
TileSetEditor();
|
||||
~TileSetEditor();
|
||||
RTileSetEditor();
|
||||
~RTileSetEditor();
|
||||
};
|
||||
|
||||
#endif // TILE_SET_EDITOR_PLUGIN_H
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
#include "core/core_string_names.h"
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::set_id(int p_id) {
|
||||
void RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::set_id(int p_id) {
|
||||
ERR_FAIL_COND(p_id < 0);
|
||||
if (source_id == p_id) {
|
||||
return;
|
||||
@ -51,11 +51,11 @@ void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::se
|
||||
emit_signal(SNAME("changed"), "id");
|
||||
}
|
||||
|
||||
int TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id() {
|
||||
int RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id() {
|
||||
return source_id;
|
||||
}
|
||||
|
||||
bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_set(const StringName &p_name, const Variant &p_value) {
|
||||
bool RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_set(const StringName &p_name, const Variant &p_value) {
|
||||
String name = p_name;
|
||||
if (name == "name") {
|
||||
// Use the resource_name property to store the source's name.
|
||||
@ -69,7 +69,7 @@ bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_s
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
bool RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (!tile_set_scenes_collection_source) {
|
||||
return false;
|
||||
}
|
||||
@ -83,21 +83,21 @@ bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_g
|
||||
return valid;
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
void RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::STRING, "name", PROPERTY_HINT_NONE, ""));
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_bind_methods() {
|
||||
void RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_bind_methods() {
|
||||
// -- Shape and layout --
|
||||
ClassDB::bind_method(D_METHOD("set_id", "id"), &TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::set_id);
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id);
|
||||
ClassDB::bind_method(D_METHOD("set_id", "id"), &RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::set_id);
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
||||
|
||||
ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what")));
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
|
||||
void RTileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
|
||||
ERR_FAIL_COND(!p_tile_set.is_valid());
|
||||
ERR_FAIL_COND(!p_tile_set_scenes_collection_source);
|
||||
ERR_FAIL_COND(p_source_id < 0);
|
||||
@ -127,7 +127,7 @@ void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::ed
|
||||
}
|
||||
|
||||
// -- Proxy object used by the tile inspector --
|
||||
bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_set(const StringName &p_name, const Variant &p_value) {
|
||||
bool RTileSetScenesCollectionSourceEditor::SceneTileProxyObject::_set(const StringName &p_name, const Variant &p_value) {
|
||||
if (!tile_set_scenes_collection_source) {
|
||||
return false;
|
||||
}
|
||||
@ -159,7 +159,7 @@ bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_set(const Strin
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
bool RTileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (!tile_set_scenes_collection_source) {
|
||||
return false;
|
||||
}
|
||||
@ -178,7 +178,7 @@ bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get(const Strin
|
||||
return false;
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
void RTileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
if (!tile_set_scenes_collection_source) {
|
||||
return;
|
||||
}
|
||||
@ -188,7 +188,7 @@ void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get_property_li
|
||||
p_list->push_back(PropertyInfo(Variant::BOOL, "display_placeholder", PROPERTY_HINT_NONE, ""));
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::edit(TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_scene_id) {
|
||||
void RTileSetScenesCollectionSourceEditor::SceneTileProxyObject::edit(TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_scene_id) {
|
||||
ERR_FAIL_COND(!p_tile_set_scenes_collection_source);
|
||||
ERR_FAIL_COND(!p_tile_set_scenes_collection_source->has_scene_tile_id(p_scene_id));
|
||||
|
||||
@ -202,21 +202,21 @@ void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::edit(TileSetScen
|
||||
notify_property_list_changed();
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_bind_methods() {
|
||||
void RTileSetScenesCollectionSourceEditor::SceneTileProxyObject::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what")));
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed(String p_what) {
|
||||
void RTileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed(String p_what) {
|
||||
if (p_what == "id") {
|
||||
emit_signal(SNAME("source_id_changed"), scenes_collection_source_proxy_object->get_id());
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed() {
|
||||
void RTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed() {
|
||||
tile_set_scenes_collection_source_changed_needs_update = true;
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) {
|
||||
void RTileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) {
|
||||
int index = p_ud;
|
||||
|
||||
if (index >= 0 && index < scene_tiles_list->get_item_count()) {
|
||||
@ -224,14 +224,14 @@ void TileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_scenes_list_item_activated(int p_index) {
|
||||
void RTileSetScenesCollectionSourceEditor::_scenes_list_item_activated(int p_index) {
|
||||
Ref<PackedScene> packed_scene = tile_set_scenes_collection_source->get_scene_tile_scene(scene_tiles_list->get_item_metadata(p_index));
|
||||
if (packed_scene.is_valid()) {
|
||||
EditorNode::get_singleton()->open_request(packed_scene->get_path());
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_source_add_pressed() {
|
||||
void RTileSetScenesCollectionSourceEditor::_source_add_pressed() {
|
||||
int scene_id = tile_set_scenes_collection_source->get_next_scene_tile_id();
|
||||
undo_redo->create_action(TTR("Add a Scene Tile"));
|
||||
undo_redo->add_do_method(tile_set_scenes_collection_source, "create_scene_tile", Ref<PackedScene>(), scene_id);
|
||||
@ -242,7 +242,7 @@ void TileSetScenesCollectionSourceEditor::_source_add_pressed() {
|
||||
_update_tile_inspector();
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_source_delete_pressed() {
|
||||
void RTileSetScenesCollectionSourceEditor::_source_delete_pressed() {
|
||||
Vector<int> selected_indices = scene_tiles_list->get_selected_items();
|
||||
ERR_FAIL_COND(selected_indices.size() <= 0);
|
||||
int scene_id = scene_tiles_list->get_item_metadata(selected_indices[0]);
|
||||
@ -256,12 +256,12 @@ void TileSetScenesCollectionSourceEditor::_source_delete_pressed() {
|
||||
_update_tile_inspector();
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_update_source_inspector() {
|
||||
void RTileSetScenesCollectionSourceEditor::_update_source_inspector() {
|
||||
// Update the proxy object.
|
||||
scenes_collection_source_proxy_object->edit(tile_set, tile_set_scenes_collection_source, tile_set_source_id);
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_update_tile_inspector() {
|
||||
void RTileSetScenesCollectionSourceEditor::_update_tile_inspector() {
|
||||
Vector<int> selected_indices = scene_tiles_list->get_selected_items();
|
||||
bool has_atlas_tile_selected = (selected_indices.size() > 0);
|
||||
|
||||
@ -276,12 +276,12 @@ void TileSetScenesCollectionSourceEditor::_update_tile_inspector() {
|
||||
tile_inspector->set_visible(has_atlas_tile_selected);
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_update_action_buttons() {
|
||||
void RTileSetScenesCollectionSourceEditor::_update_action_buttons() {
|
||||
Vector<int> selected_indices = scene_tiles_list->get_selected_items();
|
||||
scene_tile_delete_button->set_disabled(selected_indices.size() <= 0);
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_update_scenes_list() {
|
||||
void RTileSetScenesCollectionSourceEditor::_update_scenes_list() {
|
||||
if (!tile_set_scenes_collection_source) {
|
||||
return;
|
||||
}
|
||||
@ -325,7 +325,7 @@ void TileSetScenesCollectionSourceEditor::_update_scenes_list() {
|
||||
scene_tiles_list->set_fixed_icon_size(Vector2(int_size, int_size));
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_notification(int p_what) {
|
||||
void RTileSetScenesCollectionSourceEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_THEME_CHANGED:
|
||||
@ -353,7 +353,7 @@ void TileSetScenesCollectionSourceEditor::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
|
||||
void RTileSetScenesCollectionSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
|
||||
ERR_FAIL_COND(!p_tile_set.is_valid());
|
||||
ERR_FAIL_COND(!p_tile_set_scenes_collection_source);
|
||||
ERR_FAIL_COND(p_source_id < 0);
|
||||
@ -365,7 +365,7 @@ void TileSetScenesCollectionSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetS
|
||||
|
||||
// Remove listener for old objects.
|
||||
if (tile_set_scenes_collection_source) {
|
||||
tile_set_scenes_collection_source->disconnect("changed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
|
||||
tile_set_scenes_collection_source->disconnect("changed", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
|
||||
}
|
||||
|
||||
// Change the edited object.
|
||||
@ -375,7 +375,7 @@ void TileSetScenesCollectionSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetS
|
||||
|
||||
// Add the listener again.
|
||||
if (tile_set_scenes_collection_source) {
|
||||
tile_set_scenes_collection_source->connect("changed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
|
||||
tile_set_scenes_collection_source->connect("changed", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
|
||||
}
|
||||
|
||||
// Update everything.
|
||||
@ -385,7 +385,7 @@ void TileSetScenesCollectionSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetS
|
||||
_update_tile_inspector();
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
void RTileSetScenesCollectionSourceEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
if (!_can_drop_data_fw(p_point, p_data, p_from)) {
|
||||
return;
|
||||
}
|
||||
@ -412,7 +412,7 @@ void TileSetScenesCollectionSourceEditor::_drop_data_fw(const Point2 &p_point, c
|
||||
}
|
||||
}
|
||||
|
||||
bool TileSetScenesCollectionSourceEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
bool RTileSetScenesCollectionSourceEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
if (p_from == scene_tiles_list) {
|
||||
Dictionary d = p_data;
|
||||
|
||||
@ -443,15 +443,15 @@ bool TileSetScenesCollectionSourceEditor::_can_drop_data_fw(const Point2 &p_poin
|
||||
return false;
|
||||
}
|
||||
|
||||
void TileSetScenesCollectionSourceEditor::_bind_methods() {
|
||||
void RTileSetScenesCollectionSourceEditor::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("source_id_changed", PropertyInfo(Variant::INT, "source_id")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_scene_thumbnail_done"), &TileSetScenesCollectionSourceEditor::_scene_thumbnail_done);
|
||||
ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &TileSetScenesCollectionSourceEditor::_can_drop_data_fw);
|
||||
ClassDB::bind_method(D_METHOD("_drop_data_fw"), &TileSetScenesCollectionSourceEditor::_drop_data_fw);
|
||||
ClassDB::bind_method(D_METHOD("_scene_thumbnail_done"), &RTileSetScenesCollectionSourceEditor::_scene_thumbnail_done);
|
||||
ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &RTileSetScenesCollectionSourceEditor::_can_drop_data_fw);
|
||||
ClassDB::bind_method(D_METHOD("_drop_data_fw"), &RTileSetScenesCollectionSourceEditor::_drop_data_fw);
|
||||
}
|
||||
|
||||
TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
|
||||
RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionSourceEditor() {
|
||||
// -- Right side --
|
||||
HSplitContainer *split_container_right_side = memnew(HSplitContainer);
|
||||
split_container_right_side->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
@ -473,7 +473,7 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
|
||||
middle_vbox_container->add_child(scenes_collection_source_inspector_label);
|
||||
|
||||
scenes_collection_source_proxy_object = memnew(TileSetScenesCollectionProxyObject());
|
||||
scenes_collection_source_proxy_object->connect("changed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed));
|
||||
scenes_collection_source_proxy_object->connect("changed", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed));
|
||||
|
||||
scenes_collection_source_inspector = memnew(EditorInspector);
|
||||
scenes_collection_source_inspector->set_undo_redo(undo_redo);
|
||||
@ -488,8 +488,8 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
|
||||
middle_vbox_container->add_child(tile_inspector_label);
|
||||
|
||||
tile_proxy_object = memnew(SceneTileProxyObject(this));
|
||||
tile_proxy_object->connect("changed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_scenes_list).unbind(1));
|
||||
tile_proxy_object->connect("changed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_action_buttons).unbind(1));
|
||||
tile_proxy_object->connect("changed", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_update_scenes_list).unbind(1));
|
||||
tile_proxy_object->connect("changed", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_update_action_buttons).unbind(1));
|
||||
|
||||
tile_inspector = memnew(EditorInspector);
|
||||
tile_inspector->set_undo_redo(undo_redo);
|
||||
@ -506,9 +506,9 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
|
||||
scene_tiles_list->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
scene_tiles_list->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
scene_tiles_list->set_drag_forwarding(this);
|
||||
scene_tiles_list->connect("item_selected", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_tile_inspector).unbind(1));
|
||||
scene_tiles_list->connect("item_selected", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_action_buttons).unbind(1));
|
||||
scene_tiles_list->connect("item_activated", callable_mp(this, &TileSetScenesCollectionSourceEditor::_scenes_list_item_activated));
|
||||
scene_tiles_list->connect("item_selected", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_update_tile_inspector).unbind(1));
|
||||
scene_tiles_list->connect("item_selected", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_update_action_buttons).unbind(1));
|
||||
scene_tiles_list->connect("item_activated", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_scenes_list_item_activated));
|
||||
scene_tiles_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
|
||||
right_vbox_container->add_child(scene_tiles_list);
|
||||
|
||||
@ -517,17 +517,17 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
|
||||
|
||||
scene_tile_add_button = memnew(Button);
|
||||
scene_tile_add_button->set_flat(true);
|
||||
scene_tile_add_button->connect("pressed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_source_add_pressed));
|
||||
scene_tile_add_button->connect("pressed", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_source_add_pressed));
|
||||
scenes_bottom_actions->add_child(scene_tile_add_button);
|
||||
|
||||
scene_tile_delete_button = memnew(Button);
|
||||
scene_tile_delete_button->set_flat(true);
|
||||
scene_tile_delete_button->set_disabled(true);
|
||||
scene_tile_delete_button->connect("pressed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_source_delete_pressed));
|
||||
scene_tile_delete_button->connect("pressed", callable_mp(this, &RTileSetScenesCollectionSourceEditor::_source_delete_pressed));
|
||||
scenes_bottom_actions->add_child(scene_tile_delete_button);
|
||||
}
|
||||
|
||||
TileSetScenesCollectionSourceEditor::~TileSetScenesCollectionSourceEditor() {
|
||||
RTileSetScenesCollectionSourceEditor::~RTileSetScenesCollectionSourceEditor() {
|
||||
memdelete(scenes_collection_source_proxy_object);
|
||||
memdelete(tile_proxy_object);
|
||||
}
|
||||
|
@ -28,15 +28,15 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TILE_SET_SCENES_COLLECTION_SOURCE_EDITOR_H
|
||||
#define TILE_SET_SCENES_COLLECTION_SOURCE_EDITOR_H
|
||||
#ifndef RTILE_SET_SCENES_COLLECTION_SOURCE_EDITOR_H
|
||||
#define RTILE_SET_SCENES_COLLECTION_SOURCE_EDITOR_H
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/resources/tile_set.h"
|
||||
|
||||
class TileSetScenesCollectionSourceEditor : public HBoxContainer {
|
||||
GDCLASS(TileSetScenesCollectionSourceEditor, HBoxContainer);
|
||||
class RTileSetScenesCollectionSourceEditor : public HBoxContainer {
|
||||
GDCLASS(RTileSetScenesCollectionSourceEditor, HBoxContainer);
|
||||
|
||||
private:
|
||||
// -- Proxy object for an atlas source, needed by the inspector --
|
||||
@ -66,7 +66,7 @@ private:
|
||||
GDCLASS(SceneTileProxyObject, Object);
|
||||
|
||||
private:
|
||||
TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor;
|
||||
RTileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor;
|
||||
|
||||
TileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr;
|
||||
int source_id;
|
||||
@ -83,7 +83,7 @@ private:
|
||||
// Update the proxyed object.
|
||||
void edit(TileSetScenesCollectionSource *p_tile_set_atlas_source, int p_scene_id);
|
||||
|
||||
SceneTileProxyObject(TileSetScenesCollectionSourceEditor *p_tiles_set_scenes_collection_source_editor) {
|
||||
SceneTileProxyObject(RTileSetScenesCollectionSourceEditor *p_tiles_set_scenes_collection_source_editor) {
|
||||
tile_set_scenes_collection_source_editor = p_tiles_set_scenes_collection_source_editor;
|
||||
}
|
||||
};
|
||||
@ -134,8 +134,8 @@ protected:
|
||||
|
||||
public:
|
||||
void edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
|
||||
TileSetScenesCollectionSourceEditor();
|
||||
~TileSetScenesCollectionSourceEditor();
|
||||
RTileSetScenesCollectionSourceEditor();
|
||||
~RTileSetScenesCollectionSourceEditor();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -45,22 +45,22 @@
|
||||
|
||||
#include "tile_set_editor.h"
|
||||
|
||||
TilesEditorPlugin *TilesEditorPlugin::singleton = nullptr;
|
||||
RTilesEditorPlugin *RTilesEditorPlugin::singleton = nullptr;
|
||||
|
||||
void TilesEditorPlugin::_preview_frame_started() {
|
||||
RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<TilesEditorPlugin *>(this), &TilesEditorPlugin::_pattern_preview_done));
|
||||
void RTilesEditorPlugin::_preview_frame_started() {
|
||||
RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<RTilesEditorPlugin *>(this), &RTilesEditorPlugin::_pattern_preview_done));
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::_pattern_preview_done() {
|
||||
void RTilesEditorPlugin::_pattern_preview_done() {
|
||||
pattern_preview_done.post();
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::_thread_func(void *ud) {
|
||||
TilesEditorPlugin *te = (TilesEditorPlugin *)ud;
|
||||
void RTilesEditorPlugin::_thread_func(void *ud) {
|
||||
RTilesEditorPlugin *te = (RTilesEditorPlugin *)ud;
|
||||
te->_thread();
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::_thread() {
|
||||
void RTilesEditorPlugin::_thread() {
|
||||
pattern_thread_exited.clear();
|
||||
while (!pattern_thread_exit.is_set()) {
|
||||
pattern_preview_sem.wait();
|
||||
@ -116,7 +116,7 @@ void TilesEditorPlugin::_thread() {
|
||||
// Add the viewport at the lasst moment to avoid rendering too early.
|
||||
EditorNode::get_singleton()->add_child(viewport);
|
||||
|
||||
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<TilesEditorPlugin *>(this), &TilesEditorPlugin::_preview_frame_started), Vector<Variant>(), Object::CONNECT_ONESHOT);
|
||||
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<RTilesEditorPlugin *>(this), &RTilesEditorPlugin::_preview_frame_started), Vector<Variant>(), Object::CONNECT_ONESHOT);
|
||||
|
||||
pattern_preview_done.wait();
|
||||
|
||||
@ -141,11 +141,11 @@ void TilesEditorPlugin::_thread() {
|
||||
pattern_thread_exited.set();
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::_tile_map_changed() {
|
||||
void RTilesEditorPlugin::_tile_map_changed() {
|
||||
tile_map_changed_needs_update = true;
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::_update_editors() {
|
||||
void RTilesEditorPlugin::_update_editors() {
|
||||
// If tile_map is not edited, we change the edited only if we are not editing a tile_set.
|
||||
tileset_editor->edit(tile_set);
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
@ -159,7 +159,7 @@ void TilesEditorPlugin::_update_editors() {
|
||||
CanvasItemEditor::get_singleton()->update_viewport();
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::_notification(int p_what) {
|
||||
void RTilesEditorPlugin::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||
if (tile_map_changed_needs_update) {
|
||||
@ -174,7 +174,7 @@ void TilesEditorPlugin::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::make_visible(bool p_visible) {
|
||||
void RTilesEditorPlugin::make_visible(bool p_visible) {
|
||||
if (p_visible) {
|
||||
// Disable and hide invalid editors.
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
@ -193,7 +193,7 @@ void TilesEditorPlugin::make_visible(bool p_visible) {
|
||||
}
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::queue_pattern_preview(Ref<TileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback) {
|
||||
void RTilesEditorPlugin::queue_pattern_preview(Ref<TileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback) {
|
||||
ERR_FAIL_COND(!p_tile_set.is_valid());
|
||||
ERR_FAIL_COND(!p_pattern.is_valid());
|
||||
{
|
||||
@ -203,11 +203,11 @@ void TilesEditorPlugin::queue_pattern_preview(Ref<TileSet> p_tile_set, Ref<TileM
|
||||
pattern_preview_sem.post();
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::set_sources_lists_current(int p_current) {
|
||||
void RTilesEditorPlugin::set_sources_lists_current(int p_current) {
|
||||
atlas_sources_lists_current = p_current;
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::synchronize_sources_list(Object *p_current) {
|
||||
void RTilesEditorPlugin::synchronize_sources_list(Object *p_current) {
|
||||
ItemList *item_list = Object::cast_to<ItemList>(p_current);
|
||||
ERR_FAIL_COND(!item_list);
|
||||
|
||||
@ -221,13 +221,13 @@ void TilesEditorPlugin::synchronize_sources_list(Object *p_current) {
|
||||
}
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::set_atlas_view_transform(float p_zoom, Vector2 p_scroll) {
|
||||
void RTilesEditorPlugin::set_atlas_view_transform(float p_zoom, Vector2 p_scroll) {
|
||||
atlas_view_zoom = p_zoom;
|
||||
atlas_view_scroll = p_scroll;
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::synchronize_atlas_view(Object *p_current) {
|
||||
TileAtlasView *tile_atlas_view = Object::cast_to<TileAtlasView>(p_current);
|
||||
void RTilesEditorPlugin::synchronize_atlas_view(Object *p_current) {
|
||||
RTileAtlasView *tile_atlas_view = Object::cast_to<RTileAtlasView>(p_current);
|
||||
ERR_FAIL_COND(!tile_atlas_view);
|
||||
|
||||
if (tile_atlas_view->is_visible_in_tree()) {
|
||||
@ -235,11 +235,11 @@ void TilesEditorPlugin::synchronize_atlas_view(Object *p_current) {
|
||||
}
|
||||
}
|
||||
|
||||
void TilesEditorPlugin::edit(Object *p_object) {
|
||||
void RTilesEditorPlugin::edit(Object *p_object) {
|
||||
// Disconnect to changes.
|
||||
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
|
||||
if (tile_map) {
|
||||
tile_map->disconnect("changed", callable_mp(this, &TilesEditorPlugin::_tile_map_changed));
|
||||
tile_map->disconnect("changed", callable_mp(this, &RTilesEditorPlugin::_tile_map_changed));
|
||||
}
|
||||
|
||||
// Update edited objects.
|
||||
@ -267,15 +267,15 @@ void TilesEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
// Add change listener.
|
||||
if (tile_map) {
|
||||
tile_map->connect("changed", callable_mp(this, &TilesEditorPlugin::_tile_map_changed));
|
||||
tile_map->connect("changed", callable_mp(this, &RTilesEditorPlugin::_tile_map_changed));
|
||||
}
|
||||
}
|
||||
|
||||
bool TilesEditorPlugin::handles(Object *p_object) const {
|
||||
bool RTilesEditorPlugin::handles(Object *p_object) const {
|
||||
return p_object->is_class("TileMap") || p_object->is_class("TileSet");
|
||||
}
|
||||
|
||||
TilesEditorPlugin::TilesEditorPlugin(EditorNode *p_node) {
|
||||
RTilesEditorPlugin::RTilesEditorPlugin(EditorNode *p_node) {
|
||||
set_process_internal(true);
|
||||
|
||||
// Update the singleton.
|
||||
@ -284,14 +284,14 @@ TilesEditorPlugin::TilesEditorPlugin(EditorNode *p_node) {
|
||||
editor_node = p_node;
|
||||
|
||||
// Tileset editor.
|
||||
tileset_editor = memnew(TileSetEditor);
|
||||
tileset_editor = memnew(RTileSetEditor);
|
||||
tileset_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
tileset_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
tileset_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
||||
tileset_editor->hide();
|
||||
|
||||
// Tilemap editor.
|
||||
tilemap_editor = memnew(TileMapEditor);
|
||||
tilemap_editor = memnew(RTileMapEditor);
|
||||
tilemap_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
tilemap_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
tilemap_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
||||
@ -310,7 +310,7 @@ TilesEditorPlugin::TilesEditorPlugin(EditorNode *p_node) {
|
||||
_update_editors();
|
||||
}
|
||||
|
||||
TilesEditorPlugin::~TilesEditorPlugin() {
|
||||
RTilesEditorPlugin::~RTilesEditorPlugin() {
|
||||
if (pattern_preview_thread.is_started()) {
|
||||
pattern_thread_exit.set();
|
||||
pattern_preview_sem.post();
|
||||
|
@ -28,8 +28,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TILES_EDITOR_PLUGIN_H
|
||||
#define TILES_EDITOR_PLUGIN_H
|
||||
#ifndef RTILES_EDITOR_PLUGIN_H
|
||||
#define RTILES_EDITOR_PLUGIN_H
|
||||
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
@ -38,10 +38,10 @@
|
||||
#include "tile_map_editor.h"
|
||||
#include "tile_set_editor.h"
|
||||
|
||||
class TilesEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(TilesEditorPlugin, EditorPlugin);
|
||||
class RTilesEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(RTilesEditorPlugin, EditorPlugin);
|
||||
|
||||
static TilesEditorPlugin *singleton;
|
||||
static RTilesEditorPlugin *singleton;
|
||||
|
||||
private:
|
||||
EditorNode *editor_node;
|
||||
@ -51,10 +51,10 @@ private:
|
||||
Ref<TileSet> tile_set;
|
||||
|
||||
Button *tilemap_editor_button;
|
||||
TileMapEditor *tilemap_editor;
|
||||
RTileMapEditor *tilemap_editor;
|
||||
|
||||
Button *tileset_editor_button;
|
||||
TileSetEditor *tileset_editor;
|
||||
RTileSetEditor *tileset_editor;
|
||||
|
||||
void _update_editors();
|
||||
|
||||
@ -87,7 +87,7 @@ protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
public:
|
||||
_FORCE_INLINE_ static TilesEditorPlugin *get_singleton() { return singleton; }
|
||||
_FORCE_INLINE_ static RTilesEditorPlugin *get_singleton() { return singleton; }
|
||||
|
||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override { return tilemap_editor->forward_canvas_gui_input(p_event); }
|
||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override { tilemap_editor->forward_canvas_draw_over_viewport(p_overlay); }
|
||||
@ -106,8 +106,8 @@ public:
|
||||
virtual bool handles(Object *p_object) const override;
|
||||
virtual void make_visible(bool p_visible) override;
|
||||
|
||||
TilesEditorPlugin(EditorNode *p_node);
|
||||
~TilesEditorPlugin();
|
||||
RTilesEditorPlugin(EditorNode *p_node);
|
||||
~RTilesEditorPlugin();
|
||||
};
|
||||
|
||||
#endif // TILES_EDITOR_PLUGIN_H
|
||||
|
Loading…
Reference in New Issue
Block a user