MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / DrawLandingTemplate

Method DrawLandingTemplate

pcsx2/ImGui/FullscreenUI.cpp:1260–1343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1258}
1259
1260void FullscreenUI::DrawLandingTemplate(ImVec2* menu_pos, ImVec2* menu_size)
1261{
1262 const ImGuiIO& io = ImGui::GetIO();
1263 const ImVec2 heading_size =
1264 ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
1265 (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
1266 *menu_pos = ImVec2(0.0f, heading_size.y);
1267 *menu_size = ImVec2(io.DisplaySize.x, io.DisplaySize.y - heading_size.y - LayoutScale(LAYOUT_FOOTER_HEIGHT));
1268
1269 if (BeginFullscreenWindow(ImVec2(0.0f, 0.0f), heading_size, "landing_heading", UIPrimaryColor))
1270 {
1271 const std::pair<ImFont*, float> heading_font = g_large_font;
1272 ImDrawList* const dl = ImGui::GetWindowDrawList();
1273 SmallString heading_str;
1274
1275 ImGui::PushFont(heading_font.first, heading_font.second);
1276 ImGui::PushStyleColor(ImGuiCol_Text, UIPrimaryTextColor);
1277
1278 // draw branding
1279 {
1280 const ImVec2 logo_pos = LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING);
1281 const ImVec2 logo_size = LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
1282 dl->AddImage(reinterpret_cast<ImTextureID>(GetCachedTexture("icons/AppIconLarge.png")->GetNativeHandle()),
1283 logo_pos, logo_pos + logo_size);
1284 const ImVec2 branding_pos(logo_pos.x + logo_size.x + LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING), logo_pos.y);
1285 ImGuiFullscreen::AddTextWithShadow(dl, heading_font, branding_pos, ImGui::GetColorU32(ImGuiCol_Text), "PCSX2");
1286 }
1287
1288 // draw time
1289 ImVec2 time_pos;
1290 {
1291 // Waiting on (apple)clang support for P0355R7
1292 // Migrate to std::chrono::current_zone and zoned_time then
1293 const auto utc_now = std::chrono::system_clock::now();
1294 const auto utc_time_t = std::chrono::system_clock::to_time_t(utc_now);
1295 std::tm tm_local = {};
1296#ifdef _MSC_VER
1297 localtime_s(&tm_local, &utc_time_t);
1298#else
1299 localtime_r(&utc_time_t, &tm_local);
1300#endif
1301 heading_str.format(FSUI_FSTR("{:%H:%M}"), tm_local);
1302
1303 const ImVec2 time_size = heading_font.first->CalcTextSizeA(heading_font.second, FLT_MAX, 0.0f, "00:00");
1304 time_pos = ImVec2(heading_size.x - LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING) - time_size.x,
1305 LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING));
1306 ImGuiFullscreen::AddTextWithShadow(
1307 dl, heading_font, time_pos, ImGui::GetColorU32(ImGuiCol_Text), heading_str.c_str(), heading_str.end_ptr());
1308 ImGui::RenderTextClipped(time_pos, time_pos + time_size, heading_str.c_str(), heading_str.end_ptr(), &time_size);
1309 }
1310
1311 // draw achievements info
1312 if (Achievements::IsActive())
1313 {
1314 const auto lock = Achievements::GetLock();
1315 const char* username = Achievements::GetLoggedInUserName();
1316 if (username)
1317 {

Callers

nothing calls this directly

Calls 11

LayoutScaleFunction · 0.85
PushFontFunction · 0.85
to_time_tFunction · 0.85
AddImageMethod · 0.80
CalcTextSizeAMethod · 0.80
end_ptrMethod · 0.80
ImVec2Class · 0.70
GetNativeHandleMethod · 0.45
formatMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected