Skip to content

Commit

Permalink
CharFXTransform: Drop unnecessary get_value_or()
Browse files Browse the repository at this point in the history
See #23658 (comment)
The method was implemented back when Dictionary.get(key, default) did not
exist, but now that it does we do not need a custom method in CharFXTransform.

It's a new feature in 3.2, so does not break compat with 3.1.x.
  • Loading branch information
akien-mga committed Dec 12, 2019
1 parent 371de51 commit 37d164e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 27 deletions.
11 changes: 0 additions & 11 deletions doc/classes/CharFXTransform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@
<link>https://github.com/Eoin-ONeill-Yokai/Godot-Rich-Text-Effect-Test-Project</link>
</tutorials>
<methods>
<method name="get_value_or">
<return type="Variant">
</return>
<argument index="0" name="key" type="String">
</argument>
<argument index="1" name="default_value" type="Variant">
</argument>
<description>
Returns the value for [code]key[/code] in the [member env] [Dictionary], or [code]default_value[/code] if [code]key[/code] isn't defined in [member env]. If the value's type doesn't match [code]default_value[/code]'s type, this method will return [code]default_value[/code].
</description>
</method>
</methods>
<members>
<member name="absolute_index" type="int" setter="set_absolute_index" getter="get_absolute_index" default="0">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
<member name="debug/gdscript/warnings/unused_argument" type="bool" setter="" getter="" default="true">
If [code]true[/code], enables warnings when a function parameter is unused.
</member>
<member name="debug/gdscript/warnings/unused_class_variable" type="bool" setter="" getter="" default="true">
<member name="debug/gdscript/warnings/unused_class_variable" type="bool" setter="" getter="" default="false">
If [code]true[/code], enables warnings when a member variable is unused.
</member>
<member name="debug/gdscript/warnings/unused_signal" type="bool" setter="" getter="" default="true">
Expand Down
13 changes: 0 additions & 13 deletions scene/gui/rich_text_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ void CharFXTransform::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_character"), &CharFXTransform::get_character);
ClassDB::bind_method(D_METHOD("set_character", "character"), &CharFXTransform::set_character);

ClassDB::bind_method(D_METHOD("get_value_or", "key", "default_value"), &CharFXTransform::get_value_or);

ADD_PROPERTY(PropertyInfo(Variant::INT, "relative_index"), "set_relative_index", "get_relative_index");
ADD_PROPERTY(PropertyInfo(Variant::INT, "absolute_index"), "set_absolute_index", "get_absolute_index");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "elapsed_time"), "set_elapsed_time", "get_elapsed_time");
Expand All @@ -101,17 +99,6 @@ void CharFXTransform::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "character"), "set_character", "get_character");
}

Variant CharFXTransform::get_value_or(String p_key, Variant p_default_value) {
if (!this->environment.has(p_key))
return p_default_value;

Variant r = environment[p_key];
if (r.get_type() != p_default_value.get_type())
return p_default_value;

return r;
}

CharFXTransform::CharFXTransform() {
relative_index = 0;
absolute_index = 0;
Expand Down
2 changes: 0 additions & 2 deletions scene/gui/rich_text_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ class CharFXTransform : public Reference {
void set_character(int p_char) { character = (CharType)p_char; }
Dictionary get_environment() { return environment; }
void set_environment(Dictionary p_environment) { environment = p_environment; }

Variant get_value_or(String p_key, Variant p_default_value);
};

#endif // RICH_TEXT_EFFECT_H

1 comment on commit 37d164e

@Calinou
Copy link
Member

@Calinou Calinou commented on 37d164e Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, the change in doc/classes/ProjectSettings.xml is from #34271. (I thought it was changed by mistake at first.)

Please sign in to comment.