CommonHostInterface: Move fonts/logo to resources directory

This commit is contained in:
Connor McLaughlin
2021-08-09 23:56:17 +10:00
parent c4f0dafb1f
commit 4f190aa902
11 changed files with 108 additions and 10098 deletions

View File

@ -556,10 +556,40 @@ bool CommonHostInterface::CreateHostDisplayResources()
if (!m_display->CreateImGuiContext())
{
Log_ErrorPrintf("Failed to create ImGui device context");
ReportError("Failed to create ImGui device context");
return false;
}
// load text font
{
std::unique_ptr<ByteStream> stream = OpenPackageFile("resources" FS_OSPATH_SEPARATOR_STR "roboto-regular.ttf",
BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED);
std::vector<u8> font_data;
if (!stream || (font_data = FileSystem::ReadBinaryStream(stream.get()), font_data.empty()))
{
ReportError("Failed to load text font");
m_display->DestroyImGuiContext();
return false;
}
ImGuiFullscreen::SetFontData(std::move(font_data));
}
// load icon font
{
std::unique_ptr<ByteStream> stream = OpenPackageFile("resources" FS_OSPATH_SEPARATOR_STR "fa-solid-900.ttf",
BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED);
std::vector<u8> font_data;
if (!stream || (font_data = FileSystem::ReadBinaryStream(stream.get()), font_data.empty()))
{
ReportError("Failed to load icon font");
m_display->DestroyImGuiContext();
return false;
}
ImGuiFullscreen::SetIconFontData(std::move(font_data));
}
if (m_fullscreen_ui_enabled)
{
if (!FullscreenUI::Initialize(this))
@ -572,9 +602,7 @@ bool CommonHostInterface::CreateHostDisplayResources()
if (!m_fullscreen_ui_enabled)
ImGuiFullscreen::ResetFonts();
m_logo_texture = m_display->CreateTexture(APP_ICON_WIDTH, APP_ICON_HEIGHT, 1, 1, 1, HostDisplayPixelFormat::RGBA8,
APP_ICON_DATA, sizeof(u32) * APP_ICON_WIDTH, false);
if (!m_logo_texture || !m_display->UpdateImGuiFontTexture())
if (!m_display->UpdateImGuiFontTexture())
{
Log_ErrorPrintf("Failed to create ImGui font text");
if (m_fullscreen_ui_enabled)
@ -585,6 +613,10 @@ bool CommonHostInterface::CreateHostDisplayResources()
return false;
}
m_logo_texture = FullscreenUI::LoadTextureResource("logo.png", false);
if (!m_logo_texture)
m_logo_texture = FullscreenUI::LoadTextureResource("duck.png", true);
return true;
}
@ -3314,8 +3346,8 @@ void CommonHostInterface::DisplayLoadingScreen(const char* message, int progress
// eat the last imgui frame, it might've been partially rendered by the caller.
ImGui::NewFrame();
const float logo_width = static_cast<float>(APP_ICON_WIDTH) * scale;
const float logo_height = static_cast<float>(APP_ICON_HEIGHT) * scale;
const float logo_width = 260.0f * scale;
const float logo_height = 260.0f * scale;
ImGui::SetNextWindowSize(ImVec2(logo_width, logo_height), ImGuiCond_Always);
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, (io.DisplaySize.y * 0.5f) - (50.0f * scale)),