FPS toggle
This commit is contained in:
@@ -13,4 +13,4 @@ bind enter accept;
|
|||||||
bind q cancel;
|
bind q cancel;
|
||||||
bind esc quit;
|
bind esc quit;
|
||||||
|
|
||||||
bind f1 togglefps;
|
fps 1;
|
@@ -15,7 +15,7 @@ void cmdSet(const consolecmdexec_t *exec) {
|
|||||||
consolevar_t *var = &CONSOLE.variables[i];
|
consolevar_t *var = &CONSOLE.variables[i];
|
||||||
if(stringCompare(var->name, exec->argv[0]) != 0) continue;
|
if(stringCompare(var->name, exec->argv[0]) != 0) continue;
|
||||||
consoleVarSetValue(var, exec->argv[1]);
|
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++) {
|
for(i = 0; i < var->eventCount; i++) {
|
||||||
assertNotNull(var->events[i], "Event is NULL");
|
assertNotNull(var->events[i], "Event is NULL");
|
||||||
var->events[i](var);
|
var->events[i](var);
|
||||||
|
@@ -34,6 +34,8 @@ errorret_t uiInit(void) {
|
|||||||
|
|
||||||
UI.scale = 2.0f;
|
UI.scale = 2.0f;
|
||||||
|
|
||||||
|
uiFPSInit();
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,10 +8,20 @@
|
|||||||
#include "uifps.h"
|
#include "uifps.h"
|
||||||
#include "display/ui/uitext.h"
|
#include "display/ui/uitext.h"
|
||||||
#include "time/time.h"
|
#include "time/time.h"
|
||||||
|
#include "console/console.h"
|
||||||
|
#include "util/string.h"
|
||||||
|
|
||||||
|
void uiFPSInit(void) {
|
||||||
|
consoleRegVar("fps", "1", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void uiFPSRender(void) {
|
void uiFPSRender(void) {
|
||||||
float_t fps = TIME.delta > 0.0f ? (1.0f / TIME.delta) : 0.0f;
|
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];
|
char_t buffer[64];
|
||||||
snprintf(
|
snprintf(
|
||||||
buffer,
|
buffer,
|
||||||
@@ -20,8 +30,11 @@ void uiFPSRender(void) {
|
|||||||
(int32_t)fps
|
(int32_t)fps
|
||||||
);
|
);
|
||||||
|
|
||||||
color_t color = fps >= 50.0f ? COLOR_GREEN :
|
color_t color = (
|
||||||
(fps >= 30.0f ? COLOR_YELLOW : COLOR_RED);
|
fps >= 50.0f ? COLOR_GREEN :
|
||||||
|
fps >= 30.0f ? COLOR_YELLOW :
|
||||||
|
COLOR_RED
|
||||||
|
);
|
||||||
|
|
||||||
uiTextDraw(0, 0, buffer, color);
|
uiTextDraw(0, 0, buffer, color);
|
||||||
}
|
}
|
@@ -8,4 +8,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "dusk.h"
|
#include "dusk.h"
|
||||||
|
|
||||||
|
void uiFPSInit(void);
|
||||||
void uiFPSRender(void);
|
void uiFPSRender(void);
|
Reference in New Issue
Block a user