DolphinQt: Stub Host_* functions & Resource system.

This commit is contained in:
Augustin Cavalier 2014-10-18 11:07:17 -04:00
parent 742f9c6b14
commit 8d4068527b
13 changed files with 560 additions and 164 deletions

View File

@ -1,6 +1,7 @@
# because of generated UI files # because of generated UI files
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DQT_USE_QSTRINGBUILDER -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(SRCS set(SRCS
@ -8,13 +9,17 @@ set(SRCS
AboutDialog.h AboutDialog.h
Main.cpp Main.cpp
MainWindow.cpp MainWindow.cpp
MainWindow.h) MainWindow.h
Host.cpp
Utils/Resources.cpp
Utils/Utils.cpp
VideoInterface/VideoInterface.cpp)
set(UIS set(UIS
AboutDialog.ui AboutDialog.ui
MainWindow.ui) MainWindow.ui)
set(LIBS common) set(LIBS core uicommon)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(DOLPHINQT_BINARY DolphinQt) set(DOLPHINQT_BINARY DolphinQt)

View File

@ -66,9 +66,13 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="$(QtMocOutPrefix)AboutDialog.cpp" /> <ClCompile Include="$(QtMocOutPrefix)AboutDialog.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" /> <ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
<ClCompile Include="Utils\Resources.cpp" />
<ClCompile Include="Utils\Utils.cpp" />
<ClCompile Include="VideoInterface\VideoInterface.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="AboutDialog.cpp" /> <ClCompile Include="AboutDialog.cpp" />
<ClCompile Include="Host.cpp" />
<ClCompile Include="Main.cpp" /> <ClCompile Include="Main.cpp" />
<ClCompile Include="MainWindow.cpp" /> <ClCompile Include="MainWindow.cpp" />
</ItemGroup> </ItemGroup>
@ -127,6 +131,9 @@
<ProjectReference Include="$(CoreDir)VideoCommon\VideoCommon.vcxproj"> <ProjectReference Include="$(CoreDir)VideoCommon\VideoCommon.vcxproj">
<Project>{3de9ee35-3e91-4f27-a014-2866ad8c3fe3}</Project> <Project>{3de9ee35-3e91-4f27-a014-2866ad8c3fe3}</Project>
</ProjectReference> </ProjectReference>
<ProjectReference Include="$(CoreDir)UICommon\UICommon.vcxproj">
<Project>{604C8368-F34A-4D55-82C8-CC92A0C13254}</Project>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
@ -139,9 +146,12 @@
<BinaryFiles Include="$(TargetPath)" /> <BinaryFiles Include="$(TargetPath)" />
<AllInputFiles Include="@(DataDirFiles);@(ExternalDlls);@(BinaryFiles)" /> <AllInputFiles Include="@(DataDirFiles);@(ExternalDlls);@(BinaryFiles)" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClInclude Include="Utils\Resources.h" />
<ClInclude Include="Utils\Utils.h" />
</ItemGroup>
<!--Disable copying to binary dir for now on the buildbot to prevent packaging of the outputs--> <!--Disable copying to binary dir for now on the buildbot to prevent packaging of the outputs-->
<Target Name="AfterBuild" Inputs="@(AllInputFiles)" Outputs="@(AllInputFiles -> '$(BinaryOutputDir)%(RecursiveDir)%(Filename)%(Extension)')" <Target Name="AfterBuild" Inputs="@(AllInputFiles)" Outputs="@(AllInputFiles -> '$(BinaryOutputDir)%(RecursiveDir)%(Filename)%(Extension)')" Condition="'$(I_AM_BUILDACUS)'==''">
Condition="'$(I_AM_BUILDACUS)'==''">
<Message Text="Copying Data directory..." Importance="High" /> <Message Text="Copying Data directory..." Importance="High" />
<Copy SourceFiles="@(DataDirFiles)" DestinationFolder="$(BinaryOutputDir)%(RecursiveDir)" Condition="!Exists('$(BinaryOutputDir)%(RecursiveDir)%(Filename)%(DataDirFiles.Extension)') OR $([System.DateTime]::Parse('%(ModifiedTime)').Ticks) &gt; $([System.IO.File]::GetLastWriteTime('$(BinaryOutputDir)%(RecursiveDir)%(Filename)%(DataDirFiles.Extension)').Ticks)" /> <Copy SourceFiles="@(DataDirFiles)" DestinationFolder="$(BinaryOutputDir)%(RecursiveDir)" Condition="!Exists('$(BinaryOutputDir)%(RecursiveDir)%(Filename)%(DataDirFiles.Extension)') OR $([System.DateTime]::Parse('%(ModifiedTime)').Ticks) &gt; $([System.IO.File]::GetLastWriteTime('$(BinaryOutputDir)%(RecursiveDir)%(Filename)%(DataDirFiles.Extension)').Ticks)" />
<Message Text="Copying External .dlls" Importance="High" /> <Message Text="Copying External .dlls" Importance="High" />

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="AboutDialog.cpp" />
<ClCompile Include="Host.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="MainWindow.cpp" />
<ClCompile Include="VideoInterface\VideoInterface.cpp">
<Filter>VideoInterface</Filter>
</ClCompile>
<ClCompile Include="Utils\Resources.cpp">
<Filter>Utils</Filter>
</ClCompile>
<ClCompile Include="Utils\Utils.cpp">
<Filter>Utils</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="AboutDialog.h" />
<QtMoc Include="MainWindow.h" />
</ItemGroup>
<ItemGroup>
<QtUi Include="*.ui" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<Filter Include="VideoInterface">
<UniqueIdentifier>{2497846c-00eb-4f1c-b437-2d32eac9027c}</UniqueIdentifier>
</Filter>
<Filter Include="Utils">
<UniqueIdentifier>{730f2ae7-a686-4bc8-bb49-b4f8bd240329}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Utils\Resources.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="Utils\Utils.h">
<Filter>Utils</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,106 @@
// Copyright 2014 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <cstdarg>
#include <cstring>
#include "Common/MsgHandler.h"
#include "Core/Host.h"
void Host_SysMessage(const char *fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n')
msg[strlen(msg)-1] = '\0';
PanicAlert("%s", msg);
}
void Host_Message(int id)
{
// TODO
}
void* Host_GetRenderHandle()
{
return nullptr;
}
void Host_NotifyMapLoaded()
{
// TODO
}
void Host_UpdateDisasmDialog()
{
// TODO
}
void Host_UpdateMainFrame()
{
// TODO
}
void Host_UpdateTitle(const std::string& title)
{
// TODO
}
void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height)
{
// TODO
}
void Host_RequestRenderWindowSize(int width, int height)
{
// TODO
}
void Host_RequestFullscreen(bool enable_fullscreen)
{
// TODO
}
void Host_SetStartupDebuggingParameters()
{
// TODO
}
void Host_SetWiiMoteConnectionState(int state)
{
// TODO
}
bool Host_UIHasFocus()
{
// TODO
return false;
}
bool Host_RendererHasFocus()
{
// TODO
return false;
}
void Host_ConnectWiimote(int wm_idx, bool connect)
{
// TODO
}
void Host_ShowVideoConfig(void* parent, const std::string& backend_name,
const std::string& config_name)
{
// TODO
}
void Host_RefreshDSPDebuggerWindow()
{
// TODO
}

