Overlays, Shaders, Group Roots, Serialization Changes. Legalize Nuclear Bombs

This commit is contained in:
shweet committed 2026-07-09 19:49:33 -04:00
1 parent 555caf9f4f
commit 5792dd25a2
40 files changed
+6099 -747

No files matched your search

+27 -20
View File
@@ -14,6 +14,32 @@ namespace anm2ed::imgui
return editID;
}
bool input_text_rename_update(std::string& text, RenameState& state, float width)
{
bool isActivated{};
auto finish = [&]()
{
selectable_input_text_id().clear();
isActivated = true;
state = RENAME_FINISHED;
isSelectableInputTextRenaming = false;
};
if (state == RENAME_BEGIN)
{
ImGui::SetKeyboardFocusHere();
state = RENAME_EDITING;
}
ImGui::SetNextItemWidth(width);
if (input_text_string("##Edit", &text, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll))
finish();
if (ImGui::IsItemDeactivatedAfterEdit() || ImGui::IsKeyPressed(ImGuiKey_Escape)) finish();
return isActivated;
}
bool selectable_input_text(const std::string& label, const std::string& id, std::string& text, bool isSelected,
ImGuiSelectableFlags flags, RenameState& state)
{
@@ -22,26 +48,7 @@ namespace anm2ed::imgui
bool isActivated{};
if (isRename)
{
auto finish = [&]()
{
editID.clear();
isActivated = true;
state = RENAME_FINISHED;
isSelectableInputTextRenaming = false;
};
if (state == RENAME_BEGIN)
{
ImGui::SetKeyboardFocusHere();
state = RENAME_EDITING;
}
ImGui::SetNextItemWidth(-FLT_MIN);
if (input_text_string("##Edit", &text, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll))
finish();
if (ImGui::IsItemDeactivatedAfterEdit() || ImGui::IsKeyPressed(ImGuiKey_Escape)) finish();
}
isActivated = input_text_rename_update(text, state);
else
{
if (ImGui::Selectable(label.c_str(), isSelected, flags)) isActivated = true;
+2
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cfloat>
#include <string>
#include <imgui/imgui.h>
@@ -16,6 +17,7 @@ namespace anm2ed::imgui
};
std::string& selectable_input_text_id();
bool input_text_rename_update(std::string&, RenameState&, float = -FLT_MIN);
bool selectable_input_text(const std::string&, const std::string&, std::string&, bool, ImGuiSelectableFlags,
RenameState&);
}
+41
View File
@@ -0,0 +1,41 @@
#include "tree.hpp"
namespace anm2ed::imgui
{
TreeNodeInputTextResult tree_node_input_text(const std::string& label, const std::string& id, std::string& text,
bool isSelected, ImGuiTreeNodeFlags flags, RenameState& state)
{
TreeNodeInputTextResult result{};
auto& editID = selectable_input_text_id();
auto isRename = editID == id;
auto treeFlags = flags | ImGuiTreeNodeFlags_FramePadding | (isSelected ? ImGuiTreeNodeFlags_Selected : 0);
if (!isRename)
{
result.isOpen = ImGui::TreeNodeEx(id.c_str(), treeFlags, "%s", label.c_str());
result.isClicked =
ImGui::IsItemClicked(ImGuiMouseButton_Left) || ImGui::IsItemClicked(ImGuiMouseButton_Right);
result.isActivated = result.isClicked;
if (state == RENAME_FORCE_EDIT || (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)))
{
state = RENAME_BEGIN;
editID = id;
result.isActivated = true;
result.isRenameStarted = true;
}
return result;
}
result.isOpen = ImGui::TreeNodeEx(id.c_str(), treeFlags, "%s", "");
auto itemMin = ImGui::GetItemRectMin();
auto itemMax = ImGui::GetItemRectMax();
auto labelX = itemMin.x + ImGui::GetTreeNodeToLabelSpacing();
ImGui::SetCursorScreenPos(ImVec2(labelX, itemMin.y));
auto width = itemMax.x > labelX ? itemMax.x - labelX : 1.0f;
result.isActivated = input_text_rename_update(text, state, width);
result.isRenameFinished = state == RENAME_FINISHED;
return result;
}
}
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#include <string>
#include <imgui/imgui.h>
#include "selectable.hpp"
namespace anm2ed::imgui
{
struct TreeNodeInputTextResult
{
bool isOpen{};
bool isActivated{};
bool isClicked{};
bool isRenameStarted{};
bool isRenameFinished{};
};
TreeNodeInputTextResult tree_node_input_text(const std::string&, const std::string&, std::string&, bool,
ImGuiTreeNodeFlags, RenameState&);
}