Editor Snap to Ground works

This commit is contained in:
MegaMech
2025-03-07 15:18:28 -07:00
parent 55b905f377
commit e51e11c9b0
5 changed files with 46 additions and 7 deletions
+22 -1
View File
@@ -23,8 +23,29 @@ namespace Editor {
void ToolsWindow::DrawElement() {
static bool toggleState = false;
static int selectedTool = 0; // 0: Move, 1: Rotate, 2: Scale
// 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.2f, 0.8f, 0.2f, 1.0f) : ImVec4(0.8f, 0.2f, 0.2f, 1.0f));
if (ImGui::Button(label, ImVec2(125, 25))) {
selectedTool = id; // Set the selected tool
}
ImGui::PopStyleColor();
};
// Draw buttons
ToolButton("Move", 0);
ImGui::SameLine();
ToolButton("Rotate", 1);
ImGui::SameLine();
ToolButton("Scale", 2);
ImGui::PushStyleColor(ImGuiCol_Button, toggleState ? ImVec4(0.2f, 0.8f, 0.2f, 1.0f) : ImVec4(0.8f, 0.2f, 0.2f, 1.0f));
if (ImGui::Button(toggleState ? "v" : "v", ImVec2(50, 25))) {
if (ImGui::Button(toggleState ? "SNAP TO GROUND" : "SNAP TO GROUND", ImVec2(125, 25))) {
toggleState = !toggleState;
CVarSetInteger("gEditorSnapToGround", toggleState);