View File

@ -11,6 +11,9 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "DolphinQt/Utils/Utils.h"
#include "UICommon/UICommon.h"
static bool IsOsSupported() static bool IsOsSupported()
{ {
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
@ -25,11 +28,11 @@ static bool IsOsSupported()
static QString LowestSupportedOsVersion() static QString LowestSupportedOsVersion()
{ {
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
return QStringLiteral("Mac OS X 10.7"); return SL("Mac OS X 10.7");
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
return QStringLiteral("Windows Vista SP2"); return SL("Windows Vista SP2");
#else #else
return QStringLiteral("Unknown"); return SL("Unknown");
#endif #endif
} }
@ -38,6 +41,9 @@ int main(int argc, char* argv[])
QApplication app(argc, argv); QApplication app(argc, argv);
// TODO: Add command line options // TODO: Add command line options
UICommon::CreateDirectories();
UICommon::Init();
if (!IsOsSupported()) if (!IsOsSupported())
{ {
QMessageBox::critical(nullptr, QObject::tr("Unsupported OS"), QMessageBox::critical(nullptr, QObject::tr("Unsupported OS"),
@ -50,5 +56,7 @@ int main(int argc, char* argv[])
DMainWindow w; DMainWindow w;
w.show(); w.show();
return app.exec(); int retcode = app.exec();
UICommon::Shutdown();
return retcode;
} }

View File

@ -5,16 +5,23 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QUrl> #include <QUrl>
#include "AboutDialog.h"
#include "MainWindow.h"
#include "ui_MainWindow.h" #include "ui_MainWindow.h"
#include "Common/StdMakeUnique.h" #include "Common/StdMakeUnique.h"
DMainWindow::DMainWindow(QWidget* p) #include "DolphinQt/AboutDialog.h"
: QMainWindow(p) #include "DolphinQt/MainWindow.h"
#include "DolphinQt/Utils/Resources.h"
#include "DolphinQt/Utils/Utils.h"
DMainWindow::DMainWindow(QWidget* parent_widget)
: QMainWindow(parent_widget)
{ {
ui = std::make_unique<Ui::DMainWindow>(); ui = std::make_unique<Ui::DMainWindow>();
ui->setupUi(this); ui->setupUi(this);
Resources::Init();
ui->actOpen->setIcon(Resources::GetIcon(Resources::TOOLBAR_OPEN));
} }
DMainWindow::~DMainWindow() DMainWindow::~DMainWindow()
@ -23,17 +30,17 @@ DMainWindow::~DMainWindow()
void DMainWindow::on_actWebsite_triggered() void DMainWindow::on_actWebsite_triggered()
{ {
QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/"))); QDesktopServices::openUrl(QUrl(SL("https://dolphin-emu.org/")));
} }
void DMainWindow::on_actOnlineDocs_triggered() void DMainWindow::on_actOnlineDocs_triggered()
{ {
QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/docs/guides/"))); QDesktopServices::openUrl(QUrl(SL("https://dolphin-emu.org/docs/guides/")));
} }
void DMainWindow::on_actGitHub_triggered() void DMainWindow::on_actGitHub_triggered()
{ {
QDesktopServices::openUrl(QUrl(QStringLiteral("https://github.com/dolphin-emu/dolphin/"))); QDesktopServices::openUrl(QUrl(SL("https://github.com/dolphin-emu/dolphin/")));
} }
void DMainWindow::on_actAbout_triggered() void DMainWindow::on_actAbout_triggered()

View File

@ -17,7 +17,7 @@ class DMainWindow : public QMainWindow
Q_OBJECT Q_OBJECT
public: public:
explicit DMainWindow(QWidget* p = nullptr); explicit DMainWindow(QWidget* parent_widget = nullptr);
~DMainWindow(); ~DMainWindow();
private slots: private slots:

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>998</width> <width>996</width>
<height>598</height> <height>596</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,8 +15,8 @@
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
<width>64</width> <width>32</width>
<height>64</height> <height>32</height>
</size> </size>
</property> </property>
<property name="toolButtonStyle"> <property name="toolButtonStyle">
@ -31,14 +31,15 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>998</width> <width>996</width>
<height>24</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="mnuFile"> <widget class="QMenu" name="mnuFile">
<property name="title"> <property name="title">
<string>Fi&amp;le</string> <string>Fi&amp;le</string>
</property> </property>
<addaction name="actOpen"/>
</widget> </widget>
<widget class="QMenu" name="mnuEmulation"> <widget class="QMenu" name="mnuEmulation">
<property name="title"> <property name="title">
@ -70,8 +71,14 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actAbout"/> <addaction name="actAbout"/>
</widget> </widget>
<widget class="QMenu" name="mnuMovie">
<property name="title">
<string>Movie</string>
</property>
</widget>
<addaction name="mnuFile"/> <addaction name="mnuFile"/>
<addaction name="mnuEmulation"/> <addaction name="mnuEmulation"/>
<addaction name="mnuMovie"/>
<addaction name="mnuOptions"/> <addaction name="mnuOptions"/>
<addaction name="mnuTools"/> <addaction name="mnuTools"/>
<addaction name="mnuView"/> <addaction name="mnuView"/>
@ -88,6 +95,7 @@
<attribute name="toolBarBreak"> <attribute name="toolBarBreak">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<addaction name="actOpen"/>
</widget> </widget>
<action name="actWebsite"> <action name="actWebsite">
<property name="text"> <property name="text">
@ -109,6 +117,14 @@
<string>&amp;About</string> <string>&amp;About</string>
</property> </property>
</action> </action>
<action name="actOpen">
<property name="text">
<string>Open</string>
</property>
<property name="toolTip">
<string>Open file...</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View 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));
}

View 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;
};

View 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);
}

View 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);

View File

@ -0,0 +1,11 @@
// Copyright 2014 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "VideoBackends/OGL/GLInterfaceBase.h"
cInterfaceBase* HostGL_CreateGLInterface()
{
// TODO
return nullptr;
}