Add ImGuiIdIssuer class for child id

This commit is contained in:
scawful
2023-11-24 13:27:59 -05:00
parent 5f3ca25c80
commit 8448697c4d
2 changed files with 36 additions and 0 deletions

View File

@@ -1,10 +1,13 @@
#ifndef YAZE_CORE_COMMON_H
#define YAZE_CORE_COMMON_H
#include <imgui/imgui.h>
#include <chrono>
#include <cstdint>
#include <functional>
#include <memory>
#include <stack>
#include <string>
namespace yaze {
@@ -38,6 +41,9 @@ class ExperimentFlags {
// Attempt to run the dungeon room draw routine when opening a room.
bool kDrawDungeonRoomGraphics = true;
// Use the new platform specific file dialog wrappers.
bool kNewFileDialogWrapper = true;
};
ExperimentFlags() = default;
@@ -164,6 +170,27 @@ class TaskManager {
}
};
class ImGuiIdIssuer {
private:
static std::stack<ImGuiID> idStack;
public:
// Generate and push a new ID onto the stack
static ImGuiID GetNewID() {
static int counter = 1; // Start from 1 to ensure uniqueness
ImGuiID child_id = ImGui::GetID((void *)(intptr_t)counter++);
idStack.push(child_id);
return child_id;
}
// Pop all IDs from the stack (can be called explicitly or upon program exit)
static void Cleanup() {
while (!idStack.empty()) {
idStack.pop();
}
}
};
uint32_t SnesToPc(uint32_t addr);
uint32_t PcToSnes(uint32_t addr);