mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
fixed Lua profiler showing mods that aren't active
This commit is contained in:
parent
a0ae1cdc02
commit
d7352b8d2a
1 changed files with 45 additions and 33 deletions
|
@ -26,7 +26,8 @@ struct DjuiPrfDisplay {
|
||||||
struct DjuiBase base;
|
struct DjuiBase base;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DjuiPrfDisplay *sPrfDisplay = NULL;
|
static struct DjuiPrfDisplay *sPrfDisplay = NULL;
|
||||||
|
static u8 sPrfDisplayCount = 0;
|
||||||
|
|
||||||
void lua_profiler_start_counter(UNUSED struct Mod *mod) {
|
void lua_profiler_start_counter(UNUSED struct Mod *mod) {
|
||||||
if (!configLuaProfiler || sPrfDisplay == NULL) { return; }
|
if (!configLuaProfiler || sPrfDisplay == NULL) { return; }
|
||||||
|
@ -61,9 +62,44 @@ void lua_profiler_stop_counter(UNUSED struct Mod *mod) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void djui_lua_profiler_initialize_entry(struct DjuiBase *base, struct DjuiPrfEntry *entry, f64 offset) {
|
||||||
|
struct DjuiText *name = djui_text_create(base, "");
|
||||||
|
djui_text_set_alignment(name, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
|
||||||
|
djui_base_set_size_type(&name->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||||
|
djui_base_set_size(&name->base, 1.0f, name->fontScale * 2);
|
||||||
|
djui_base_set_location(&name->base, 0, -name->fontScale / 3.0f + offset);
|
||||||
|
djui_base_set_color(&name->base, 255, 255, 255, 240);
|
||||||
|
|
||||||
|
struct DjuiText *timing = djui_text_create(base, "");
|
||||||
|
djui_text_set_alignment(timing, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
|
||||||
|
djui_base_set_size_type(&timing->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||||
|
djui_base_set_size(&timing->base, 1.0f, timing->fontScale * 2);
|
||||||
|
djui_base_set_location(&timing->base, 0, -timing->fontScale / 3.0f + offset);
|
||||||
|
djui_base_set_color(&timing->base, 255, 255, 255, 240);
|
||||||
|
|
||||||
|
entry->name = name;
|
||||||
|
entry->timing = timing;
|
||||||
|
}
|
||||||
|
|
||||||
void djui_lua_profiler_update(void) {
|
void djui_lua_profiler_update(void) {
|
||||||
if (!configLuaProfiler || sPrfDisplay == NULL) { return; }
|
if (!configLuaProfiler || sPrfDisplay == NULL) { return; }
|
||||||
|
|
||||||
|
if (sPrfDisplayCount != gActiveMods.entryCount) {
|
||||||
|
for (s32 i = 0; i < MAX(sPrfDisplayCount, gActiveMods.entryCount); i++) {
|
||||||
|
struct DjuiPrfEntry *entry = &sPrfDisplay->entries[i];
|
||||||
|
if (i >= sPrfDisplayCount) {
|
||||||
|
djui_lua_profiler_initialize_entry(&sPrfDisplay->base, entry, 4.0 + (i * 22.0));
|
||||||
|
}
|
||||||
|
if (i >= gActiveMods.entryCount) {
|
||||||
|
djui_base_destroy(&entry->name->base);
|
||||||
|
djui_base_destroy(&entry->timing->base);
|
||||||
|
entry->name = NULL;
|
||||||
|
entry->timing = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sPrfDisplayCount = gActiveMods.entryCount;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the counters.
|
// Draw the counters.
|
||||||
for (s32 i = 0; i < MIN(MAX_PROFILED_MODS, gActiveMods.entryCount); i++) {
|
for (s32 i = 0; i < MIN(MAX_PROFILED_MODS, gActiveMods.entryCount); i++) {
|
||||||
struct DjuiPrfEntry *entry = &sPrfDisplay->entries[i];
|
struct DjuiPrfEntry *entry = &sPrfDisplay->entries[i];
|
||||||
|
@ -105,25 +141,6 @@ void djui_lua_profiler_on_destroy(UNUSED struct DjuiBase* base) {
|
||||||
free(sPrfDisplay);
|
free(sPrfDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void djui_lua_profiler_initialize_entry(struct DjuiBase *base, struct DjuiPrfEntry *entry, f64 offset) {
|
|
||||||
struct DjuiText *name = djui_text_create(base, "");
|
|
||||||
djui_text_set_alignment(name, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
|
|
||||||
djui_base_set_size_type(&name->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
|
||||||
djui_base_set_size(&name->base, 1.0f, name->fontScale * 2);
|
|
||||||
djui_base_set_location(&name->base, 0, -name->fontScale / 3.0f + offset);
|
|
||||||
djui_base_set_color(&name->base, 255, 255, 255, 240);
|
|
||||||
|
|
||||||
struct DjuiText *timing = djui_text_create(base, "");
|
|
||||||
djui_text_set_alignment(timing, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
|
|
||||||
djui_base_set_size_type(&timing->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
|
||||||
djui_base_set_size(&timing->base, 1.0f, timing->fontScale * 2);
|
|
||||||
djui_base_set_location(&timing->base, 0, -timing->fontScale / 3.0f + offset);
|
|
||||||
djui_base_set_color(&timing->base, 255, 255, 255, 240);
|
|
||||||
|
|
||||||
entry->name = name;
|
|
||||||
entry->timing = timing;
|
|
||||||
}
|
|
||||||
|
|
||||||
void djui_lua_profiler_create(void) {
|
void djui_lua_profiler_create(void) {
|
||||||
struct DjuiPrfDisplay *prfDisplay = calloc(1, sizeof(struct DjuiPrfDisplay));
|
struct DjuiPrfDisplay *prfDisplay = calloc(1, sizeof(struct DjuiPrfDisplay));
|
||||||
struct DjuiBase *base = &prfDisplay->base;
|
struct DjuiBase *base = &prfDisplay->base;
|
||||||
|
@ -135,11 +152,6 @@ void djui_lua_profiler_create(void) {
|
||||||
djui_base_set_padding(base, 4, 4, 4, 4);
|
djui_base_set_padding(base, 4, 4, 4, 4);
|
||||||
djui_base_set_location(base, 0, 300.0f);
|
djui_base_set_location(base, 0, 300.0f);
|
||||||
|
|
||||||
f64 offset = 4.0;
|
|
||||||
for (s32 i = 0; i < MAX_PROFILED_MODS; ++i, offset += 22.0) {
|
|
||||||
djui_lua_profiler_initialize_entry(base, &prfDisplay->entries[i], offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
sPrfDisplay = prfDisplay;
|
sPrfDisplay = prfDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue