| 9120e874 Andy McCall | 1 | // Commander X16 Emulator — ImGui debugger panel registry (C++). |
| 2 | // |
|
| 3 | // THE KEY TO PARALLELISM: every panel lives in its own .cpp under panels/ and |
|
| 4 | // self-registers via a file-static DebugPanelRegistration object. There is NO |
|
| 5 | // central list any panel must edit — debug_ui.cpp just iterates |
|
| 6 | // debug_ui_panels(). Five sessions can therefore each own one panel file with |
|
| 7 | // zero merge conflicts. |
|
| 8 | // |
|
| 9 | // To add a panel, create panels/<name>_panel.cpp: |
|
| 10 | // |
|
| 11 | // #include "imgui.h" |
|
| 12 | // #include "debug_ui_panels.h" |
|
| 13 | // // (optional, to read emulator state) #include "debug_ui_bridge.h" |
|
| 14 | // |
|
| 15 | // static void mypanel_render(bool *p_open) { |
|
| 16 | // if (ImGui::Begin("My Panel", p_open)) { |
|
| 17 | // ImGui::TextUnformatted("..."); |
|
| 18 | // } |
|
| 19 | // ImGui::End(); |
|
| 20 | // } |
|
| 21 | // static DebugPanelRegistration s_reg("My Panel", mypanel_render, true); |
|
| 22 | // |
|
| 23 | // and add the file to CMakeLists.txt X16_SOURCES. (The five foundation panels |
|
| 24 | // are already listed, so editing their *contents* needs no CMake change.) |
|
| 25 | |
|
| 26 | |
|
| 27 | ||
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | ; |
|
| 35 | ||
| 36 | // Function-LOCAL static registry. Returning a static defined inside the |
|
| 37 | // function guarantees the vector is constructed on first use — before any |
|
| 38 | // panel's file-static registration runs — which sidesteps the static |
|
| 39 | // initialization-order fiasco across translation units. |
|
| 40 | std::vector<DebugPanel> &; |
|
| 41 | ||
| 42 | // Constructing one of these (as a file-static in a panel .cpp) appends the |
|
| 43 | // panel to the registry. `open` is the initial visibility. |
|
| 44 | |
|
| 45 | |
|
| 46 | ; |
|
| 47 | ||
| 48 | // DEBUG_UI_PANELS_H |