mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
DolphinQt: Stub Host_* functions & Resource system.
This commit is contained in:
101
Source/Core/DolphinQt/Utils/Resources.cpp
Normal file
101
Source/Core/DolphinQt/Utils/Resources.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
// Copyright 2014 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
|
||||
#include "DolphinQt/Utils/Resources.h"
|
||||
#include "DolphinQt/Utils/Utils.h"
|
||||
|
||||
QVector<QPixmap> Resources::m_platforms;
|
||||
QVector<QPixmap> Resources::m_regions;
|
||||
QVector<QPixmap> Resources::m_ratings;
|
||||
QVector<QPixmap> Resources::m_pixmaps;
|
||||
|
||||
void Resources::Init()
|
||||
{
|
||||
QString dir = QString::fromStdString(File::GetSysDirectory() + "Resources/");
|
||||
|
||||
m_regions.resize(DiscIO::IVolume::NUMBER_OF_COUNTRIES);
|
||||
m_regions[DiscIO::IVolume::COUNTRY_EUROPE].load(dir + SL("Flag_Europe.png"));
|
||||
m_regions[DiscIO::IVolume::COUNTRY_FRANCE].load(dir + SL("Flag_France.png"));
|
||||
m_regions[DiscIO::IVolume::COUNTRY_RUSSIA].load(dir + SL("Flag_Unknown.png")); // TODO
|
||||
m_regions[DiscIO::IVolume::COUNTRY_USA].load(dir + SL("Flag_USA.png"));
|
||||
m_regions[DiscIO::IVolume::COUNTRY_JAPAN].load(dir + SL("Flag_Japan.png"));
|
||||
m_regions[DiscIO::IVolume::COUNTRY_KOREA].load(dir + SL("Flag_Korea.png"));
|
||||
m_regions[DiscIO::IVolume::COUNTRY_ITALY].load(dir + SL("Flag_Italy.png"));
|
||||
m_regions[DiscIO::IVolume::COUNTRY_TAIWAN].load(dir + SL("Flag_Taiwan.png"));
|
||||
m_regions[DiscIO::IVolume::COUNTRY_SDK].load(dir + SL("Flag_SDK.png"));
|
||||
m_regions[DiscIO::IVolume::COUNTRY_UNKNOWN].load(dir + SL("Flag_Unknown.png"));
|
||||
|
||||
m_platforms.resize(3);
|
||||
m_platforms[0].load(dir + SL("Platform_Gamecube.png"));
|
||||
m_platforms[1].load(dir + SL("Platform_Wii.png"));
|
||||
m_platforms[2].load(dir + SL("Platform_Wad.png"));
|
||||
|
||||
m_ratings.resize(6);
|
||||
m_ratings[0].load(dir + SL("rating0.png"));
|
||||
m_ratings[1].load(dir + SL("rating1.png"));
|
||||
m_ratings[2].load(dir + SL("rating2.png"));
|
||||
m_ratings[3].load(dir + SL("rating3.png"));
|
||||
m_ratings[4].load(dir + SL("rating4.png"));
|
||||
m_ratings[5].load(dir + SL("rating5.png"));
|
||||
|
||||
m_pixmaps.resize(NUM_ICONS);
|
||||
m_pixmaps[DOLPHIN_LOGO].load(dir + SL("Dolphin.png"));
|
||||
UpdatePixmaps();
|
||||
}
|
||||
|
||||
void Resources::UpdatePixmaps()
|
||||
{
|
||||
QString dir = QString::fromStdString(File::GetThemeDir(SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name));
|
||||
m_pixmaps[TOOLBAR_OPEN].load(dir + SL("open.png"));
|
||||
m_pixmaps[TOOLBAR_REFRESH].load(dir + SL("refresh.png"));
|
||||
m_pixmaps[TOOLBAR_BROWSE].load(dir + SL("browse.png"));
|
||||
m_pixmaps[TOOLBAR_PLAY].load(dir + SL("play.png"));
|
||||
m_pixmaps[TOOLBAR_STOP].load(dir + SL("stop.png"));
|
||||
m_pixmaps[TOOLBAR_PAUSE].load(dir + SL("pause.png"));
|
||||
m_pixmaps[TOOLBAR_FULLSCREEN].load(dir + SL("fullscreen.png"));
|
||||
m_pixmaps[TOOLBAR_SCREENSHOT].load(dir + SL("screenshot.png"));
|
||||
m_pixmaps[TOOLBAR_CONFIGURE].load(dir + SL("config.png"));
|
||||
m_pixmaps[TOOLBAR_PLUGIN_GFX].load(dir + SL("graphics.png"));
|
||||
m_pixmaps[TOOLBAR_PLUGIN_DSP].load(dir + SL("dsp.png"));
|
||||
m_pixmaps[TOOLBAR_PLUGIN_GCPAD].load(dir + SL("gcpad.png"));
|
||||
m_pixmaps[TOOLBAR_PLUGIN_WIIMOTE].load(dir + SL("wiimote.png"));
|
||||
m_pixmaps[TOOLBAR_HELP].load(dir + SL("nobanner.png")); // TODO
|
||||
// TODO: toolbar[MEMCARD];
|
||||
// TODO: toolbar[HOTKEYS];
|
||||
m_pixmaps[BANNER_MISSING].load(dir + SL("nobanner.png"));
|
||||
}
|
||||
|
||||
QPixmap& Resources::GetRegionPixmap(DiscIO::IVolume::ECountry region)
|
||||
{
|
||||
return m_regions[region];
|
||||
}
|
||||
|
||||
QPixmap& Resources::GetPlatformPixmap(int console)
|
||||
{
|
||||
if (console >= m_platforms.size() || console < 0)
|
||||
return m_platforms[0];
|
||||
return m_platforms[console];
|
||||
}
|
||||
|
||||
QPixmap& Resources::GetRatingPixmap(int rating)
|
||||
{
|
||||
if (rating >= m_ratings.size() || rating < 0)
|
||||
return m_ratings[0];
|
||||
return m_ratings[rating];
|
||||
}
|
||||
|
||||
QPixmap& Resources::GetPixmap(int id)
|
||||
{
|
||||
if (id >= m_pixmaps.size() || id < 0)
|
||||
return m_pixmaps[0];
|
||||
return m_pixmaps[id];
|
||||
}
|
||||
|
||||
QIcon Resources::GetIcon(int id)
|
||||
{
|
||||
return QIcon(GetPixmap(id));
|
||||
}
|
53
Source/Core/DolphinQt/Utils/Resources.h
Normal file
53
Source/Core/DolphinQt/Utils/Resources.h
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright 2014 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QVector>
|
||||
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
class Resources
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
static void UpdatePixmaps();
|
||||
|
||||
static QPixmap& GetPlatformPixmap(int console);
|
||||
static QPixmap& GetRegionPixmap(DiscIO::IVolume::ECountry region);
|
||||
static QPixmap& GetRatingPixmap(int rating);
|
||||
static QPixmap& GetPixmap(int id);
|
||||
static QIcon GetIcon(int id);
|
||||
|
||||
enum
|
||||
{
|
||||
TOOLBAR_OPEN = 0,
|
||||
TOOLBAR_REFRESH,
|
||||
TOOLBAR_BROWSE,
|
||||
TOOLBAR_PLAY,
|
||||
TOOLBAR_STOP,
|
||||
TOOLBAR_PAUSE,
|
||||
TOOLBAR_FULLSCREEN,
|
||||
TOOLBAR_SCREENSHOT,
|
||||
TOOLBAR_CONFIGURE,
|
||||
TOOLBAR_PLUGIN_GFX,
|
||||
TOOLBAR_PLUGIN_DSP,
|
||||
TOOLBAR_PLUGIN_GCPAD,
|
||||
TOOLBAR_PLUGIN_WIIMOTE,
|
||||
TOOLBAR_HELP,
|
||||
MEMCARD,
|
||||
HOTKEYS,
|
||||
DOLPHIN_LOGO,
|
||||
BANNER_MISSING,
|
||||
NUM_ICONS
|
||||
};
|
||||
|
||||
private:
|
||||
static QVector<QPixmap> m_platforms;
|
||||
static QVector<QPixmap> m_regions;
|
||||
static QVector<QPixmap> m_ratings;
|
||||
static QVector<QPixmap> m_pixmaps;
|
||||
};
|
21
Source/Core/DolphinQt/Utils/Utils.cpp
Normal file
21
Source/Core/DolphinQt/Utils/Utils.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2014 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QStringListIterator>
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
QString NiceSizeFormat(s64 size)
|
||||
{
|
||||
QStringList list = { SL("KB"), SL("MB"), SL("GB"), SL("TB"), SL("PB"), SL("EB") };
|
||||
QStringListIterator i(list);
|
||||
QString unit = SL("b");
|
||||
double num = size;
|
||||
while (num >= 1024.0 && i.hasNext())
|
||||
{
|
||||
unit = i.next();
|
||||
num /= 1024.0;
|
||||
}
|
||||
return SL("%1 %2").arg(QString::number(num, 'f', 1)).arg(unit);
|
||||
}
|
14
Source/Core/DolphinQt/Utils/Utils.h
Normal file
14
Source/Core/DolphinQt/Utils/Utils.h
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2014 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
// Shorter version of QStringLiteral(str)
|
||||
#define SL(str) QStringLiteral(str)
|
||||
|
||||
QString NiceSizeFormat(s64 size);
|
Reference in New Issue
Block a user