Proper display of building types
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -38,17 +38,30 @@ func editor_event(evname: String, args: Array):
|
|||||||
var mode_next = args[1]
|
var mode_next = args[1]
|
||||||
if vmode.has(mode_next):
|
if vmode.has(mode_next):
|
||||||
vmode[mode_next].show()
|
vmode[mode_next].show()
|
||||||
|
if mode_next == 2:
|
||||||
|
$WorldEditor.editor_command("get_building_types", [])
|
||||||
elif evname == "result:get_closest_building":
|
elif evname == "result:get_closest_building":
|
||||||
print(evname, args)
|
print(evname, args)
|
||||||
select_building(args[0], args[3])
|
select_building(args[0], args[3], args[4])
|
||||||
|
elif evname == "result:get_building_types":
|
||||||
|
print(evname, args)
|
||||||
|
var btypes = args[0]
|
||||||
|
$"%building_type".clear()
|
||||||
|
for k in btypes.keys():
|
||||||
|
$"%building_type".add_item(k)
|
||||||
else:
|
else:
|
||||||
breakpoint
|
breakpoint
|
||||||
var selected_building
|
var selected_building
|
||||||
var selected_building_xform
|
var selected_building_xform
|
||||||
func select_building(xform, id):
|
func select_building(xform, id, mid):
|
||||||
selected_building = id
|
selected_building = id
|
||||||
selected_building_xform = xform
|
selected_building_xform = xform
|
||||||
print("selected id: ", id)
|
print("selected id: ", id)
|
||||||
|
for h in range($"%building_type".get_item_count()):
|
||||||
|
var item = $"%building_type".get_item_text(h)
|
||||||
|
if item == mid:
|
||||||
|
$"%building_type".select(h)
|
||||||
|
break
|
||||||
if !$building_cursor.visible:
|
if !$building_cursor.visible:
|
||||||
$building_cursor.show()
|
$building_cursor.show()
|
||||||
$building_cursor.global_transform.origin = xform.origin
|
$building_cursor.global_transform.origin = xform.origin
|
||||||
|
|||||||
@@ -36,13 +36,6 @@ void StreamWorld::read_buildings_json(const String &buildings_path)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
building::from_dict(&b, json[key], key);
|
building::from_dict(&b, json[key], key);
|
||||||
#if 0
|
|
||||||
b.key = key;
|
|
||||||
b.id = json[key].get("id");
|
|
||||||
String aabb_s = json[key].get("aabb");
|
|
||||||
b.xform = from_string<Transform>(key);
|
|
||||||
b.aabb = from_string<AABB>(aabb_s);
|
|
||||||
#endif
|
|
||||||
buildings.push_back(b);
|
buildings.push_back(b);
|
||||||
e = e->next();
|
e = e->next();
|
||||||
}
|
}
|
||||||
@@ -67,7 +60,7 @@ void StreamWorld::save_buildings_json(const String &buildings_path)
|
|||||||
int i;
|
int i;
|
||||||
String buildings_json = FileAccess::get_file_as_string(buildings_path);
|
String buildings_json = FileAccess::get_file_as_string(buildings_path);
|
||||||
String backup_path = buildings_path + ".bak";
|
String backup_path = buildings_path + ".bak";
|
||||||
String store_path = buildings_path + ".new";
|
String store_path = buildings_path;
|
||||||
FileAccess *fa = FileAccess::open(backup_path, FileAccess::WRITE);
|
FileAccess *fa = FileAccess::open(backup_path, FileAccess::WRITE);
|
||||||
fa->store_string(buildings_json);
|
fa->store_string(buildings_json);
|
||||||
fa->close();
|
fa->close();
|
||||||
@@ -410,11 +403,12 @@ void StreamWorld::run_command(const String &command, const Array &args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Array ret_data;
|
Array ret_data;
|
||||||
ret_data.resize(4);
|
ret_data.resize(5);
|
||||||
ret_data[0] = ret;
|
ret_data[0] = ret;
|
||||||
ret_data[1] = dst;
|
ret_data[1] = dst;
|
||||||
ret_data[2] = rkey;
|
ret_data[2] = rkey;
|
||||||
ret_data[3] = id;
|
ret_data[3] = id;
|
||||||
|
ret_data[4] = buildings[id].id;
|
||||||
emit_signal("command_result", command, ret_data);
|
emit_signal("command_result", command, ret_data);
|
||||||
} else if (command == "get_building_id_for_key") {
|
} else if (command == "get_building_id_for_key") {
|
||||||
if (args.size() == 0) {
|
if (args.size() == 0) {
|
||||||
@@ -454,6 +448,12 @@ void StreamWorld::run_command(const String &command, const Array &args)
|
|||||||
String buildings_path =
|
String buildings_path =
|
||||||
config.get_value("buildings", "buildings_path");
|
config.get_value("buildings", "buildings_path");
|
||||||
save_buildings_json(buildings_path);
|
save_buildings_json(buildings_path);
|
||||||
|
} else if (command == "get_building_types") {
|
||||||
|
Dictionary buildings_data =
|
||||||
|
config.get_value("buildings", "building_data");
|
||||||
|
Array ret_data;
|
||||||
|
ret_data.push_back(buildings_data);
|
||||||
|
emit_signal("command_result", command, ret_data);
|
||||||
} else
|
} else
|
||||||
print_error("No command " + command);
|
print_error("No command " + command);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,10 @@ void WorldEditor::editor_command(const String &command, const Array &args)
|
|||||||
if (stream_world) {
|
if (stream_world) {
|
||||||
stream_world->run_command(command, args);
|
stream_world->run_command(command, args);
|
||||||
}
|
}
|
||||||
|
} else if (command == "get_building_types") {
|
||||||
|
if (stream_world) {
|
||||||
|
stream_world->run_command(command, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user