diff options
Diffstat (limited to 'modules/visual_script')
-rw-r--r-- | modules/visual_script/visual_script_editor.cpp | 272 | ||||
-rw-r--r-- | modules/visual_script/visual_script_expression.cpp | 180 | ||||
-rw-r--r-- | modules/visual_script/visual_script_yield_nodes.cpp | 28 |
3 files changed, 356 insertions, 124 deletions
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 9a4076bec4..3649486724 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -342,84 +342,212 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { Color color; if (dark_theme) switch (p_type) { - case Variant::NIL: color = Color(0.41, 0.93, 0.74); break; - - case Variant::BOOL: color = Color(0.55, 0.65, 0.94); break; - case Variant::INT: color = Color(0.49, 0.78, 0.94); break; - case Variant::FLOAT: color = Color(0.38, 0.85, 0.96); break; - case Variant::STRING: color = Color(0.42, 0.65, 0.93); break; - - case Variant::VECTOR2: color = Color(0.74, 0.57, 0.95); break; - case Variant::VECTOR2I: color = Color(0.74, 0.57, 0.95); break; - case Variant::RECT2: color = Color(0.95, 0.57, 0.65); break; - case Variant::RECT2I: color = Color(0.95, 0.57, 0.65); break; - case Variant::VECTOR3: color = Color(0.84, 0.49, 0.93); break; - case Variant::VECTOR3I: color = Color(0.84, 0.49, 0.93); break; - case Variant::TRANSFORM2D: color = Color(0.77, 0.93, 0.41); break; - case Variant::PLANE: color = Color(0.97, 0.44, 0.44); break; - case Variant::QUAT: color = Color(0.93, 0.41, 0.64); break; - case Variant::AABB: color = Color(0.93, 0.47, 0.57); break; - case Variant::BASIS: color = Color(0.89, 0.93, 0.41); break; - case Variant::TRANSFORM: color = Color(0.96, 0.66, 0.43); break; - - case Variant::COLOR: color = Color(0.62, 1.0, 0.44); break; - case Variant::NODE_PATH: color = Color(0.41, 0.58, 0.93); break; - case Variant::_RID: color = Color(0.41, 0.93, 0.6); break; - case Variant::OBJECT: color = Color(0.47, 0.95, 0.91); break; - case Variant::DICTIONARY: color = Color(0.47, 0.93, 0.69); break; - - case Variant::ARRAY: color = Color(0.88, 0.88, 0.88); break; - case Variant::PACKED_BYTE_ARRAY: color = Color(0.67, 0.96, 0.78); break; - case Variant::PACKED_INT32_ARRAY: color = Color(0.69, 0.86, 0.96); break; - case Variant::PACKED_FLOAT32_ARRAY: color = Color(0.59, 0.91, 0.97); break; - case Variant::PACKED_INT64_ARRAY: color = Color(0.69, 0.86, 0.96); break; - case Variant::PACKED_FLOAT64_ARRAY: color = Color(0.59, 0.91, 0.97); break; - case Variant::PACKED_STRING_ARRAY: color = Color(0.62, 0.77, 0.95); break; - case Variant::PACKED_VECTOR2_ARRAY: color = Color(0.82, 0.7, 0.96); break; - case Variant::PACKED_VECTOR3_ARRAY: color = Color(0.87, 0.61, 0.95); break; - case Variant::PACKED_COLOR_ARRAY: color = Color(0.91, 1.0, 0.59); break; + case Variant::NIL: + color = Color(0.41, 0.93, 0.74); + break; + + case Variant::BOOL: + color = Color(0.55, 0.65, 0.94); + break; + case Variant::INT: + color = Color(0.49, 0.78, 0.94); + break; + case Variant::FLOAT: + color = Color(0.38, 0.85, 0.96); + break; + case Variant::STRING: + color = Color(0.42, 0.65, 0.93); + break; + + case Variant::VECTOR2: + color = Color(0.74, 0.57, 0.95); + break; + case Variant::VECTOR2I: + color = Color(0.74, 0.57, 0.95); + break; + case Variant::RECT2: + color = Color(0.95, 0.57, 0.65); + break; + case Variant::RECT2I: + color = Color(0.95, 0.57, 0.65); + break; + case Variant::VECTOR3: + color = Color(0.84, 0.49, 0.93); + break; + case Variant::VECTOR3I: + color = Color(0.84, 0.49, 0.93); + break; + case Variant::TRANSFORM2D: + color = Color(0.77, 0.93, 0.41); + break; + case Variant::PLANE: + color = Color(0.97, 0.44, 0.44); + break; + case Variant::QUAT: + color = Color(0.93, 0.41, 0.64); + break; + case Variant::AABB: + color = Color(0.93, 0.47, 0.57); + break; + case Variant::BASIS: + color = Color(0.89, 0.93, 0.41); + break; + case Variant::TRANSFORM: + color = Color(0.96, 0.66, 0.43); + break; + + case Variant::COLOR: + color = Color(0.62, 1.0, 0.44); + break; + case Variant::NODE_PATH: + color = Color(0.41, 0.58, 0.93); + break; + case Variant::_RID: + color = Color(0.41, 0.93, 0.6); + break; + case Variant::OBJECT: + color = Color(0.47, 0.95, 0.91); + break; + case Variant::DICTIONARY: + color = Color(0.47, 0.93, 0.69); + break; + + case Variant::ARRAY: + color = Color(0.88, 0.88, 0.88); + break; + case Variant::PACKED_BYTE_ARRAY: + color = Color(0.67, 0.96, 0.78); + break; + case Variant::PACKED_INT32_ARRAY: + color = Color(0.69, 0.86, 0.96); + break; + case Variant::PACKED_FLOAT32_ARRAY: + color = Color(0.59, 0.91, 0.97); + break; + case Variant::PACKED_INT64_ARRAY: + color = Color(0.69, 0.86, 0.96); + break; + case Variant::PACKED_FLOAT64_ARRAY: + color = Color(0.59, 0.91, 0.97); + break; + case Variant::PACKED_STRING_ARRAY: + color = Color(0.62, 0.77, 0.95); + break; + case Variant::PACKED_VECTOR2_ARRAY: + color = Color(0.82, 0.7, 0.96); + break; + case Variant::PACKED_VECTOR3_ARRAY: + color = Color(0.87, 0.61, 0.95); + break; + case Variant::PACKED_COLOR_ARRAY: + color = Color(0.91, 1.0, 0.59); + break; default: color.set_hsv(p_type / float(Variant::VARIANT_MAX), 0.7, 0.7); } else switch (p_type) { - case Variant::NIL: color = Color(0.15, 0.89, 0.63); break; - - case Variant::BOOL: color = Color(0.43, 0.56, 0.92); break; - case Variant::INT: color = Color(0.31, 0.7, 0.91); break; - case Variant::FLOAT: color = Color(0.15, 0.8, 0.94); break; - case Variant::STRING: color = Color(0.27, 0.56, 0.91); break; - - case Variant::VECTOR2: color = Color(0.68, 0.46, 0.93); break; - case Variant::VECTOR2I: color = Color(0.68, 0.46, 0.93); break; - case Variant::RECT2: color = Color(0.93, 0.46, 0.56); break; - case Variant::RECT2I: color = Color(0.93, 0.46, 0.56); break; - case Variant::VECTOR3: color = Color(0.86, 0.42, 0.93); break; - case Variant::VECTOR3I: color = Color(0.86, 0.42, 0.93); break; - case Variant::TRANSFORM2D: color = Color(0.59, 0.81, 0.1); break; - case Variant::PLANE: color = Color(0.97, 0.44, 0.44); break; - case Variant::QUAT: color = Color(0.93, 0.41, 0.64); break; - case Variant::AABB: color = Color(0.93, 0.47, 0.57); break; - case Variant::BASIS: color = Color(0.7, 0.73, 0.1); break; - case Variant::TRANSFORM: color = Color(0.96, 0.56, 0.28); break; - - case Variant::COLOR: color = Color(0.24, 0.75, 0.0); break; - case Variant::NODE_PATH: color = Color(0.41, 0.58, 0.93); break; - case Variant::_RID: color = Color(0.17, 0.9, 0.45); break; - case Variant::OBJECT: color = Color(0.07, 0.84, 0.76); break; - case Variant::DICTIONARY: color = Color(0.34, 0.91, 0.62); break; - - case Variant::ARRAY: color = Color(0.45, 0.45, 0.45); break; - case Variant::PACKED_BYTE_ARRAY: color = Color(0.38, 0.92, 0.6); break; - case Variant::PACKED_INT32_ARRAY: color = Color(0.38, 0.73, 0.92); break; - case Variant::PACKED_FLOAT32_ARRAY: color = Color(0.25, 0.83, 0.95); break; - case Variant::PACKED_INT64_ARRAY: color = Color(0.38, 0.73, 0.92); break; - case Variant::PACKED_FLOAT64_ARRAY: color = Color(0.25, 0.83, 0.95); break; - case Variant::PACKED_STRING_ARRAY: color = Color(0.38, 0.62, 0.92); break; - case Variant::PACKED_VECTOR2_ARRAY: color = Color(0.62, 0.36, 0.92); break; - case Variant::PACKED_VECTOR3_ARRAY: color = Color(0.79, 0.35, 0.92); break; - case Variant::PACKED_COLOR_ARRAY: color = Color(0.57, 0.73, 0.0); break; + case Variant::NIL: + color = Color(0.15, 0.89, 0.63); + break; + + case Variant::BOOL: + color = Color(0.43, 0.56, 0.92); + break; + case Variant::INT: + color = Color(0.31, 0.7, 0.91); + break; + case Variant::FLOAT: + color = Color(0.15, 0.8, 0.94); + break; + case Variant::STRING: + color = Color(0.27, 0.56, 0.91); + break; + + case Variant::VECTOR2: + color = Color(0.68, 0.46, 0.93); + break; + case Variant::VECTOR2I: + color = Color(0.68, 0.46, 0.93); + break; + case Variant::RECT2: + color = Color(0.93, 0.46, 0.56); + break; + case Variant::RECT2I: + color = Color(0.93, 0.46, 0.56); + break; + case Variant::VECTOR3: + color = Color(0.86, 0.42, 0.93); + break; + case Variant::VECTOR3I: + color = Color(0.86, 0.42, 0.93); + break; + case Variant::TRANSFORM2D: + color = Color(0.59, 0.81, 0.1); + break; + case Variant::PLANE: + color = Color(0.97, 0.44, 0.44); + break; + case Variant::QUAT: + color = Color(0.93, 0.41, 0.64); + break; + case Variant::AABB: + color = Color(0.93, 0.47, 0.57); + break; + case Variant::BASIS: + color = Color(0.7, 0.73, 0.1); + break; + case Variant::TRANSFORM: + color = Color(0.96, 0.56, 0.28); + break; + + case Variant::COLOR: + color = Color(0.24, 0.75, 0.0); + break; + case Variant::NODE_PATH: + color = Color(0.41, 0.58, 0.93); + break; + case Variant::_RID: + color = Color(0.17, 0.9, 0.45); + break; + case Variant::OBJECT: + color = Color(0.07, 0.84, 0.76); + break; + case Variant::DICTIONARY: + color = Color(0.34, 0.91, 0.62); + break; + + case Variant::ARRAY: + color = Color(0.45, 0.45, 0.45); + break; + case Variant::PACKED_BYTE_ARRAY: + color = Color(0.38, 0.92, 0.6); + break; + case Variant::PACKED_INT32_ARRAY: + color = Color(0.38, 0.73, 0.92); + break; + case Variant::PACKED_FLOAT32_ARRAY: + color = Color(0.25, 0.83, 0.95); + break; + case Variant::PACKED_INT64_ARRAY: + color = Color(0.38, 0.73, 0.92); + break; + case Variant::PACKED_FLOAT64_ARRAY: + color = Color(0.25, 0.83, 0.95); + break; + case Variant::PACKED_STRING_ARRAY: + color = Color(0.38, 0.62, 0.92); + break; + case Variant::PACKED_VECTOR2_ARRAY: + color = Color(0.62, 0.36, 0.92); + break; + case Variant::PACKED_VECTOR3_ARRAY: + color = Color(0.79, 0.35, 0.92); + break; + case Variant::PACKED_COLOR_ARRAY: + color = Color(0.57, 0.73, 0.0); + break; default: color.set_hsv(p_type / float(Variant::VARIANT_MAX), 0.3, 0.3); diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index 71ed483d65..616a621845 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -386,11 +386,21 @@ Error VisualScriptExpression::_get_token(Token &r_token) { switch (next) { - case 'b': res = 8; break; - case 't': res = 9; break; - case 'n': res = 10; break; - case 'f': res = 12; break; - case 'r': res = 13; break; + case 'b': + res = 8; + break; + case 't': + res = 9; + break; + case 'n': + res = 10; + break; + case 'f': + res = 12; + break; + case 'r': + res = 13; + break; case 'u': { // hex number for (int j = 0; j < 4; j++) { @@ -1005,27 +1015,69 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { Variant::Operator op = Variant::OP_MAX; switch (tk.type) { - case TK_OP_IN: op = Variant::OP_IN; break; - case TK_OP_EQUAL: op = Variant::OP_EQUAL; break; - case TK_OP_NOT_EQUAL: op = Variant::OP_NOT_EQUAL; break; - case TK_OP_LESS: op = Variant::OP_LESS; break; - case TK_OP_LESS_EQUAL: op = Variant::OP_LESS_EQUAL; break; - case TK_OP_GREATER: op = Variant::OP_GREATER; break; - case TK_OP_GREATER_EQUAL: op = Variant::OP_GREATER_EQUAL; break; - case TK_OP_AND: op = Variant::OP_AND; break; - case TK_OP_OR: op = Variant::OP_OR; break; - case TK_OP_NOT: op = Variant::OP_NOT; break; - case TK_OP_ADD: op = Variant::OP_ADD; break; - case TK_OP_SUB: op = Variant::OP_SUBTRACT; break; - case TK_OP_MUL: op = Variant::OP_MULTIPLY; break; - case TK_OP_DIV: op = Variant::OP_DIVIDE; break; - case TK_OP_MOD: op = Variant::OP_MODULE; break; - case TK_OP_SHIFT_LEFT: op = Variant::OP_SHIFT_LEFT; break; - case TK_OP_SHIFT_RIGHT: op = Variant::OP_SHIFT_RIGHT; break; - case TK_OP_BIT_AND: op = Variant::OP_BIT_AND; break; - case TK_OP_BIT_OR: op = Variant::OP_BIT_OR; break; - case TK_OP_BIT_XOR: op = Variant::OP_BIT_XOR; break; - case TK_OP_BIT_INVERT: op = Variant::OP_BIT_NEGATE; break; + case TK_OP_IN: + op = Variant::OP_IN; + break; + case TK_OP_EQUAL: + op = Variant::OP_EQUAL; + break; + case TK_OP_NOT_EQUAL: + op = Variant::OP_NOT_EQUAL; + break; + case TK_OP_LESS: + op = Variant::OP_LESS; + break; + case TK_OP_LESS_EQUAL: + op = Variant::OP_LESS_EQUAL; + break; + case TK_OP_GREATER: + op = Variant::OP_GREATER; + break; + case TK_OP_GREATER_EQUAL: + op = Variant::OP_GREATER_EQUAL; + break; + case TK_OP_AND: + op = Variant::OP_AND; + break; + case TK_OP_OR: + op = Variant::OP_OR; + break; + case TK_OP_NOT: + op = Variant::OP_NOT; + break; + case TK_OP_ADD: + op = Variant::OP_ADD; + break; + case TK_OP_SUB: + op = Variant::OP_SUBTRACT; + break; + case TK_OP_MUL: + op = Variant::OP_MULTIPLY; + break; + case TK_OP_DIV: + op = Variant::OP_DIVIDE; + break; + case TK_OP_MOD: + op = Variant::OP_MODULE; + break; + case TK_OP_SHIFT_LEFT: + op = Variant::OP_SHIFT_LEFT; + break; + case TK_OP_SHIFT_RIGHT: + op = Variant::OP_SHIFT_RIGHT; + break; + case TK_OP_BIT_AND: + op = Variant::OP_BIT_AND; + break; + case TK_OP_BIT_OR: + op = Variant::OP_BIT_OR; + break; + case TK_OP_BIT_XOR: + op = Variant::OP_BIT_XOR; + break; + case TK_OP_BIT_INVERT: + op = Variant::OP_BIT_NEGATE; + break; default: { }; } @@ -1074,36 +1126,74 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { unary = true; break; - case Variant::OP_MULTIPLY: priority = 2; break; - case Variant::OP_DIVIDE: priority = 2; break; - case Variant::OP_MODULE: priority = 2; break; + case Variant::OP_MULTIPLY: + priority = 2; + break; + case Variant::OP_DIVIDE: + priority = 2; + break; + case Variant::OP_MODULE: + priority = 2; + break; - case Variant::OP_ADD: priority = 3; break; - case Variant::OP_SUBTRACT: priority = 3; break; + case Variant::OP_ADD: + priority = 3; + break; + case Variant::OP_SUBTRACT: + priority = 3; + break; - case Variant::OP_SHIFT_LEFT: priority = 4; break; - case Variant::OP_SHIFT_RIGHT: priority = 4; break; + case Variant::OP_SHIFT_LEFT: + priority = 4; + break; + case Variant::OP_SHIFT_RIGHT: + priority = 4; + break; - case Variant::OP_BIT_AND: priority = 5; break; - case Variant::OP_BIT_XOR: priority = 6; break; - case Variant::OP_BIT_OR: priority = 7; break; + case Variant::OP_BIT_AND: + priority = 5; + break; + case Variant::OP_BIT_XOR: + priority = 6; + break; + case Variant::OP_BIT_OR: + priority = 7; + break; - case Variant::OP_LESS: priority = 8; break; - case Variant::OP_LESS_EQUAL: priority = 8; break; - case Variant::OP_GREATER: priority = 8; break; - case Variant::OP_GREATER_EQUAL: priority = 8; break; + case Variant::OP_LESS: + priority = 8; + break; + case Variant::OP_LESS_EQUAL: + priority = 8; + break; + case Variant::OP_GREATER: + priority = 8; + break; + case Variant::OP_GREATER_EQUAL: + priority = 8; + break; - case Variant::OP_EQUAL: priority = 8; break; - case Variant::OP_NOT_EQUAL: priority = 8; break; + case Variant::OP_EQUAL: + priority = 8; + break; + case Variant::OP_NOT_EQUAL: + priority = 8; + break; - case Variant::OP_IN: priority = 10; break; + case Variant::OP_IN: + priority = 10; + break; case Variant::OP_NOT: priority = 11; unary = true; break; - case Variant::OP_AND: priority = 12; break; - case Variant::OP_OR: priority = 13; break; + case Variant::OP_AND: + priority = 12; + break; + case Variant::OP_OR: + priority = 13; + break; default: { _set_error("Parser bug, invalid operator in expression: " + itos(expression[i].op)); diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index b300aec385..2296745ad0 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -81,10 +81,18 @@ String VisualScriptYield::get_caption() const { String VisualScriptYield::get_text() const { switch (yield_mode) { - case YIELD_RETURN: return ""; break; - case YIELD_FRAME: return "Next Frame"; break; - case YIELD_PHYSICS_FRAME: return "Next Physics Frame"; break; - case YIELD_WAIT: return rtos(wait_time) + " sec(s)"; break; + case YIELD_RETURN: + return ""; + break; + case YIELD_FRAME: + return "Next Frame"; + break; + case YIELD_PHYSICS_FRAME: + return "Next Physics Frame"; + break; + case YIELD_WAIT: + return rtos(wait_time) + " sec(s)"; + break; } return String(); @@ -122,9 +130,15 @@ public: case VisualScriptYield::YIELD_RETURN: ret = STEP_EXIT_FUNCTION_BIT; break; //return the yield - case VisualScriptYield::YIELD_FRAME: state->connect_to_signal(tree, "idle_frame", Array()); break; - case VisualScriptYield::YIELD_PHYSICS_FRAME: state->connect_to_signal(tree, "physics_frame", Array()); break; - case VisualScriptYield::YIELD_WAIT: state->connect_to_signal(tree->create_timer(wait_time).ptr(), "timeout", Array()); break; + case VisualScriptYield::YIELD_FRAME: + state->connect_to_signal(tree, "idle_frame", Array()); + break; + case VisualScriptYield::YIELD_PHYSICS_FRAME: + state->connect_to_signal(tree, "physics_frame", Array()); + break; + case VisualScriptYield::YIELD_WAIT: + state->connect_to_signal(tree->create_timer(wait_time).ptr(), "timeout", Array()); + break; } *p_working_mem = state; |