Add reproduction safety trial and resizable cellular panels

This commit is contained in:
dingo
2026-10-27 09:13:28 -04:00
parent 7ca5f74f03
commit 5416590f9e
26 changed files with 805 additions and 52 deletions
+42 -1
View File
@@ -677,6 +677,44 @@ void cellular_panels(const std::filesystem::path& review) {
CHECK(vitals->Pos.x == anchored.x && vitals->Pos.y == anchored.y);
drag("Field notes", form.notes_placement, 30, 10);
drag("Nearby", form.map_placement, -35, 20);
const auto resize_edge = [&](const char* name, HudPanelPlacement& placement, int edge,
float delta) {
auto* panel = ImGui::FindWindowByName(name);
CHECK(panel);
const auto before = panel->Size;
ImVec2 start{panel->Pos.x + panel->Size.x / 2, panel->Pos.y + panel->Size.y / 2};
if (edge == 0 || edge == 2)
start.x = panel->Pos.x + (edge == 0 ? panel->Size.x + 1 : -1);
else
start.y = panel->Pos.y + (edge == 1 ? panel->Size.y + 1 : -1);
const ImVec2 end{start.x + (edge % 2 == 0 ? delta : 0),
start.y + (edge % 2 != 0 ? delta : 0)};
mouse(id, SDL_EVENT_MOUSE_MOTION, start.x, start.y);
for (int i = 0; i < 4; ++i)
draw();
mouse(id, SDL_EVENT_MOUSE_BUTTON_DOWN, start.x, start.y);
draw();
CHECK(!app->take_navigation().click);
mouse(id, SDL_EVENT_MOUSE_MOTION, end.x, end.y);
draw();
mouse(id, SDL_EVENT_MOUSE_BUTTON_UP, end.x, end.y);
for (int i = 0; i < 4; ++i)
draw();
CHECK(placement.size && placement.anchor && fits(panel));
CHECK(edge % 2 == 0 ? panel->Size.x != before.x : panel->Size.y != before.y);
CHECK(!app->take_navigation().click);
const auto retained = panel->Size;
toggle(name, edge == 0 && std::string{name} == "Vitals" ? form.vitals_minimized
: std::string{name} == "Field notes" ? form.notes_minimized
: form.map_minimized);
CHECK(panel->Size.x == retained.x && panel->Size.y == retained.y);
CHECK(panel->DC.ChildWindows[0]->ScrollMax.x == 0);
};
drag("Vitals", form.vitals_placement, 0, 30);
resize_edge("Vitals", form.vitals_placement, 0, 35);
resize_edge("Field notes", form.notes_placement, 1, 25);
resize_edge("Nearby", form.map_placement, 2, -25);
resize_edge("Nearby", form.map_placement, 3, -20);
if (!review.empty()) {
mouse(id, SDL_EVENT_MOUSE_MOTION, 5, 5);
draw();
@@ -706,9 +744,12 @@ void cellular_panels(const std::filesystem::path& review) {
mouse(id, SDL_EVENT_MOUSE_BUTTON_UP, reset_at.x, reset_at.y);
draw();
}
CHECK(!form.map_placement.anchor && !app->take_navigation().click);
CHECK(!form.map_placement.anchor && !form.map_placement.size &&
!app->take_navigation().click);
form.vitals_placement.anchor.reset();
form.notes_placement.anchor.reset();
form.vitals_placement.size.reset();
form.notes_placement.size.reset();
for (int i = 0; i < 3; ++i)
draw();
}