Fix a a few signal arguments.

This commit is contained in:
Relintai 2021-12-12 18:56:25 +01:00
parent 763487cbb6
commit efbe5e0be0
6 changed files with 72 additions and 65 deletions

View File

@ -198,7 +198,7 @@ void RTileMapEditorTilesPlugin::_update_tile_set_sources_list() {
RTilesEditorPlugin::get_singleton()->set_sources_lists_current(sources_list->get_current());
}
void RTileMapEditorTilesPlugin::_update_source_display() {
void RTileMapEditorTilesPlugin::_update_source_display(const int index) {
// Update the atlas display.
RTileMap *tile_map = Object::cast_to<RTileMap>(ObjectDB::get_instance(tile_map_id));
if (!tile_map) {
@ -1412,7 +1412,7 @@ void RTileMapEditorTilesPlugin::_stop_dragging() {
drag_type = DRAG_TYPE_NONE;
}
void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered() {
void RTileMapEditorTilesPlugin::_update_fix_selected_and_hovered(int i) {
RTileMap *tile_map = Object::cast_to<RTileMap>(ObjectDB::get_instance(tile_map_id));
if (!tile_map) {
hovered_tile.source_id = RTileSet::INVALID_SOURCE;
@ -2139,7 +2139,7 @@ RTileMapEditorTilesPlugin::RTileMapEditorTilesPlugin() {
// --- Bottom panel tiles ---
tiles_bottom_panel = memnew(VBoxContainer);
tiles_bottom_panel->connect("tree_entered", this, "_update_theme");
tiles_bottom_panel->connect("theme_changed", this, "_update_theme");
//tiles_bottom_panel->connect("theme_changed", this, "_update_theme");
tiles_bottom_panel->connect("visibility_changed", this, "_stop_dragging");
tiles_bottom_panel->connect("visibility_changed", this, "_tab_changed");
tiles_bottom_panel->set_name(TTR("Tiles"));
@ -3256,7 +3256,7 @@ void RTileMapEditorTerrainsPlugin::edit(ObjectID p_tile_map_id, int p_tile_map_l
RTileMapEditorTerrainsPlugin::RTileMapEditorTerrainsPlugin() {
main_vbox_container = memnew(VBoxContainer);
main_vbox_container->connect("tree_entered", this, "_update_theme");
main_vbox_container->connect("theme_changed", this, "_update_theme");
//main_vbox_container->connect("theme_changed", this, "_update_theme");
main_vbox_container->set_name("Terrains");
HSplitContainer *tilemap_tab_terrains = memnew(HSplitContainer);
@ -3363,6 +3363,7 @@ RTileMapEditorTerrainsPlugin::~RTileMapEditorTerrainsPlugin() {
void RTileMapEditorTerrainsPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_tiles_list"), &RTileMapEditorTerrainsPlugin::_update_tiles_list);
ClassDB::bind_method(D_METHOD("_update_theme"), &RTileMapEditorTerrainsPlugin::_update_theme);
}
void RTileMapEditor::_notification(int p_what) {

View File

@ -133,7 +133,7 @@ private:
void _update_selection_pattern_from_tileset_tiles_selection();
void _update_selection_pattern_from_tileset_pattern_selection();
void _update_tileset_selection_from_selection_pattern();
void _update_fix_selected_and_hovered();
void _update_fix_selected_and_hovered(const int index = 0);
void _fix_invalid_tiles_in_tile_map_selection();
///// Bottom panel common ////
@ -149,7 +149,7 @@ private:
Ref<Texture> missing_atlas_texture_icon;
void _update_tile_set_sources_list();
void _update_source_display();
void _update_source_display(const int index = 0);
// Atlas sources.
RTileMapCell hovered_tile;

View File

@ -44,11 +44,11 @@
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "core/core_string_names.h"
#include "../geometry_2d.h"
#include "core/os/keyboard.h"
#include "core/os/input.h"
#include "../math_ext.h"
#include "core/core_string_names.h"
#include "core/os/input.h"
#include "core/os/keyboard.h"
void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::set_id(int p_id) {
ERR_FAIL_COND(p_id < 0);
@ -485,38 +485,38 @@ void RTileSetAtlasSourceEditor::AtlasTileProxyObject::edit(RTileSetAtlasSource *
ERR_FAIL_COND(E->get().alternative < 0);
}
/*
// Disconnect to changes.
for (Set<TileSelection>::Element *E = tiles.front(); E; E = E->next()) {
const Vector2i &coords = E->get().tile;
const int &alternative = E->get().alternative;
/*
// Disconnect to changes.
for (Set<TileSelection>::Element *E = tiles.front(); E; E = E->next()) {
const Vector2i &coords = E->get().tile;
const int &alternative = E->get().alternative;
if (tile_set_atlas_source && tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
if (tile_data->is_connected(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed))) {
tile_data->disconnect(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed));
if (tile_set_atlas_source && tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
if (tile_data->is_connected(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed))) {
tile_data->disconnect(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed));
}
}
}
}
*/
*/
/*
tile_set_atlas_source = p_tile_set_atlas_source;
tiles = Set<TileSelection>(p_tiles);
/*
tile_set_atlas_source = p_tile_set_atlas_source;
tiles = Set<TileSelection>(p_tiles);
// Connect to changes.
for (Set<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) {
const Vector2i &coords = E->get().tile;
const int &alternative = E->get().alternative;
// Connect to changes.
for (Set<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) {
const Vector2i &coords = E->get().tile;
const int &alternative = E->get().alternative;
if (tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
if (!tile_data->is_connected(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed))) {
tile_data->connect(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed));
if (tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
if (!tile_data->is_connected(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed))) {
tile_data->connect(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed));
}
}
}
}
*/
*/
property_list_changed_notify();
}
@ -530,7 +530,7 @@ void RTileSetAtlasSourceEditor::_inspector_property_selected(String p_property)
_update_current_tile_data_editor();
}
void RTileSetAtlasSourceEditor::_update_tile_id_label() {
void RTileSetAtlasSourceEditor::_update_tile_id_label(Node *button) {
if (selection.size() == 1) {
TileSelection selected = selection.front()->get();
tool_tile_id_label->set_text(vformat("%d, %s, %d", tile_set_atlas_source_id, Vector2(selected.tile), selected.alternative));
@ -546,7 +546,7 @@ void RTileSetAtlasSourceEditor::_update_source_inspector() {
atlas_source_proxy_object->edit(tile_set, tile_set_atlas_source, tile_set_atlas_source_id);
}
void RTileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() {
void RTileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles(Node *button) {
// Fix selected.
for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
TileSelection selected = E->get();
@ -566,14 +566,14 @@ void RTileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() {
}
}
void RTileSetAtlasSourceEditor::_update_atlas_source_inspector() {
void RTileSetAtlasSourceEditor::_update_atlas_source_inspector(Node *button) {
// 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 RTileSetAtlasSourceEditor::_update_tile_inspector() {
void RTileSetAtlasSourceEditor::_update_tile_inspector(Node *button) {
// Update visibility.
if (tools_button_group->get_pressed_button() == tool_select_button) {
if (!selection.empty()) {
@ -589,7 +589,7 @@ void RTileSetAtlasSourceEditor::_update_tile_inspector() {
}
}
void RTileSetAtlasSourceEditor::_update_tile_data_editors() {
void RTileSetAtlasSourceEditor::_update_tile_data_editors(Node *button) {
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);
@ -862,10 +862,10 @@ void RTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() {
Point2 ofs;
//if (is_layout_rtl()) {
// ofs = Point2(get_constant(("arrow_margin"), ("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2)));
// ofs = Point2(get_constant(("arrow_margin"), ("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2)));
//} else {
ofs = Point2(size.width - arrow->get_width() - get_constant(("arrow_margin"), ("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2)));
// }
ofs = Point2(size.width - arrow->get_width() - get_constant(("arrow_margin"), ("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2)));
// }
arrow->draw(ci, ofs, clr);
}
@ -885,7 +885,7 @@ void RTileSetAtlasSourceEditor::_tile_data_editors_tree_selected() {
alternative_tiles_control_unscaled->update();
}
void RTileSetAtlasSourceEditor::_update_atlas_view() {
void RTileSetAtlasSourceEditor::_update_atlas_view(Node *p_button) {
// Update the atlas display.
tile_atlas_view->set_atlas_source(*tile_set, tile_set_atlas_source, tile_set_atlas_source_id);
@ -947,7 +947,7 @@ void RTileSetAtlasSourceEditor::_update_atlas_view() {
RTilesEditorPlugin::get_singleton()->synchronize_atlas_view(tile_atlas_view);
}
void RTileSetAtlasSourceEditor::_update_toolbar() {
void RTileSetAtlasSourceEditor::_update_toolbar(Node *button) {
// Show the tools and settings.
if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) {
if (current_tile_data_editor_toolbar) {
@ -1405,7 +1405,6 @@ void RTileSetAtlasSourceEditor::_end_dragging() {
MathExt::rect2i_set_end(&area, MathExt::vector2i_min((MathExt::rect2i_get_end(area) + Vector2i(1, 1)), tile_set_atlas_source->get_atlas_grid_size()));
//area.set_end((area.get_end() + Vector2i(1, 1)).min(tile_set_atlas_source->get_atlas_grid_size()));
List<PropertyInfo> list;
tile_set_atlas_source->get_property_list(&list);
Map<Vector2i, List<const PropertyInfo *>> per_tile = _group_properties_per_tiles(list, tile_set_atlas_source);
@ -2363,7 +2362,6 @@ void RTileSetAtlasSourceEditor::_bind_methods() {
ADD_SIGNAL(MethodInfo("source_id_changed", PropertyInfo(Variant::INT, "source_id")));
ClassDB::bind_method(D_METHOD("_update_fix_selected_and_hovered_tiles"), &RTileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles);
ClassDB::bind_method(D_METHOD("_update_tile_id_label"), &RTileSetAtlasSourceEditor::_update_tile_id_label);
ClassDB::bind_method(D_METHOD("_update_atlas_source_inspector"), &RTileSetAtlasSourceEditor::_update_atlas_source_inspector);
@ -2492,12 +2490,11 @@ RTileSetAtlasSourceEditor::RTileSetAtlasSourceEditor() {
// -- Toolbox --
tools_button_group.instance();
tools_button_group->connect("pressed",this, "_update_fix_selected_and_hovered_tiles");
tools_button_group->connect("pressed", this, "_update_fix_selected_and_hovered_tiles");
tools_button_group->connect("pressed", this, "_update_tile_id_label");
tools_button_group->connect("pressed", this, "_update_atlas_source_inspector");
tools_button_group->connect("pressed", this, "_update_tile_inspector");
tools_button_group->connect("pressed", this, "_update_tile_data_editors");
tools_button_group->connect("pressed", this, "_update_tile_data_editors");
tools_button_group->connect("pressed", this, "_update_atlas_view");
tools_button_group->connect("pressed", this, "_update_toolbar");

View File

@ -248,16 +248,16 @@ private:
void _tile_alternatives_control_gui_input(const Ref<InputEvent> &p_event);
// -- Update functions --
void _update_tile_id_label();
void _update_tile_id_label(Node * button = nullptr);
void _update_source_inspector();
void _update_fix_selected_and_hovered_tiles();
void _update_atlas_source_inspector();
void _update_tile_inspector();
void _update_tile_data_editors();
void _update_fix_selected_and_hovered_tiles(Node * button = nullptr);
void _update_atlas_source_inspector(Node * button = nullptr);
void _update_tile_inspector(Node * button = nullptr);
void _update_tile_data_editors(Node * button = nullptr);
void _update_current_tile_data_editor();
void _update_manage_tile_properties_button();
void _update_atlas_view();
void _update_toolbar();
void _update_atlas_view(Node * button = nullptr);
void _update_toolbar(Node * button = nullptr);
// -- input events --
void _unhandled_key_input(const Ref<InputEvent> &p_event);

View File

@ -261,7 +261,7 @@ void RTileSetScenesCollectionSourceEditor::_update_source_inspector() {
scenes_collection_source_proxy_object->edit(tile_set, tile_set_scenes_collection_source, tile_set_source_id);
}
void RTileSetScenesCollectionSourceEditor::_update_tile_inspector() {
void RTileSetScenesCollectionSourceEditor::_update_tile_inspector(const int index) {
Vector<int> selected_indices = scene_tiles_list->get_selected_items();
bool has_atlas_tile_selected = (selected_indices.size() > 0);
@ -276,12 +276,16 @@ void RTileSetScenesCollectionSourceEditor::_update_tile_inspector() {
tile_inspector->set_visible(has_atlas_tile_selected);
}
void RTileSetScenesCollectionSourceEditor::_update_action_buttons() {
void RTileSetScenesCollectionSourceEditor::_update_action_buttons(const int index) {
Vector<int> selected_indices = scene_tiles_list->get_selected_items();
scene_tile_delete_button->set_disabled(selected_indices.size() <= 0);
}
void RTileSetScenesCollectionSourceEditor::_update_scenes_list() {
void RTileSetScenesCollectionSourceEditor::_update_action_buttons_str(const String &a) {
_update_action_buttons();
}
void RTileSetScenesCollectionSourceEditor::_update_scenes_list(const int index) {
if (!tile_set_scenes_collection_source) {
return;
}
@ -327,6 +331,10 @@ void RTileSetScenesCollectionSourceEditor::_update_scenes_list() {
scene_tiles_list->set_fixed_icon_size(Vector2(int_size, int_size));
}
void RTileSetScenesCollectionSourceEditor::_update_scenes_list_str(const String &a) {
_update_scenes_list();
}
void RTileSetScenesCollectionSourceEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
@ -453,8 +461,6 @@ void RTileSetScenesCollectionSourceEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_drop_data_fw"), &RTileSetScenesCollectionSourceEditor::_drop_data_fw);
ClassDB::bind_method(D_METHOD("_tile_set_scenes_collection_source_changed"), &RTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed);
ClassDB::bind_method(D_METHOD("_scenes_collection_source_proxy_object_changed"), &RTileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed);
ClassDB::bind_method(D_METHOD("_update_scenes_list"), &RTileSetScenesCollectionSourceEditor::_update_scenes_list);
ClassDB::bind_method(D_METHOD("_update_action_buttons"), &RTileSetScenesCollectionSourceEditor::_update_action_buttons);
@ -462,7 +468,8 @@ void RTileSetScenesCollectionSourceEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_scenes_list_item_activated"), &RTileSetScenesCollectionSourceEditor::_scenes_list_item_activated);
ClassDB::bind_method(D_METHOD("_source_add_pressed"), &RTileSetScenesCollectionSourceEditor::_source_add_pressed);
ClassDB::bind_method(D_METHOD("_source_delete_pressed"), &RTileSetScenesCollectionSourceEditor::_source_delete_pressed);
ClassDB::bind_method(D_METHOD("_tile_set_scenes_collection_source_changed"), &RTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed);
ClassDB::bind_method(D_METHOD("_update_action_buttons_str"), &RTileSetScenesCollectionSourceEditor::_update_action_buttons_str);
ClassDB::bind_method(D_METHOD("_update_scenes_list_str"), &RTileSetScenesCollectionSourceEditor::_update_scenes_list_str);
}
RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionSourceEditor() {
@ -502,8 +509,8 @@ RTileSetScenesCollectionSourceEditor::RTileSetScenesCollectionSourceEditor() {
middle_vbox_container->add_child(tile_inspector_label);
tile_proxy_object = memnew(SceneTileProxyObject(this));
tile_proxy_object->connect("changed", this, "_update_scenes_list");
tile_proxy_object->connect("changed", this, "_update_action_buttons");
tile_proxy_object->connect("changed", this, "_update_scenes_list_str");
tile_proxy_object->connect("changed", this, "_update_action_buttons_str");
tile_inspector = memnew(EditorInspector);
tile_inspector->set_undo_redo(undo_redo);

View File

@ -121,9 +121,11 @@ private:
// Update methods.
void _update_source_inspector();
void _update_tile_inspector();
void _update_scenes_list();
void _update_action_buttons();
void _update_tile_inspector(const int index = 0);
void _update_scenes_list(const int index = 0);
void _update_action_buttons(const int index = 0);
void _update_scenes_list_str(const String &a);
void _update_action_buttons_str(const String &a);
void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;