Skip to content

Commit

Permalink
GH-488 Update InspectorDock when ProjectSettings change
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Jul 10, 2024
1 parent eb3fe8e commit 2397ef8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/script/nodes/input/input_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ class OScriptNodeInputActionInstance : public OScriptNodeInstance

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void OScriptNodeInputAction::_settings_changed()
{
// If the node is selected and the user modifies the project settings, this makes sure that the action
// list will be regenerated in the InspectorDock to reflect the changes potentially to any new InputMap
// actions that were defined.
notify_property_list_changed();
}

PackedStringArray OScriptNodeInputAction::_get_action_names() const
{
PackedStringArray action_names;
Expand Down Expand Up @@ -144,6 +152,28 @@ void OScriptNodeInputAction::_bind_methods()
BIND_ENUM_CONSTANT(AM_JUST_RELEASED)
}

void OScriptNodeInputAction::post_initialize()
{
if (_is_in_editor())
{
ProjectSettings* settings = ProjectSettings::get_singleton();
settings->connect("settings_changed", callable_mp(this, &OScriptNodeInputAction::_settings_changed));
}

super::post_initialize();
}

void OScriptNodeInputAction::post_placed_new_node()
{
if (_is_in_editor())
{
ProjectSettings* settings = ProjectSettings::get_singleton();
settings->connect("settings_changed", callable_mp(this, &OScriptNodeInputAction::_settings_changed));
}

super::post_placed_new_node();
}

void OScriptNodeInputAction::allocate_default_pins()
{
create_pin(PD_Output, PT_Data, PropertyUtils::make_typed("state", Variant::BOOL))->set_label(_get_mode());
Expand Down
5 changes: 5 additions & 0 deletions src/script/nodes/input/input_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ class OScriptNodeInputAction : public OScriptNode
bool _set(const StringName &p_name, const Variant &p_value);
//~ End Wrapped Interface

/// Called when the project settings are modified.
void _settings_changed();

PackedStringArray _get_action_names() const;
String _get_mode() const;

public:

//~ Begin OScriptNode Interface
void post_initialize() override;
void post_placed_new_node() override;
void allocate_default_pins() override;
String get_tooltip_text() const override;
String get_node_title() const override;
Expand Down

0 comments on commit 2397ef8

Please sign in to comment.