Removing generated stuff via prefixes
This commit is contained in:
@@ -324,6 +324,9 @@ protected:
|
|||||||
->show();
|
->show();
|
||||||
update_metadata_editor();
|
update_metadata_editor();
|
||||||
break;
|
break;
|
||||||
|
case 30:
|
||||||
|
editor->remove_generated_stuff();
|
||||||
|
break;
|
||||||
case 51:
|
case 51:
|
||||||
editor->set_point_to_cursor();
|
editor->set_point_to_cursor();
|
||||||
break;
|
break;
|
||||||
@@ -988,6 +991,11 @@ String RoadLinesEditor::get_current_line_metadata() const
|
|||||||
assert(lines.has(current_line));
|
assert(lines.has(current_line));
|
||||||
return JSON::print(lines[current_line].metadata, "\t", true);
|
return JSON::print(lines[current_line].metadata, "\t", true);
|
||||||
}
|
}
|
||||||
|
void RoadLinesEditor::remove_generated_stuff()
|
||||||
|
{
|
||||||
|
Array args;
|
||||||
|
editor->editor_command("remove_generated_stuff", args);
|
||||||
|
}
|
||||||
template <class T> T *RoadLinesEditor::get_as_node(const String &path)
|
template <class T> T *RoadLinesEditor::get_as_node(const String &path)
|
||||||
{
|
{
|
||||||
Node *node = scene()->get_node(NodePath(path));
|
Node *node = scene()->get_node(NodePath(path));
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
void save_data();
|
void save_data();
|
||||||
void update_current_line_metadata(const String &text);
|
void update_current_line_metadata(const String &text);
|
||||||
String get_current_line_metadata() const;
|
String get_current_line_metadata() const;
|
||||||
|
void remove_generated_stuff();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void activate();
|
void activate();
|
||||||
|
|||||||
@@ -385,6 +385,27 @@ void StreamWorld::remove_generated_stuff()
|
|||||||
ERR_FAIL_COND_MSG(result != OK, "Failed to load config");
|
ERR_FAIL_COND_MSG(result != OK, "Failed to load config");
|
||||||
Array gen_prefixes = config.get_value("lines", "gen_prefixes");
|
Array gen_prefixes = config.get_value("lines", "gen_prefixes");
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
|
std::vector<int> erased_indices;
|
||||||
|
erased_indices.reserve(buildings.size());
|
||||||
|
int i, j;
|
||||||
|
for (i = 0; i < (int)buildings.size(); i++) {
|
||||||
|
for (j = 0; j < (int)gen_prefixes.size(); j++) {
|
||||||
|
String prefix = gen_prefixes[j];
|
||||||
|
if (buildings[i].id.begins_with(prefix)) {
|
||||||
|
erased_indices.push_back(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = erased_indices.size() - 1; i >= 0; i--) {
|
||||||
|
int index = erased_indices[i];
|
||||||
|
unload_building(index);
|
||||||
|
buildings.erase(buildings.begin() + index);
|
||||||
|
for (j = index; j < (int)buildings.size(); j++)
|
||||||
|
item_nodes[j] = item_nodes[j + 1];
|
||||||
|
item_nodes.erase(buildings.size());
|
||||||
|
}
|
||||||
|
update_items();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamWorld::remove_building(int index)
|
void StreamWorld::remove_building(int index)
|
||||||
|
|||||||
@@ -239,6 +239,8 @@ void WorldEditor::editor_command(const String &command, const Array &args)
|
|||||||
}
|
}
|
||||||
} else if (command == "select_building") {
|
} else if (command == "select_building") {
|
||||||
select_building(args[0], args[1], args[2]);
|
select_building(args[0], args[1], args[2]);
|
||||||
|
} else if (command == "remove_generated_stuff") {
|
||||||
|
stream_world->run_command(command, args);
|
||||||
} else if (road_lines_editor) {
|
} else if (road_lines_editor) {
|
||||||
road_lines_editor->editor_command(command, args);
|
road_lines_editor->editor_command(command, args);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user