From 8d4068527bf2e74aae36f33fabbbdfde29fcb8e9 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 18 Oct 2014 11:07:17 -0400 Subject: [PATCH] DolphinQt: Stub Host_* functions & Resource system. --- Source/Core/DolphinQt/CMakeLists.txt | 9 +- Source/Core/DolphinQt/DolphinQt.vcxproj | 298 +++++++++--------- .../Core/DolphinQt/DolphinQt.vcxproj.filters | 44 +++ Source/Core/DolphinQt/Host.cpp | 106 +++++++ Source/Core/DolphinQt/Main.cpp | 16 +- Source/Core/DolphinQt/MainWindow.cpp | 21 +- Source/Core/DolphinQt/MainWindow.h | 2 +- Source/Core/DolphinQt/MainWindow.ui | 28 +- Source/Core/DolphinQt/Utils/Resources.cpp | 101 ++++++ Source/Core/DolphinQt/Utils/Resources.h | 53 ++++ Source/Core/DolphinQt/Utils/Utils.cpp | 21 ++ Source/Core/DolphinQt/Utils/Utils.h | 14 + .../VideoInterface/VideoInterface.cpp | 11 + 13 files changed, 560 insertions(+), 164 deletions(-) create mode 100644 Source/Core/DolphinQt/DolphinQt.vcxproj.filters create mode 100644 Source/Core/DolphinQt/Host.cpp create mode 100644 Source/Core/DolphinQt/Utils/Resources.cpp create mode 100644 Source/Core/DolphinQt/Utils/Resources.h create mode 100644 Source/Core/DolphinQt/Utils/Utils.cpp create mode 100644 Source/Core/DolphinQt/Utils/Utils.h create mode 100644 Source/Core/DolphinQt/VideoInterface/VideoInterface.cpp diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index afd108efaf..8bbd09ed2f 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -1,6 +1,7 @@ # because of generated UI files 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(SRCS @@ -8,13 +9,17 @@ set(SRCS AboutDialog.h Main.cpp MainWindow.cpp - MainWindow.h) + MainWindow.h + Host.cpp + Utils/Resources.cpp + Utils/Utils.cpp + VideoInterface/VideoInterface.cpp) set(UIS AboutDialog.ui MainWindow.ui) -set(LIBS common) +set(LIBS core uicommon) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(DOLPHINQT_BINARY DolphinQt) diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index f137547714..7399f17771 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -1,152 +1,162 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {69D2B16E-122A-4E5D-8C37-8EC7B0F7CEB0} + + + + + Debug + x64 + + + Release + x64 + + + + {69D2B16E-122A-4E5D-8C37-8EC7B0F7CEB0} - - - - Application - v120 - Unicode - - - true - - - false - - - - - - - - - - - - - - - 0x00400000 - false - true - $(ExternalsDir)OpenAL\$(PlatformName);%(AdditionalLibraryDirectories) - iphlpapi.lib;winmm.lib;setupapi.lib;vfw32.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - - - - - + --> + + + + Application + v120 + Unicode + + + true + + + false + + + + + + + + + + + + + + + 0x00400000 + false + true + $(ExternalsDir)OpenAL\$(PlatformName);%(AdditionalLibraryDirectories) + iphlpapi.lib;winmm.lib;setupapi.lib;vfw32.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - {8ada04d7-6db1-4da4-ab55-64fb12a0997b} - - - {4c9f135b-a85e-430c-bad4-4c67ef5fc12c} - - - {ab993f38-c31d-4897-b139-a620c42bc565} - - - {93d73454-2512-424e-9cda-4bb357fe13dd} - - - {ff213b23-2c26-4214-9f88-85271e557e87} - - - {54aa7840-5beb-4a0c-9452-74ba4cc7fd44} - - - {2e6c348c-c75c-4d94-8d1e-9c1fcbf3efe4} - - - {41279555-f94f-4ebc-99de-af863c10c5c4} - - - {e54cf649-140e-4255-81a5-30a673c1fb36} - - - {160bdc25-5626-4b0d-bdd8-2953d9777fb5} - - - {6bbd47cf-91fd-4077-b676-8b76980178a9} - - - {96020103-4ba5-4fd2-b4aa-5b6d24492d4e} - - - {ec1a314c-5588-4506-9c1e-2e58e5817f75} - - - {a4c423aa-f57c-46c7-a172-d1a777017d29} - - - {3de9ee35-3e91-4f27-a014-2866ad8c3fe3} - - - - - - - - - - - - - - - - - - - - - - + --> + + + + + + {8ada04d7-6db1-4da4-ab55-64fb12a0997b} + + + {4c9f135b-a85e-430c-bad4-4c67ef5fc12c} + + + {ab993f38-c31d-4897-b139-a620c42bc565} + + + {93d73454-2512-424e-9cda-4bb357fe13dd} + + + {ff213b23-2c26-4214-9f88-85271e557e87} + + + {54aa7840-5beb-4a0c-9452-74ba4cc7fd44} + + + {2e6c348c-c75c-4d94-8d1e-9c1fcbf3efe4} + + + {41279555-f94f-4ebc-99de-af863c10c5c4} + + + {e54cf649-140e-4255-81a5-30a673c1fb36} + + + {160bdc25-5626-4b0d-bdd8-2953d9777fb5} + + + {6bbd47cf-91fd-4077-b676-8b76980178a9} + + + {96020103-4ba5-4fd2-b4aa-5b6d24492d4e} + + + {ec1a314c-5588-4506-9c1e-2e58e5817f75} + + + {a4c423aa-f57c-46c7-a172-d1a777017d29} + + + {3de9ee35-3e91-4f27-a014-2866ad8c3fe3} + + + {604C8368-F34A-4D55-82C8-CC92A0C13254} + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj.filters b/Source/Core/DolphinQt/DolphinQt.vcxproj.filters new file mode 100644 index 0000000000..d94c197d64 --- /dev/null +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + + + + + VideoInterface + + + Utils + + + Utils + + + + + + + + + + + + + + + {2497846c-00eb-4f1c-b437-2d32eac9027c} + + + {730f2ae7-a686-4bc8-bb49-b4f8bd240329} + + + + + Utils + + + Utils + + + \ No newline at end of file diff --git a/Source/Core/DolphinQt/Host.cpp b/Source/Core/DolphinQt/Host.cpp new file mode 100644 index 0000000000..ced35df0ab --- /dev/null +++ b/Source/Core/DolphinQt/Host.cpp @@ -0,0 +1,106 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include +#include + +#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 +} diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp index f2b034fadb..9bcea4de27 100644 --- a/Source/Core/DolphinQt/Main.cpp +++ b/Source/Core/DolphinQt/Main.cpp @@ -11,6 +11,9 @@ #include "MainWindow.h" +#include "DolphinQt/Utils/Utils.h" +#include "UICommon/UICommon.h" + static bool IsOsSupported() { #ifdef Q_OS_OSX @@ -25,11 +28,11 @@ static bool IsOsSupported() static QString LowestSupportedOsVersion() { #ifdef Q_OS_OSX - return QStringLiteral("Mac OS X 10.7"); + return SL("Mac OS X 10.7"); #elif defined(Q_OS_WIN) - return QStringLiteral("Windows Vista SP2"); + return SL("Windows Vista SP2"); #else - return QStringLiteral("Unknown"); + return SL("Unknown"); #endif } @@ -38,6 +41,9 @@ int main(int argc, char* argv[]) QApplication app(argc, argv); // TODO: Add command line options + UICommon::CreateDirectories(); + UICommon::Init(); + if (!IsOsSupported()) { QMessageBox::critical(nullptr, QObject::tr("Unsupported OS"), @@ -50,5 +56,7 @@ int main(int argc, char* argv[]) DMainWindow w; w.show(); - return app.exec(); + int retcode = app.exec(); + UICommon::Shutdown(); + return retcode; } diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 2b82949b01..b67ec2198a 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -5,16 +5,23 @@ #include #include -#include "AboutDialog.h" -#include "MainWindow.h" #include "ui_MainWindow.h" + #include "Common/StdMakeUnique.h" -DMainWindow::DMainWindow(QWidget* p) - : QMainWindow(p) +#include "DolphinQt/AboutDialog.h" +#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->setupUi(this); + + Resources::Init(); + ui->actOpen->setIcon(Resources::GetIcon(Resources::TOOLBAR_OPEN)); } DMainWindow::~DMainWindow() @@ -23,17 +30,17 @@ DMainWindow::~DMainWindow() 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() { - 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() { - 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() diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index 5757bfe8ba..d7db3b6294 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -17,7 +17,7 @@ class DMainWindow : public QMainWindow Q_OBJECT public: - explicit DMainWindow(QWidget* p = nullptr); + explicit DMainWindow(QWidget* parent_widget = nullptr); ~DMainWindow(); private slots: diff --git a/Source/Core/DolphinQt/MainWindow.ui b/Source/Core/DolphinQt/MainWindow.ui index 29200f44a5..7172fc4424 100644 --- a/Source/Core/DolphinQt/MainWindow.ui +++ b/Source/Core/DolphinQt/MainWindow.ui @@ -6,8 +6,8 @@ 0 0 - 998 - 598 + 996 + 596 @@ -15,8 +15,8 @@ - 64 - 64 + 32 + 32 @@ -31,14 +31,15 @@ 0 0 - 998 - 24 + 996 + 21 Fi&le + @@ -70,8 +71,14 @@ + + + Movie + + + @@ -88,6 +95,7 @@ false + @@ -109,6 +117,14 @@ &About + + + Open + + + Open file... + + diff --git a/Source/Core/DolphinQt/Utils/Resources.cpp b/Source/Core/DolphinQt/Utils/Resources.cpp new file mode 100644 index 0000000000..08c9e37ed2 --- /dev/null +++ b/Source/Core/DolphinQt/Utils/Resources.cpp @@ -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 Resources::m_platforms; +QVector Resources::m_regions; +QVector Resources::m_ratings; +QVector 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)); +} diff --git a/Source/Core/DolphinQt/Utils/Resources.h b/Source/Core/DolphinQt/Utils/Resources.h new file mode 100644 index 0000000000..df9def2697 --- /dev/null +++ b/Source/Core/DolphinQt/Utils/Resources.h @@ -0,0 +1,53 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include + +#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 m_platforms; + static QVector m_regions; + static QVector m_ratings; + static QVector m_pixmaps; +}; diff --git a/Source/Core/DolphinQt/Utils/Utils.cpp b/Source/Core/DolphinQt/Utils/Utils.cpp new file mode 100644 index 0000000000..db1fb19b19 --- /dev/null +++ b/Source/Core/DolphinQt/Utils/Utils.cpp @@ -0,0 +1,21 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include + +#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); +} diff --git a/Source/Core/DolphinQt/Utils/Utils.h b/Source/Core/DolphinQt/Utils/Utils.h new file mode 100644 index 0000000000..9591d4dd98 --- /dev/null +++ b/Source/Core/DolphinQt/Utils/Utils.h @@ -0,0 +1,14 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +#include + +#include "Common/CommonTypes.h" + +// Shorter version of QStringLiteral(str) +#define SL(str) QStringLiteral(str) + +QString NiceSizeFormat(s64 size); diff --git a/Source/Core/DolphinQt/VideoInterface/VideoInterface.cpp b/Source/Core/DolphinQt/VideoInterface/VideoInterface.cpp new file mode 100644 index 0000000000..4424175f16 --- /dev/null +++ b/Source/Core/DolphinQt/VideoInterface/VideoInterface.cpp @@ -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; +}