Worked on buildings in lines
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "from_string.h"
|
||||
#include "road_lines_data.h"
|
||||
#include "road_processing.h"
|
||||
#include "buildings_data.h"
|
||||
#include "road_lines_editor.h"
|
||||
|
||||
static ImmediateGeometry *line_im = nullptr;
|
||||
@@ -241,6 +242,8 @@ public:
|
||||
"%road_lines_metadata_update");
|
||||
TextEdit *metadata_edit = editor->get_as_node<TextEdit>(
|
||||
"%road_lines_metadata_edit");
|
||||
Button *line_buildings_close =
|
||||
editor->get_as_node<Button>("%line_buildings_close");
|
||||
cancel_button->connect("pressed", this, "cancel_handler");
|
||||
line_name->connect("text_entered", this, "entered_handler");
|
||||
line_name->connect("text_changed", this, "changed_handler");
|
||||
@@ -250,10 +253,14 @@ public:
|
||||
"update_metadata_handler");
|
||||
metadata_edit->connect("text_changed", this,
|
||||
"metadata_changed_handler");
|
||||
line_buildings_close->connect("pressed", this,
|
||||
"line_buildings_close_handler");
|
||||
}
|
||||
virtual ~HandleCreateNewLine()
|
||||
{
|
||||
int i;
|
||||
Button *line_buildings_close =
|
||||
editor->get_as_node<Button>("%line_buildings_close");
|
||||
TextEdit *metadata_edit = editor->get_as_node<TextEdit>(
|
||||
"%road_lines_metadata_edit");
|
||||
Button *update_metadata_button = editor->get_as_node<Button>(
|
||||
@@ -264,6 +271,8 @@ public:
|
||||
"%road_lines_create_new_cancel");
|
||||
LineEdit *line_name = editor->get_as_node<LineEdit>(
|
||||
"%road_lines_create_new_line_name");
|
||||
line_buildings_close->disconnect(
|
||||
"pressed", this, "line_buildings_close_handler");
|
||||
metadata_edit->disconnect("text_changed", this,
|
||||
"metadata_changed_handler");
|
||||
update_metadata_button->disconnect("pressed", this,
|
||||
@@ -296,6 +305,25 @@ protected:
|
||||
String text = editor->get_current_line_metadata();
|
||||
metadata_edit->set_text(text);
|
||||
}
|
||||
void update_line_buildings_editor()
|
||||
{
|
||||
int i;
|
||||
if (current_line == "")
|
||||
return;
|
||||
ItemList *items =
|
||||
editor->get_as_node<ItemList>("%line_buildings_list");
|
||||
items->clear();
|
||||
for (i = 0; i < (int)RoadLinesData::get_singleton()
|
||||
->lines[current_line]
|
||||
.buildings.size();
|
||||
i++) {
|
||||
const String &key = RoadLinesData::get_singleton()
|
||||
->lines[current_line]
|
||||
.buildings[i]
|
||||
.building_key;
|
||||
items->add_item(key);
|
||||
}
|
||||
}
|
||||
void main_handler(int id)
|
||||
{
|
||||
switch (id) {
|
||||
@@ -340,12 +368,25 @@ protected:
|
||||
case 33:
|
||||
editor->remove_road_meshes();
|
||||
break;
|
||||
case 34: {
|
||||
RoadLinesData::get_singleton()->assign_close_buildings(
|
||||
current_line);
|
||||
editor->update_line_geometry();
|
||||
} break;
|
||||
case 36:
|
||||
editor->get_as_node<Control>("%road_lines_base")->hide();
|
||||
editor->get_as_node<Control>("%road_lines_buildings")
|
||||
->show();
|
||||
update_line_buildings_editor();
|
||||
break;
|
||||
case 51:
|
||||
editor->set_point_to_cursor();
|
||||
break;
|
||||
case 52:
|
||||
editor->move_cursor_to_point();
|
||||
break;
|
||||
case 53:
|
||||
editor->move_cursor_to_closest_building();
|
||||
case 101:
|
||||
editor->save_data();
|
||||
break;
|
||||
@@ -403,6 +444,7 @@ protected:
|
||||
} break;
|
||||
default:
|
||||
print_line("menu option pressed: " + itos(id));
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
void cancel_handler()
|
||||
@@ -496,6 +538,19 @@ protected:
|
||||
} else
|
||||
metadata_text->remove_color_override("font_color");
|
||||
}
|
||||
void line_buildings_close_handler()
|
||||
{
|
||||
editor->get_as_node<Control>("%road_lines_base")->show();
|
||||
editor->get_as_node<Control>("%road_lines_buildings")->hide();
|
||||
}
|
||||
void line_buildings_assign_handler()
|
||||
{
|
||||
update_line_buildings_editor();
|
||||
}
|
||||
void line_buildings_remove_handler()
|
||||
{
|
||||
update_line_buildings_editor();
|
||||
}
|
||||
static void _bind_methods()
|
||||
{
|
||||
ClassDB::bind_method(D_METHOD("main_handler", "id"),
|
||||
@@ -515,6 +570,15 @@ protected:
|
||||
ClassDB::bind_method(
|
||||
D_METHOD("metadata_changed_handler"),
|
||||
&HandleCreateNewLine::metadata_changed_handler);
|
||||
ClassDB::bind_method(
|
||||
D_METHOD("line_buildings_close_handler"),
|
||||
&HandleCreateNewLine::line_buildings_close_handler);
|
||||
ClassDB::bind_method(
|
||||
D_METHOD("line_buildings_assign_handler"),
|
||||
&HandleCreateNewLine::line_buildings_assign_handler);
|
||||
ClassDB::bind_method(
|
||||
D_METHOD("line_buildings_remove_handler"),
|
||||
&HandleCreateNewLine::line_buildings_remove_handler);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -593,6 +657,25 @@ void RoadLinesEditor::update_line_geometry()
|
||||
}
|
||||
line_im->end();
|
||||
}
|
||||
if (rld->lines[current_line].buildings.size() > 1) {
|
||||
line_im->begin(Mesh::PRIMITIVE_LINES);
|
||||
for (i = 0;
|
||||
i < (int)rld->lines[current_line].buildings.size();
|
||||
i++) {
|
||||
const RoadLinesData::line_building_data &b =
|
||||
rld->lines[current_line].buildings[i];
|
||||
Vector3 pt = rld->get_point_by_offsets(
|
||||
current_line, b.line_offset,
|
||||
b.normal_offset);
|
||||
line_im->set_color(
|
||||
Color(0.1f, 0.8f, 0.8f, 1.0f));
|
||||
line_im->add_vertex(pt +
|
||||
Vector3(0.0f, 5.0f, 0.0f));
|
||||
line_im->add_vertex(pt +
|
||||
Vector3(0.0f, 15.0f, 0.0f));
|
||||
}
|
||||
line_im->end();
|
||||
}
|
||||
}
|
||||
}
|
||||
void RoadLinesEditor::update_line_index_ui()
|
||||
@@ -705,6 +788,20 @@ void RoadLinesEditor::move_cursor_to_point()
|
||||
set_ui_cursor_position(xform.origin);
|
||||
}
|
||||
|
||||
void RoadLinesEditor::move_cursor_to_closest_building()
|
||||
{
|
||||
print_line("move_cursor_to_closest_building");
|
||||
Vector3 pt = get_cursor_position();
|
||||
int index = BuildingsData::get_singleton()->get_closest_building(
|
||||
Transform(Basis(), pt));
|
||||
const Transform &xform =
|
||||
BuildingsData::get_singleton()->buildings[index].xform;
|
||||
set_cursor_position(xform.origin);
|
||||
Spatial *cursor = get_as_node<Spatial>(cursor_name);
|
||||
if (!cursor->is_visible())
|
||||
cursor->show();
|
||||
}
|
||||
|
||||
void RoadLinesEditor::update(float delta)
|
||||
{
|
||||
if (!active)
|
||||
@@ -794,6 +891,7 @@ void RoadLinesEditor::update_ui()
|
||||
get_as_node<Control>("%road_lines_base")->show();
|
||||
get_as_node<Control>("%road_lines_create_new_line_dlg")->hide();
|
||||
get_as_node<Control>("%road_lines_edit_metadata_dlg")->hide();
|
||||
get_as_node<Control>("%road_lines_buildings")->hide();
|
||||
ItemList *lines_list = get_as_node<ItemList>("%lines_list");
|
||||
List<String> line_keys;
|
||||
rld->lines.get_key_list(&line_keys);
|
||||
|
||||
Reference in New Issue
Block a user