simple fps display in top left corner (#527)

* simple fps display in top left corner

* added other languages

thank you to everyone in #translation-station, and to Google translate (some languages may need revisiting later)

* render from left not center, grey fps text
This commit is contained in:
Isaac0-dev 2023-11-23 11:04:14 +10:00 committed by GitHub
parent f9f4c61921
commit aa3e5fad12
18 changed files with 80 additions and 29 deletions

View File

@ -147,6 +147,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"
[DYNOS]
DYNOS = "DYNOS"
@ -357,6 +358,3 @@ REFRESHING = "Obnovování..."
ENTER_PASSWORD = "Zadejte heslo soukromé hry:"
SEARCH = "Hledat"
NONE_FOUND = "Nebyly nalezeny žádné hry."
[LOADING_SCREEN]
LOADING = "Načítání"

View File

@ -146,6 +146,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"
[DYNOS]
DYNOS = "DYNOS"
@ -355,6 +356,3 @@ REFRESHING = "herladen..."
ENTER_PASSWORD = "Typ het wachtwoord van de privé lobby:"
SEARCH = "Zoek"
NONE_FOUND = "Er zijn geen lobby's gevonden."
[LOADING_SCREEN]
LOADING = "Bezig met laden"

View File

@ -147,6 +147,7 @@ DYNOS_PACKS = "DynOS Packs"
ANTIALIASING = "Anti-aliasing"
OFF = "Off"
MUST_RESTART = "Restart the game to apply some changes."
SHOW_FPS = "Show FPS"
[DYNOS]
DYNOS = "DYNOS"
@ -357,6 +358,3 @@ REFRESHING = "Refreshing..."
ENTER_PASSWORD = "Enter the private lobby's password:"
SEARCH = "Search"
NONE_FOUND = "No lobbies were found."
[LOADING_SCREEN]
LOADING = "Loading"

View File

@ -147,6 +147,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"
[DYNOS]
DYNOS = "DYNOS"
@ -357,6 +358,3 @@ REFRESHING = "Actualisation..."
ENTER_PASSWORD = "Entrez le mot de passe de la partie:"
SEARCH = "Rechercher"
NONE_FOUND = "Aucune partie n'a été trouvée."
[LOADING_SCREEN]
LOADING = "Chargement"

View File

@ -147,6 +147,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"
[DYNOS]
DYNOS = "DYNOS"
@ -357,6 +358,3 @@ REFRESHING = "Aktualisiere..."
ENTER_PASSWORD = "Gib das Passwort für die Lobby ein:"
SEARCH = "Suchen"
NONE_FOUND = "Keine Lobbys gefunden."
[LOADING_SCREEN]
LOADING = "Wird geladen"

View File

@ -145,6 +145,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"
[DYNOS]
DYNOS = "DYNOS"
@ -354,6 +355,3 @@ REFRESHING = "Refreshing..."
ENTER_PASSWORD = "Enter the private lobby's password:"
SEARCH = "Search"
NONE_FOUND = "No lobbies were found."
[LOADING_SCREEN]
LOADING = "Caricamento"

View File

@ -144,6 +144,7 @@ DYNOS_PACKS = "Paczki DynOS"
ANTIALIASING = "Anti-aliasing"
OFF = "Wylaczone"
MUST_RESTART = "Musisz zrestartowac gre, aby zmiany zaczely obowiazywac."
SHOW_FPS = "Pokaż FPS"
[DYNOS]
DYNOS = "DYNOS"

View File

@ -147,10 +147,11 @@ 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"
[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\\#c8c8c8\\'.\n\n Você também pode convidar canais de servidores clicando em \\#d0d0ff\\mais\\#c8c8c8\\ botão ao lado do local onde você entra no chat.\n\nGame Activity \\#ffa0a0\\precisa estar\\#c8c8c8\\ ativado nas suas\n configurações do discord.\n\n status offline\\#ffa0a0\\vai prevenir\\#c8c8c8\\ convites de serem enviados."
@ -357,6 +358,3 @@ REFRESHING = "Recarregando..."
ENTER_PASSWORD = "Coloque a senha para a partida privada:"
SEARCH = "Pesquisar"
NONE_FOUND = "Nenhuma partida foi encontrada."
[LOADING_SCREEN]
LOADING = "Carregando"

View File

@ -146,6 +146,7 @@ DYNOS_PACKS = "Пакеты DynOS"
ANTIALIASING = "Анизотропная фильтрация"
OFF = "Выкл"
MUST_RESTART = "Перезапустите игру, чтобы изменения вступили в силу"
SHOW_FPS = "Показывать FPS"
[DYNOS]
DYNOS = "DYNOS"
@ -356,6 +357,3 @@ REFRESHING = "Обновление..."
ENTER_PASSWORD = "Введите пароль закрытой группы:"
SEARCH = "Поиск"
NONE_FOUND = "Группы не найдены."
[LOADING_SCREEN]
LOADING = "Загрузка"

View File

@ -147,6 +147,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"
[DYNOS]
DYNOS = "DYNOS"

View File

@ -139,6 +139,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;
@ -222,6 +223,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},

View File

@ -98,6 +98,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;

View File

@ -6,6 +6,7 @@
#include "djui_panel_join.h"
#include "djui_panel_join_message.h"
#include "djui_console.h"
#include "djui_fps_display.h"
#include "../debuglog.h"
#include "pc/cliopts.h"
#include "game/level_update.h"
@ -82,6 +83,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) {

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -65,10 +65,11 @@ void djui_panel_display_create(struct DjuiBase* caller) {
djui_checkbox_create(body, DLANG(DISPLAY, FORCE_4BY3), &configForce4By3, djui_panel_display_apply);
#ifdef EXTERNAL_DATA
#ifdef EXTERNAL_DATA
djui_checkbox_create(body, DLANG(DISPLAY, PRELOAD_TEXTURES), &configPrecacheRes, NULL);
#endif
#endif
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);

View File

@ -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"
@ -194,7 +195,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;