diff --git a/lang/Czech.ini b/lang/Czech.ini index d8a7196b..9ffcd158 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -139,6 +139,7 @@ DYNOS_PACKS = "DynOS packy" ANTIALIASING = "Anti-aliasing" OFF = "Vypnuto" MUST_RESTART = "Musíte restartovat hru pro aplikování změn." +SHOW_FPS = "Zobrazit FPS" [DJUI_THEMES] DJUI_THEMES = "TÉMATA DJUI" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index 2d9cb54e..4696c7a3 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -139,6 +139,7 @@ DYNOS_PACKS = "DynOS Packs" ANTIALIASING = "Anti-aliasing" OFF = "UIT" MUST_RESTART = "Je moet de game opnieuw opstarten voor sommige veranderingen om effect te hebben." +SHOW_FPS = "Toon FPS" [DJUI_THEMES] DJUI_THEMES = "DJUI THEMA'S" diff --git a/lang/English.ini b/lang/English.ini index 5d1461af..5aaaf862 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -139,6 +139,7 @@ DYNOS_PACKS = "DynOS Packs" ANTIALIASING = "Anti-aliasing" OFF = "Off" MUST_RESTART = "Restart the game to apply changes." +SHOW_FPS = "Show FPS" [DJUI_THEMES] DJUI_THEMES = "DJUI THEMES" diff --git a/lang/French.ini b/lang/French.ini index ac05d76b..b8ea35d4 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -140,6 +140,7 @@ DYNOS_PACKS = "Packs DynOS" ANTIALIASING = "Anti-aliasing" OFF = "Désactivé" MUST_RESTART = "Vous devez relancer le jeu pour que certains changements prennent effet." +SHOW_FPS = "Afficher FPS" [DJUI_THEMES] DJUI_THEMES = "THÈMES DJUI" diff --git a/lang/German.ini b/lang/German.ini index c3066d83..2eae5816 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -139,6 +139,7 @@ DYNOS_PACKS = "DynOS-Pakete" ANTIALIASING = "Kantenglättung" OFF = "Aus" MUST_RESTART = "Um einige Änderungen zu übernehmen, muss das Spiel neugestartet werden." +SHOW_FPS = "FPS anzeigen" [DJUI_THEMES] DJUI_THEMES = "DJUI-THEMEN" diff --git a/lang/Italian.ini b/lang/Italian.ini index c1463371..0228948d 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -137,6 +137,7 @@ DYNOS_PACKS = "Pacchetti DynOS" ANTIALIASING = "Anti-aliasing" OFF = "Off" MUST_RESTART = "You must restart the game for some changes to take effect." +SHOW_FPS = "Mostra FPS" [DJUI_THEMES] DJUI_THEMES = "TEMI DJUI" diff --git a/lang/Polish.ini b/lang/Polish.ini index 7a24c891..4c53595c 100644 --- a/lang/Polish.ini +++ b/lang/Polish.ini @@ -139,6 +139,7 @@ DYNOS_PACKS = "Paczki DynOS" ANTIALIASING = "Anti-aliasing" OFF = "Wylaczone" MUST_RESTART = "Musisz zrestartowac gre, aby zmiany zaczely obowiazywac." +SHOW_FPS = "Pokaż FPS" [DJUI_THEMES] DJUI_THEMES = "TEMATY DJUI" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index 1c87bbe4..240e11cb 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -139,6 +139,7 @@ DYNOS_PACKS = "DynOS Packs" ANTIALIASING = "Anti-aliasing" OFF = "Desligado" MUST_RESTART = "Você precisará reiniciar o jogo para algumas alterações serem aplicadas." +SHOW_FPS = "Mostrar FPS" [DJUI_THEMES] DJUI_THEMES = "TEMAS DJUI" @@ -152,7 +153,7 @@ FILE_SELECT_THEME = "Seleção de arquivo" [DYNOS] DYNOS = "DYNOS" - + [HOST_MESSAGE] INFO_TITLE = "INFO" WARN_DISCORD = "Convide amigos clicando com o botão direito do mouse no nome deles no Discord e clicando em\n'\\#d0d0ff\\convidar para o jogo\\#dcdcdc\\'.\n\n Você também pode convidar canais de servidores clicando em \\#d0d0ff\\mais\\#dcdcdc\\ botão ao lado do local onde você entra no chat.\n\nGame Activity \\#ffa0a0\\precisa estar\\#dcdcdc\\ ativado nas suas\n configurações do discord.\n\n status offline\\#ffa0a0\\vai prevenir\\#dcdcdc\\ convites de serem enviados." diff --git a/lang/Russian.ini b/lang/Russian.ini index 85aa4bbd..28eade1c 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -138,6 +138,7 @@ DYNOS_PACKS = "Пакеты DynOS" ANTIALIASING = "Анизотропная фильтрация" OFF = "Выкл" MUST_RESTART = "Перезапустите игру, чтобы изменения вступили в силу" +SHOW_FPS = "Показывать FPS" [DJUI_THEMES] DJUI_THEMES = "ТЕМЫ DJUI" diff --git a/lang/SpanishUS.ini b/lang/SpanishUS.ini index 7f6d8fa6..ca6ea338 100644 --- a/lang/SpanishUS.ini +++ b/lang/SpanishUS.ini @@ -139,6 +139,7 @@ DYNOS_PACKS = "Packs de DynOS" ANTIALIASING = "Anti-aliasing" OFF = "Desactivado" MUST_RESTART = "Tienes que reiniciar el juego para que algunos cambios surtan efecto." +SHOW_FPS = "Mostrar FPS" [DJUI_THEMES] DJUI_THEMES = "TEMAS de DJUI" diff --git a/src/pc/configfile.c b/src/pc/configfile.c index b3249ff8..d9f54ee0 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -137,6 +137,7 @@ bool configMenuRandom = false; bool configMenuDemos = false; struct PlayerPalette configPlayerPalette = {{{ 0x00, 0x00, 0xff }, { 0xff, 0x00, 0x00 }, { 0xff, 0xff, 0xff }, { 0x72, 0x1c, 0x0e }, { 0x73, 0x06, 0x00 }, { 0xfe, 0xc1, 0x79 }, { 0xff, 0x00, 0x00 }}}; struct PlayerPalette configCustomPalette = {{{ 0x00, 0x00, 0xff }, { 0xff, 0x00, 0x00 }, { 0xff, 0xff, 0xff }, { 0x72, 0x1c, 0x0e }, { 0x73, 0x06, 0x00 }, { 0xfe, 0xc1, 0x79 }, { 0xff, 0x00, 0x00 }}}; +bool configShowFPS = false; bool configUncappedFramerate = true; unsigned int configFrameLimit = 60; unsigned int configDrawDistance = 5; @@ -218,6 +219,7 @@ static const struct ConfigOption options[] = { {.name = "debug_offset", .type = CONFIG_TYPE_U64 , .u64Value = &gPcDebug.bhvOffset}, {.name = "debug_tags", .type = CONFIG_TYPE_U64 , .u64Value = gPcDebug.tags}, // coop-specific + {.name = "show_fps", .type = CONFIG_TYPE_BOOL , .boolValue = &configShowFPS}, {.name = "uncapped_framerate", .type = CONFIG_TYPE_BOOL , .boolValue = &configUncappedFramerate}, {.name = "frame_limit" , .type = CONFIG_TYPE_UINT , .uintValue = &configFrameLimit}, {.name = "amount_of_players", .type = CONFIG_TYPE_UINT , .uintValue = &configAmountofPlayers}, diff --git a/src/pc/configfile.h b/src/pc/configfile.h index acf7154e..aaad0637 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -96,6 +96,7 @@ extern bool configMenuRandom; extern bool configMenuDemos; extern struct PlayerPalette configPlayerPalette; extern struct PlayerPalette configCustomPalette; +extern bool configShowFPS; extern bool configUncappedFramerate; extern unsigned int configFrameLimit; extern unsigned int configDrawDistance; diff --git a/src/pc/djui/djui.c b/src/pc/djui/djui.c index fabd5a55..5090eea7 100644 --- a/src/pc/djui/djui.c +++ b/src/pc/djui/djui.c @@ -5,6 +5,7 @@ #include "djui_panel_pause.h" #include "djui_panel_join.h" #include "djui_panel_join_message.h" +#include "djui_fps_display.h" #include "../debuglog.h" #include "pc/cliopts.h" #include "game/level_update.h" @@ -81,6 +82,9 @@ void djui_init(void) { djui_panel_playerlist_create(NULL); djui_console_create(); + + djui_fps_display_create(); + sDjuiInited = true; } @@ -140,6 +144,8 @@ void djui_render(void) { djui_base_render(&gDjuiRoot->base); } + djui_fps_display_render(); + if (sDjuiLuaErrorTimeout > 0) { sDjuiLuaErrorTimeout--; if (sDjuiLuaErrorTimeout == 0) { diff --git a/src/pc/djui/djui_fps_display.c b/src/pc/djui/djui_fps_display.c new file mode 100644 index 00000000..c9948383 --- /dev/null +++ b/src/pc/djui/djui_fps_display.c @@ -0,0 +1,47 @@ +#include "djui.h" +#include "../pc_main.h" + +struct DjuiFpsDisplay { + struct DjuiText *text; + struct DjuiBase base; +}; + +struct DjuiFpsDisplay *sFpsDisplay = NULL; + +void djui_fps_display_update(s16 fps) { + if (configShowFPS) { + char fpsText[30] = ""; + snprintf(fpsText, 30, "\\#dcdcdc\\FPS \\#ffffff\\%d", fps); + djui_text_set_text(sFpsDisplay->text, fpsText); + } +} + +void djui_fps_display_render(void) { + if (configShowFPS) { + djui_rect_render(&sFpsDisplay->base); + djui_base_render(&sFpsDisplay->base); + } +} + +void djui_fps_display_create(void) { + struct DjuiFpsDisplay *fpsDisplay = malloc(sizeof(struct DjuiFpsDisplay)); + struct DjuiBase* base = &fpsDisplay->base; + djui_base_init(NULL, base, NULL, NULL); + djui_base_set_size(base, 150, 50); + djui_base_set_color(base, 0, 0, 0, 240); + djui_base_set_border_color(base, 0, 0, 0, 200); + djui_base_set_border_width(base, 8); + djui_base_set_padding(base, 16, 16, 16, 16); + + { + // FPS text + struct DjuiText *text = djui_text_create(base, ""); + djui_base_set_size_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&text->base, 1.0f, text->fontScale * 2); + djui_base_set_location(&text->base, 0, -text->fontScale / 2); + + fpsDisplay->text = text; + } + + sFpsDisplay = fpsDisplay; +} diff --git a/src/pc/djui/djui_fps_display.h b/src/pc/djui/djui_fps_display.h new file mode 100644 index 00000000..a35ea17b --- /dev/null +++ b/src/pc/djui/djui_fps_display.h @@ -0,0 +1,6 @@ +#pragma once +#include "djui.h" + +void djui_fps_display_update(s16 fps); +void djui_fps_display_render(void); +void djui_fps_display_create(void); diff --git a/src/pc/djui/djui_panel.c b/src/pc/djui/djui_panel.c index 400ff1e8..e29f8de0 100644 --- a/src/pc/djui/djui_panel.c +++ b/src/pc/djui/djui_panel.c @@ -28,7 +28,7 @@ struct DjuiBase* djui_panel_find_first_interactable(struct DjuiBaseChild* child) } // If we didn't find anything at all. Return NULL. - LOG_ERROR("Failed to find a interactable for child %p.", child); + // LOG_ERROR("Failed to find a interactable for child %p.", child); return NULL; } diff --git a/src/pc/djui/djui_panel_display.c b/src/pc/djui/djui_panel_display.c index a9f789fa..5061b3e6 100644 --- a/src/pc/djui/djui_panel_display.c +++ b/src/pc/djui/djui_panel_display.c @@ -64,6 +64,7 @@ void djui_panel_display_create(struct DjuiBase* caller) { djui_checkbox_create(body, DLANG(DISPLAY, FORCE_4BY3), &configForce4By3, djui_panel_display_apply); + djui_checkbox_create(body, DLANG(DISPLAY, SHOW_FPS), &configShowFPS, NULL); djui_checkbox_create(body, DLANG(DISPLAY, VSYNC), &configWindow.vsync, djui_panel_display_apply); djui_checkbox_create(body, DLANG(DISPLAY, UNCAPPED_FRAMERATE), &configUncappedFramerate, djui_panel_display_uncapped_change); diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 5e7eaf45..ddb79644 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -43,6 +43,7 @@ #include "pc/djui/djui_unicode.h" #include "pc/djui/djui_panel.h" #include "pc/djui/djui_panel_modlist.h" +#include "pc/djui/djui_fps_display.h" #include "pc/debuglog.h" #include "pc/utils/misc.h" @@ -196,7 +197,8 @@ void produce_interpolation_frames_and_delay(void) { u32 fps = sFramesSinceFpsUpdate / ((f32)(sCurrentFpsUpdateTime - sLastFpsUpdateTime)); sLastFpsUpdateTime = sCurrentFpsUpdateTime; sFramesSinceFpsUpdate = 0; - // printf("fps: %u\n", fps); + + djui_fps_display_update(floor(fps)); } sFrameTimeStart = sFrameTargetTime;