mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-30 12:59:18 +01:00
Cleaned up PolygonEdit.
This commit is contained in:
parent
8178d526ba
commit
665f8be21f
@ -1,106 +1,73 @@
|
||||
|
||||
#include "polygon_edit.h"
|
||||
|
||||
#include "polygon_dialog.h"
|
||||
#include "polygon_view.h"
|
||||
#include "scene/gui/button.h"
|
||||
|
||||
Variant PolygonEdit::get_Variant() {
|
||||
return Variant;
|
||||
}
|
||||
|
||||
void PolygonEdit::set_Variant(const Variant &val) {
|
||||
Variant = val;
|
||||
}
|
||||
|
||||
#include "../../../nodes/bases/polygon_base.h"
|
||||
|
||||
bool PolygonEdit::get_closed() const {
|
||||
return closed;
|
||||
return closed;
|
||||
}
|
||||
|
||||
void PolygonEdit::set_closed(const bool val) {
|
||||
closed = val;
|
||||
void PolygonEdit::set_closed(const bool c) {
|
||||
closed = c;
|
||||
_polygon_view->set_closed(c);
|
||||
}
|
||||
|
||||
|
||||
Variant PolygonEdit::get_Variant() {
|
||||
return Variant;
|
||||
Ref<PolygonBase> PolygonEdit::get_value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
void PolygonEdit::set_Variant(const Variant &val) {
|
||||
Variant = val;
|
||||
void PolygonEdit::set_value(const Ref<PolygonBase> &v) {
|
||||
value = v;
|
||||
_polygon_view->set_polygon(value);
|
||||
_polygon_view->update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//tool;
|
||||
//var MMPolygon = preload("res://addons/mat_maker_gd/nodes/bases/polygon_base.gd");
|
||||
//export ;
|
||||
// setget set_closed;
|
||||
bool closed = true;
|
||||
// setget set_value;
|
||||
Variant = null;
|
||||
signal updated(polygon);
|
||||
|
||||
void PolygonEdit::set_closed(const bool c) {
|
||||
closed = c;
|
||||
$PolygonView.set_closed(c);
|
||||
void PolygonEdit::_on_PolygonEdit_pressed() {
|
||||
PolygonDialog *dialog = memnew(PolygonDialog);
|
||||
dialog->set_closed(closed);
|
||||
add_child(dialog);
|
||||
dialog->connect("polygon_changed", this, "on_value_changed");
|
||||
dialog->edit_polygon(value);
|
||||
}
|
||||
|
||||
|
||||
void PolygonEdit::set_value(const Variant &v) {
|
||||
value = v;
|
||||
$PolygonView.set_polygon(value);
|
||||
$PolygonView.update();
|
||||
void PolygonEdit::on_value_changed(const Variant &v) {
|
||||
//set_value(v);
|
||||
emit_signal("updated", v);
|
||||
_polygon_view->update();
|
||||
}
|
||||
|
||||
PolygonEdit::PolygonEdit() {
|
||||
closed = true;
|
||||
|
||||
void PolygonEdit::_on_PolygonEdit_pressed() {
|
||||
//var dialog = preload("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_dialog.tscn").instance();
|
||||
dialog.set_closed(closed);
|
||||
add_child(dialog);
|
||||
dialog.connect("polygon_changed", self, "on_value_changed");
|
||||
dialog.edit_polygon(value);
|
||||
set_custom_minimum_size(Vector2(32, 32));
|
||||
set_focus_mode(FOCUS_CLICK);
|
||||
|
||||
_polygon_view = memnew(PolygonView);
|
||||
add_child(_polygon_view);
|
||||
_polygon_view->set_anchors_and_margins_preset(PRESET_WIDE);
|
||||
_polygon_view->set_mouse_filter(MOUSE_FILTER_IGNORE);
|
||||
}
|
||||
|
||||
|
||||
void PolygonEdit::on_value_changed(const Variant &v) {
|
||||
//set_value(v);
|
||||
emit_signal("updated", v);
|
||||
$PolygonView.update();
|
||||
PolygonEdit::~PolygonEdit() {
|
||||
}
|
||||
|
||||
void PolygonEdit::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("updated", PropertyInfo(Variant::OBJECT, "polygon", PROPERTY_HINT_RESOURCE_TYPE, "PolygonBase")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_closed"), &PolygonEdit::get_closed);
|
||||
ClassDB::bind_method(D_METHOD("set_closed", "value"), &PolygonEdit::set_closed);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "closed"), "set_closed", "get_closed");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_value"), &PolygonEdit::get_value);
|
||||
ClassDB::bind_method(D_METHOD("set_value", "value"), &PolygonEdit::set_value);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "PolygonBase"), "set_value", "get_value");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_closed", "c"), &PolygonEdit::set_closed, true);
|
||||
ClassDB::bind_method(D_METHOD("set_value", "v"), &PolygonEdit::set_value);
|
||||
ClassDB::bind_method(D_METHOD("_on_PolygonEdit_pressed"), &PolygonEdit::_on_PolygonEdit_pressed);
|
||||
ClassDB::bind_method(D_METHOD("on_value_changed", "v"), &PolygonEdit::on_value_changed);
|
||||
}
|
||||
|
||||
PolygonEdit::PolygonEdit() {
|
||||
//var MMPolygon = preload("res://addons/mat_maker_gd/nodes/bases/polygon_base.gd");
|
||||
closed = true;
|
||||
= null;
|
||||
}
|
||||
|
||||
PolygonEdit::~PolygonEdit() {
|
||||
}
|
||||
|
||||
|
||||
static void PolygonEdit::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_Variant"), &PolygonEdit::get_Variant);
|
||||
ClassDB::bind_method(D_METHOD("set_Variant", "value"), &PolygonEdit::set_Variant);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_closed"), &PolygonEdit::get_closed);
|
||||
ClassDB::bind_method(D_METHOD("set_closed", "value"), &PolygonEdit::set_closed);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "closed"), "set_closed", "get_closed");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_Variant"), &PolygonEdit::get_Variant);
|
||||
ClassDB::bind_method(D_METHOD("set_Variant", "value"), &PolygonEdit::set_Variant);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_closed", "c"), &PolygonEdit::set_closed, true);
|
||||
ClassDB::bind_method(D_METHOD("set_value", "v"), &PolygonEdit::set_value);
|
||||
ClassDB::bind_method(D_METHOD("_on_PolygonEdit_pressed"), &PolygonEdit::_on_PolygonEdit_pressed);
|
||||
ClassDB::bind_method(D_METHOD("on_value_changed", "v"), &PolygonEdit::on_value_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,78 +0,0 @@
|
||||
|
||||
void construct() {
|
||||
|
||||
//Script: res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.gd
|
||||
Button *polygonedit = memnew(Button);
|
||||
polygonedit->set_name("PolygonEdit");
|
||||
|
||||
polygonedit->set_name("PolygonEdit");
|
||||
//polygonedit->set("name", PolygonEdit));
|
||||
|
||||
polygonedit->set_filename("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn");
|
||||
//polygonedit->set("filename", "res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn");
|
||||
|
||||
polygonedit->set_anchor_left(1);
|
||||
//polygonedit->set("anchor_left", 1);
|
||||
|
||||
polygonedit->set_anchor_right(1);
|
||||
//polygonedit->set("anchor_right", 1);
|
||||
|
||||
polygonedit->set_anchor_bottom(1);
|
||||
//polygonedit->set("anchor_bottom", 1);
|
||||
|
||||
polygonedit->set_margin_left(-1280);
|
||||
//polygonedit->set("margin_left", -1280);
|
||||
|
||||
polygonedit->set_margin_right(-1248);
|
||||
//polygonedit->set("margin_right", -1248);
|
||||
|
||||
polygonedit->set_margin_bottom(-688);
|
||||
//polygonedit->set("margin_bottom", -688);
|
||||
|
||||
polygonedit->set_rect_position(Vector2(-1280, 0));
|
||||
//polygonedit->set("rect_position", Vector2(-1280, 0));
|
||||
|
||||
polygonedit->set_rect_global_position(Vector2(-1280, 0));
|
||||
//polygonedit->set("rect_global_position", Vector2(-1280, 0));
|
||||
|
||||
polygonedit->set_rect_size(Vector2(32, 20));
|
||||
//polygonedit->set("rect_size", Vector2(32, 20));
|
||||
|
||||
polygonedit->set_rect_min_size(Vector2(32, 32));
|
||||
//polygonedit->set("rect_min_size", Vector2(32, 32));
|
||||
|
||||
polygonedit->set_focus_mode(1);
|
||||
//polygonedit->set("focus_mode", 1);
|
||||
|
||||
//polygonedit property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False}
|
||||
|
||||
|
||||
|
||||
//Script: res://addons/mat_maker_gd/widgets/polygon_edit/polygon_view.gd
|
||||
Control *polygonview_polygonedit = memnew(Control);
|
||||
polygonview_polygonedit->set_name("PolygonView");
|
||||
polygonedit->add_child(polygonview_polygonedit);
|
||||
|
||||
polygonview_polygonedit->set_name("PolygonView");
|
||||
//polygonview_polygonedit->set("name", PolygonView));
|
||||
|
||||
polygonview_polygonedit->set_filename("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_view.tscn");
|
||||
//polygonview_polygonedit->set("filename", "res://addons/mat_maker_gd/widgets/polygon_edit/polygon_view.tscn");
|
||||
|
||||
//polygonview_polygonedit property owner TYPE_OBJECT value: PolygonEdit:[Button:42430]
|
||||
|
||||
polygonview_polygonedit->set_anchor_right(1);
|
||||
//polygonview_polygonedit->set("anchor_right", 1);
|
||||
|
||||
polygonview_polygonedit->set_anchor_bottom(1);
|
||||
//polygonview_polygonedit->set("anchor_bottom", 1);
|
||||
|
||||
polygonview_polygonedit->set_mouse_filter(2);
|
||||
//polygonview_polygonedit->set("mouse_filter", 2);
|
||||
|
||||
//polygonview_polygonedit property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,41 +1,36 @@
|
||||
#ifndef POLYGON_EDIT_H
|
||||
#define POLYGON_EDIT_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
#include "scene/gui/control.h"
|
||||
|
||||
class PolygonBase;
|
||||
class PolygonView;
|
||||
|
||||
class PolygonEdit : public Control {
|
||||
GDCLASS(PolygonEdit, Control);
|
||||
GDCLASS(PolygonEdit, Control);
|
||||
|
||||
public:
|
||||
public:
|
||||
bool get_closed() const;
|
||||
void set_closed(const bool c = true);
|
||||
|
||||
Variant get_Variant();
|
||||
void set_Variant(const Variant &val);
|
||||
Ref<PolygonBase> get_value();
|
||||
void set_value(const Ref<PolygonBase> &v);
|
||||
|
||||
bool get_closed() const;
|
||||
void set_closed(const bool val);
|
||||
void _on_PolygonEdit_pressed();
|
||||
void on_value_changed(const Variant &v);
|
||||
|
||||
Variant get_Variant();
|
||||
void set_Variant(const Variant &val);
|
||||
PolygonEdit();
|
||||
~PolygonEdit();
|
||||
|
||||
void set_closed(const bool c = true);
|
||||
void set_value(const Variant &v);
|
||||
void _on_PolygonEdit_pressed();
|
||||
void on_value_changed(const Variant &v);
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
PolygonEdit();
|
||||
~PolygonEdit();
|
||||
bool closed;
|
||||
Ref<PolygonBase> value;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
Variant = preload("res://addons/mat_maker_gd/nodes/bases/polygon_base.gd");
|
||||
//export
|
||||
// setget set_closed
|
||||
bool closed = true;
|
||||
// setget set_value
|
||||
Variant = null;
|
||||
signal updated(polygon);
|
||||
PolygonView *_polygon_view;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user