2015-11-27 08:33:07 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2017-05-30 20:42:21 +00:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QScreen>
|
2015-11-27 08:33:07 +00:00
|
|
|
#include <QStringList>
|
|
|
|
|
2015-10-30 09:04:54 +00:00
|
|
|
#include "Common/CommonPaths.h"
|
2015-11-27 08:33:07 +00:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "DolphinQt2/Resources.h"
|
2017-05-30 20:42:21 +00:00
|
|
|
#include "DolphinQt2/Settings.h"
|
2015-11-27 08:33:07 +00:00
|
|
|
|
|
|
|
QList<QPixmap> Resources::m_platforms;
|
|
|
|
QList<QPixmap> Resources::m_countries;
|
|
|
|
QList<QPixmap> Resources::m_ratings;
|
|
|
|
QList<QPixmap> Resources::m_misc;
|
|
|
|
|
2017-05-30 20:42:21 +00:00
|
|
|
QIcon Resources::GetIcon(const QString& name, const QString& dir)
|
|
|
|
{
|
|
|
|
QString base_path = dir + name;
|
|
|
|
|
|
|
|
const auto dpr = QGuiApplication::primaryScreen()->devicePixelRatio();
|
|
|
|
|
|
|
|
QIcon icon(base_path.append(QStringLiteral(".png")));
|
|
|
|
|
|
|
|
if (dpr > 2)
|
|
|
|
{
|
|
|
|
QPixmap pixmap(base_path.append(QStringLiteral("@4x.png")));
|
|
|
|
if (!pixmap.isNull())
|
|
|
|
{
|
|
|
|
pixmap.setDevicePixelRatio(4.0);
|
|
|
|
icon.addPixmap(pixmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap Resources::GetPixmap(const QString& name, const QString& dir)
|
|
|
|
{
|
|
|
|
const auto icon = GetIcon(name, dir);
|
|
|
|
return icon.pixmap(icon.availableSizes()[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
QIcon Resources::GetScaledIcon(const std::string& name)
|
|
|
|
{
|
2017-05-31 07:17:39 +00:00
|
|
|
return GetIcon(QString::fromStdString(name), Settings::Instance().GetResourcesDir());
|
2017-05-30 20:42:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QIcon Resources::GetScaledThemeIcon(const std::string& name)
|
|
|
|
{
|
2017-05-31 07:17:39 +00:00
|
|
|
return GetIcon(QString::fromStdString(name), Settings::Instance().GetThemeDir());
|
2017-05-30 20:42:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap Resources::GetScaledPixmap(const std::string& name)
|
|
|
|
{
|
2017-05-31 07:17:39 +00:00
|
|
|
return GetPixmap(QString::fromStdString(name), Settings::Instance().GetResourcesDir());
|
2017-05-30 20:42:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap Resources::GetScaledThemePixmap(const std::string& name)
|
|
|
|
{
|
2017-05-31 07:17:39 +00:00
|
|
|
return GetPixmap(QString::fromStdString(name), Settings::Instance().GetThemeDir());
|
2017-05-30 20:42:21 +00:00
|
|
|
}
|
|
|
|
|
2015-11-27 08:33:07 +00:00
|
|
|
void Resources::Init()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QString sys_dir = QString::fromStdString(File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP);
|
2015-11-27 08:33:07 +00:00
|
|
|
|
2017-05-30 20:42:21 +00:00
|
|
|
for (const std::string& platform :
|
|
|
|
{"Platform_Gamecube", "Platform_Wii", "Platform_Wad", "Platform_File"})
|
|
|
|
{
|
|
|
|
m_platforms.append(GetScaledPixmap(platform));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const std::string& country :
|
|
|
|
{"Flag_Europe", "Flag_Japan", "Flag_USA", "Flag_Australia", "Flag_France", "Flag_Germany",
|
|
|
|
"Flag_Italy", "Flag_Korea", "Flag_Netherlands", "Flag_Russia", "Flag_Spain", "Flag_Taiwan",
|
|
|
|
"Flag_International", "Flag_Unknown"})
|
|
|
|
{
|
|
|
|
m_countries.append(GetScaledPixmap(country));
|
|
|
|
}
|
|
|
|
for (int stars = 0; stars <= 5; stars++)
|
2017-05-30 21:02:20 +00:00
|
|
|
m_ratings.append(GetScaledThemePixmap("rating" + std::to_string(stars)));
|
2017-05-30 20:42:21 +00:00
|
|
|
|
|
|
|
m_misc.append(GetScaledPixmap("nobanner"));
|
|
|
|
m_misc.append(GetScaledPixmap("dolphin_logo"));
|
|
|
|
m_misc.append(GetScaledPixmap("Dolphin"));
|
2015-11-27 08:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap Resources::GetPlatform(int platform)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return m_platforms[platform];
|
2015-11-27 08:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap Resources::GetCountry(int country)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return m_countries[country];
|
2015-11-27 08:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap Resources::GetRating(int rating)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return m_ratings[rating];
|
2015-11-27 08:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap Resources::GetMisc(int id)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return m_misc[id];
|
2015-11-27 08:33:07 +00:00
|
|
|
}
|