mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
feat(editor): auto-load objects/NPCs, mode buttons, number key shortcuts
- Loading an ADT now auto-loads objects.json and creatures.json from the output directory if they exist (full session persistence) - Toolbar buttons now highlight active mode in blue (clearer visual) - Number keys 1-5 switch modes: 1=Sculpt 2=Paint 3=Objects 4=Water 5=NPCs - Toast shows loaded object/NPC count on zone open
This commit is contained in:
parent
e18c2cf009
commit
864415d246
2 changed files with 37 additions and 15 deletions
|
|
@ -206,6 +206,14 @@ void EditorApp::processEvents() {
|
|||
auto sc = event.key.keysym.scancode;
|
||||
if (sc == SDL_SCANCODE_F3) setWireframe(!isWireframe());
|
||||
if (sc == SDL_SCANCODE_F5) saveBookmark("");
|
||||
// Number keys switch modes (when not typing in ImGui)
|
||||
if (!io.WantCaptureKeyboard) {
|
||||
if (sc == SDL_SCANCODE_1) setMode(EditorMode::Sculpt);
|
||||
if (sc == SDL_SCANCODE_2) setMode(EditorMode::Paint);
|
||||
if (sc == SDL_SCANCODE_3) setMode(EditorMode::PlaceObject);
|
||||
if (sc == SDL_SCANCODE_4) setMode(EditorMode::Water);
|
||||
if (sc == SDL_SCANCODE_5) setMode(EditorMode::NPC);
|
||||
}
|
||||
// F1 handled by UI (showHelp_ toggle)
|
||||
// Transform shortcuts (Blender-style)
|
||||
if (objectPlacer_.getSelected()) {
|
||||
|
|
@ -542,6 +550,15 @@ void EditorApp::loadADT(const std::string& mapName, int tileX, int tileY) {
|
|||
camera_.setYawPitch(0.0f, -45.0f);
|
||||
|
||||
LOG_INFO("ADT loaded: ", mapName, " [", tileX, ",", tileY, "]");
|
||||
|
||||
// Try loading objects/NPCs from output directory if they exist
|
||||
std::string outBase = "output/" + mapName;
|
||||
if (objectPlacer_.loadFromFile(outBase + "/objects.json"))
|
||||
showToast("Loaded " + std::to_string(objectPlacer_.objectCount()) + " objects");
|
||||
if (npcSpawner_.loadFromFile(outBase + "/creatures.json"))
|
||||
showToast("Loaded " + std::to_string(npcSpawner_.spawnCount()) + " NPCs");
|
||||
if (objectPlacer_.objectCount() > 0 || npcSpawner_.spawnCount() > 0)
|
||||
objectsDirty_ = true;
|
||||
}
|
||||
|
||||
void EditorApp::createNewTerrain(const std::string& mapName, int tileX, int tileY, float baseHeight, Biome biome) {
|
||||
|
|
|
|||
|
|
@ -212,26 +212,31 @@ void EditorUI::renderMenuBar(EditorApp& app) {
|
|||
|
||||
void EditorUI::renderToolbar(EditorApp& app) {
|
||||
ImGui::SetNextWindowPos(ImVec2(300, 30), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(400, 50), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(500, 50), ImGuiCond_FirstUseEver);
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoScrollbar;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 8));
|
||||
if (ImGui::Begin("##Toolbar", nullptr, flags)) {
|
||||
auto mode = app.getMode();
|
||||
if (ImGui::RadioButton("Sculpt", mode == EditorMode::Sculpt))
|
||||
app.setMode(EditorMode::Sculpt);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("Paint", mode == EditorMode::Paint))
|
||||
app.setMode(EditorMode::Paint);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("Objects", mode == EditorMode::PlaceObject))
|
||||
app.setMode(EditorMode::PlaceObject);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("Water", mode == EditorMode::Water))
|
||||
app.setMode(EditorMode::Water);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("NPCs", mode == EditorMode::NPC))
|
||||
app.setMode(EditorMode::NPC);
|
||||
|
||||
auto modeButton = [&](const char* label, EditorMode m) {
|
||||
bool active = (mode == m);
|
||||
if (active) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.3f, 0.6f, 0.9f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 1));
|
||||
}
|
||||
if (ImGui::Button(label, ImVec2(70, 28)))
|
||||
app.setMode(m);
|
||||
if (active)
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::SameLine();
|
||||
};
|
||||
|
||||
modeButton("Sculpt", EditorMode::Sculpt);
|
||||
modeButton("Paint", EditorMode::Paint);
|
||||
modeButton("Objects", EditorMode::PlaceObject);
|
||||
modeButton("Water", EditorMode::Water);
|
||||
modeButton("NPCs", EditorMode::NPC);
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue