Add a live interface scale slider and room blueprints

This commit is contained in:
Codex committed 2026-11-29 20:21:04 +03:00
1 parent 2a71ed6242
commit 85547b00b9
12 files changed
+553 -96

No files matched your search

+43
View File
@@ -721,6 +721,48 @@ void test_object_tools_work_in_an_older_demo_world() {
static_cast<void>(save_roundtrip(*world));
}
void test_room_builds_and_saves_as_separate_parts() {
using namespace settlement;
World world(61, 16, 16);
static_cast<void>(world.spawn_agent({3, 3}));
const auto storage = world.add_storage({2, 2}, 32);
world.stock_storage(storage, ItemType::Wood, 32);
auto room = make_room_plan({9, 8}, {6, 5});
room.entrance = RoomSide::East;
const auto place = [&](const RoomPlan& plan) {
return world.apply_command({1, world.next_command_sequence(1), CommandKind::PlaceRoom, plan.first,
static_cast<std::uint8_t>(plan.entrance), plan.last}).status;
};
require(room.recipe_at({9, 6}) == RecipeId::BuildDoorAlongY, "room lost its entrance");
world.set_blocked({10, 6}, true);
require(place(room) == CommandStatus::InvalidTarget && world.production_orders().empty(),
"a room with a blocked entrance was partially scheduled");
world.set_blocked({10, 6}, false);
require(place(room) == CommandStatus::Accepted && world.production_orders().size() == 16,
"room did not queue floor, walls and entrance together");
require(place(room) == CommandStatus::InvalidTarget && world.production_orders().size() == 16,
"duplicate room placement altered its construction orders");
world.step();
require(world.production_orders().front().state == JobState::InProgress, "builders did not start the room");
auto resumed = save_roundtrip(world);
for (int i = 0; i < 850; ++i) resumed->step();
for (const auto& order : resumed->production_orders()) {
require(order.state == JobState::Completed && order.recipe == room.recipe_at(order.position),
"room component did not survive delivery and construction after load");
}
require(resumed->storages().front().item_count(ItemType::Wood) == 15, "room used incorrect materials");
const auto apply = [&](CommandKind command, GridPosition cell) {
return resumed->apply_command({1, resumed->next_command_sequence(1), command, cell}).status;
};
const GridPosition floor{7, 6};
require(apply(CommandKind::PlaceLoom, floor) == CommandStatus::Accepted,
"finished floor could not hold furniture");
require(apply(CommandKind::DemolishObject, floor) == CommandStatus::Accepted &&
resumed->production_orders().size() == 16 && resumed->can_place_storage(floor),
"demolition removed the floor instead of the furniture");
static_cast<void>(save_roundtrip(*resumed));
}
} // namespace
int main() {
@@ -746,6 +788,7 @@ int main() {
test_field_growth_requires_a_worker();
test_opening_a_mine_invalidates_unreachable_routes();
test_object_tools_work_in_an_older_demo_world();
test_room_builds_and_saves_as_separate_parts();
} catch (const std::exception& error) {
std::cerr << "Test failed: " << error.what() << '\n';
return 1;