feat(editor): in-editor "Random Populate" menu mirrors CLI

Adds EditorApp::randomPopulateZone(creatureCount, objectCount, seed)
and a Generate-menu submenu with sliders for both counts plus a
seed input. Same logic and bestiary as the --random-populate-zone
CLI: 12 creature templates with level jitter, 5 placeholder WMO
prop types with randomized rotation/scale.

Spawns are placed within the loaded tile's world bbox, marked
dirty + auto-save pending so the populated content persists across
restarts.

The CLI command remains for CI / scripting / batch workflows; the
menu serves designers who want to populate from the GUI without
context-switching to a terminal.

Same-seed reproducibility: a hover hint reminds the user that the
seed determines the output deterministically.
This commit is contained in:
Kelsi 2026-05-07 12:14:13 -07:00
parent bdf2497f46
commit 89dacba666
3 changed files with 98 additions and 0 deletions

View file

@ -379,6 +379,22 @@ void EditorUI::renderMenuBar(EditorApp& app) {
}
if (ImGui::MenuItem("Generate Complete Zone", nullptr, false, app.hasTerrainLoaded()))
app.generateCompleteZone();
if (ImGui::BeginMenu("Random Populate", app.hasTerrainLoaded())) {
static int rpCreatures = 20;
static int rpObjects = 10;
static int rpSeed = 42;
ImGui::SliderInt("Creatures##rp", &rpCreatures, 0, 200);
ImGui::SliderInt("Objects##rp", &rpObjects, 0, 200);
ImGui::InputInt("Seed##rp", &rpSeed);
if (rpSeed < 0) rpSeed = 0;
if (ImGui::Button("Populate##rp", ImVec2(-1, 0))) {
app.randomPopulateZone(rpCreatures, rpObjects,
static_cast<uint32_t>(rpSeed));
}
ImGui::TextColored(ImVec4(0.6f, 0.6f, 0.6f, 1),
"Same seed → same population (reproducible)");
ImGui::EndMenu();
}
if (ImGui::MenuItem("Clear All Objects/NPCs", nullptr, false, app.hasTerrainLoaded())) {
if (app.getObjectPlacer().objectCount() > 0 || app.getNpcSpawner().spawnCount() > 0)
app.clearAllObjects();