mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-27 02:44:16 +08:00
Merge pull request #109 from otavepto/patch-stats-overlay
overlay fps/frametime/playtime
This commit is contained in:
commit
e492aec54b
@ -165,6 +165,16 @@ struct Overlay_Appearance {
|
||||
float element_active_b = -1.0f;
|
||||
float element_active_a = -1.0f;
|
||||
|
||||
float stats_background_r = 0.0f;
|
||||
float stats_background_g = 0.0f;
|
||||
float stats_background_b = 0.0f;
|
||||
float stats_background_a = 0.6f;
|
||||
|
||||
float stats_text_r = 0.8f;
|
||||
float stats_text_g = 0.7f;
|
||||
float stats_text_b = 0.0f;
|
||||
float stats_text_a = 1.0f;
|
||||
|
||||
NotificationPosition ach_earned_pos = NotificationPosition::bot_right; // achievement earned
|
||||
NotificationPosition invite_pos = default_pos; // lobby/game invitation
|
||||
NotificationPosition chat_msg_pos = NotificationPosition::top_center; // chat message from a friend
|
||||
@ -315,6 +325,9 @@ public:
|
||||
bool disable_overlay_achievement_notification = false;
|
||||
bool disable_overlay_friend_notification = false;
|
||||
bool disable_overlay_achievement_progress = false;
|
||||
unsigned overlay_fps_avg_window = 10;
|
||||
float overlay_stats_pos_x = 0.0f;
|
||||
float overlay_stats_pos_y = 0.0f;
|
||||
//warn people who use local save
|
||||
bool overlay_warn_local_save = false;
|
||||
//disable overlay warning for local save
|
||||
|
@ -376,6 +376,62 @@ static void load_overlay_appearance(class Settings *settings_client, class Setti
|
||||
auto pos = Overlay_Appearance::translate_notification_position(value);
|
||||
settings_client->overlay_appearance.chat_msg_pos = pos;
|
||||
settings_server->overlay_appearance.chat_msg_pos = pos;
|
||||
// >>> FPS background
|
||||
} else if (name.compare("Stats_Background_R") == 0) {
|
||||
float val = std::stof(value, NULL);
|
||||
settings_client->overlay_appearance.stats_background_r = val;
|
||||
settings_server->overlay_appearance.stats_background_r = val;
|
||||
} else if (name.compare("Stats_Background_G") == 0) {
|
||||
float val = std::stof(value, NULL);
|
||||
settings_client->overlay_appearance.stats_background_g = val;
|
||||
settings_server->overlay_appearance.stats_background_g = val;
|
||||
} else if (name.compare("Stats_Background_B") == 0) {
|
||||
float val = std::stof(value, NULL);
|
||||
settings_client->overlay_appearance.stats_background_b = val;
|
||||
settings_server->overlay_appearance.stats_background_b = val;
|
||||
} else if (name.compare("Stats_Background_A") == 0) {
|
||||
float val = std::stof(value, NULL);
|
||||
settings_client->overlay_appearance.stats_background_a = val;
|
||||
settings_server->overlay_appearance.stats_background_a = val;
|
||||
// FPS background END <<<
|
||||
// >>> FPS text color
|
||||
} else if (name.compare("Stats_Text_R") == 0) {
|
||||
float val = std::stof(value, NULL);
|
||||
settings_client->overlay_appearance.stats_text_r = val;
|
||||
settings_server->overlay_appearance.stats_text_r = val;
|
||||
} else if (name.compare("Stats_Text_G") == 0) {
|
||||
float val = std::stof(value, NULL);
|
||||
settings_client->overlay_appearance.stats_text_g = val;
|
||||
settings_server->overlay_appearance.stats_text_g = val;
|
||||
} else if (name.compare("Stats_Text_B") == 0) {
|
||||
float val = std::stof(value, NULL);
|
||||
settings_client->overlay_appearance.stats_text_b = val;
|
||||
settings_server->overlay_appearance.stats_text_b = val;
|
||||
} else if (name.compare("Stats_Text_A") == 0) {
|
||||
float val = std::stof(value, NULL);
|
||||
settings_client->overlay_appearance.stats_text_a = val;
|
||||
settings_server->overlay_appearance.stats_text_a = val;
|
||||
// FPS text color END <<<
|
||||
// >>> FPS position
|
||||
} else if (name.compare("Stats_Pos_x") == 0) {
|
||||
auto pos = std::stof(value);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
} else if (pos > 1.0f) {
|
||||
pos = 1.0f;
|
||||
}
|
||||
settings_client->overlay_stats_pos_x = pos;
|
||||
settings_server->overlay_stats_pos_x = pos;
|
||||
} else if (name.compare("Stats_Pos_y") == 0) {
|
||||
auto pos = std::stof(value);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
} else if (pos > 1.0f) {
|
||||
pos = 1.0f;
|
||||
}
|
||||
settings_client->overlay_stats_pos_y = pos;
|
||||
settings_server->overlay_stats_pos_y = pos;
|
||||
// FPS position END <<<
|
||||
} else {
|
||||
PRINT_DEBUG("unknown overlay appearance setting");
|
||||
}
|
||||
@ -1366,6 +1422,20 @@ static void parse_overlay_general_config(class Settings *settings_client, class
|
||||
settings_client->overlay_upload_achs_icons_to_gpu = ini.GetBoolValue("overlay::general", "upload_achievements_icons_to_gpu", settings_client->overlay_upload_achs_icons_to_gpu);
|
||||
settings_server->overlay_upload_achs_icons_to_gpu = ini.GetBoolValue("overlay::general", "upload_achievements_icons_to_gpu", settings_server->overlay_upload_achs_icons_to_gpu);
|
||||
|
||||
{
|
||||
auto val = ini.GetLongValue("overlay::general", "fps_averaging_window", settings_client->overlay_fps_avg_window);
|
||||
if (val > 0) {
|
||||
settings_client->overlay_fps_avg_window = val;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto val = ini.GetLongValue("overlay::general", "fps_averaging_window", settings_server->overlay_fps_avg_window);
|
||||
if (val > 0) {
|
||||
settings_server->overlay_fps_avg_window = val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// main::misc::steam_game_stats_reports_dir
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <memory>
|
||||
#include "InGameOverlay/RendererHook.h"
|
||||
#include "InGameOverlay/ImGui/imgui.h"
|
||||
#include "overlay/steam_overlay_stats.h"
|
||||
|
||||
static constexpr size_t max_chat_len = 768;
|
||||
|
||||
@ -109,6 +110,7 @@ class Steam_Overlay
|
||||
class SteamCallBacks* callbacks;
|
||||
class RunEveryRunCB* run_every_runcb;
|
||||
class Networking* network;
|
||||
class Steam_Overlay_Stats stats;
|
||||
|
||||
// friend id, show client window (to chat and accept invite maybe)
|
||||
std::map<Friend, friend_window_state, Friend_Less> friends{};
|
||||
|
48
overlay_experimental/overlay/steam_overlay_stats.h
Normal file
48
overlay_experimental/overlay/steam_overlay_stats.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef _STEAM_OVERLAY_STATS_H_
|
||||
#define _STEAM_OVERLAY_STATS_H_
|
||||
|
||||
#include <chrono>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include "dll/settings.h"
|
||||
#include "InGameOverlay/ImGui/imgui.h"
|
||||
|
||||
|
||||
class Steam_Overlay_Stats {
|
||||
private:
|
||||
class Settings* settings{};
|
||||
|
||||
unsigned last_frametime_idx{};
|
||||
std::chrono::high_resolution_clock::time_point last_frame_timepoint =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
unsigned running_frametime_ms = 0; // used for the ongoing calculation
|
||||
float active_frametime_ms = 0; // the final calculated frametime after averaging
|
||||
unsigned active_fps = 0; // the final calculated FPS after averaging
|
||||
|
||||
|
||||
std::chrono::high_resolution_clock::time_point initial_time =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
std::chrono::high_resolution_clock::time_point last_playtime =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
unsigned active_playtime_hr = 0;
|
||||
unsigned active_playtime_min = 0;
|
||||
unsigned active_playtime_sec = 0;
|
||||
|
||||
void update_frametime(const std::chrono::high_resolution_clock::time_point &now);
|
||||
void update_playtime(const std::chrono::high_resolution_clock::time_point &now);
|
||||
|
||||
public:
|
||||
ImFont *font = nullptr;
|
||||
bool show_fps = false;
|
||||
bool show_frametime = false;
|
||||
bool show_playtime = false;
|
||||
|
||||
Steam_Overlay_Stats(class Settings* settings);
|
||||
|
||||
bool show_any_stats() const;
|
||||
void render_stats(int current_language);
|
||||
};
|
||||
|
||||
|
||||
#endif // _STEAM_OVERLAY_STATS_H_
|
@ -1,3 +1,6 @@
|
||||
#ifndef _STEAM_OVERLAY_TRANSLATIONS_H
|
||||
#define _STEAM_OVERLAY_TRANSLATIONS_H
|
||||
|
||||
|
||||
const int TRANSLATION_NUMBER_OF_LANGUAGES = 31;
|
||||
const int TRANSLATION_BUFFER_SIZE = 256;
|
||||
@ -3477,3 +3480,678 @@ const char translationAutoAcceptFriendInvite[TRANSLATION_NUMBER_OF_LANGUAGES][TR
|
||||
u8"Invitations are controlled by auto_accept_invite.txt!",
|
||||
|
||||
};
|
||||
|
||||
const char translationFpsCheckbox[TRANSLATION_NUMBER_OF_LANGUAGES][TRANSLATION_BUFFER_SIZE] = {
|
||||
// 0 - English
|
||||
u8"FPS",
|
||||
|
||||
// 1 - Arabic
|
||||
u8"FPS",
|
||||
|
||||
// 2 - Bulgarian
|
||||
u8"FPS",
|
||||
|
||||
// 3 - Simplified Chinese
|
||||
u8"FPS",
|
||||
|
||||
// 4 - Traditional Chinese
|
||||
u8"FPS",
|
||||
|
||||
// 5 - Czech
|
||||
u8"FPS",
|
||||
|
||||
// 6 - Danish
|
||||
u8"FPS",
|
||||
|
||||
// 7 - Dutch
|
||||
u8"FPS",
|
||||
|
||||
// 8 - Finnish
|
||||
u8"FPS",
|
||||
|
||||
// 9 - French
|
||||
u8"FPS",
|
||||
|
||||
// 10 - German
|
||||
u8"FPS",
|
||||
|
||||
// 11 - Greek
|
||||
u8"FPS",
|
||||
|
||||
// 12 - Hungarian
|
||||
u8"FPS",
|
||||
|
||||
// 13 - Italian
|
||||
u8"FPS",
|
||||
|
||||
// 14 - Japanese
|
||||
u8"FPS",
|
||||
|
||||
// 15 - Korean
|
||||
u8"FPS",
|
||||
|
||||
// 16 - Norwegian
|
||||
u8"FPS",
|
||||
|
||||
// 17 - Polish
|
||||
u8"FPS",
|
||||
|
||||
// 18 - Portuguese
|
||||
u8"FPS",
|
||||
|
||||
// 19 - Brazilian Portuguese
|
||||
u8"FPS",
|
||||
|
||||
// 20 - Romanian
|
||||
u8"FPS",
|
||||
|
||||
// 21 - Russian
|
||||
u8"FPS",
|
||||
|
||||
// 22 - Spanish
|
||||
u8"FPS",
|
||||
|
||||
// 23 - Latin American
|
||||
u8"FPS",
|
||||
|
||||
// 24 - Swedish
|
||||
u8"FPS",
|
||||
|
||||
// 25 - Thai
|
||||
u8"FPS",
|
||||
|
||||
// 26 - Turkish
|
||||
u8"FPS",
|
||||
|
||||
// 27 - Ukrainian
|
||||
u8"FPS",
|
||||
|
||||
// 28 - Vietnamese
|
||||
u8"FPS",
|
||||
|
||||
// 29 - Croatian
|
||||
u8"FPS",
|
||||
|
||||
// 30 - Indonesian
|
||||
u8"FPS",
|
||||
|
||||
};
|
||||
|
||||
const char translationFpsDisplay[TRANSLATION_NUMBER_OF_LANGUAGES][TRANSLATION_BUFFER_SIZE] = {
|
||||
// 0 - English
|
||||
u8"FPS: ",
|
||||
|
||||
// 1 - Arabic
|
||||
u8"FPS: ",
|
||||
|
||||
// 2 - Bulgarian
|
||||
u8"FPS: ",
|
||||
|
||||
// 3 - Simplified Chinese
|
||||
u8"FPS: ",
|
||||
|
||||
// 4 - Traditional Chinese
|
||||
u8"FPS: ",
|
||||
|
||||
// 5 - Czech
|
||||
u8"FPS: ",
|
||||
|
||||
// 6 - Danish
|
||||
u8"FPS: ",
|
||||
|
||||
// 7 - Dutch
|
||||
u8"FPS: ",
|
||||
|
||||
// 8 - Finnish
|
||||
u8"FPS: ",
|
||||
|
||||
// 9 - French
|
||||
u8"FPS: ",
|
||||
|
||||
// 10 - German
|
||||
u8"FPS: ",
|
||||
|
||||
// 11 - Greek
|
||||
u8"FPS: ",
|
||||
|
||||
// 12 - Hungarian
|
||||
u8"FPS: ",
|
||||
|
||||
// 13 - Italian
|
||||
u8"FPS: ",
|
||||
|
||||
// 14 - Japanese
|
||||
u8"FPS: ",
|
||||
|
||||
// 15 - Korean
|
||||
u8"FPS: ",
|
||||
|
||||
// 16 - Norwegian
|
||||
u8"FPS: ",
|
||||
|
||||
// 17 - Polish
|
||||
u8"FPS: ",
|
||||
|
||||
// 18 - Portuguese
|
||||
u8"FPS: ",
|
||||
|
||||
// 19 - Brazilian Portuguese
|
||||
u8"FPS: ",
|
||||
|
||||
// 20 - Romanian
|
||||
u8"FPS: ",
|
||||
|
||||
// 21 - Russian
|
||||
u8"FPS: ",
|
||||
|
||||
// 22 - Spanish
|
||||
u8"FPS: ",
|
||||
|
||||
// 23 - Latin American
|
||||
u8"FPS: ",
|
||||
|
||||
// 24 - Swedish
|
||||
u8"FPS: ",
|
||||
|
||||
// 25 - Thai
|
||||
u8"FPS: ",
|
||||
|
||||
// 26 - Turkish
|
||||
u8"FPS: ",
|
||||
|
||||
// 27 - Ukrainian
|
||||
u8"FPS: ",
|
||||
|
||||
// 28 - Vietnamese
|
||||
u8"FPS: ",
|
||||
|
||||
// 29 - Croatian
|
||||
u8"FPS: ",
|
||||
|
||||
// 30 - Indonesian
|
||||
u8"FPS: ",
|
||||
|
||||
};
|
||||
|
||||
const char translationFrametimeCheckbox[TRANSLATION_NUMBER_OF_LANGUAGES][TRANSLATION_BUFFER_SIZE] = {
|
||||
// 0 - English
|
||||
u8"Frametime",
|
||||
|
||||
// 1 - Arabic
|
||||
u8"Frametime",
|
||||
|
||||
// 2 - Bulgarian
|
||||
u8"Frametime",
|
||||
|
||||
// 3 - Simplified Chinese
|
||||
u8"Frametime",
|
||||
|
||||
// 4 - Traditional Chinese
|
||||
u8"Frametime",
|
||||
|
||||
// 5 - Czech
|
||||
u8"Frametime",
|
||||
|
||||
// 6 - Danish
|
||||
u8"Frametime",
|
||||
|
||||
// 7 - Dutch
|
||||
u8"Frametime",
|
||||
|
||||
// 8 - Finnish
|
||||
u8"Frametime",
|
||||
|
||||
// 9 - French
|
||||
u8"Frametime",
|
||||
|
||||
// 10 - German
|
||||
u8"Frametime",
|
||||
|
||||
// 11 - Greek
|
||||
u8"Frametime",
|
||||
|
||||
// 12 - Hungarian
|
||||
u8"Frametime",
|
||||
|
||||
// 13 - Italian
|
||||
u8"Frametime",
|
||||
|
||||
// 14 - Japanese
|
||||
u8"Frametime",
|
||||
|
||||
// 15 - Korean
|
||||
u8"Frametime",
|
||||
|
||||
// 16 - Norwegian
|
||||
u8"Frametime",
|
||||
|
||||
// 17 - Polish
|
||||
u8"Frametime",
|
||||
|
||||
// 18 - Portuguese
|
||||
u8"Frametime",
|
||||
|
||||
// 19 - Brazilian Portuguese
|
||||
u8"Frametime",
|
||||
|
||||
// 20 - Romanian
|
||||
u8"Frametime",
|
||||
|
||||
// 21 - Russian
|
||||
u8"Frametime",
|
||||
|
||||
// 22 - Spanish
|
||||
u8"Frametime",
|
||||
|
||||
// 23 - Latin American
|
||||
u8"Frametime",
|
||||
|
||||
// 24 - Swedish
|
||||
u8"Frametime",
|
||||
|
||||
// 25 - Thai
|
||||
u8"Frametime",
|
||||
|
||||
// 26 - Turkish
|
||||
u8"Frametime",
|
||||
|
||||
// 27 - Ukrainian
|
||||
u8"Frametime",
|
||||
|
||||
// 28 - Vietnamese
|
||||
u8"Frametime",
|
||||
|
||||
// 29 - Croatian
|
||||
u8"Frametime",
|
||||
|
||||
// 30 - Indonesian
|
||||
u8"Frametime",
|
||||
|
||||
};
|
||||
|
||||
const char translationFrametimeDisplay[TRANSLATION_NUMBER_OF_LANGUAGES][TRANSLATION_BUFFER_SIZE] = {
|
||||
// 0 - English
|
||||
u8"FRT: ",
|
||||
|
||||
// 1 - Arabic
|
||||
u8"FRT: ",
|
||||
|
||||
// 2 - Bulgarian
|
||||
u8"FRT: ",
|
||||
|
||||
// 3 - Simplified Chinese
|
||||
u8"FRT: ",
|
||||
|
||||
// 4 - Traditional Chinese
|
||||
u8"FRT: ",
|
||||
|
||||
// 5 - Czech
|
||||
u8"FRT: ",
|
||||
|
||||
// 6 - Danish
|
||||
u8"FRT: ",
|
||||
|
||||
// 7 - Dutch
|
||||
u8"FRT: ",
|
||||
|
||||
// 8 - Finnish
|
||||
u8"FRT: ",
|
||||
|
||||
// 9 - French
|
||||
u8"FRT: ",
|
||||
|
||||
// 10 - German
|
||||
u8"FRT: ",
|
||||
|
||||
// 11 - Greek
|
||||
u8"FRT: ",
|
||||
|
||||
// 12 - Hungarian
|
||||
u8"FRT: ",
|
||||
|
||||
// 13 - Italian
|
||||
u8"FRT: ",
|
||||
|
||||
// 14 - Japanese
|
||||
u8"FRT: ",
|
||||
|
||||
// 15 - Korean
|
||||
u8"FRT: ",
|
||||
|
||||
// 16 - Norwegian
|
||||
u8"FRT: ",
|
||||
|
||||
// 17 - Polish
|
||||
u8"FRT: ",
|
||||
|
||||
// 18 - Portuguese
|
||||
u8"FRT: ",
|
||||
|
||||
// 19 - Brazilian Portuguese
|
||||
u8"FRT: ",
|
||||
|
||||
// 20 - Romanian
|
||||
u8"FRT: ",
|
||||
|
||||
// 21 - Russian
|
||||
u8"FRT: ",
|
||||
|
||||
// 22 - Spanish
|
||||
u8"FRT: ",
|
||||
|
||||
// 23 - Latin American
|
||||
u8"FRT: ",
|
||||
|
||||
// 24 - Swedish
|
||||
u8"FRT: ",
|
||||
|
||||
// 25 - Thai
|
||||
u8"FRT: ",
|
||||
|
||||
// 26 - Turkish
|
||||
u8"FRT: ",
|
||||
|
||||
// 27 - Ukrainian
|
||||
u8"FRT: ",
|
||||
|
||||
// 28 - Vietnamese
|
||||
u8"FRT: ",
|
||||
|
||||
// 29 - Croatian
|
||||
u8"FRT: ",
|
||||
|
||||
// 30 - Indonesian
|
||||
u8"FRT: ",
|
||||
|
||||
};
|
||||
|
||||
const char translationFrametimeUnitDisplay[TRANSLATION_NUMBER_OF_LANGUAGES][TRANSLATION_BUFFER_SIZE] = {
|
||||
// 0 - English
|
||||
u8" ms",
|
||||
|
||||
// 1 - Arabic
|
||||
u8" ms",
|
||||
|
||||
// 2 - Bulgarian
|
||||
u8" ms",
|
||||
|
||||
// 3 - Simplified Chinese
|
||||
u8" ms",
|
||||
|
||||
// 4 - Traditional Chinese
|
||||
u8" ms",
|
||||
|
||||
// 5 - Czech
|
||||
u8" ms",
|
||||
|
||||
// 6 - Danish
|
||||
u8" ms",
|
||||
|
||||
// 7 - Dutch
|
||||
u8" ms",
|
||||
|
||||
// 8 - Finnish
|
||||
u8" ms",
|
||||
|
||||
// 9 - French
|
||||
u8" ms",
|
||||
|
||||
// 10 - German
|
||||
u8" ms",
|
||||
|
||||
// 11 - Greek
|
||||
u8" ms",
|
||||
|
||||
// 12 - Hungarian
|
||||
u8" ms",
|
||||
|
||||
// 13 - Italian
|
||||
u8" ms",
|
||||
|
||||
// 14 - Japanese
|
||||
u8" ms",
|
||||
|
||||
// 15 - Korean
|
||||
u8" ms",
|
||||
|
||||
// 16 - Norwegian
|
||||
u8" ms",
|
||||
|
||||
// 17 - Polish
|
||||
u8" ms",
|
||||
|
||||
// 18 - Portuguese
|
||||
u8" ms",
|
||||
|
||||
// 19 - Brazilian Portuguese
|
||||
u8" ms",
|
||||
|
||||
// 20 - Romanian
|
||||
u8" ms",
|
||||
|
||||
// 21 - Russian
|
||||
u8" ms",
|
||||
|
||||
// 22 - Spanish
|
||||
u8" ms",
|
||||
|
||||
// 23 - Latin American
|
||||
u8" ms",
|
||||
|
||||
// 24 - Swedish
|
||||
u8" ms",
|
||||
|
||||
// 25 - Thai
|
||||
u8" ms",
|
||||
|
||||
// 26 - Turkish
|
||||
u8" ms",
|
||||
|
||||
// 27 - Ukrainian
|
||||
u8" ms",
|
||||
|
||||
// 28 - Vietnamese
|
||||
u8" ms",
|
||||
|
||||
// 29 - Croatian
|
||||
u8" ms",
|
||||
|
||||
// 30 - Indonesian
|
||||
u8" ms",
|
||||
|
||||
};
|
||||
|
||||
const char translationPlaytimeCheckbox[TRANSLATION_NUMBER_OF_LANGUAGES][TRANSLATION_BUFFER_SIZE] = {
|
||||
// 0 - English
|
||||
u8"Playtime",
|
||||
|
||||
// 1 - Arabic
|
||||
u8"Playtime",
|
||||
|
||||
// 2 - Bulgarian
|
||||
u8"Playtime",
|
||||
|
||||
// 3 - Simplified Chinese
|
||||
u8"Playtime",
|
||||
|
||||
// 4 - Traditional Chinese
|
||||
u8"Playtime",
|
||||
|
||||
// 5 - Czech
|
||||
u8"Playtime",
|
||||
|
||||
// 6 - Danish
|
||||
u8"Playtime",
|
||||
|
||||
// 7 - Dutch
|
||||
u8"Playtime",
|
||||
|
||||
// 8 - Finnish
|
||||
u8"Playtime",
|
||||
|
||||
// 9 - French
|
||||
u8"Playtime",
|
||||
|
||||
// 10 - German
|
||||
u8"Playtime",
|
||||
|
||||
// 11 - Greek
|
||||
u8"Playtime",
|
||||
|
||||
// 12 - Hungarian
|
||||
u8"Playtime",
|
||||
|
||||
// 13 - Italian
|
||||
u8"Playtime",
|
||||
|
||||
// 14 - Japanese
|
||||
u8"Playtime",
|
||||
|
||||
// 15 - Korean
|
||||
u8"Playtime",
|
||||
|
||||
// 16 - Norwegian
|
||||
u8"Playtime",
|
||||
|
||||
// 17 - Polish
|
||||
u8"Playtime",
|
||||
|
||||
// 18 - Portuguese
|
||||
u8"Playtime",
|
||||
|
||||
// 19 - Brazilian Portuguese
|
||||
u8"Playtime",
|
||||
|
||||
// 20 - Romanian
|
||||
u8"Playtime",
|
||||
|
||||
// 21 - Russian
|
||||
u8"Playtime",
|
||||
|
||||
// 22 - Spanish
|
||||
u8"Playtime",
|
||||
|
||||
// 23 - Latin American
|
||||
u8"Playtime",
|
||||
|
||||
// 24 - Swedish
|
||||
u8"Playtime",
|
||||
|
||||
// 25 - Thai
|
||||
u8"Playtime",
|
||||
|
||||
// 26 - Turkish
|
||||
u8"Playtime",
|
||||
|
||||
// 27 - Ukrainian
|
||||
u8"Playtime",
|
||||
|
||||
// 28 - Vietnamese
|
||||
u8"Playtime",
|
||||
|
||||
// 29 - Croatian
|
||||
u8"Playtime",
|
||||
|
||||
// 30 - Indonesian
|
||||
u8"Playtime",
|
||||
|
||||
};
|
||||
|
||||
const char translationPlaytimeDisplay[TRANSLATION_NUMBER_OF_LANGUAGES][TRANSLATION_BUFFER_SIZE] = {
|
||||
// 0 - English
|
||||
u8"PLT: ",
|
||||
|
||||
// 1 - Arabic
|
||||
u8"PLT: ",
|
||||
|
||||
// 2 - Bulgarian
|
||||
u8"PLT: ",
|
||||
|
||||
// 3 - Simplified Chinese
|
||||
u8"PLT: ",
|
||||
|
||||
// 4 - Traditional Chinese
|
||||
u8"PLT: ",
|
||||
|
||||
// 5 - Czech
|
||||
u8"PLT: ",
|
||||
|
||||
// 6 - Danish
|
||||
u8"PLT: ",
|
||||
|
||||
// 7 - Dutch
|
||||
u8"PLT: ",
|
||||
|
||||
// 8 - Finnish
|
||||
u8"PLT: ",
|
||||
|
||||
// 9 - French
|
||||
u8"PLT: ",
|
||||
|
||||
// 10 - German
|
||||
u8"PLT: ",
|
||||
|
||||
// 11 - Greek
|
||||
u8"PLT: ",
|
||||
|
||||
// 12 - Hungarian
|
||||
u8"PLT: ",
|
||||
|
||||
// 13 - Italian
|
||||
u8"PLT: ",
|
||||
|
||||
// 14 - Japanese
|
||||
u8"PLT: ",
|
||||
|
||||
// 15 - Korean
|
||||
u8"PLT: ",
|
||||
|
||||
// 16 - Norwegian
|
||||
u8"PLT: ",
|
||||
|
||||
// 17 - Polish
|
||||
u8"PLT: ",
|
||||
|
||||
// 18 - Portuguese
|
||||
u8"PLT: ",
|
||||
|
||||
// 19 - Brazilian Portuguese
|
||||
u8"PLT: ",
|
||||
|
||||
// 20 - Romanian
|
||||
u8"PLT: ",
|
||||
|
||||
// 21 - Russian
|
||||
u8"PLT: ",
|
||||
|
||||
// 22 - Spanish
|
||||
u8"PLT: ",
|
||||
|
||||
// 23 - Latin American
|
||||
u8"PLT: ",
|
||||
|
||||
// 24 - Swedish
|
||||
u8"PLT: ",
|
||||
|
||||
// 25 - Thai
|
||||
u8"PLT: ",
|
||||
|
||||
// 26 - Turkish
|
||||
u8"PLT: ",
|
||||
|
||||
// 27 - Ukrainian
|
||||
u8"PLT: ",
|
||||
|
||||
// 28 - Vietnamese
|
||||
u8"PLT: ",
|
||||
|
||||
// 29 - Croatian
|
||||
u8"PLT: ",
|
||||
|
||||
// 30 - Indonesian
|
||||
u8"PLT: ",
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // _STEAM_OVERLAY_TRANSLATIONS_H
|
||||
|
@ -101,7 +101,8 @@ Steam_Overlay::Steam_Overlay(Settings* settings, Local_Storage *local_storage, S
|
||||
callback_results(callback_results),
|
||||
callbacks(callbacks),
|
||||
run_every_runcb(run_every_runcb),
|
||||
network(network)
|
||||
network(network),
|
||||
stats(Steam_Overlay_Stats(settings))
|
||||
{
|
||||
// don't even bother initializing the overlay
|
||||
if (settings->disable_overlay) return;
|
||||
@ -299,6 +300,7 @@ void Steam_Overlay::create_fonts()
|
||||
// note: base85 compressed arrays caused a compiler heap allocation error, regular compression is more guaranteed
|
||||
ImFont *font = fonts_atlas.AddFontFromMemoryCompressedTTF(unifont_compressed_data, unifont_compressed_size, font_size, &font_cfg);
|
||||
font_notif = font_default = font;
|
||||
stats.font = font;
|
||||
|
||||
bool res = fonts_atlas.Build();
|
||||
PRINT_DEBUG("created fonts atlas (result=%i)", (int)res);
|
||||
@ -1253,6 +1255,10 @@ void Steam_Overlay::overlay_render_proc()
|
||||
build_notifications(io.DisplaySize.x, io.DisplaySize.y);
|
||||
}
|
||||
|
||||
if (stats.show_any_stats()) {
|
||||
stats.render_stats(current_language);
|
||||
}
|
||||
|
||||
load_next_ach_icon();
|
||||
}
|
||||
|
||||
@ -1390,6 +1396,24 @@ void Steam_Overlay::render_main_window()
|
||||
show_settings = !show_settings;
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
// user clicked on "FPS"
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Checkbox(translationFpsCheckbox[current_language], &stats.show_fps)) {
|
||||
allow_renderer_frame_processing(stats.show_fps);
|
||||
}
|
||||
// user clicked on "Frametime"
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Checkbox(translationFrametimeCheckbox[current_language], &stats.show_frametime)) {
|
||||
allow_renderer_frame_processing(stats.show_frametime);
|
||||
}
|
||||
// user clicked on "Playtime"
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Checkbox(translationPlaytimeCheckbox[current_language], &stats.show_playtime)) {
|
||||
allow_renderer_frame_processing(stats.show_playtime);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
ImGui::LabelText("##label", "%s", translationFriends[current_language]);
|
||||
|
149
overlay_experimental/steam_overlay_stats.cpp
Normal file
149
overlay_experimental/steam_overlay_stats.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
#include "overlay/steam_overlay_stats.h"
|
||||
// translation
|
||||
#include "overlay/steam_overlay_translations.h"
|
||||
#include <utility>
|
||||
|
||||
|
||||
Steam_Overlay_Stats::Steam_Overlay_Stats(class Settings* settings):
|
||||
settings(settings)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Steam_Overlay_Stats::show_any_stats() const
|
||||
{
|
||||
return show_fps || show_frametime || show_playtime;
|
||||
}
|
||||
|
||||
void Steam_Overlay_Stats::update_frametime(const std::chrono::high_resolution_clock::time_point &now)
|
||||
{
|
||||
running_frametime_ms += static_cast<unsigned>(
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(now - last_frame_timepoint).count()
|
||||
);
|
||||
last_frame_timepoint = now;
|
||||
if (last_frametime_idx >= (settings->overlay_fps_avg_window - 1)) {
|
||||
last_frametime_idx = 0;
|
||||
active_frametime_ms = static_cast<float>(running_frametime_ms) / settings->overlay_fps_avg_window;
|
||||
if (running_frametime_ms > 0) {
|
||||
active_fps = static_cast<unsigned>((1000 * settings->overlay_fps_avg_window) / running_frametime_ms);
|
||||
} else { // happens when avg window =1, no idea why!
|
||||
active_fps = 999;
|
||||
}
|
||||
running_frametime_ms = 0;
|
||||
} else {
|
||||
++last_frametime_idx;
|
||||
}
|
||||
}
|
||||
|
||||
void Steam_Overlay_Stats::update_playtime(const std::chrono::high_resolution_clock::time_point &now)
|
||||
{
|
||||
const auto update_duration_sec = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
now - last_playtime
|
||||
).count();
|
||||
if (update_duration_sec < 1) return;
|
||||
|
||||
last_playtime = now;
|
||||
|
||||
const auto time_duration_sec = (unsigned long long)std::chrono::duration_cast<std::chrono::seconds>(
|
||||
now - initial_time
|
||||
).count();
|
||||
active_playtime_sec = static_cast<unsigned>(time_duration_sec % 60);
|
||||
|
||||
const auto time_duration_min = time_duration_sec / 60;
|
||||
active_playtime_min = static_cast<unsigned>(time_duration_min % 60);
|
||||
|
||||
const auto time_duration_hr = time_duration_min / 60;
|
||||
active_playtime_hr = static_cast<unsigned>(time_duration_hr % 24);
|
||||
}
|
||||
|
||||
void Steam_Overlay_Stats::render_stats(int current_language)
|
||||
{
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
if (show_fps || show_frametime) {
|
||||
update_frametime(now);
|
||||
}
|
||||
if (show_playtime) {
|
||||
update_playtime(now);
|
||||
}
|
||||
|
||||
ImGui::PushFont(font);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, settings->overlay_appearance.notification_rounding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(
|
||||
settings->overlay_appearance.stats_background_r,
|
||||
settings->overlay_appearance.stats_background_g,
|
||||
settings->overlay_appearance.stats_background_b,
|
||||
settings->overlay_appearance.stats_background_a
|
||||
));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(
|
||||
settings->overlay_appearance.stats_text_r,
|
||||
settings->overlay_appearance.stats_text_g,
|
||||
settings->overlay_appearance.stats_text_b,
|
||||
settings->overlay_appearance.stats_text_a
|
||||
));
|
||||
|
||||
std::stringstream stats_txt_buff{};
|
||||
if (show_fps) {
|
||||
stats_txt_buff << translationFpsDisplay[current_language]
|
||||
<< std::left << std::setw(2)
|
||||
<< active_fps
|
||||
<< std::right << std::setw(0);
|
||||
}
|
||||
if (show_frametime) {
|
||||
if (stats_txt_buff.tellp() > 0) {
|
||||
stats_txt_buff << " | ";
|
||||
}
|
||||
stats_txt_buff << translationFrametimeDisplay[current_language]
|
||||
<< std::left << std::setw(4) << std::fixed << std::setprecision(1)
|
||||
<< active_frametime_ms
|
||||
<< std::defaultfloat << std::right << std::setw(0)
|
||||
<< translationFrametimeUnitDisplay[current_language];
|
||||
}
|
||||
if (show_playtime) {
|
||||
if (stats_txt_buff.tellp() > 0) {
|
||||
stats_txt_buff << " | ";
|
||||
}
|
||||
const auto org_fill = stats_txt_buff.fill();
|
||||
stats_txt_buff << translationPlaytimeDisplay[current_language]
|
||||
<< std::setw(2) << std::setfill('0')
|
||||
<< active_playtime_hr << ':'
|
||||
<< std::setw(2) << std::setfill('0')
|
||||
<< active_playtime_min << ':'
|
||||
<< std::setw(2) << std::setfill('0')
|
||||
<< active_playtime_sec
|
||||
<< std::setw(0) << std::setfill(org_fill);
|
||||
}
|
||||
const auto stats_txt = stats_txt_buff.str();
|
||||
|
||||
// set FPS box width/height based on text size
|
||||
const auto msg_box = ImGui::CalcTextSize(
|
||||
stats_txt.c_str(),
|
||||
stats_txt.c_str() + stats_txt.size()
|
||||
);
|
||||
auto &global_style = ImGui::GetStyle();
|
||||
const float padding_all_sides = global_style.WindowPadding.y + global_style.WindowPadding.x;
|
||||
const auto stats_box = ImVec2(msg_box.x + padding_all_sides, msg_box.y + padding_all_sides);
|
||||
ImGui::SetNextWindowSize(stats_box);
|
||||
|
||||
auto &io = ImGui::GetIO();
|
||||
const auto anchor_point_x = stats_box.x * settings->overlay_stats_pos_x;
|
||||
const auto anchor_point_y = stats_box.y * settings->overlay_stats_pos_y;
|
||||
ImGui::SetNextWindowPos({
|
||||
io.DisplaySize.x * settings->overlay_stats_pos_x - anchor_point_x,
|
||||
io.DisplaySize.y * settings->overlay_stats_pos_y - anchor_point_y
|
||||
});
|
||||
|
||||
if (ImGui::Begin("wnd_fps_frametime", nullptr,
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoInputs |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollWithMouse)) {
|
||||
ImGui::TextWrapped("%s", stats_txt.c_str());
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::PopFont();
|
||||
}
|
@ -44,6 +44,12 @@ disable_warning_local_save=0
|
||||
# in that case achievements icons win't be displayed
|
||||
# default=1
|
||||
upload_achievements_icons_to_gpu=1
|
||||
# amount of frames to accumulate, to eventually calculate the average frametime (in milliseconds)
|
||||
# lower values would result in instantaneous frametime/fps, but the FPS would be erratic
|
||||
# higher values would result in a more stable frametime/fps, but will be inaccurate due to averaging over long time
|
||||
# minimum allowed value = 1
|
||||
# default=10
|
||||
fps_averaging_window=10
|
||||
|
||||
[overlay::appearance]
|
||||
# load custom TrueType font from a path, it could be absolute, or relative
|
||||
@ -130,3 +136,26 @@ PosInvitation=top_right
|
||||
# position of chat messages
|
||||
PosChatMsg=top_center
|
||||
# ############################# #
|
||||
|
||||
# ############################# #
|
||||
# FPS background color
|
||||
Stats_Background_R=0.0
|
||||
Stats_Background_G=0.0
|
||||
Stats_Background_B=0.0
|
||||
Stats_Background_A=0.6
|
||||
|
||||
# FPS text color
|
||||
Stats_Text_R=0.8
|
||||
Stats_Text_G=0.7
|
||||
Stats_Text_B=0.0
|
||||
Stats_Text_A=1.0
|
||||
|
||||
# FPS position in percentage [0.0, 1.0]
|
||||
# X=0.0 : left
|
||||
# X=1.0 : right
|
||||
Stats_Pos_x=0.0
|
||||
|
||||
# Y=0.0 : up
|
||||
# Y=1.0 : down
|
||||
Stats_Pos_y=0.0
|
||||
# ############################# #
|
||||
|
Loading…
x
Reference in New Issue
Block a user