|
1 | | -// SPDX-FileCopyrightText: 2002-2025 PCSX2 Dev Team |
| 1 | +// SPDX-FileCopyrightText: 2002-2025 PCSX2 Dev Team |
2 | 2 | // SPDX-License-Identifier: GPL-3.0+ |
3 | 3 |
|
4 | 4 | #include "BuildVersion.h" |
|
46 | 46 | #include <span> |
47 | 47 | #include <tuple> |
48 | 48 | #include <unordered_map> |
| 49 | +#include <iomanip> |
| 50 | +#include <sstream> |
| 51 | +#include <ctime> |
49 | 52 |
|
50 | 53 | std::string GetSystemDate() |
51 | 54 | { |
@@ -148,33 +151,45 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f |
148 | 151 | { |
149 | 152 | bool first = true; |
150 | 153 | // --- Display System Time and Date First + Second Line in Imgui or most top-right by default --- |
151 | | - if (GSConfig.OsdShowSystemTime) |
| 154 | + if (GSConfig.OsdShowSystemTime || GSConfig.OsdShowSystemDate) |
152 | 155 | { |
153 | | - std::string systemTimeStr = GetSystemTime(); |
| 156 | + text.clear(); // Clear for this new line |
154 | 157 |
|
155 | | - // Extract hours, minutes, and seconds from the host time string to prepare easier visuals such as HH:MM:SS |
156 | | - std::string systemhours = systemTimeStr.substr(0, 2); |
157 | | - std::string systemminutes = systemTimeStr.substr(3, 2); |
158 | | - std::string systemseconds = systemTimeStr.substr(6, 2); |
| 158 | + if (GSConfig.OsdShowSystemTime) |
| 159 | + { |
| 160 | + std::string systemTimeStr = GetSystemTime(); |
159 | 161 |
|
160 | | - text.clear(); // Clear for this new line |
161 | | - text.append_format("Time: {}:{}:{} (HH:MM:SS)", systemhours, systemminutes, systemseconds); // Example: Time: 04H:48M:30S combination possible or just 04:48:30 as well or combined with what format it is with that and say HH:MM:SS but perhaps best in tooltip instead. |
162 | | - if (!text.empty() && !systemTimeStr.empty()) // Ensure GetSystemTime returns the string |
163 | | - DRAW_LINE(fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255)); // Default White color |
164 | | - } |
| 162 | + // Extract hours, minutes, and seconds from the host time string to prepare easier visuals such as HH:MM:SS |
| 163 | + std::string systemhours = systemTimeStr.substr(0, 2); |
| 164 | + std::string systemminutes = systemTimeStr.substr(3, 2); |
| 165 | + std::string systemseconds = systemTimeStr.substr(6, 2); |
165 | 166 |
|
166 | | - if (GSConfig.OsdShowSystemDate) |
167 | | - { |
168 | | - std::string systemDateStr = GetSystemDate(); |
| 167 | + // Append formatted time using text.append_format (no icon used here) |
| 168 | + // TODO ICON_FA_CLOCK |
| 169 | + text.append_format("{}:{}:{}", systemhours.c_str(), systemminutes.c_str(), systemseconds.c_str()); // Currently: 04:48:30 other examples: 04:48:30 or Time: 04H:48M:30S combination possible or just 04:48:30 as well or combined with what format it is with that and say HH:MM:SS but perhaps best in tooltip instead. |
| 170 | + first = false; // After the first item is added, set 'first' to false to handle pipe separator correctly. |
| 171 | + } |
169 | 172 |
|
170 | | - // Extract year, month, and day from the date string to prepare easier visuals such as YYYY-MM-DD |
171 | | - std::string year = systemDateStr.substr(0, 4); |
172 | | - std::string month = systemDateStr.substr(5, 2); |
173 | | - std::string day = systemDateStr.substr(8, 2); |
| 173 | + if (GSConfig.OsdShowSystemDate) |
| 174 | + { |
| 175 | + std::string systemDateStr = GetSystemDate(); |
174 | 176 |
|
175 | | - text.clear(); // Clear for this new line |
176 | | - text.append_format("Date: {}-{}-{} (YYYY-MM-DD)", year, month, day); // Example: Date: 2025 Y - 10 M - 05 D but can do 2025-10-05 as well or combined with what format it is or even look at the locale of user but perhaps best in tooltip instead. |
177 | | - if (!text.empty() && !systemDateStr.empty()) // Ensure GetSystemDate returns the string |
| 177 | + // Extract year, month, and day from the date string to prepare easier visuals such as YYYY-MM-DD |
| 178 | + std::string year = systemDateStr.substr(0, 4); |
| 179 | + std::string month = systemDateStr.substr(5, 2); |
| 180 | + std::string day = systemDateStr.substr(8, 2); |
| 181 | + |
| 182 | + // Append formatted date with pipe separator if not the first item |
| 183 | + if (!first) // If this is not the first item, add the pipe separator before appending the date |
| 184 | + text.append(" | "); // Add pipe separator if this isn't the first item |
| 185 | + |
| 186 | + // Append formatted date using text.append_format (no icon used here) |
| 187 | + // TODO ICON_FA_CALENDAR |
| 188 | + text.append_format("{}-{}-{}", year.c_str(), month.c_str(), day.c_str()); // Currently: 📅 2025-10-05 other examples: 2025-10-05 or Date: 2025 Y - 10 M - 05 D but can do 2025-10-05 as well or combined with what format it is or even look at the locale of user but perhaps best in tooltip instead. |
| 189 | + } |
| 190 | + |
| 191 | + // Only draw if there's any text to display |
| 192 | + if (!text.empty()) |
178 | 193 | DRAW_LINE(fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255)); // Default White color |
179 | 194 | } |
180 | 195 |
|
|
0 commit comments