FrontendCommon: Add duck icon to loading screens

This commit is contained in:
Connor McLaughlin 2020-10-01 23:32:01 +10:00
parent defe70794b
commit 5bc61849eb
4 changed files with 50 additions and 3 deletions

View file

@ -482,7 +482,8 @@ bool QtHostInterface::AcquireHostDisplay()
createImGuiContext(display_widget->devicePixelRatioFromScreen());
if (!m_display->MakeRenderContextCurrent() ||
!m_display->InitializeRenderDevice(GetShaderCacheBasePath(), g_settings.gpu_use_debug_device))
!m_display->InitializeRenderDevice(GetShaderCacheBasePath(), g_settings.gpu_use_debug_device) ||
!CreateHostDisplayResources())
{
destroyImGuiContext();
m_display->DestroyRenderDevice();
@ -561,6 +562,7 @@ void QtHostInterface::ReleaseHostDisplay()
{
Assert(m_display);
ReleaseHostDisplayResources();
m_display->DestroyRenderDevice();
destroyImGuiContext();
emit destroyDisplayRequested();

View file

@ -248,11 +248,16 @@ bool SDLHostInterface::AcquireHostDisplay()
ImGui::NewFrame();
}
if (!CreateHostDisplayResources())
return false;
return true;
}
void SDLHostInterface::ReleaseHostDisplay()
{
ReleaseHostDisplayResources();
if (m_fullscreen)
SetFullscreen(false);

View file

@ -19,6 +19,7 @@
#include "core/system.h"
#include "core/timers.h"
#include "game_list.h"
#include "icon.h"
#include "imgui.h"
#include "ini_settings_interface.h"
#include "save_state_selector_ui.h"
@ -432,6 +433,21 @@ bool CommonHostInterface::SetFullscreen(bool enabled)
return false;
}
bool CommonHostInterface::CreateHostDisplayResources()
{
m_logo_texture =
m_display->CreateTexture(APP_ICON_WIDTH, APP_ICON_HEIGHT, APP_ICON_DATA, sizeof(u32) * APP_ICON_WIDTH, false);
if (!m_logo_texture)
Log_WarningPrintf("Failed to create logo texture");
return true;
}
void CommonHostInterface::ReleaseHostDisplayResources()
{
m_logo_texture.reset();
}
std::unique_ptr<AudioStream> CommonHostInterface::CreateAudioStream(AudioBackend backend)
{
switch (backend)
@ -2035,9 +2051,26 @@ void CommonHostInterface::DisplayLoadingScreen(const char* message, int progress
// ImGui::EndFrame();
// ImGui::NewFrame();
const float logo_width = static_cast<float>(APP_ICON_WIDTH) * scale;
const float logo_height = static_cast<float>(APP_ICON_HEIGHT) * 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)),
ImGuiCond_Always, ImVec2(0.5f, 0.5f));
if (ImGui::Begin("LoadingScreenLogo", nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav |
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing |
ImGuiWindowFlags_NoBackground))
{
if (m_logo_texture)
ImGui::Image(m_logo_texture->GetHandle(), ImVec2(logo_width, logo_height));
}
ImGui::End();
ImGui::SetNextWindowSize(ImVec2(width, (has_progress ? 50.0f : 30.0f) * scale), ImGuiCond_Always);
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always,
ImVec2(0.5f, 0.5f));
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, (io.DisplaySize.y * 0.5f) + (100.0f * scale)),
ImGuiCond_Always, ImVec2(0.5f, 0.0f));
if (ImGui::Begin("LoadingScreen", nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav |

View file

@ -12,6 +12,8 @@
#include <utility>
#include <vector>
class HostDisplayTexture;
class ControllerInterface;
namespace FrontendCommon {
@ -296,6 +298,9 @@ protected:
void ApplyGameSettings(bool display_osd_messages);
bool CreateHostDisplayResources();
void ReleaseHostDisplayResources();
virtual void DrawImGuiWindows();
void DrawFPSWindow();
@ -307,6 +312,8 @@ protected:
std::unique_ptr<ControllerInterface> m_controller_interface;
std::unique_ptr<HostDisplayTexture> m_logo_texture;
std::deque<OSDMessage> m_osd_messages;
std::mutex m_osd_messages_lock;