Merge pull request #22351 from DualMatrix/remove_obsolete

Removed obsoleted core/helper/value_evaluator.h and moved math_fieldwise to core/math/
This commit is contained in:
Rémi Verschelde 2018-09-23 15:27:20 +02:00 committed by GitHub
commit 2c7908739a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 8 additions and 170 deletions

View file

@ -1,7 +0,0 @@
#!/usr/bin/env python
Import('env')
env.add_source_files(env.core_sources, "*.cpp")
Export('env')

View file

@ -1,46 +0,0 @@
/*************************************************************************/
/* value_evaluator.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VALUE_EVALUATOR_H
#define VALUE_EVALUATOR_H
#include "core/object.h"
class ValueEvaluator : public Object {
GDCLASS(ValueEvaluator, Object);
public:
virtual double eval(const String &p_text) {
return p_text.to_double();
}
};
#endif // VALUE_EVALUATOR_H

View file

@ -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) {

View file

@ -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() {
}

View file

@ -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

View file

@ -159,7 +159,7 @@ void TreeItem::set_text(int p_column, String p_text) {
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].text = p_text;
if (cells[p_column].mode == TreeItem::CELL_MODE_RANGE || cells[p_column].mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
if (cells[p_column].mode == TreeItem::CELL_MODE_RANGE) {
Vector<String> strings = p_text.split(",");
cells.write[p_column].min = INT_MAX;
@ -791,7 +791,6 @@ void TreeItem::_bind_methods() {
BIND_ENUM_CONSTANT(CELL_MODE_STRING);
BIND_ENUM_CONSTANT(CELL_MODE_CHECK);
BIND_ENUM_CONSTANT(CELL_MODE_RANGE);
BIND_ENUM_CONSTANT(CELL_MODE_RANGE_EXPRESSION);
BIND_ENUM_CONSTANT(CELL_MODE_ICON);
BIND_ENUM_CONSTANT(CELL_MODE_CUSTOM);
@ -1245,9 +1244,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
//font->draw( ci, text_pos, p_item->cells[i].text, col,item_rect.size.x-check_w );
} break;
case TreeItem::CELL_MODE_RANGE:
case TreeItem::CELL_MODE_RANGE_EXPRESSION: {
case TreeItem::CELL_MODE_RANGE: {
if (p_item->cells[i].text != "") {
if (!p_item->cells[i].editable)
@ -1821,9 +1818,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
//p_item->edited_signal.call(col);
} break;
case TreeItem::CELL_MODE_RANGE:
case TreeItem::CELL_MODE_RANGE_EXPRESSION: {
case TreeItem::CELL_MODE_RANGE: {
if (c.text != "") {
//if (x >= (get_column_width(col)-item_h/2)) {
@ -2010,21 +2005,6 @@ void Tree::text_editor_enter(String p_text) {
//popup_edited_item->edited_signal.call( popup_edited_item_col );
} break;
case TreeItem::CELL_MODE_RANGE_EXPRESSION: {
if (evaluator)
c.val = evaluator->eval(p_text);
else
c.val = p_text.to_double();
if (c.step > 0)
c.val = Math::stepify(c.val, c.step);
if (c.val < c.min)
c.val = c.min;
else if (c.val > c.max)
c.val = c.max;
} break;
default: { ERR_FAIL(); }
}
@ -2453,7 +2433,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
update();
}
if (pressing_for_editor && popup_edited_item && (popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE || popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE_EXPRESSION)) {
if (pressing_for_editor && popup_edited_item && (popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE)) {
//range drag
if (!range_drag_enabled) {
@ -2697,7 +2677,7 @@ bool Tree::edit_selected() {
item_edited(col, s);
return true;
} else if ((c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) && c.text != "") {
} else if (c.mode == TreeItem::CELL_MODE_RANGE && c.text != "") {
popup_menu->clear();
for (int i = 0; i < c.text.get_slice_count(","); i++) {
@ -2713,7 +2693,7 @@ bool Tree::edit_selected() {
popup_edited_item_col = col;
return true;
} else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
} else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE) {
Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
Point2i textedpos = get_global_position() + rect.position - ofs;
@ -2723,7 +2703,7 @@ bool Tree::edit_selected() {
text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::step_decimals(c.step)));
text_editor->select_all();
if (c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
if (c.mode == TreeItem::CELL_MODE_RANGE) {
value_editor->set_position(textedpos + Point2i(0, text_editor->get_size().height));
value_editor->set_size(Size2(rect.size.width, 1));
@ -3713,10 +3693,6 @@ bool Tree::is_folding_hidden() const {
return hide_folding;
}
void Tree::set_value_evaluator(ValueEvaluator *p_evaluator) {
evaluator = p_evaluator;
}
void Tree::set_drop_mode_flags(int p_flags) {
if (drop_mode_flags == p_flags)
return;
@ -3934,8 +3910,6 @@ Tree::Tree() {
hide_folding = false;
evaluator = NULL;
drop_mode_flags = 0;
drop_mode_over = NULL;
drop_mode_section = 0;

View file

@ -31,7 +31,6 @@
#ifndef TREE_H
#define TREE_H
#include "core/helper/value_evaluator.h"
#include "scene/gui/control.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/popup_menu.h"
@ -504,8 +503,6 @@ private:
bool hide_folding;
ValueEvaluator *evaluator;
int _count_selected_items(TreeItem *p_from) const;
void _go_left();
void _go_right();
@ -601,8 +598,6 @@ public:
void set_allow_reselect(bool p_allow);
bool get_allow_reselect() const;
void set_value_evaluator(ValueEvaluator *p_evaluator);
Tree();
~Tree();
};