Show FPS counter in its own top-right widget
This commit is contained in:
parent
fb796d7611
commit
d9f23fc156
1
README
1
README
|
@ -14,7 +14,6 @@ sources (GPL) and nDoom (GPLv2). See LICENSE.
|
|||
UI improvements TODO:
|
||||
-> Better keyboard layout (including more keys, eg. Run)
|
||||
=> Edit messages accordingly ("press y"/etc)
|
||||
-> Figure out why blue key looks yellow in status bar
|
||||
|
||||
WAD support TODO:
|
||||
-> Unmodified 1.9 shareware WAD works all the way through?
|
||||
|
|
|
@ -95,6 +95,12 @@ extern boolean automapactive;
|
|||
|
||||
static boolean headsupactive = false;
|
||||
|
||||
/* CGDoom */
|
||||
static hu_stext_t w_fpscounter;
|
||||
static boolean fpscounter_on;
|
||||
int fpscounter_data = 0;
|
||||
boolean fpscounteractive = false;
|
||||
|
||||
//
|
||||
// Builtin map names.
|
||||
// The actual names can be found in DStrings.h.
|
||||
|
@ -222,6 +228,12 @@ void HU_Start(void)
|
|||
hu_font,
|
||||
HU_FONTSTART);
|
||||
|
||||
/* CGDoom: Create the FPS counter widget */
|
||||
HUlib_initSText(&w_fpscounter,
|
||||
SCREENWIDTH-48, HU_MSGY, HU_MSGHEIGHT,
|
||||
hu_font,
|
||||
HU_FONTSTART, &fpscounter_on);
|
||||
|
||||
switch ( gamemode )
|
||||
{
|
||||
case shareware:
|
||||
|
@ -274,6 +286,8 @@ void HU_Drawer(void)
|
|||
{
|
||||
|
||||
HUlib_drawSText(&w_message);
|
||||
if (fpscounteractive)
|
||||
HUlib_drawSText(&w_fpscounter);
|
||||
HUlib_drawIText(&w_chat);
|
||||
if (automapactive)
|
||||
HUlib_drawTextLine(&w_title, false);
|
||||
|
@ -283,6 +297,8 @@ void HU_Drawer(void)
|
|||
void HU_Erase(void)
|
||||
{
|
||||
HUlib_eraseSText(&w_message);
|
||||
if (fpscounteractive)
|
||||
HUlib_eraseSText(&w_fpscounter);
|
||||
HUlib_eraseIText(&w_chat);
|
||||
HUlib_eraseTextLine(&w_title);
|
||||
|
||||
|
@ -316,6 +332,15 @@ void HU_Ticker(void)
|
|||
}
|
||||
|
||||
} // else message_on = false;
|
||||
|
||||
if (fpscounteractive)
|
||||
{
|
||||
/* Update FPS counter text */
|
||||
static char text[10];
|
||||
sprintf(text, "%d FPS", fpscounter_data);
|
||||
HUlib_addMessageToSText(&w_fpscounter, 0, text);
|
||||
fpscounter_on = true;
|
||||
}
|
||||
}
|
||||
|
||||
#define QUEUESIZE 128
|
||||
|
|
|
@ -329,7 +329,9 @@ void I_StartTic (void)
|
|||
{
|
||||
static KeyboardState st = { 0 };
|
||||
|
||||
static int fps_show = 0;
|
||||
extern boolean fpscounteractive;
|
||||
extern int fpscounter_data;
|
||||
|
||||
/* Number of frames since FPS count started */
|
||||
static int fps_frames = 0;
|
||||
/* Time when the FPS count started */
|
||||
|
@ -341,14 +343,7 @@ void I_StartTic (void)
|
|||
if(++fps_frames >= 16)
|
||||
{
|
||||
int now = RTC_GetTicks();
|
||||
int fps = (now == fps_ticks) ? -1 : 128 * fps_frames / (now - fps_ticks);
|
||||
|
||||
if (fps_show)
|
||||
{
|
||||
static char message[16];
|
||||
sprintf(message, "%d FPS", fps);
|
||||
players[consoleplayer].message = message;
|
||||
}
|
||||
fpscounter_data = (now == fps_ticks) ? -1 : 128 * fps_frames / (now - fps_ticks);
|
||||
|
||||
fps_ticks = now;
|
||||
fps_frames = 0;
|
||||
|
@ -373,7 +368,7 @@ void I_StartTic (void)
|
|||
if (KeycodePressed(st, next_st, KEYCODE_FD))
|
||||
CGFreeMem();
|
||||
if (KeycodePressed(st, next_st, KEYCODE_LEFTP))
|
||||
fps_show ^= 1;
|
||||
fpscounteractive = !fpscounteractive;
|
||||
if (KeycodePressed(st, next_st, KEYCODE_VARS))
|
||||
CGRefreshSwitch();
|
||||
|
||||
|
|
Loading…
Reference in New Issue