Graph look + cleanup
This commit is contained in:
@@ -79,10 +79,10 @@ entries=[ {
|
|||||||
}, {
|
}, {
|
||||||
"children": [ ],
|
"children": [ ],
|
||||||
"index": 12,
|
"index": 12,
|
||||||
"name": "wc_0",
|
"name": "bedroom_0",
|
||||||
"room_type": 200,
|
"room_type": 202,
|
||||||
"type": "room",
|
"type": "room",
|
||||||
"window": false
|
"window": true
|
||||||
}, {
|
}, {
|
||||||
"children": [ ],
|
"children": [ ],
|
||||||
"index": 13,
|
"index": 13,
|
||||||
@@ -93,10 +93,10 @@ entries=[ {
|
|||||||
}, {
|
}, {
|
||||||
"children": [ ],
|
"children": [ ],
|
||||||
"index": 14,
|
"index": 14,
|
||||||
"name": "bedroom_0",
|
"name": "wc_0",
|
||||||
"room_type": 202,
|
"room_type": 200,
|
||||||
"type": "room",
|
"type": "room",
|
||||||
"window": true
|
"window": false
|
||||||
}, {
|
}, {
|
||||||
"children": [ ],
|
"children": [ ],
|
||||||
"index": 15,
|
"index": 15,
|
||||||
|
|||||||
@@ -150,9 +150,6 @@ public:
|
|||||||
std::vector<Variant> args_data2 = {
|
std::vector<Variant> args_data2 = {
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
MARGIN_RIGHT, 1.0f, MARGIN_BOTTOM, 1.0f,
|
MARGIN_RIGHT, 1.0f, MARGIN_BOTTOM, 1.0f,
|
||||||
// Control::SIZE_EXPAND_FILL, Control::SIZE_EXPAND_FILL,
|
|
||||||
// MARGIN_RIGHT, 1.0f, MARGIN_BOTTOM, 1.0f,
|
|
||||||
// Control::SIZE_EXPAND_FILL, Control::SIZE_EXPAND_FILL,
|
|
||||||
"Layout Graph",
|
"Layout Graph",
|
||||||
MARGIN_RIGHT, 1.0f, MARGIN_BOTTOM, 1.0f,
|
MARGIN_RIGHT, 1.0f, MARGIN_BOTTOM, 1.0f,
|
||||||
"buildings_layout_graph",
|
"buildings_layout_graph",
|
||||||
@@ -181,6 +178,8 @@ public:
|
|||||||
print_line(String::num(value));
|
print_line(String::num(value));
|
||||||
}
|
}
|
||||||
Vector<Vector2> buttons;
|
Vector<Vector2> buttons;
|
||||||
|
#define DEPTH_MUL 160
|
||||||
|
#define Y_MUL 130
|
||||||
void update_buttons(ColorRect *canvas)
|
void update_buttons(ColorRect *canvas)
|
||||||
{
|
{
|
||||||
assert(current_layout.length() > 0);
|
assert(current_layout.length() > 0);
|
||||||
@@ -207,19 +206,27 @@ public:
|
|||||||
int y = e.get<WorldEditor::components::
|
int y = e.get<WorldEditor::components::
|
||||||
buildings_layout_graph_node>()
|
buildings_layout_graph_node>()
|
||||||
->y_pos;
|
->y_pos;
|
||||||
#if 0
|
|
||||||
e.get_mut<WorldEditor::components::
|
|
||||||
buildings_layout_graph_node>()
|
|
||||||
->y_pos = y;
|
|
||||||
#endif
|
|
||||||
/* make button here */
|
/* make button here */
|
||||||
Vector2 pt(depth * 120 + 40, y * 110 + 40);
|
Vector2 pt(depth * DEPTH_MUL + 40, y * Y_MUL + 40);
|
||||||
|
if (pt.x + 16.0f >= canvas->get_size().x ||
|
||||||
|
pt.y + 16.0f >= canvas->get_size().y) {
|
||||||
|
Vector2 old_size = canvas->get_size();
|
||||||
|
Vector2 new_size(MAX(pt.x + 200.0f, old_size.x),
|
||||||
|
MAX(pt.y + 200.0f,
|
||||||
|
old_size.y));
|
||||||
|
Object::cast_to<Control>(canvas->get_parent())
|
||||||
|
->set_custom_minimum_size(new_size);
|
||||||
|
canvas->set_size(new_size);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
|
VBoxContainer *box = memnew(VBoxContainer);
|
||||||
MenuButton *button = memnew(MenuButton);
|
MenuButton *button = memnew(MenuButton);
|
||||||
button->set_text("");
|
button->set_text("");
|
||||||
canvas->add_child(button);
|
box->add_child(button);
|
||||||
|
canvas->add_child(box);
|
||||||
button->set_size(Vector2(80, 40));
|
button->set_size(Vector2(80, 40));
|
||||||
button->set_position(pt);
|
box->set_position(pt);
|
||||||
|
box->update();
|
||||||
List<Pair<int, String> > menu_options;
|
List<Pair<int, String> > menu_options;
|
||||||
List<Pair<int, String> >::Element *pe;
|
List<Pair<int, String> >::Element *pe;
|
||||||
BuildingLayoutGraph::get_singleton()
|
BuildingLayoutGraph::get_singleton()
|
||||||
@@ -267,16 +274,6 @@ public:
|
|||||||
}
|
}
|
||||||
button->set_text(button->get_text() +
|
button->set_text(button->get_text() +
|
||||||
String(e.name()));
|
String(e.name()));
|
||||||
#if 0
|
|
||||||
button->get_popup()->add_item(
|
|
||||||
"Create block unit", 100);
|
|
||||||
button->get_popup()->add_item(
|
|
||||||
"Create private zone", 101);
|
|
||||||
button->get_popup()->add_item(
|
|
||||||
"Create public zone", 102);
|
|
||||||
button->get_popup()->add_item(
|
|
||||||
"Create hallway", 103);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (e.has<WorldEditor::components::
|
if (e.has<WorldEditor::components::
|
||||||
buildings_layout_room>()) {
|
buildings_layout_room>()) {
|
||||||
@@ -288,12 +285,11 @@ public:
|
|||||||
button->get_text() + "Room\n" +
|
button->get_text() + "Room\n" +
|
||||||
String(e.name() + " " +
|
String(e.name() + " " +
|
||||||
itos(room_type)));
|
itos(room_type)));
|
||||||
PopupMenu *mp = memnew(PopupMenu);
|
|
||||||
std::vector<Variant> args = {
|
std::vector<Variant> args = {
|
||||||
"Room Area: ", "area_value"
|
"Area: ", "area_value"
|
||||||
};
|
};
|
||||||
HashMap<String, Object *> save_data;
|
HashMap<String, Object *> save_data;
|
||||||
ui_field::ui_field_builder(canvas, mp,
|
ui_field::ui_field_builder(canvas, box,
|
||||||
"p{h{lx#$}}",
|
"p{h{lx#$}}",
|
||||||
args.data(),
|
args.data(),
|
||||||
args.size(),
|
args.size(),
|
||||||
@@ -304,65 +300,15 @@ public:
|
|||||||
"room_size_entered",
|
"room_size_entered",
|
||||||
varray(save_data["area_value"],
|
varray(save_data["area_value"],
|
||||||
String(e.path())));
|
String(e.path())));
|
||||||
button->get_popup()->add_child(mp);
|
|
||||||
mp->set_name("subedit");
|
|
||||||
button->get_popup()->add_submenu_item(
|
|
||||||
"SubEdit Moo", "subedit", 400);
|
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
button->set_text(
|
|
||||||
button->get_text() + "size: \n" +
|
|
||||||
itos(e.get<WorldEditor::components::
|
|
||||||
buildings_layout_graph_node>()
|
|
||||||
->size));
|
|
||||||
#endif
|
|
||||||
// button->get_popup()->add_separator();
|
|
||||||
// button->get_popup()->add_item("Delete", 1000);
|
|
||||||
button->get_popup()->connect(
|
button->get_popup()->connect(
|
||||||
"id_pressed", this, "menu_pressed",
|
"id_pressed", this, "menu_pressed",
|
||||||
varray(button, String(e.path())));
|
varray(button, String(e.path())));
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
int count = 0;
|
|
||||||
int offset = y;
|
|
||||||
#endif
|
|
||||||
e.children([&queue](flecs::entity fe) {
|
e.children([&queue](flecs::entity fe) {
|
||||||
#if 0
|
|
||||||
int size =
|
|
||||||
fe.get<WorldEditor::components::
|
|
||||||
buildings_layout_graph_node>()
|
|
||||||
->size;
|
|
||||||
fe.set<WorldEditor::components::
|
|
||||||
buildings_layout_graph_node>(
|
|
||||||
{ depth + 1, offset, size });
|
|
||||||
offset += size;
|
|
||||||
count++;
|
|
||||||
#endif
|
|
||||||
queue.push_back(fe);
|
queue.push_back(fe);
|
||||||
});
|
});
|
||||||
|
|
||||||
// if (count > 1)
|
|
||||||
// height += count - 1;
|
|
||||||
// // height++;
|
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (layout_empty) {
|
|
||||||
MenuButton *button = memnew(MenuButton);
|
|
||||||
button->set_text("Entry");
|
|
||||||
canvas->add_child(button);
|
|
||||||
button->set_size(Vector2(80, 40));
|
|
||||||
button->set_position(Vector2(40, 45));
|
|
||||||
button->get_popup()->add_item("Create block unit", 100);
|
|
||||||
button->get_popup()->add_item("Create private zone",
|
|
||||||
101);
|
|
||||||
button->get_popup()->add_item("Create public zone",
|
|
||||||
102);
|
|
||||||
button->get_popup()->add_item("Create hallway", 103);
|
|
||||||
button->get_popup()->connect("id_pressed", this,
|
|
||||||
"menu_pressed",
|
|
||||||
varray(button));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
void update_graph()
|
void update_graph()
|
||||||
{
|
{
|
||||||
@@ -427,10 +373,21 @@ public:
|
|||||||
int y = button_e.get<WorldEditor::components::
|
int y = button_e.get<WorldEditor::components::
|
||||||
buildings_layout_graph_node>()
|
buildings_layout_graph_node>()
|
||||||
->y_pos;
|
->y_pos;
|
||||||
Vector2 pt(depth * 120 + 40, y * 110 + 40);
|
Vector2 pt(depth * DEPTH_MUL + 40,
|
||||||
|
y * Y_MUL + 40);
|
||||||
|
Vector2 p1x = pt + Vector2(40, 20);
|
||||||
|
Vector2 p2x = pt + Vector2(110, 20);
|
||||||
|
float r = 40.0f;
|
||||||
|
canvas_item->draw_rect(
|
||||||
|
Rect2(p1x - Vector2(0, r),
|
||||||
|
(p2x - p1x) +
|
||||||
|
Vector2(0, r * 2.0)),
|
||||||
|
Color(0.4, 0.4, 0.55, 1.0), true, 4.0f,
|
||||||
|
true);
|
||||||
canvas_item->draw_circle(
|
canvas_item->draw_circle(
|
||||||
pt + Vector2(40, 20), 40.0f,
|
p1x, r, Color(0.4, 0.4, 0.55, 1.0));
|
||||||
Color(0.4, 0.4, 0.55, 1.0));
|
canvas_item->draw_circle(
|
||||||
|
p2x, r, Color(0.4, 0.4, 0.55, 1.0));
|
||||||
p1 = pt + Vector2(40, 20);
|
p1 = pt + Vector2(40, 20);
|
||||||
}
|
}
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
@@ -442,7 +399,8 @@ public:
|
|||||||
int y = e.get<WorldEditor::components::
|
int y = e.get<WorldEditor::components::
|
||||||
buildings_layout_graph_node>()
|
buildings_layout_graph_node>()
|
||||||
->y_pos;
|
->y_pos;
|
||||||
Vector2 p2(depth * 120 + 40, y * 110 + 40);
|
Vector2 p2(depth * DEPTH_MUL + 40,
|
||||||
|
y * Y_MUL + 40);
|
||||||
p2 += Vector2(40, 20);
|
p2 += Vector2(40, 20);
|
||||||
Vector2 p3(p1.x, p2.y);
|
Vector2 p3(p1.x, p2.y);
|
||||||
canvas_item->draw_line(p1, p3,
|
canvas_item->draw_line(p1, p3,
|
||||||
|
|||||||
Reference in New Issue
Block a user