diff options
Diffstat (limited to 'src/port/ui/Tools.cpp')
| -rw-r--r-- | src/port/ui/Tools.cpp | 220 |
1 files changed, 109 insertions, 111 deletions
diff --git a/src/port/ui/Tools.cpp b/src/port/ui/Tools.cpp index 9bfdda26b..a41710681 100644 --- a/src/port/ui/Tools.cpp +++ b/src/port/ui/Tools.cpp @@ -20,141 +20,139 @@ extern "C" { namespace Editor { - ToolsWindow::~ToolsWindow() { - SPDLOG_TRACE("destruct tools window"); - } +ToolsWindow::~ToolsWindow() { + SPDLOG_TRACE("destruct tools window"); +} + +void ToolsWindow::InitElement() { +} + +void ToolsWindow::DrawElement() { + static bool toggleGroundSnap = CVarGetInteger("gEditorSnapToGround", 0); + static bool toggleBoundary = CVarGetInteger("gEditorBoundary", 0); + static int selectedTool = 0; // 0: Move, 1: Rotate, 2: Scale - void ToolsWindow::InitElement() { - + // Save button + if (ImGui::Button(ICON_FA_FLOPPY_O, ImVec2(50, 25))) { + SaveLevel(); } - void ToolsWindow::DrawElement() { - static bool toggleGroundSnap = CVarGetInteger("gEditorSnapToGround", 0); - static bool toggleBoundary = CVarGetInteger("gEditorBoundary", 0); - static int selectedTool = 0; // 0: Move, 1: Rotate, 2: Scale + ImGui::SameLine(); - // Save button - if (ImGui::Button(ICON_FA_FLOPPY_O, ImVec2(50, 25))) { - SaveLevel(); - } + ImVec4 defaultColor = ImGui::GetStyle().Colors[ImGuiCol_Button]; + // Function to check and highlight the selected button + auto ToolButton = [&](const char* label, int id) { + bool isSelected = (selectedTool == id); + ImGui::PushStyleColor(ImGuiCol_Button, isSelected ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor); - ImGui::SameLine(); - - ImVec4 defaultColor = ImGui::GetStyle().Colors[ImGuiCol_Button]; - // Function to check and highlight the selected button - auto ToolButton = [&](const char* label, int id) { - bool isSelected = (selectedTool == id); - ImGui::PushStyleColor(ImGuiCol_Button, isSelected ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor); - - if (ImGui::Button(label, ImVec2(50, 25))) { - selectedTool = id; // Set the selected tool - CVarSetInteger("eGizmoMode", id); - } - - ImGui::PopStyleColor(); - }; - - // Draw buttons - ToolButton(ICON_FA_ARROWS, 0); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::Text("Translate"); - ImGui::EndTooltip(); - } - ImGui::SameLine(); - ToolButton(ICON_FA_REPEAT, 1); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::Text("Rotate"); - ImGui::EndTooltip(); - } - ImGui::SameLine(); - ToolButton(ICON_FA_EXPAND, 2); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::Text("Scale"); - ImGui::EndTooltip(); + if (ImGui::Button(label, ImVec2(50, 25))) { + selectedTool = id; // Set the selected tool + CVarSetInteger("eGizmoMode", id); } - ImGui::SameLine(); + ImGui::PopStyleColor(); + }; + + // Draw buttons + ToolButton(ICON_FA_ARROWS, 0); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("Translate"); + ImGui::EndTooltip(); + } + ImGui::SameLine(); + ToolButton(ICON_FA_REPEAT, 1); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("Rotate"); + ImGui::EndTooltip(); + } + ImGui::SameLine(); + ToolButton(ICON_FA_EXPAND, 2); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("Scale"); + ImGui::EndTooltip(); + } - // Snap to ground - ImGui::PushStyleColor(ImGuiCol_Button, toggleGroundSnap ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor); + ImGui::SameLine(); - if (ImGui::Button(ICON_FA_LINK, ImVec2(50, 25))) { - toggleGroundSnap = !toggleGroundSnap; + // Snap to ground + ImGui::PushStyleColor(ImGuiCol_Button, toggleGroundSnap ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor); - CVarSetInteger("gEditorSnapToGround", toggleGroundSnap); - } - ImGui::PopStyleColor(); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::Text("Snap object to surface"); - ImGui::EndTooltip(); - } + if (ImGui::Button(ICON_FA_LINK, ImVec2(50, 25))) { + toggleGroundSnap = !toggleGroundSnap; - ImGui::SameLine(); + CVarSetInteger("gEditorSnapToGround", toggleGroundSnap); + } + ImGui::PopStyleColor(); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("Snap object to surface"); + ImGui::EndTooltip(); + } - // Boundary - ImGui::PushStyleColor(ImGuiCol_Button, toggleBoundary ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor); - if (ImGui::Button(toggleBoundary ? "Map Boundaries" : "Map Boundaries", ImVec2(125, 25))) { - toggleBoundary = !toggleBoundary; + ImGui::SameLine(); - CVarSetInteger("gEditorBoundary", toggleBoundary); - } - ImGui::PopStyleColor(); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::Text("Stops translated objects from leaving the track area."); - ImGui::Text("This helps prevent moving objects really far away off the level."); - ImGui::EndTooltip(); - } + // Boundary + ImGui::PushStyleColor(ImGuiCol_Button, toggleBoundary ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor); + if (ImGui::Button(toggleBoundary ? "Map Boundaries" : "Map Boundaries", ImVec2(125, 25))) { + toggleBoundary = !toggleBoundary; - ImGui::SameLine(); + CVarSetInteger("gEditorBoundary", toggleBoundary); + } + ImGui::PopStyleColor(); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("Stops translated objects from leaving the track area."); + ImGui::Text("This helps prevent moving objects really far away off the level."); + ImGui::EndTooltip(); + } - // Toggle player human/ai - bool playerToggle = (gPlayerOne->type & PLAYER_KART_AI); - ImGui::PushStyleColor(ImGuiCol_Button, defaultColor); - if (ImGui::Button(playerToggle ? ICON_FA_DESKTOP : ICON_FA_GAMEPAD, ImVec2(50, 25))) { - if (playerToggle) { - gPlayerOne->type &= ~PLAYER_KART_AI; - } else { - gPlayerOne->type |= PLAYER_KART_AI; - } + ImGui::SameLine(); + // Toggle player human/ai + bool playerToggle = (gPlayerOne->type & PLAYER_KART_AI); + ImGui::PushStyleColor(ImGuiCol_Button, defaultColor); + if (ImGui::Button(playerToggle ? ICON_FA_DESKTOP : ICON_FA_GAMEPAD, ImVec2(50, 25))) { + if (playerToggle) { + gPlayerOne->type &= ~PLAYER_KART_AI; + } else { + gPlayerOne->type |= PLAYER_KART_AI; } - ImGui::PopStyleColor(); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::Text("Toggle player 1's AI or human player state."); - ImGui::EndTooltip(); - } + } + ImGui::PopStyleColor(); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("Toggle player 1's AI or human player state."); + ImGui::EndTooltip(); + } - ImGui::SameLine(); + ImGui::SameLine(); - // Play/pause button - ImGui::PushStyleColor(ImGuiCol_Button, defaultColor); - if (ImGui::Button(gIsEditorPaused ? ICON_FA_PLAY : ICON_FA_PAUSE, ImVec2(50, 25))) { + // Play/pause button + ImGui::PushStyleColor(ImGuiCol_Button, defaultColor); + if (ImGui::Button(gIsEditorPaused ? ICON_FA_PLAY : ICON_FA_PAUSE, ImVec2(50, 25))) { - gIsEditorPaused = !gIsEditorPaused; - } - ImGui::PopStyleColor(); + gIsEditorPaused = !gIsEditorPaused; + } + ImGui::PopStyleColor(); - ImGui::SameLine(); + ImGui::SameLine(); - // Toggle hud - ImGui::PushStyleColor(ImGuiCol_Button, gIsHUDVisible ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor); - if (ImGui::Button("Toggle HUD", ImVec2(150, 25))) { + // Toggle hud + ImGui::PushStyleColor(ImGuiCol_Button, gIsHUDVisible ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor); + if (ImGui::Button("Toggle HUD", ImVec2(150, 25))) { - gIsHUDVisible = !gIsHUDVisible; - } - ImGui::PopStyleColor(); + gIsHUDVisible = !gIsHUDVisible; + } + ImGui::PopStyleColor(); - ImGui::SameLine(); + ImGui::SameLine(); - // Delete - if (ImGui::Button(ICON_FA_TRASH_O, ImVec2(50, 25))) { - gEditor.DeleteObject(); - } + // Delete + if (ImGui::Button(ICON_FA_TRASH_O, ImVec2(50, 25))) { + gEditor.DeleteObject(); } } +} // namespace Editor |
