From faccec00f60f4c9647aa6782ce1183648265bd1e Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Tue, 12 Sep 2023 19:34:09 +0200 Subject: [PATCH] Only hide secret achievements --- data/cdata/ui_scripts/achievements/menu.lua | 8 ++++++-- data/zonetool/localizedstrings/english.json | 2 ++ src/client/component/achievements.cpp | 14 ++++++++++++-- src/client/component/achievements.hpp | 2 ++ src/client/component/ui_scripting.cpp | 1 + 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/data/cdata/ui_scripts/achievements/menu.lua b/data/cdata/ui_scripts/achievements/menu.lua index ff3afebd..a44658a1 100644 --- a/data/cdata/ui_scripts/achievements/menu.lua +++ b/data/cdata/ui_scripts/achievements/menu.lua @@ -54,7 +54,7 @@ LUI.MenuBuilder.registerType("achievements_menu", function(root, controller) }, { "Faded", - 500 + 1000 } }) end @@ -300,7 +300,11 @@ LUI.MenuBuilder.registerType("achievements_menu", function(root, controller) if (locked) then btnbg:animateToState("locked") image:animateToState("locked") - desc:setText("") + + if (achievements.issecret(i)) then + title:setText(Engine.ToUpperCase(Engine.Localize("ACHIEVEMENT_HIDDEN"))) + desc:setText(Engine.Localize("ACHIEVEMENT_HIDDEN_DESC")) + end end addelement(achievementcontainer) diff --git a/data/zonetool/localizedstrings/english.json b/data/zonetool/localizedstrings/english.json index a91caf00..14206034 100644 --- a/data/zonetool/localizedstrings/english.json +++ b/data/zonetool/localizedstrings/english.json @@ -128,6 +128,8 @@ "LUA_MENU_ACHIEVEMENTS_DESC": "View achievements.", "LUA_MENU_UNKNOWN_ACHIEVEMENT": "???", + "ACHIEVEMENT_HIDDEN": "Secret achievement", + "ACHIEVEMENT_HIDDEN_DESC": "Keep playing to unlock it", "ACHIEVEMENT_EARNED": "Achievement Unlocked!", "ACHIEVEMENT_NAME_0": "Is That All You Got?", "ACHIEVEMENT_DETAIL_0": "Earn all available trophies for Call of Duty®: Modern Warfare® 2 Campaign Remastered.", diff --git a/src/client/component/achievements.cpp b/src/client/component/achievements.cpp index e5ec1b64..18e02de3 100644 --- a/src/client/component/achievements.cpp +++ b/src/client/component/achievements.cpp @@ -70,13 +70,13 @@ namespace achievements achievement_t(ACHIEVEMENT_40, "NIGHT_MUSEUM", ACHIEVEMENT_RARITY_1), achievement_t(ACHIEVEMENT_41, "STUDENT_MASTER", ACHIEVEMENT_RARITY_1), achievement_t(ACHIEVEMENT_42, "REAL_GUN_GAME", ACHIEVEMENT_RARITY_1), - achievement_t(ACHIEVEMENT_43, "PRECOGNITIVE_PARANOIA", ACHIEVEMENT_RARITY_0), + achievement_t(ACHIEVEMENT_43, "PRECOGNITIVE_PARANOIA", ACHIEVEMENT_RARITY_0, true), achievement_t(ACHIEVEMENT_44, "IMMORTAL", ACHIEVEMENT_RARITY_2), achievement_t(ACHIEVEMENT_45, "SILENT_SKIES", ACHIEVEMENT_RARITY_0), achievement_t(ACHIEVEMENT_46, "CLAYMORE", ACHIEVEMENT_RARITY_0), achievement_t(ACHIEVEMENT_47, "BIRD_HUNTER", ACHIEVEMENT_RARITY_1), achievement_t(ACHIEVEMENT_48, "HOT_POTATO", ACHIEVEMENT_RARITY_0), - achievement_t(ACHIEVEMENT_49, "CLOWN_IN_TRAINING", ACHIEVEMENT_RARITY_0), + achievement_t(ACHIEVEMENT_49, "CLOWN_IN_TRAINING", ACHIEVEMENT_RARITY_0, true), achievement_t(ACHIEVEMENT_50, "HEADBANGER", ACHIEVEMENT_RARITY_0), achievement_t(ACHIEVEMENT_51, "BRAINS", ACHIEVEMENT_RARITY_2), achievement_t(ACHIEVEMENT_52, "RAMIREZ", ACHIEVEMENT_RARITY_2), @@ -378,6 +378,16 @@ namespace achievements return achievements[id].rarity; } + bool is_secret(int id) + { + if (id >= ACHIEVEMENT_TOTAL_COUNT) + { + return false; + } + + return achievements[id].secret; + } + class component final : public component_interface { public: diff --git a/src/client/component/achievements.hpp b/src/client/component/achievements.hpp index 383a00c0..c098655f 100644 --- a/src/client/component/achievements.hpp +++ b/src/client/component/achievements.hpp @@ -75,6 +75,7 @@ namespace achievements achievement_id id; std::string_view code; achievement_rarity rarity; + bool secret{}; }; struct achievement_file_t @@ -93,4 +94,5 @@ namespace achievements std::string get_details(int id); std::optional get_background(int id); int get_rarity(int id); + bool is_secret(int id); } diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index 64451922..f2199917 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -694,6 +694,7 @@ namespace ui_scripting achievements_table["getname"] = achievements::get_name; achievements_table["getdetails"] = achievements::get_details; achievements_table["getbackground"] = achievements::get_background; + achievements_table["issecret"] = achievements::is_secret; achievements_table["count"] = achievements::get_count; achievements_table["table"] = []()