[client] overlay: add new configuration overlay [wip]

This commit is contained in:
Geoffrey McRae 2021-08-04 10:27:47 +10:00
parent 80c9f7223a
commit d2c36b8449
6 changed files with 31 additions and 4 deletions

View file

@ -118,6 +118,7 @@ set(SOURCES
src/overlay/fps.c src/overlay/fps.c
src/overlay/graphs.c src/overlay/graphs.c
src/overlay/help.c src/overlay/help.c
src/overlay/config.c
) )
# Force cimgui to build as a static library. # Force cimgui to build as a static library.

View file

@ -825,6 +825,7 @@ static int lg_run(void)
app_registerOverlay(&LGOverlayFPS , NULL); app_registerOverlay(&LGOverlayFPS , NULL);
app_registerOverlay(&LGOverlayGraphs, NULL); app_registerOverlay(&LGOverlayGraphs, NULL);
app_registerOverlay(&LGOverlayHelp , NULL); app_registerOverlay(&LGOverlayHelp , NULL);
app_registerOverlay(&LGOverlayConfig, NULL);
// initialize metrics ringbuffers // initialize metrics ringbuffers
g_state.renderTimings = ringbuffer_new(256, sizeof(float)); g_state.renderTimings = ringbuffer_new(256, sizeof(float));

View file

@ -97,13 +97,19 @@ static int graphs_render(void * udata, bool interactive,
float fontSize = igGetFontSize(); float fontSize = igGetFontSize();
GraphHandle graph;
int graphCount = 0;
for (ll_reset(gs.graphs); ll_walk(gs.graphs, (void **)&graph); )
if (graph->enabled)
++graphCount;
ImVec2 pos = {0.0f, 0.0f}; ImVec2 pos = {0.0f, 0.0f};
igSetNextWindowBgAlpha(0.4f); igSetNextWindowBgAlpha(0.4f);
igSetNextWindowPos(pos, ImGuiCond_FirstUseEver, pos); igSetNextWindowPos(pos, ImGuiCond_FirstUseEver, pos);
igSetNextWindowSize( igSetNextWindowSize(
(ImVec2){ (ImVec2){
28.0f * fontSize, 28.0f * fontSize,
7.0f * fontSize * ll_count(gs.graphs) 7.0f * fontSize * graphCount
}, },
ImGuiCond_FirstUseEver); ImGuiCond_FirstUseEver);
@ -115,10 +121,9 @@ static int graphs_render(void * udata, bool interactive,
ImVec2 winSize; ImVec2 winSize;
igGetContentRegionAvail(&winSize); igGetContentRegionAvail(&winSize);
const float height = (winSize.y / ll_count(gs.graphs)) const float height = (winSize.y / graphCount)
- igGetStyle()->ItemSpacing.y; - igGetStyle()->ItemSpacing.y;
GraphHandle graph;
for (ll_reset(gs.graphs); ll_walk(gs.graphs, (void **)&graph); ) for (ll_reset(gs.graphs); ll_walk(gs.graphs, (void **)&graph); )
{ {
if (!graph->enabled) if (!graph->enabled)
@ -179,3 +184,11 @@ void overlayGraph_unregister(GraphHandle handle)
{ {
handle->enabled = false; handle->enabled = false;
} }
void overlayGraph_iterate(void (*callback)(GraphHandle handle, const char * name,
bool * enabled, void * udata), void * udata)
{
GraphHandle graph;
for (ll_reset(gs.graphs); ll_walk(gs.graphs, (void **)&graph); )
callback(graph, graph->name, &graph->enabled, udata);
}

View file

@ -27,8 +27,12 @@ extern struct LG_OverlayOps LGOverlayAlert;
extern struct LG_OverlayOps LGOverlayFPS; extern struct LG_OverlayOps LGOverlayFPS;
extern struct LG_OverlayOps LGOverlayGraphs; extern struct LG_OverlayOps LGOverlayGraphs;
extern struct LG_OverlayOps LGOverlayHelp; extern struct LG_OverlayOps LGOverlayHelp;
extern struct LG_OverlayOps LGOverlayConfig;
GraphHandle overlayGraph_register(const char * name, RingBuffer buffer, float min, float max); GraphHandle overlayGraph_register(const char * name, RingBuffer buffer,
float min, float max);
void overlayGraph_unregister(); void overlayGraph_unregister();
void overlayGraph_iterate(void (*callback)(GraphHandle handle, const char * name,
bool * enabled, void * udata), void * udata);
#endif #endif

View file

@ -22,6 +22,7 @@ endif()
add_subdirectory(src/platform) add_subdirectory(src/platform)
set(COMMON_SOURCES set(COMMON_SOURCES
src/appstrings.c
src/stringutils.c src/stringutils.c
src/stringlist.c src/stringlist.c
src/option.c src/option.c

View file

@ -87,4 +87,11 @@ typedef enum CursorType
} }
CursorType; CursorType;
typedef struct StringPair
{
const char * name;
const char * value;
}
StringPair;
#endif #endif