diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-09-23 15:27:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-23 15:27:20 +0200 |
commit | 2c7908739a9508cdd725fdd3175477f4d048ea26 (patch) | |
tree | faf33ee70bf2b7ab9d8bce33b3fd5993480330cf /editor | |
parent | 3b510224293dd012278dcf6416835198fa9b67a2 (diff) | |
parent | f483460e389727cd29fdd53e212037934a0bd767 (diff) |
Merge pull request #22351 from DualMatrix/remove_obsolete
Removed obsoleted core/helper/value_evaluator.h and moved math_fieldwise to core/math/
Diffstat (limited to 'editor')
-rw-r--r-- | editor/multi_node_edit.cpp | 2 | ||||
-rw-r--r-- | editor/property_editor.cpp | 57 | ||||
-rw-r--r-- | editor/property_editor.h | 21 |
3 files changed, 1 insertions, 79 deletions
diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index 173be01586..be4e752d55 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -30,7 +30,7 @@ #include "multi_node_edit.h" -#include "core/helper/math_fieldwise.h" +#include "core/math/math_fieldwise.h" #include "editor_node.h" bool MultiNodeEdit::_set(const StringName &p_name, const Variant &p_value) { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 508db2e03f..c611327a31 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -1991,60 +1991,3 @@ CustomPropertyEditor::CustomPropertyEditor() { create_dialog = NULL; property_select = NULL; } - -///////////////////////////// - -double PropertyValueEvaluator::eval(const String &p_text) { - - // If range value contains a comma replace it with dot (issue #6028) - const String &p_new_text = p_text.replace(",", "."); - - if (!obj || !script_language) - return _default_eval(p_new_text); - - Ref<Script> script = Ref<Script>(script_language->create_script()); - script->set_source_code(_build_script(p_new_text)); - Error err = script->reload(); - if (err) { - ERR_PRINTS("PropertyValueEvaluator: Error loading script for expression: " + p_new_text); - return _default_eval(p_new_text); - } - - Object dummy; - ScriptInstance *script_instance = script->instance_create(&dummy); - if (!script_instance) - return _default_eval(p_new_text); - - Variant::CallError call_err; - Variant arg = obj; - const Variant *args[] = { &arg }; - double result = script_instance->call("eval", args, 1, call_err); - if (call_err.error == Variant::CallError::CALL_OK) { - return result; - } - ERR_PRINTS("PropertyValueEvaluator: Eval failed, error code: " + itos(call_err.error)); - - return _default_eval(p_new_text); -} - -void PropertyValueEvaluator::edit(Object *p_obj) { - obj = p_obj; -} - -String PropertyValueEvaluator::_build_script(const String &p_text) { - String script_text = "tool\nextends Object\nfunc eval(s):\n\tself = s\n\treturn " + p_text.strip_edges() + "\n"; - return script_text; -} - -PropertyValueEvaluator::PropertyValueEvaluator() { - script_language = NULL; - - for (int i = 0; i < ScriptServer::get_language_count(); i++) { - if (ScriptServer::get_language(i)->get_name() == "GDScript") { - script_language = ScriptServer::get_language(i); - } - } -} - -PropertyValueEvaluator::~PropertyValueEvaluator() { -} diff --git a/editor/property_editor.h b/editor/property_editor.h index ee3a56d857..c74103df3d 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -171,30 +171,9 @@ public: void set_read_only(bool p_read_only) { read_only = p_read_only; } - void set_value_evaluator(PropertyValueEvaluator *p_evaluator) { evaluator = p_evaluator; } - bool edit(Object *p_owner, const String &p_name, Variant::Type p_type, const Variant &p_variant, int p_hint, String p_hint_text); CustomPropertyEditor(); }; -class PropertyValueEvaluator : public ValueEvaluator { - GDCLASS(PropertyValueEvaluator, ValueEvaluator); - - Object *obj; - ScriptLanguage *script_language; - String _build_script(const String &p_text); - - _FORCE_INLINE_ double _default_eval(const String &p_text) { - return p_text.to_double(); - } - -public: - void edit(Object *p_obj); - double eval(const String &p_text); - - PropertyValueEvaluator(); - ~PropertyValueEvaluator(); -}; - #endif |