DolphinWX: Support 2x images for all resources
This commit is contained in:
parent
d134858403
commit
53acd063f9
|
@ -26,7 +26,7 @@ AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id,
|
||||||
: wxDialog(parent, id, title, position, size, style)
|
: wxDialog(parent, id, title, position, size, style)
|
||||||
{
|
{
|
||||||
wxGenericStaticBitmap* const sbDolphinLogo = new wxGenericStaticBitmap(this, wxID_ANY,
|
wxGenericStaticBitmap* const sbDolphinLogo = new wxGenericStaticBitmap(this, wxID_ANY,
|
||||||
WxUtils::LoadResourceBitmap("dolphin_logo", true));
|
WxUtils::LoadResourceBitmap("dolphin_logo"));
|
||||||
|
|
||||||
const wxString DolphinText = _("Dolphin");
|
const wxString DolphinText = _("Dolphin");
|
||||||
const wxString RevisionText = scm_desc_str;
|
const wxString RevisionText = scm_desc_str;
|
||||||
|
|
|
@ -173,34 +173,34 @@ void CGameListCtrl::InitBitmaps()
|
||||||
SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL);
|
SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL);
|
||||||
|
|
||||||
m_FlagImageIndex.resize(DiscIO::IVolume::NUMBER_OF_COUNTRIES);
|
m_FlagImageIndex.resize(DiscIO::IVolume::NUMBER_OF_COUNTRIES);
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_JAPAN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Japan", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_JAPAN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Japan", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_EUROPE] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Europe", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_EUROPE] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Europe", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_USA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_USA", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_USA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_USA", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_AUSTRALIA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Australia", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_AUSTRALIA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Australia", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_FRANCE] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_France", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_FRANCE] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_France", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_GERMANY] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Germany", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_GERMANY] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Germany", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_ITALY] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Italy", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_ITALY] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Italy", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_KOREA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Korea", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_KOREA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Korea", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_NETHERLANDS] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Netherlands", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_NETHERLANDS] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Netherlands", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_RUSSIA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Russia", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_RUSSIA] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Russia", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_SPAIN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Spain", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_SPAIN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Spain", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_TAIWAN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Taiwan", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_TAIWAN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Taiwan", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_WORLD] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_International", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_WORLD] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_International", size));
|
||||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_UNKNOWN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Flag_Unknown", size));
|
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_UNKNOWN] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Flag_Unknown", size));
|
||||||
|
|
||||||
m_PlatformImageIndex.resize(4);
|
m_PlatformImageIndex.resize(4);
|
||||||
m_PlatformImageIndex[DiscIO::IVolume::GAMECUBE_DISC] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Platform_Gamecube", size));
|
m_PlatformImageIndex[DiscIO::IVolume::GAMECUBE_DISC] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Platform_Gamecube", size));
|
||||||
m_PlatformImageIndex[DiscIO::IVolume::WII_DISC] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Platform_Wii", size));
|
m_PlatformImageIndex[DiscIO::IVolume::WII_DISC] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Platform_Wii", size));
|
||||||
m_PlatformImageIndex[DiscIO::IVolume::WII_WAD] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Platform_Wad", size));
|
m_PlatformImageIndex[DiscIO::IVolume::WII_WAD] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Platform_Wad", size));
|
||||||
m_PlatformImageIndex[DiscIO::IVolume::ELF_DOL] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("Platform_File", size));
|
m_PlatformImageIndex[DiscIO::IVolume::ELF_DOL] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("Platform_File", size));
|
||||||
|
|
||||||
m_EmuStateImageIndex.resize(6);
|
m_EmuStateImageIndex.resize(6);
|
||||||
m_EmuStateImageIndex[0] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating0", size));
|
m_EmuStateImageIndex[0] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating0", size));
|
||||||
m_EmuStateImageIndex[1] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating1", size));
|
m_EmuStateImageIndex[1] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating1", size));
|
||||||
m_EmuStateImageIndex[2] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating2", size));
|
m_EmuStateImageIndex[2] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating2", size));
|
||||||
m_EmuStateImageIndex[3] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating3", size));
|
m_EmuStateImageIndex[3] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating3", size));
|
||||||
m_EmuStateImageIndex[4] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating4", size));
|
m_EmuStateImageIndex[4] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating4", size));
|
||||||
m_EmuStateImageIndex[5] = m_imageListSmall->Add(WxUtils::LoadResourceBitmapPadded("rating5", size));
|
m_EmuStateImageIndex[5] = m_imageListSmall->Add(WxUtils::LoadResourceBitmap("rating5", size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::BrowseForDirectory()
|
void CGameListCtrl::BrowseForDirectory()
|
||||||
|
|
|
@ -60,13 +60,13 @@ void ShowErrorDialog(const wxString& error_msg)
|
||||||
wxMessageBox(error_msg, _("Error"), wxOK | wxICON_ERROR);
|
wxMessageBox(error_msg, _("Error"), wxOK | wxICON_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap LoadResourceBitmap(const std::string& name, bool allow_2x)
|
wxBitmap LoadResourceBitmap(const std::string& name, const wxSize& padded_size)
|
||||||
{
|
{
|
||||||
const std::string path_base = File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + name;
|
const std::string path_base = File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + name;
|
||||||
std::string path = path_base + ".png";
|
std::string path = path_base + ".png";
|
||||||
#ifdef __APPLE__
|
|
||||||
double scale_factor = 1.0;
|
double scale_factor = 1.0;
|
||||||
if (allow_2x && wxTheApp->GetTopWindow()->GetContentScaleFactor() >= 2)
|
#ifdef __APPLE__
|
||||||
|
if (wxTheApp->GetTopWindow()->GetContentScaleFactor() >= 2)
|
||||||
{
|
{
|
||||||
const std::string path_2x = path_base + "@2x.png";
|
const std::string path_2x = path_base + "@2x.png";
|
||||||
if (File::Exists(path_2x))
|
if (File::Exists(path_2x))
|
||||||
|
@ -77,6 +77,15 @@ wxBitmap LoadResourceBitmap(const std::string& name, bool allow_2x)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
wxImage image(StrToWxStr(path), wxBITMAP_TYPE_PNG);
|
wxImage image(StrToWxStr(path), wxBITMAP_TYPE_PNG);
|
||||||
|
|
||||||
|
if (padded_size != wxSize())
|
||||||
|
{
|
||||||
|
// Add padding if necessary (or crop, but images aren't supposed to be large enough to require that).
|
||||||
|
// The image will be left-aligned and vertically centered.
|
||||||
|
const wxSize scaled_padded_size = padded_size * scale_factor;
|
||||||
|
image.Resize(scaled_padded_size, wxPoint(0, (scaled_padded_size.GetHeight() - image.GetHeight()) / 2));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return wxBitmap(image, -1, scale_factor);
|
return wxBitmap(image, -1, scale_factor);
|
||||||
#else
|
#else
|
||||||
|
@ -84,13 +93,6 @@ wxBitmap LoadResourceBitmap(const std::string& name, bool allow_2x)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap LoadResourceBitmapPadded(const std::string& name, const wxSize& size)
|
|
||||||
{
|
|
||||||
wxImage image(StrToWxStr(File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + name + ".png"), wxBITMAP_TYPE_PNG);
|
|
||||||
image.Resize(size, wxPoint(0, (size.GetHeight() - image.GetHeight()) / 2)); // Vertically centered
|
|
||||||
return wxBitmap(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original)
|
wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original)
|
||||||
{
|
{
|
||||||
wxImage image = original.ConvertToImage();
|
wxImage image = original.ConvertToImage();
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <wx/gdicmn.h>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
|
||||||
class wxBitmap;
|
class wxBitmap;
|
||||||
class wxSize;
|
|
||||||
class wxToolBar;
|
class wxToolBar;
|
||||||
|
|
||||||
namespace WxUtils
|
namespace WxUtils
|
||||||
|
@ -24,8 +24,7 @@ void Explore(const std::string& path);
|
||||||
void ShowErrorDialog(const wxString& error_msg);
|
void ShowErrorDialog(const wxString& error_msg);
|
||||||
|
|
||||||
// Reads a PNG from the Resources folder
|
// Reads a PNG from the Resources folder
|
||||||
wxBitmap LoadResourceBitmap(const std::string& name, bool allow_2x = false);
|
wxBitmap LoadResourceBitmap(const std::string& name, const wxSize& padded_size = wxSize());
|
||||||
wxBitmap LoadResourceBitmapPadded(const std::string& name, const wxSize& size);
|
|
||||||
|
|
||||||
// From a wxBitmap, creates the corresponding disabled version for toolbar buttons
|
// From a wxBitmap, creates the corresponding disabled version for toolbar buttons
|
||||||
wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original);
|
wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original);
|
||||||
|
|
Loading…
Reference in New Issue