diff --git a/assets/init.dcf b/assets/init.dcf index 44844e2..5e13f81 100644 --- a/assets/init.dcf +++ b/assets/init.dcf @@ -13,4 +13,4 @@ bind enter accept; bind q cancel; bind esc quit; -bind f1 togglefps; \ No newline at end of file +fps 1; \ No newline at end of file diff --git a/src/console/cmd/cmdset.h b/src/console/cmd/cmdset.h index e468ea2..6481645 100644 --- a/src/console/cmd/cmdset.h +++ b/src/console/cmd/cmdset.h @@ -15,7 +15,7 @@ void cmdSet(const consolecmdexec_t *exec) { consolevar_t *var = &CONSOLE.variables[i]; if(stringCompare(var->name, exec->argv[0]) != 0) continue; consoleVarSetValue(var, exec->argv[1]); - consolePrint("%s %s", var->name, var->value); + // consolePrint("%s %s", var->name, var->value); for(i = 0; i < var->eventCount; i++) { assertNotNull(var->events[i], "Event is NULL"); var->events[i](var); diff --git a/src/display/ui/ui.c b/src/display/ui/ui.c index 8810ceb..83d26be 100644 --- a/src/display/ui/ui.c +++ b/src/display/ui/ui.c @@ -34,6 +34,8 @@ errorret_t uiInit(void) { UI.scale = 2.0f; + uiFPSInit(); + errorOk(); } diff --git a/src/display/ui/uifps.c b/src/display/ui/uifps.c index 0403839..2fa8119 100644 --- a/src/display/ui/uifps.c +++ b/src/display/ui/uifps.c @@ -8,10 +8,20 @@ #include "uifps.h" #include "display/ui/uitext.h" #include "time/time.h" +#include "console/console.h" +#include "util/string.h" + +void uiFPSInit(void) { + consoleRegVar("fps", "1", NULL); +} void uiFPSRender(void) { float_t fps = TIME.delta > 0.0f ? (1.0f / TIME.delta) : 0.0f; + if(stringCompare(consoleVarGet("fps")->value, "0") == 0) { + return; + } + char_t buffer[64]; snprintf( buffer, @@ -20,8 +30,11 @@ void uiFPSRender(void) { (int32_t)fps ); - color_t color = fps >= 50.0f ? COLOR_GREEN : - (fps >= 30.0f ? COLOR_YELLOW : COLOR_RED); + color_t color = ( + fps >= 50.0f ? COLOR_GREEN : + fps >= 30.0f ? COLOR_YELLOW : + COLOR_RED + ); uiTextDraw(0, 0, buffer, color); } \ No newline at end of file diff --git a/src/display/ui/uifps.h b/src/display/ui/uifps.h index ced375e..4c5cd75 100644 --- a/src/display/ui/uifps.h +++ b/src/display/ui/uifps.h @@ -8,4 +8,5 @@ #pragma once #include "dusk.h" +void uiFPSInit(void); void uiFPSRender(void); \ No newline at end of file