Skip to content

Commit

Permalink
feat: handles the creation of a slot and it's update
Browse files Browse the repository at this point in the history
  • Loading branch information
OctoD committed Feb 1, 2024
1 parent fc1b5ee commit 4b09761
Show file tree
Hide file tree
Showing 17 changed files with 450 additions and 158 deletions.
6 changes: 6 additions & 0 deletions project/.ggs/1.0.0/equipment/head.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_resource type="EquipmentSlot" format=3 uid="uid://2h6o2lbxds84"]

[resource]
slot_name = &"head"
accepts_items_with_tags = PackedStringArray("type.armor.helm")
resource_name = "head.tres"
20 changes: 20 additions & 0 deletions src/editor_plugin/main_scene/ggs_new_resource_modal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ void NewResourceModal::_bind_methods()
ClassDB::bind_method(D_METHOD("_handle_close_button_pressed"), &NewResourceModal::_handle_close_button_pressed);
ClassDB::bind_method(D_METHOD("_handle_create_button_pressed"), &NewResourceModal::_handle_create_button_pressed);
ClassDB::bind_method(D_METHOD("_handle_line_edit_text_changed"), &NewResourceModal::_handle_line_edit_text_changed);
ClassDB::bind_method(D_METHOD("set_create_button_text", "p_button_text"), &NewResourceModal::set_create_button_text);
ClassDB::bind_method(D_METHOD("toggle_visibility"), &NewResourceModal::toggle_visibility);

/// signals binding
ADD_SIGNAL(MethodInfo("create_requested", PropertyInfo(Variant::STRING, "resource_name")));
}
Expand Down Expand Up @@ -95,3 +98,20 @@ void NewResourceModal::_ready()
set_min_size(Size2(320, 240));
set_max_size(Size2(480, 320));
}

void NewResourceModal::set_create_button_text(String p_text)
{
create_button->set_text(p_text);
}

void NewResourceModal::toggle_visibility()
{
if (is_visible())
{
hide();
}
else
{
popup_centered();
}
}
4 changes: 3 additions & 1 deletion src/editor_plugin/main_scene/ggs_new_resource_modal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ namespace ggs::editor_plugin
static void _bind_methods();
void _handle_close_button_pressed();
void _handle_create_button_pressed();
void _handle_line_edit_text_changed(String text);
void _handle_line_edit_text_changed(String popup_exclusive_centered);
Button *create_button;
Label *resource_name_label;
LineEdit *resource_name_line_edit;

public:
void _ready() override;
void set_create_button_text(String p_text);
void toggle_visibility();
};
}

Expand Down
Loading

0 comments on commit 4b09761

Please sign in to comment.