mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-08 04:25:37 +00:00
ImGuiManager: Use fullscreen UI theme for OSD
This commit is contained in:
parent
b6fa2cecd3
commit
cffafad2ca
@ -660,7 +660,6 @@ bool FullscreenUI::Initialize()
|
|||||||
if (s_state.tried_to_initialize)
|
if (s_state.tried_to_initialize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ImGuiFullscreen::SetTheme(Host::GetBaseStringSettingValue("UI", "FullscreenUITheme", "Dark"));
|
|
||||||
ImGuiFullscreen::SetSmoothScrolling(Host::GetBaseBoolSettingValue("Main", "FullscreenUISmoothScrolling", true));
|
ImGuiFullscreen::SetSmoothScrolling(Host::GetBaseBoolSettingValue("Main", "FullscreenUISmoothScrolling", true));
|
||||||
ImGuiFullscreen::UpdateLayoutScale();
|
ImGuiFullscreen::UpdateLayoutScale();
|
||||||
|
|
||||||
|
@ -257,6 +257,7 @@ bool ImGuiManager::Initialize(float global_scale, float screen_margin, Error* er
|
|||||||
|
|
||||||
SetKeyMap();
|
SetKeyMap();
|
||||||
SetStyle(s_state.imgui_context->Style, s_state.global_scale);
|
SetStyle(s_state.imgui_context->Style, s_state.global_scale);
|
||||||
|
ImGuiFullscreen::SetTheme(Host::GetBaseStringSettingValue("UI", "FullscreenUITheme", "Dark"));
|
||||||
|
|
||||||
if (!AddImGuiFonts(false, false) || !g_gpu_device->UpdateImGuiFontTexture())
|
if (!AddImGuiFonts(false, false) || !g_gpu_device->UpdateImGuiFontTexture())
|
||||||
{
|
{
|
||||||
@ -953,6 +954,10 @@ void ImGuiManager::AcquirePendingOSDMessages(Timer::Value current_time)
|
|||||||
|
|
||||||
void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
|
void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
|
||||||
{
|
{
|
||||||
|
using ImGuiFullscreen::ModAlpha;
|
||||||
|
using ImGuiFullscreen::RenderShadowedTextClipped;
|
||||||
|
using ImGuiFullscreen::UIStyle;
|
||||||
|
|
||||||
static constexpr float MOVE_DURATION = 0.5f;
|
static constexpr float MOVE_DURATION = 0.5f;
|
||||||
|
|
||||||
ImFont* const font = s_state.osd_font;
|
ImFont* const font = s_state.osd_font;
|
||||||
@ -979,13 +984,13 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
|
|||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
|
|
||||||
u8 opacity;
|
float opacity;
|
||||||
if (time_passed < OSD_FADE_IN_TIME)
|
if (time_passed < OSD_FADE_IN_TIME)
|
||||||
opacity = static_cast<u8>((time_passed / OSD_FADE_IN_TIME) * 255.0f);
|
opacity = time_passed / OSD_FADE_IN_TIME;
|
||||||
else if (time_passed > (msg.duration - OSD_FADE_OUT_TIME))
|
else if (time_passed > (msg.duration - OSD_FADE_OUT_TIME))
|
||||||
opacity = static_cast<u8>(std::min((msg.duration - time_passed) / OSD_FADE_OUT_TIME, 1.0f) * 255.0f);
|
opacity = std::min((msg.duration - time_passed) / OSD_FADE_OUT_TIME, 1.0f);
|
||||||
else
|
else
|
||||||
opacity = 255;
|
opacity = 1.0f;
|
||||||
|
|
||||||
const float expected_y = position_y;
|
const float expected_y = position_y;
|
||||||
float actual_y = msg.last_y;
|
float actual_y = msg.last_y;
|
||||||
@ -1031,13 +1036,15 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
|
|||||||
const ImVec2 text_size(font->CalcTextSizeA(font->FontSize, max_width, max_width, msg.text.c_str(),
|
const ImVec2 text_size(font->CalcTextSizeA(font->FontSize, max_width, max_width, msg.text.c_str(),
|
||||||
msg.text.c_str() + msg.text.length()));
|
msg.text.c_str() + msg.text.length()));
|
||||||
const ImVec2 size(text_size.x + padding * 2.0f, text_size.y + padding * 2.0f);
|
const ImVec2 size(text_size.x + padding * 2.0f, text_size.y + padding * 2.0f);
|
||||||
const ImVec4 text_rect(pos.x + padding, pos.y + padding, pos.x + size.x - padding, pos.y + size.y - padding);
|
const ImRect text_rect(pos.x + padding, pos.y + padding, pos.x + size.x - padding, pos.y + size.y - padding);
|
||||||
|
|
||||||
ImDrawList* dl = ImGui::GetForegroundDrawList();
|
ImDrawList* dl = ImGui::GetForegroundDrawList();
|
||||||
dl->AddRectFilled(pos, ImVec2(pos.x + size.x, pos.y + size.y), IM_COL32(0x21, 0x21, 0x21, opacity), rounding);
|
dl->AddRectFilled(pos, ImVec2(pos.x + size.x, pos.y + size.y),
|
||||||
dl->AddRect(pos, ImVec2(pos.x + size.x, pos.y + size.y), IM_COL32(0x48, 0x48, 0x48, opacity), rounding);
|
ImGui::GetColorU32(ModAlpha(UIStyle.ToastBackgroundColor, opacity * 0.95f)), rounding);
|
||||||
dl->AddText(font, font->FontSize, ImVec2(text_rect.x, text_rect.y), IM_COL32(0xff, 0xff, 0xff, opacity),
|
RenderShadowedTextClipped(dl, font, text_rect.Min, text_rect.Max,
|
||||||
msg.text.c_str(), msg.text.c_str() + msg.text.length(), max_width, &text_rect);
|
ImGui::GetColorU32(ModAlpha(UIStyle.ToastTextColor, opacity)), msg.text.c_str(),
|
||||||
|
msg.text.c_str() + msg.text.length(), &text_size, ImVec2(0.0f, 0.0f), max_width,
|
||||||
|
&text_rect, scale);
|
||||||
position_y += size.y + spacing;
|
position_y += size.y + spacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user