Add achievements display to overlay and ability to change some settings.

This commit is contained in:
Mr_Goldberg 2022-08-05 02:09:43 -04:00
parent c17fb0c931
commit 5e880cd974
No known key found for this signature in database
GPG key ID: 8597D87419DEF278
11 changed files with 411 additions and 36 deletions

View file

@ -76,6 +76,16 @@ const char *Settings::get_language()
return language.c_str();
}
void Settings::set_local_name(char *name)
{
this->name = name;
}
void Settings::set_language(char *language)
{
this->language = language;
}
void Settings::set_game_id(CGameID game_id)
{
this->game_id = game_id;

View file

@ -92,7 +92,10 @@ public:
CSteamID get_local_steam_id();
CGameID get_local_game_id();
const char *get_local_name();
void set_local_name(char *name);
const char *get_language();
void set_language(char *language);
void set_game_id(CGameID game_id);
void set_lobby(CSteamID lobby_id);
CSteamID get_lobby();
@ -155,6 +158,12 @@ public:
//make lobby creation fail in the matchmaking interface
bool disable_lobby_creation = false;
//warn people who use force_ settings
bool warn_forced = false;
//warn people who use local save
bool warn_local_save = false;
};
#endif

View file

@ -180,10 +180,13 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
}
}
bool local_save = false;
{
char array[33] = {};
if (Local_Storage::get_file_data(program_path + "local_save.txt", array, sizeof(array) - 1) != -1) {
save_path = program_path + Settings::sanitize(array);
local_save = true;
}
}
@ -263,6 +266,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
bool disable_lobby_creation = false;
int build_id = 10;
bool warn_forced = false;
{
std::string steam_settings_path = Local_Storage::get_game_settings_path();
@ -279,22 +284,32 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
disable_lobby_creation = true;
} else if (p == "force_language.txt") {
int len = Local_Storage::get_file_data(steam_settings_path + "force_language.txt", language, sizeof(language) - 1);
if (len > 0) language[len] = 0;
if (len > 0) {
language[len] = 0;
warn_forced = true;
}
} else if (p == "force_steamid.txt") {
char steam_id_text[32] = {};
if (Local_Storage::get_file_data(steam_settings_path + "force_steamid.txt", steam_id_text, sizeof(steam_id_text) - 1) > 0) {
CSteamID temp_id = CSteamID((uint64)std::atoll(steam_id_text));
if (temp_id.IsValid()) {
user_id = temp_id;
warn_forced = true;
}
}
} else if (p == "force_account_name.txt") {
int len = Local_Storage::get_file_data(steam_settings_path + "force_account_name.txt", name, sizeof(name) - 1);
if (len > 0) name[len] = 0;
if (len > 0) {
name[len] = 0;
warn_forced = true;
}
} else if (p == "force_listen_port.txt") {
char array_port[10] = {};
int len = Local_Storage::get_file_data(steam_settings_path + "force_listen_port.txt", array_port, sizeof(array_port) - 1);
if (len > 0) port = std::stoi(array_port);
if (len > 0) {
port = std::stoi(array_port);
warn_forced = true;
}
} else if (p == "build_id.txt") {
char array_id[10] = {};
int len = Local_Storage::get_file_data(steam_settings_path + "build_id.txt", array_id, sizeof(array_id) - 1);
@ -317,6 +332,10 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
settings_server->disable_lobby_creation = disable_lobby_creation;
settings_client->build_id = build_id;
settings_server->build_id = build_id;
settings_client->warn_forced = warn_forced;
settings_server->warn_forced = warn_forced;
settings_client->warn_local_save = local_save;
settings_server->warn_local_save = local_save;
{
std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt";
@ -571,3 +590,9 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
return appid;
}
void save_global_settings(Local_Storage *local_storage, char *name, char *language)
{
local_storage->store_data_settings("account_name.txt", name, strlen(name));
local_storage->store_data_settings("language.txt", language, strlen(language));
}

View file

@ -22,6 +22,6 @@
//returns appid
uint32 create_localstorage_settings(Settings **settings_client_out, Settings **settings_server_out, Local_Storage **local_storage_out);
void save_global_settings(Local_Storage *local_storage, char *name, char *language);
#endif

View file

@ -133,6 +133,11 @@ static void steam_friends_run_every_runcb(void *object)
steam_friends->RunCallbacks();
}
void resend_friend_data()
{
modified = true;
}
Steam_Friends(Settings* settings, Networking* network, SteamCallResults* callback_results, SteamCallBacks* callbacks, RunEveryRunCB* run_every_runcb, Steam_Overlay* overlay):
settings(settings),
network(network),
@ -550,7 +555,8 @@ void ActivateGameOverlayToUser( const char *pchDialog, CSteamID steamID )
// full address with protocol type is required, e.g. http://www.steamgames.com/
void ActivateGameOverlayToWebPage( const char *pchURL, EActivateGameOverlayToWebPageMode eMode = k_EActivateGameOverlayToWebPageMode_Default )
{
PRINT_DEBUG("Steam_Friends::ActivateGameOverlayToWebPage\n");
PRINT_DEBUG("Steam_Friends::ActivateGameOverlayToWebPage %s %u\n", pchURL, eMode);
overlay->OpenOverlayWebpage(pchURL);
}
void ActivateGameOverlayToWebPage( const char *pchURL )
@ -721,13 +727,13 @@ bool SetRichPresence( const char *pchKey, const char *pchValue )
auto prev_value = (*us.mutable_rich_presence()).find(pchKey);
if (prev_value == (*us.mutable_rich_presence()).end() || prev_value->second != pchValue) {
(*us.mutable_rich_presence())[pchKey] = pchValue;
modified = true;
resend_friend_data();
}
} else {
auto to_remove = us.mutable_rich_presence()->find(pchKey);
if (to_remove != us.mutable_rich_presence()->end()) {
us.mutable_rich_presence()->erase(to_remove);
modified = true;
resend_friend_data();
}
}
@ -739,7 +745,7 @@ void ClearRichPresence()
PRINT_DEBUG("Steam_Friends::ClearRichPresence\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
us.mutable_rich_presence()->clear();
modified = true;
resend_friend_data();
}
@ -1053,7 +1059,7 @@ void RunCallbacks()
PRINT_DEBUG("Steam_Friends::RunCallbacks\n");
if (settings->get_lobby() != lobby_id) {
lobby_id = settings->get_lobby();
modified = true;
resend_friend_data();
}
if (modified) {