From 5cf94e5a15705bf0296047f63f7bb01726732444 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 6 Sep 2015 21:08:14 +0100 Subject: [PATCH] gui: Allow screenshot icon to be themed. The logo and all the other icons can apparently be themed (though theming is a bit broken). Let's allow the camera screenshot to be themed as well. --- pcsx2/gui/App.h | 2 ++ pcsx2/gui/AppRes.cpp | 28 +++++++++++++++++++ pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp | 5 +--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 1018b702b9..40dc665655 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -242,6 +242,7 @@ public: ScopedPtr ToolbarImages; ScopedPtr IconBundle; ScopedPtr Bitmap_Logo; + ScopedPtr ScreenshotBitmap; ScopedPtr GameDB; pxAppResources(); @@ -559,6 +560,7 @@ public: pxAppResources& GetResourceCache(); const wxIconBundle& GetIconBundle(); const wxBitmap& GetLogoBitmap(); + const wxBitmap& GetScreenshotBitmap(); wxImageList& GetImgList_Config(); wxImageList& GetImgList_Toolbars(); diff --git a/pcsx2/gui/AppRes.cpp b/pcsx2/gui/AppRes.cpp index 8d0d6f60b7..0585df3e76 100644 --- a/pcsx2/gui/AppRes.cpp +++ b/pcsx2/gui/AppRes.cpp @@ -23,6 +23,7 @@ #include "Resources/EmbeddedImage.h" #include "Resources/BackgroundLogo.h" +#include "Resources/ButtonIcon_Camera.h" #include "Resources/ConfigIcon_Cpu.h" #include "Resources/ConfigIcon_Video.h" @@ -149,6 +150,28 @@ const wxBitmap& Pcsx2App::GetLogoBitmap() return *logo; } +const wxBitmap& Pcsx2App::GetScreenshotBitmap() +{ + ScopedPtr& screenshot(GetResourceCache().ScreenshotBitmap); + if (screenshot) return *screenshot; + + wxFileName mess; + bool useTheme = (g_Conf->DeskTheme != L"default"); + + if (useTheme) + { + wxDirName theme(PathDefs::GetThemes() + g_Conf->DeskTheme); + mess = theme.ToString(); + } + + wxImage img; + EmbeddedImage temp; // because gcc can't allow non-const temporaries. + LoadImageAny(img, useTheme, mess, L"ButtonIcon_Camera", temp); + screenshot = new wxBitmap(img); + + return *screenshot; +} + wxImageList& Pcsx2App::GetImgList_Config() { ScopedPtr& images( GetResourceCache().ConfigImages ); @@ -168,6 +191,11 @@ wxImageList& Pcsx2App::GetImgList_Config() // GCC Specific: wxT() macro is required when using string token pasting. For some // reason L generates syntax errors. >_< + // TODO: This can be fixed with something like + // #define L_STR(x) L_STR2(x) + // #define L_STR2(x) L ## x + // but it's probably best to do it everywhere at once. wxWidgets + // recommends not to use it since v2.9.0. #undef FancyLoadMacro #define FancyLoadMacro( name ) \ diff --git a/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp b/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp index 96b3e336e0..962015dd71 100644 --- a/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp +++ b/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp @@ -22,9 +22,6 @@ #include "ModalPopups.h" #include "Panels/ConfigurationPanels.h" -#include "Resources/EmbeddedImage.h" -#include "Resources/ButtonIcon_Camera.h" - #include #include #include @@ -187,7 +184,7 @@ void Dialogs::BaseConfigurationDialog::AddOkCancel( wxSizer* sizer ) if( wxWindow* apply = FindWindow( wxID_APPLY ) ) apply->Disable(); SomethingChanged_StateModified_IsChanged(); - wxBitmapButton& screenshotButton( *new wxBitmapButton( this, wxID_SAVE, EmbeddedImage().Get() ) ); + wxBitmapButton& screenshotButton(*new wxBitmapButton(this, wxID_SAVE, wxGetApp().GetScreenshotBitmap())); screenshotButton.SetToolTip( _("Saves a snapshot of this settings panel to a PNG file.") ); *m_extraButtonSizer += screenshotButton|pxMiddle;