Started buildings undo system implementation
This commit is contained in:
@@ -17,6 +17,7 @@ func _ready():
|
||||
$"%select_poi",
|
||||
$"%select_road_lines",
|
||||
$"%select_npc",
|
||||
$"%buildings_save",
|
||||
]:
|
||||
b.connect("pressed", $WorldEditor, "editor_command", [b.name, []])
|
||||
$WorldEditor.connect("editor_event", self, "editor_event")
|
||||
@@ -120,8 +121,9 @@ func check_edit_building():
|
||||
print("get closest building")
|
||||
$WorldEditor.editor_command("get_closest_building", [Transform(Basis(), proj)])
|
||||
elif Input.is_action_pressed("mouse1"):
|
||||
# Moving buildings
|
||||
if $"%buildings_edit_mode".selected == 1:
|
||||
if drag_delay < 0.0:
|
||||
if drag_delay < 0.0 && !dragging:
|
||||
dragging = true
|
||||
var position = get_viewport().get_mouse_position()
|
||||
var camera = get_viewport().get_camera()
|
||||
@@ -132,8 +134,8 @@ func check_edit_building():
|
||||
var result = space_state.intersect_ray(start, end, [], 1 << 15, false, true)
|
||||
if result.has("collider"):
|
||||
var proj = result.position
|
||||
if $"%buildings_edit_mode".selected == 1:
|
||||
drag_start = proj
|
||||
$WorldEditor.editor_command("buildings_checkpoint", [])
|
||||
else:
|
||||
drag_delay -= get_process_delta_time()
|
||||
else:
|
||||
|
||||
@@ -110,7 +110,7 @@ text = "NPC Mode"
|
||||
unique_name_in_owner = true
|
||||
margin_top = 154.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 224.0
|
||||
margin_bottom = 248.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_buildings"]
|
||||
margin_right = 160.0
|
||||
@@ -138,11 +138,18 @@ margin_right = 160.0
|
||||
margin_bottom = 70.0
|
||||
text = "Building Type"
|
||||
|
||||
[node name="buildings_save" type="Button" parent="VBoxContainer/v_buildings"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 74.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 94.0
|
||||
text = "Save Buildings"
|
||||
|
||||
[node name="v_navigation" type="VBoxContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 228.0
|
||||
margin_top = 252.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 250.0
|
||||
margin_bottom = 274.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_navigation"]
|
||||
margin_right = 160.0
|
||||
@@ -156,9 +163,9 @@ text = "Navigation mode"
|
||||
|
||||
[node name="v_poi" type="VBoxContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 254.0
|
||||
margin_top = 278.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 276.0
|
||||
margin_bottom = 300.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_poi"]
|
||||
margin_right = 160.0
|
||||
@@ -172,9 +179,9 @@ text = "POI mode"
|
||||
|
||||
[node name="v_road_lines" type="VBoxContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 280.0
|
||||
margin_top = 304.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 302.0
|
||||
margin_bottom = 326.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_road_lines"]
|
||||
margin_right = 160.0
|
||||
@@ -188,9 +195,9 @@ text = "Road Lines mode"
|
||||
|
||||
[node name="v_npc" type="VBoxContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 306.0
|
||||
margin_top = 330.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 328.0
|
||||
margin_bottom = 352.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_npc"]
|
||||
margin_right = 160.0
|
||||
|
||||
@@ -337,6 +337,12 @@ void StreamWorld::run_command(const String &command, const Array &args)
|
||||
bnode->set_global_transform(args[1]);
|
||||
VariantWriter::write_to_string(buildings[id].xform, key);
|
||||
buildings[id].key = key;
|
||||
} else if (command == "buildings_checkpoint") {
|
||||
/* TODO */
|
||||
} else if (command == "buildings_undo") {
|
||||
/* TODO */
|
||||
} else if (command == "buildings_save") {
|
||||
/* TODO */
|
||||
} else
|
||||
print_error("No command " + command);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,18 @@ void WorldEditor::editor_command(const String &command, const Array &args)
|
||||
if (stream_world) {
|
||||
stream_world->run_command(command, args);
|
||||
}
|
||||
} else if (command == "buildings_checkpoint") {
|
||||
if (stream_world) {
|
||||
stream_world->run_command(command, args);
|
||||
}
|
||||
} else if (command == "buildings_undo") {
|
||||
if (stream_world) {
|
||||
stream_world->run_command(command, args);
|
||||
}
|
||||
} else if (command == "buildings_save") {
|
||||
if (stream_world) {
|
||||
stream_world->run_command(command, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user