| 2155 | |
| 2156 | |
| 2157 | void Achievements::DrawGameOverlays() |
| 2158 | { |
| 2159 | using ImGuiFullscreen::g_medium_font; |
| 2160 | using ImGuiFullscreen::LayoutScale; |
| 2161 | |
| 2162 | if (!HasActiveGame() || !(EmuConfig.Achievements.Overlays || EmuConfig.Achievements.LBOverlays)) |
| 2163 | return; |
| 2164 | |
| 2165 | const auto lock = GetLock(); |
| 2166 | |
| 2167 | const float spacing = LayoutScale(10.0f); |
| 2168 | const float padding = LayoutScale(10.0f); |
| 2169 | const ImVec2 image_size = LayoutScale(ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT); |
| 2170 | const ImGuiIO& io = ImGui::GetIO(); |
| 2171 | ImVec2 position = CalculateOverlayPosition(io, padding, EmuConfig.Achievements.OverlayPosition); |
| 2172 | ImDrawList* dl = ImGui::GetBackgroundDrawList(); |
| 2173 | |
| 2174 | if (!s_active_challenge_indicators.empty() && EmuConfig.Achievements.Overlays) |
| 2175 | { |
| 2176 | const ImVec2 stack_direction = GetStackingDirection(EmuConfig.Achievements.OverlayPosition); |
| 2177 | ImVec2 current_position = AdjustPositionForAlignment(position, image_size, EmuConfig.Achievements.OverlayPosition); |
| 2178 | const float x_advance = image_size.x + spacing; |
| 2179 | |
| 2180 | for (auto it = s_active_challenge_indicators.begin(); it != s_active_challenge_indicators.end();) |
| 2181 | { |
| 2182 | const AchievementChallengeIndicator& indicator = *it; |
| 2183 | const float opacity = IndicatorOpacity(indicator); |
| 2184 | const u32 col = ImGui::GetColorU32(ImVec4(1.0f, 1.0f, 1.0f, opacity)); |
| 2185 | |
| 2186 | GSTexture* badge = ImGuiFullscreen::GetCachedTextureAsync(indicator.badge_path.c_str()); |
| 2187 | if (badge) |
| 2188 | { |
| 2189 | dl->AddImage(reinterpret_cast<ImTextureID>(badge->GetNativeHandle()), |
| 2190 | current_position, current_position + image_size, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), col); |
| 2191 | |
| 2192 | // For horizontal layouts, go horizontally for vertical layouts, stay in the same row |
| 2193 | if (std::abs(stack_direction.x) > 0.0f) |
| 2194 | { |
| 2195 | current_position.x += stack_direction.x * x_advance; |
| 2196 | } |
| 2197 | else |
| 2198 | { |
| 2199 | // For right-aligned vertical layouts, move left for next indicator |
| 2200 | switch (EmuConfig.Achievements.OverlayPosition) |
| 2201 | { |
| 2202 | case AchievementOverlayPosition::TopRight: |
| 2203 | case AchievementOverlayPosition::BottomRight: |
| 2204 | current_position.x -= x_advance; |
| 2205 | break; |
| 2206 | default: |
| 2207 | current_position.x += x_advance; |
| 2208 | break; |
| 2209 | } |
| 2210 | } |
| 2211 | } |
| 2212 | |
| 2213 | if (!indicator.active && opacity <= 0.01f) |
| 2214 | { |
nothing calls this directly
no test coverage detected