Can create and delete lines
This commit is contained in:
@@ -279,7 +279,8 @@ protected:
|
|||||||
->show();
|
->show();
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 22:
|
||||||
/* TODO: delete line */
|
/* delete line */
|
||||||
|
editor->delete_current_line();
|
||||||
break;
|
break;
|
||||||
case 51:
|
case 51:
|
||||||
editor->set_point_to_cursor();
|
editor->set_point_to_cursor();
|
||||||
@@ -322,7 +323,6 @@ protected:
|
|||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
line_name->remove_color_override("font_color");
|
line_name->remove_color_override("font_color");
|
||||||
/* TODO: do what is needed to create line in editor */
|
|
||||||
editor->create_new_line_at_cursor(text);
|
editor->create_new_line_at_cursor(text);
|
||||||
/* clean text */
|
/* clean text */
|
||||||
line_name->set_text("");
|
line_name->set_text("");
|
||||||
@@ -620,6 +620,29 @@ void RoadLinesEditor::update_ui()
|
|||||||
void RoadLinesEditor::create_new_line_at_cursor(const String &line_name)
|
void RoadLinesEditor::create_new_line_at_cursor(const String &line_name)
|
||||||
{
|
{
|
||||||
print_line("creating new line called: " + line_name);
|
print_line("creating new line called: " + line_name);
|
||||||
|
struct road_line rline;
|
||||||
|
rline.flags = 0;
|
||||||
|
rline.indices.resize(0);
|
||||||
|
rline.lanes = -1;
|
||||||
|
if (line_name.ends_with("_road"))
|
||||||
|
rline.lanes = 4;
|
||||||
|
rline.metadata = Dictionary();
|
||||||
|
rline.pattern = 0;
|
||||||
|
Transform cursor_position(Basis(), get_cursor_position());
|
||||||
|
rline.points.push_back(cursor_position);
|
||||||
|
lines[line_name] = rline;
|
||||||
|
update_line_index_ui();
|
||||||
|
update_ui();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoadLinesEditor::delete_current_line()
|
||||||
|
{
|
||||||
|
String delete_line = current_line;
|
||||||
|
const String *k = lines.next(&delete_line);
|
||||||
|
current_line = *k;
|
||||||
|
lines.erase(delete_line);
|
||||||
|
update_line_index_ui();
|
||||||
|
update_ui();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 RoadLinesEditor::get_cursor_position()
|
Vector3 RoadLinesEditor::get_cursor_position()
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public:
|
|||||||
int get_camera_mode() const;
|
int get_camera_mode() const;
|
||||||
void update_ui();
|
void update_ui();
|
||||||
void create_new_line_at_cursor(const String &line_name);
|
void create_new_line_at_cursor(const String &line_name);
|
||||||
|
void delete_current_line();
|
||||||
Vector3 get_cursor_position();
|
Vector3 get_cursor_position();
|
||||||
void set_cursor_position(const Vector3 &cursor_position);
|
void set_cursor_position(const Vector3 &cursor_position);
|
||||||
void set_point_position(const Vector3 &position);
|
void set_point_position(const Vector3 &position);
|
||||||
|
|||||||
Reference in New Issue
Block a user