diff --git a/dll/settings.h b/dll/settings.h index 1f7a6602..43b8c6bc 100644 --- a/dll/settings.h +++ b/dll/settings.h @@ -101,6 +101,26 @@ struct Group_Clans { struct Overlay_Appearance { float font_size = 16.0; float icon_size = 64.0; + float notification_r = 0.16; + float notification_g = 0.29; + float notification_b = 0.48; + float notification_a = 1.0; + float background_r = -1.0; + float background_g = -1.0; + float background_b = -1.0; + float background_a = -1.0; + float element_r = -1.0; + float element_g = -1.0; + float element_b = -1.0; + float element_a = -1.0; + float element_hovered_r = -1.0; + float element_hovered_g = -1.0; + float element_hovered_b = -1.0; + float element_hovered_a = -1.0; + float element_active_r = -1.0; + float element_active_g = -1.0; + float element_active_b = -1.0; + float element_active_a = -1.0; }; class Settings { @@ -174,6 +194,8 @@ public: //stats std::map getStats() { return stats; } void setStatDefiniton(std::string name, struct Stat_config stat_config) {stats[ascii_to_lowercase(name)] = stat_config; } + // bypass to make SetAchievement() always return true, prevent some games from breaking + bool achievement_bypass = false; //subscribed lobby/group ids std::set subscribed_groups; @@ -198,6 +220,7 @@ public: bool disable_overlay = false; bool disable_overlay_achievement_notification = false; bool disable_overlay_friend_notification = false; + bool disable_overlay_warning = false; Overlay_Appearance overlay_appearance; //app build id diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 6d6e7673..877e7f4b 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -102,13 +102,93 @@ static void load_overlay_appearance(std::string appearance_filepath, Settings *s try { if (name.compare("Font_Size") == 0) { - float nfont_size = std::stoull(value, NULL, 0); + float nfont_size = std::stof(value, NULL); settings_client->overlay_appearance.font_size = nfont_size; settings_server->overlay_appearance.font_size = nfont_size; } else if (name.compare("Icon_Size") == 0) { - float nicon_size = std::stoull(value, NULL, 0); + float nicon_size = std::stof(value, NULL); settings_client->overlay_appearance.icon_size = nicon_size; settings_server->overlay_appearance.icon_size = nicon_size; + } else if (name.compare("Notification_R") == 0) { + float nnotification_r = std::stof(value, NULL); + settings_client->overlay_appearance.notification_r = nnotification_r; + settings_server->overlay_appearance.notification_r = nnotification_r; + } else if (name.compare("Notification_G") == 0) { + float nnotification_g = std::stof(value, NULL); + settings_client->overlay_appearance.notification_g = nnotification_g; + settings_server->overlay_appearance.notification_g = nnotification_g; + } else if (name.compare("Notification_B") == 0) { + float nnotification_b = std::stof(value, NULL); + settings_client->overlay_appearance.notification_b = nnotification_b; + settings_server->overlay_appearance.notification_b = nnotification_b; + } else if (name.compare("Notification_A") == 0) { + float nnotification_a = std::stof(value, NULL); + settings_client->overlay_appearance.notification_a = nnotification_a; + settings_server->overlay_appearance.notification_a = nnotification_a; + } else if (name.compare("Background_R") == 0) { + float nbackground_r = std::stof(value, NULL); + settings_client->overlay_appearance.background_r = nbackground_r; + settings_server->overlay_appearance.background_r = nbackground_r; + } else if (name.compare("Background_G") == 0) { + float nbackground_g = std::stof(value, NULL); + settings_client->overlay_appearance.background_g = nbackground_g; + settings_server->overlay_appearance.background_g = nbackground_g; + } else if (name.compare("Background_B") == 0) { + float nbackground_b = std::stof(value, NULL); + settings_client->overlay_appearance.background_b = nbackground_b; + settings_server->overlay_appearance.background_b = nbackground_b; + } else if (name.compare("Background_A") == 0) { + float nbackground_a = std::stof(value, NULL); + settings_client->overlay_appearance.background_a = nbackground_a; + settings_server->overlay_appearance.background_a = nbackground_a; + } else if (name.compare("Element_R") == 0) { + float nelement_r = std::stof(value, NULL); + settings_client->overlay_appearance.element_r = nelement_r; + settings_server->overlay_appearance.element_r = nelement_r; + } else if (name.compare("Element_G") == 0) { + float nelement_g = std::stof(value, NULL); + settings_client->overlay_appearance.element_g = nelement_g; + settings_server->overlay_appearance.element_g = nelement_g; + } else if (name.compare("Element_B") == 0) { + float nelement_b = std::stof(value, NULL); + settings_client->overlay_appearance.element_b = nelement_b; + settings_server->overlay_appearance.element_b = nelement_b; + } else if (name.compare("Element_A") == 0) { + float nelement_a = std::stof(value, NULL); + settings_client->overlay_appearance.element_a = nelement_a; + settings_server->overlay_appearance.element_a = nelement_a; + } else if (name.compare("ElementHovered_R") == 0) { + float nelement_hovered_r = std::stof(value, NULL); + settings_client->overlay_appearance.element_hovered_r = nelement_hovered_r; + settings_server->overlay_appearance.element_hovered_r = nelement_hovered_r; + } else if (name.compare("ElementHovered_G") == 0) { + float nelement_hovered_g = std::stof(value, NULL); + settings_client->overlay_appearance.element_hovered_g = nelement_hovered_g; + settings_server->overlay_appearance.element_hovered_g = nelement_hovered_g; + } else if (name.compare("ElementHovered_B") == 0) { + float nelement_hovered_b = std::stof(value, NULL); + settings_client->overlay_appearance.element_hovered_b = nelement_hovered_b; + settings_server->overlay_appearance.element_hovered_b = nelement_hovered_b; + } else if (name.compare("ElementHovered_A") == 0) { + float nelement_hovered_a = std::stof(value, NULL); + settings_client->overlay_appearance.element_hovered_a = nelement_hovered_a; + settings_server->overlay_appearance.element_hovered_a = nelement_hovered_a; + } else if (name.compare("ElementActive_R") == 0) { + float nelement_active_r = std::stof(value, NULL); + settings_client->overlay_appearance.element_active_r = nelement_active_r; + settings_server->overlay_appearance.element_active_r = nelement_active_r; + } else if (name.compare("ElementActive_G") == 0) { + float nelement_active_g = std::stof(value, NULL); + settings_client->overlay_appearance.element_active_g = nelement_active_g; + settings_server->overlay_appearance.element_active_g = nelement_active_g; + } else if (name.compare("ElementActive_B") == 0) { + float nelement_active_b = std::stof(value, NULL); + settings_client->overlay_appearance.element_active_b = nelement_active_b; + settings_server->overlay_appearance.element_active_b = nelement_active_b; + } else if (name.compare("ElementActive_A") == 0) { + float nelement_active_a = std::stof(value, NULL); + settings_client->overlay_appearance.element_active_a = nelement_active_a; + settings_server->overlay_appearance.element_active_a = nelement_active_a; } PRINT_DEBUG("Overlay appearance %s %s\n", name.c_str(), value.c_str()); } catch (...) {} @@ -376,9 +456,11 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s bool disable_overlay = false; bool disable_overlay_achievement_notification = false; bool disable_overlay_friend_notification = false; + bool disable_overlay_warning = false; bool disable_lobby_creation = false; bool disable_source_query = false; bool disable_account_avatar = false; + bool achievement_bypass = false; int build_id = 10; bool warn_forced = false; @@ -403,12 +485,16 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s disable_overlay_achievement_notification = true; } else if (p == "disable_overlay_friend_notification.txt") { disable_overlay_friend_notification = true; + } else if (p == "disable_overlay_warning.txt") { + disable_overlay_warning = true; } else if (p == "disable_lobby_creation.txt") { disable_lobby_creation = true; } else if (p == "disable_source_query.txt") { disable_source_query = true; } else if (p == "disable_account_avatar.txt") { disable_account_avatar = true; + } else if (p == "achievements_bypass.txt") { + achievement_bypass = 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) { @@ -459,6 +545,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s settings_server->disable_overlay_achievement_notification = disable_overlay_achievement_notification; settings_client->disable_overlay_friend_notification = disable_overlay_friend_notification; settings_server->disable_overlay_friend_notification = disable_overlay_friend_notification; + settings_client->disable_overlay_warning = disable_overlay_warning; + settings_server->disable_overlay_warning = disable_overlay_warning; settings_client->disable_lobby_creation = disable_lobby_creation; settings_server->disable_lobby_creation = disable_lobby_creation; settings_client->disable_source_query = disable_source_query; @@ -477,6 +565,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s settings_server->steam_deck = steam_deck_mode; settings_client->http_online = steamhttp_online_mode; settings_server->http_online = steamhttp_online_mode; + settings_client->achievement_bypass = achievement_bypass; + settings_server->achievement_bypass = achievement_bypass; if (local_save) { settings_client->local_save = save_path; diff --git a/dll/steam_controller.h b/dll/steam_controller.h index db04d603..ec8fcbf9 100644 --- a/dll/steam_controller.h +++ b/dll/steam_controller.h @@ -1121,7 +1121,7 @@ const char *GetGlyphPNGForActionOrigin( EInputActionOrigin eOrigin, ESteamInputG { PRINT_DEBUG("TODO %s\n", __FUNCTION__); //TODO SteamInput005 - return ""; + return GetGlyphForActionOrigin(eOrigin); } // Get a local path to a SVG file for the provided origin's glyph. diff --git a/dll/steam_user_stats.h b/dll/steam_user_stats.h index 5f348c4d..b8bb5a9a 100644 --- a/dll/steam_user_stats.h +++ b/dll/steam_user_stats.h @@ -487,6 +487,9 @@ bool SetAchievement( const char *pchName ) { PRINT_DEBUG("SetAchievement %s\n", pchName); if (pchName == nullptr) return false; + + if (settings->achievement_bypass) return true; + std::lock_guard lock(global_mutex); try { diff --git a/files_example/steam_settings.EXAMPLE/achievements_bypass.EXAMPLE.txt b/files_example/steam_settings.EXAMPLE/achievements_bypass.EXAMPLE.txt new file mode 100644 index 00000000..57fbe3be --- /dev/null +++ b/files_example/steam_settings.EXAMPLE/achievements_bypass.EXAMPLE.txt @@ -0,0 +1 @@ +Rename this to: achievements_bypass.txt to make SetAchievement() always return true. \ No newline at end of file diff --git a/files_example/steam_settings.EXAMPLE/disable_overlay_warning.EXAMPLE.txt b/files_example/steam_settings.EXAMPLE/disable_overlay_warning.EXAMPLE.txt new file mode 100644 index 00000000..fac731f1 --- /dev/null +++ b/files_example/steam_settings.EXAMPLE/disable_overlay_warning.EXAMPLE.txt @@ -0,0 +1 @@ +Rename this to: disable_overlay_warning.txt to disable the local_save warning. \ No newline at end of file diff --git a/files_example/steam_settings.EXAMPLE/overlay_appearance.EXAMPLE.txt b/files_example/steam_settings.EXAMPLE/overlay_appearance.EXAMPLE.txt index 811c98ce..ff06aaf3 100644 --- a/files_example/steam_settings.EXAMPLE/overlay_appearance.EXAMPLE.txt +++ b/files_example/steam_settings.EXAMPLE/overlay_appearance.EXAMPLE.txt @@ -1,2 +1,22 @@ Font_Size 16.0 -Icon_Size 64.0 \ No newline at end of file +Icon_Size 64.0 +Notification_R 0.16 +Notification_G 0.29 +Notification_B 0.48 +Notification_A 1.0 +Background_R 0.0 +Background_G 0.0 +Background_B 0.1 +Background_A 0.5 +Element_R 0.0 +Element_G 0.1 +Element_B 0.0 +Element_A 1.0 +ElementHovered_R 0.0 +ElementHovered_G 0.5 +ElementHovered_B 0.0 +ElementHovered_A 1.0 +ElementActive_R 0.0 +ElementActive_G 0.75 +ElementActive_B 0.0 +ElementActive_A 1.0 \ No newline at end of file diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index 21ff3b40..db0cb1e5 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -452,6 +452,10 @@ void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach) // Load achievement image std::string file_path = Local_Storage::get_game_settings_path() + ach["icon"].get(); unsigned long long file_size = file_size_(file_path); + if (!file_size) { + file_path = Local_Storage::get_game_settings_path() + "achievement_images/" + ach["icon"].get(); + file_size = file_size_(file_path); + } if (file_size) { std::string img = Local_Storage::load_image_resized(file_path, "", settings->overlay_appearance.icon_size); if (img.length() > 0) { @@ -695,23 +699,23 @@ void Steam_Overlay::BuildNotifications(int width, int height) if ( elapsed_notif < Notification::fade_in) { - float alpha = Notification::max_alpha * (elapsed_notif.count() / static_cast(Notification::fade_in.count())); + float alpha = settings->overlay_appearance.notification_a * (elapsed_notif.count() / static_cast(Notification::fade_in.count())); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, alpha)); - ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(Notification::r, Notification::g, Notification::b, alpha)); + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(settings->overlay_appearance.notification_r, settings->overlay_appearance.notification_g, settings->overlay_appearance.notification_b, alpha)); ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(255, 255, 255, alpha*2)); } else if ( elapsed_notif > Notification::fade_out_start) { - float alpha = Notification::max_alpha * ((Notification::show_time - elapsed_notif).count() / static_cast(Notification::fade_out.count())); + float alpha = settings->overlay_appearance.notification_a * ((Notification::show_time - elapsed_notif).count() / static_cast(Notification::fade_out.count())); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, alpha)); - ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(Notification::r, Notification::g, Notification::b, alpha)); + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(settings->overlay_appearance.notification_r, settings->overlay_appearance.notification_g, settings->overlay_appearance.notification_b, alpha)); ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(255, 255, 255, alpha*2)); } else { - ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, Notification::max_alpha)); - ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(Notification::r, Notification::g, Notification::b, Notification::max_alpha)); - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(255, 255, 255, Notification::max_alpha*2)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, settings->overlay_appearance.notification_a)); + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(settings->overlay_appearance.notification_r, settings->overlay_appearance.notification_g, settings->overlay_appearance.notification_b, settings->overlay_appearance.notification_a)); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(255, 255, 255, settings->overlay_appearance.notification_a*2)); } ImGui::SetNextWindowPos(ImVec2((float)width - width * Notification::width, Notification::height * font_size * i )); @@ -956,6 +960,33 @@ void Steam_Overlay::OverlayProc() windowTitle.append(tmp); windowTitle.append(")"); + if ((settings->overlay_appearance.background_r != -1.0) && (settings->overlay_appearance.background_g != -1.0) && (settings->overlay_appearance.background_b != -1.0) && (settings->overlay_appearance.background_a != -1.0)) { + ImVec4 colorSet = ImVec4(settings->overlay_appearance.background_r, settings->overlay_appearance.background_g, settings->overlay_appearance.background_b, settings->overlay_appearance.background_a); + ImGui::PushStyleColor(ImGuiCol_WindowBg, colorSet); + } + if ((settings->overlay_appearance.element_r != -1.0) && (settings->overlay_appearance.element_g != -1.0) && (settings->overlay_appearance.element_b != -1.0) && (settings->overlay_appearance.element_a != -1.0)) { + ImVec4 colorSet = ImVec4(settings->overlay_appearance.element_r, settings->overlay_appearance.element_g, settings->overlay_appearance.element_b, settings->overlay_appearance.element_a); + ImGui::PushStyleColor(ImGuiCol_TitleBgActive, colorSet); + ImGui::PushStyleColor(ImGuiCol_Button, colorSet); + ImGui::PushStyleColor(ImGuiCol_FrameBg, colorSet); + ImGui::PushStyleColor(ImGuiCol_ResizeGrip, colorSet); + } + if ((settings->overlay_appearance.element_hovered_r != -1.0) && (settings->overlay_appearance.element_hovered_g != -1.0) && (settings->overlay_appearance.element_hovered_b != -1.0) && (settings->overlay_appearance.element_hovered_a != -1.0)) { + ImVec4 colorSet = ImVec4(settings->overlay_appearance.element_hovered_r, settings->overlay_appearance.element_hovered_g, settings->overlay_appearance.element_hovered_b, settings->overlay_appearance.element_hovered_a); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, colorSet); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, colorSet); + ImGui::PushStyleColor(ImGuiCol_ResizeGripHovered, colorSet); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, colorSet); + } + if ((settings->overlay_appearance.element_active_r != -1.0) && (settings->overlay_appearance.element_active_g != -1.0) && (settings->overlay_appearance.element_active_b != -1.0) && (settings->overlay_appearance.element_active_a != -1.0)) { + ImVec4 colorSet = ImVec4(settings->overlay_appearance.element_active_r, settings->overlay_appearance.element_active_g, settings->overlay_appearance.element_active_b, settings->overlay_appearance.element_active_a); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, colorSet); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, colorSet); + ImGui::PushStyleColor(ImGuiCol_ResizeGripActive, colorSet); + ImGui::PushStyleColor(ImGuiCol_Header, colorSet); + ImGui::PushStyleColor(ImGuiCol_HeaderActive, colorSet); + } + if (ImGui::Begin(windowTitle.c_str(), &show, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus)) { ImGui::LabelText("##label", translationUserPlaying[current_language], @@ -1016,6 +1047,10 @@ void Steam_Overlay::OverlayProc() if (x.icon.expired()) { std::string file_path = Local_Storage::get_game_settings_path() + x.icon_name; unsigned long long file_size = file_size_(file_path); + if (!file_size) { + file_path = Local_Storage::get_game_settings_path() + "achievement_images/" + x.icon_name; + file_size = file_size_(file_path); + } if (file_size) { std::string img = Local_Storage::load_image_resized(file_path, "", settings->overlay_appearance.icon_size); if (img.length() > 0) { @@ -1023,17 +1058,35 @@ void Steam_Overlay::OverlayProc() } } } + if (x.icon_gray.expired()) { + std::string file_path = Local_Storage::get_game_settings_path() + x.icon_gray_name; + unsigned long long file_size = file_size_(file_path); + if (!file_size) { + file_path = Local_Storage::get_game_settings_path() + "achievement_images/" + x.icon_gray_name; + file_size = file_size_(file_path); + } + if (file_size) { + std::string img = Local_Storage::load_image_resized(file_path, "", settings->overlay_appearance.icon_size); + if (img.length() > 0) { + if (_renderer) x.icon_gray = _renderer->CreateImageResource((void*)img.c_str(), settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size); + } + } + } ImGui::Separator(); - if (!x.icon.expired()) { + if (!x.icon.expired() && !x.icon_gray.expired()) { ImGui::BeginTable(x.title.c_str(), 2); ImGui::TableSetupColumn("imgui_table_image", ImGuiTableColumnFlags_WidthFixed, settings->overlay_appearance.icon_size); ImGui::TableSetupColumn("imgui_table_text"); ImGui::TableNextRow(ImGuiTableRowFlags_None, settings->overlay_appearance.icon_size); ImGui::TableSetColumnIndex(0); - ImGui::Image((ImU64)*x.icon.lock().get(), ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size)); + if (achieved) { + ImGui::Image((ImU64)*x.icon.lock().get(), ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size)); + } else { + ImGui::Image((ImU64)*x.icon_gray.lock().get(), ImVec2(settings->overlay_appearance.icon_size, settings->overlay_appearance.icon_size)); + } ImGui::TableSetColumnIndex(1); ImGui::Text("%s", x.title.c_str()); @@ -1057,7 +1110,7 @@ void Steam_Overlay::OverlayProc() ImGui::TextColored(ImVec4(255, 0, 0, 255), translationNotAchieved[current_language]); } - if (!x.icon.expired()) ImGui::EndTable(); + if (!x.icon.expired() && !x.icon_gray.expired()) ImGui::EndTable(); ImGui::Separator(); } @@ -1122,7 +1175,7 @@ void Steam_Overlay::OverlayProc() ImGui::End(); } - bool show_warning = local_save || warning_forced || appid == 0; + bool show_warning = (local_save & !settings->disable_overlay_warning) || warning_forced || appid == 0; if (show_warning) { ImGui::SetNextWindowSizeConstraints(ImVec2(ImGui::GetFontSize() * 32, ImGui::GetFontSize() * 32), ImVec2(8192, 8192)); ImGui::SetNextWindowFocus(); @@ -1213,8 +1266,8 @@ void Steam_Overlay::RunCallbacks() ach.unlock_time = 0; } - if (achieved) ach.icon_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), true); - else ach.icon_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), false); + ach.icon_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), true); + ach.icon_gray_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), false); achievements.push_back(ach); } diff --git a/overlay_experimental/steam_overlay.h b/overlay_experimental/steam_overlay.h index d2fbae61..846c4c72 100644 --- a/overlay_experimental/steam_overlay.h +++ b/overlay_experimental/steam_overlay.h @@ -58,10 +58,6 @@ struct Notification static constexpr std::chrono::milliseconds fade_out = std::chrono::milliseconds(2000); static constexpr std::chrono::milliseconds show_time = std::chrono::milliseconds(6000) + fade_in + fade_out; static constexpr std::chrono::milliseconds fade_out_start = show_time - fade_out; - static constexpr float r = 0.16; - static constexpr float g = 0.29; - static constexpr float b = 0.48; - static constexpr float max_alpha = 1.0f; int id; uint8 type; @@ -77,10 +73,12 @@ struct Overlay_Achievement std::string title; std::string description; std::string icon_name; + std::string icon_gray_name; bool hidden; bool achieved; uint32 unlock_time; std::weak_ptr icon; + std::weak_ptr icon_gray; }; #ifdef EMU_OVERLAY