diff --git a/src/core/libraries/np_trophy/trophy_ui.cpp b/src/core/libraries/np_trophy/trophy_ui.cpp index 9b152ce3d..78e0f4e24 100644 --- a/src/core/libraries/np_trophy/trophy_ui.cpp +++ b/src/core/libraries/np_trophy/trophy_ui.cpp @@ -11,6 +11,8 @@ #include "imgui/imgui_std.h" #include "trophy_ui.h" +CMRC_DECLARE(res); + using namespace ImGui; namespace Libraries::NpTrophy { @@ -29,6 +31,22 @@ TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::strin fmt::UTF(trophyIconPath.u8string())); } + std::string pathString; + if (trophy_type == "P") { + pathString = "Resources/platinum.png"; + } else if (trophy_type == "G") { + pathString = "Resources/gold.png"; + } else if (trophy_type == "S") { + pathString = "Resources/silver.png"; + } else if (trophy_type == "B") { + pathString = "Resources/bronze.png"; + } + + auto resource = cmrc::res::get_filesystem(); + auto file = resource.open(pathString); + std::vector imgdata(file.begin(), file.end()); + trophy_type_icon = RefCountedTexture::DecodePngTexture(imgdata); + AddLayer(this); } @@ -57,9 +75,10 @@ void TrophyUI::Draw() { if (Begin("Trophy Window", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs)) { - if (trophy_icon) { + if (trophy_type_icon) { SetCursorPosY((window_size.y * 0.5f) - (25 * AdjustHeight)); - Image(trophy_icon.GetTexture().im_id, ImVec2((50 * AdjustWidth), (50 * AdjustHeight))); + Image(trophy_type_icon.GetTexture().im_id, + ImVec2((50 * AdjustWidth), (50 * AdjustHeight))); ImGui::SameLine(); } else { // placeholder @@ -74,7 +93,20 @@ void TrophyUI::Draw() { const float text_height = ImGui::CalcTextSize(std::strcat(earned_text, trophy_name.c_str())).y; SetCursorPosY((window_size.y - text_height) * 0.5f); + + ImGui::PushTextWrapPos(window_size.x - (60 * AdjustWidth)); TextWrapped("Trophy earned!\n%s", trophy_name.c_str()); + ImGui::SameLine(window_size.x - (60 * AdjustWidth)); + + if (trophy_icon) { + SetCursorPosY((window_size.y * 0.5f) - (25 * AdjustHeight)); + Image(trophy_icon.GetTexture().im_id, ImVec2((50 * AdjustWidth), (50 * AdjustHeight))); + } else { + // placeholder + const auto pos = GetCursorScreenPos(); + ImGui::GetWindowDrawList()->AddRectFilled(pos, pos + ImVec2{30.0f * AdjustHeight}, + GetColorU32(ImVec4{0.7f})); + } } End();