Skip to content

Commit

Permalink
Use RTR() for VisualScriptNode captions and texts
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyqiu committed Mar 11, 2022
1 parent 3f3826e commit 77f80aa
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 76 deletions.
2 changes: 1 addition & 1 deletion modules/visual_script/visual_script_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ PropertyInfo VisualScriptExpression::get_output_value_port_info(int p_idx) const
}

String VisualScriptExpression::get_caption() const {
return TTR("Expression");
return RTR("Expression");
}

String VisualScriptExpression::get_text() const {
Expand Down
28 changes: 14 additions & 14 deletions modules/visual_script/visual_script_flow_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ PropertyInfo VisualScriptReturn::get_output_value_port_info(int p_idx) const {
}

String VisualScriptReturn::get_caption() const {
return TTR("Return");
return RTR("Return");
}

String VisualScriptReturn::get_text() const {
Expand Down Expand Up @@ -201,11 +201,11 @@ PropertyInfo VisualScriptCondition::get_output_value_port_info(int p_idx) const
}

String VisualScriptCondition::get_caption() const {
return TTR("Condition");
return RTR("Condition");
}

String VisualScriptCondition::get_text() const {
return TTR("if (cond) is:");
return RTR("if (cond) is:");
}

void VisualScriptCondition::_bind_methods() {
Expand Down Expand Up @@ -281,11 +281,11 @@ PropertyInfo VisualScriptWhile::get_output_value_port_info(int p_idx) const {
}

String VisualScriptWhile::get_caption() const {
return TTR("While");
return RTR("While");
}

String VisualScriptWhile::get_text() const {
return TTR("while (cond):");
return RTR("while (cond):");
}

void VisualScriptWhile::_bind_methods() {
Expand Down Expand Up @@ -364,11 +364,11 @@ PropertyInfo VisualScriptIterator::get_output_value_port_info(int p_idx) const {
}

String VisualScriptIterator::get_caption() const {
return TTR("Iterator");
return RTR("Iterator");
}

String VisualScriptIterator::get_text() const {
return TTR("for (elem) in (input):");
return RTR("for (elem) in (input):");
}

void VisualScriptIterator::_bind_methods() {
Expand Down Expand Up @@ -478,11 +478,11 @@ PropertyInfo VisualScriptSequence::get_output_value_port_info(int p_idx) const {
}

String VisualScriptSequence::get_caption() const {
return TTR("Sequence");
return RTR("Sequence");
}

String VisualScriptSequence::get_text() const {
return TTR("in order:");
return RTR("in order:");
}

void VisualScriptSequence::set_steps(int p_steps) {
Expand Down Expand Up @@ -587,11 +587,11 @@ PropertyInfo VisualScriptSwitch::get_output_value_port_info(int p_idx) const {
}

String VisualScriptSwitch::get_caption() const {
return TTR("Switch");
return RTR("Switch");
}

String VisualScriptSwitch::get_text() const {
return TTR("'input' is:");
return RTR("'input' is:");
}

class VisualScriptNodeInstanceSwitch : public VisualScriptNodeInstance {
Expand Down Expand Up @@ -720,14 +720,14 @@ PropertyInfo VisualScriptTypeCast::get_output_value_port_info(int p_idx) const {
}

String VisualScriptTypeCast::get_caption() const {
return TTR("Type Cast");
return RTR("Type Cast");
}

String VisualScriptTypeCast::get_text() const {
if (!script.is_empty()) {
return vformat(TTR("Is %s?"), script.get_file());
return vformat(RTR("Is %s?"), script.get_file());
} else {
return vformat(TTR("Is %s?"), base_type);
return vformat(RTR("Is %s?"), base_type);
}
}

Expand Down
49 changes: 25 additions & 24 deletions modules/visual_script/visual_script_func_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "core/config/engine.h"
#include "core/io/resource_loader.h"
#include "core/os/os.h"
#include "core/templates/local_vector.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "visual_script_nodes.h"
Expand Down Expand Up @@ -261,13 +262,13 @@ String VisualScriptFunctionCall::get_text() const {
String text;

if (call_mode == CALL_MODE_BASIC_TYPE) {
text = vformat(TTR("On %s"), Variant::get_type_name(basic_type));
text = vformat(RTR("On %s"), Variant::get_type_name(basic_type));
} else if (call_mode == CALL_MODE_INSTANCE) {
text = vformat(TTR("On %s"), base_type);
text = vformat(RTR("On %s"), base_type);
} else if (call_mode == CALL_MODE_NODE_PATH) {
text = "[" + String(base_path.simplified()) + "]";
} else if (call_mode == CALL_MODE_SELF) {
text = TTR("On Self");
text = RTR("On Self");
} else if (call_mode == CALL_MODE_SINGLETON) {
text = String(singleton) + ":" + String(function) + "()";
}
Expand Down Expand Up @@ -1032,40 +1033,40 @@ PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) cons
}

String VisualScriptPropertySet::get_caption() const {
static const char *opname[ASSIGN_OP_MAX] = {
TTRC("Set %s"),
TTRC("Add %s"),
TTRC("Subtract %s"),
TTRC("Multiply %s"),
TTRC("Divide %s"),
TTRC("Mod %s"),
TTRC("ShiftLeft %s"),
TTRC("ShiftRight %s"),
TTRC("BitAnd %s"),
TTRC("BitOr %s"),
TTRC("BitXor %s")
static const LocalVector<String> opname = {
RTR("Set %s"),
RTR("Add %s"),
RTR("Subtract %s"),
RTR("Multiply %s"),
RTR("Divide %s"),
RTR("Mod %s"),
RTR("ShiftLeft %s"),
RTR("ShiftRight %s"),
RTR("BitAnd %s"),
RTR("BitOr %s"),
RTR("BitXor %s"),
};

String prop = property;
if (index != StringName()) {
prop += "." + String(index);
}

return vformat(TTRGET(opname[assign_op]), prop);
return vformat(opname[assign_op], prop);
}

String VisualScriptPropertySet::get_text() const {
if (!has_input_sequence_port()) {
return "";
}
if (call_mode == CALL_MODE_BASIC_TYPE) {
return vformat(TTR("On %s"), Variant::get_type_name(basic_type));
return vformat(RTR("On %s"), Variant::get_type_name(basic_type));
} else if (call_mode == CALL_MODE_INSTANCE) {
return vformat(TTR("On %s"), base_type);
return vformat(RTR("On %s"), base_type);
} else if (call_mode == CALL_MODE_NODE_PATH) {
return " [" + String(base_path.simplified()) + "]";
} else {
return TTR("On Self");
return RTR("On Self");
}
}

Expand Down Expand Up @@ -1776,18 +1777,18 @@ String VisualScriptPropertyGet::get_caption() const {
prop += "." + String(index);
}

return vformat(TTR("Get %s"), prop);
return vformat(RTR("Get %s"), prop);
}

String VisualScriptPropertyGet::get_text() const {
if (call_mode == CALL_MODE_BASIC_TYPE) {
return vformat(TTR("On %s"), Variant::get_type_name(basic_type));
return vformat(RTR("On %s"), Variant::get_type_name(basic_type));
} else if (call_mode == CALL_MODE_INSTANCE) {
return vformat(TTR("On %s"), base_type);
return vformat(RTR("On %s"), base_type);
} else if (call_mode == CALL_MODE_NODE_PATH) {
return " [" + String(base_path.simplified()) + "]";
} else {
return TTR("On Self");
return RTR("On Self");
}
}

Expand Down Expand Up @@ -2303,7 +2304,7 @@ PropertyInfo VisualScriptEmitSignal::get_output_value_port_info(int p_idx) const
}

String VisualScriptEmitSignal::get_caption() const {
return vformat(TTR("Emit %s"), name);
return vformat(RTR("Emit %s"), name);
}

void VisualScriptEmitSignal::set_signal(const StringName &p_type) {
Expand Down
Loading

0 comments on commit 77f80aa

Please sign in to comment.