Merge pull request #62 from JosJuice/merge-upstream

Merge remote-tracking branch 'upstream/master'
This commit is contained in:
David Liu 2020-12-02 00:26:56 -05:00 committed by GitHub
commit 0f94aa9ef2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
970 changed files with 100021 additions and 88645 deletions

View file

@ -3,6 +3,9 @@
// Refer to the license.txt file included.
#ifdef _WIN32
#include <string>
#include <vector>
#include <Windows.h>
#include <cstdio>
#endif
@ -15,12 +18,13 @@
#include <QPushButton>
#include <QWidget>
#include "Common/Config/Config.h"
#include "Common/MsgHandler.h"
#include "Common/ScopeGuard.h"
#include "Core/Analytics.h"
#include "Core/Boot/Boot.h"
#include "Core/ConfigManager.h"
#include "Core/Config/MainSettings.h"
#include "Core/Core.h"
#include "DolphinQt/Host.h"
@ -96,11 +100,18 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no
return false;
}
// N.B. On Windows, this should be called from WinMain. Link against qtmain and specify
// /SubSystem:Windows
#ifndef _WIN32
int main(int argc, char* argv[])
{
#ifdef _WIN32
#else
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
std::vector<std::string> utf8_args = CommandLineToUtf8Argv(GetCommandLineW());
const int utf8_argc = static_cast<int>(utf8_args.size());
std::vector<char*> utf8_argv(utf8_args.size());
for (size_t i = 0; i < utf8_args.size(); ++i)
utf8_argv[i] = utf8_args[i].data();
const bool console_attached = AttachConsole(ATTACH_PARENT_PROCESS) != FALSE;
HANDLE stdout_handle = ::GetStdHandle(STD_OUTPUT_HANDLE);
if (console_attached && stdout_handle)
@ -110,8 +121,25 @@ int main(int argc, char* argv[])
}
#endif
#ifdef __APPLE__
// On macOS, a command line option matching the format "-psn_X_XXXXXX" is passed when
// the application is launched for the first time. This is to set the "ProcessSerialNumber",
// something used by the legacy Process Manager from Carbon. optparse will fail if it finds
// this as it isn't a valid Dolphin command line option, so pretend like it doesn't exist
// if found.
if (strncmp(argv[argc - 1], "-psn", 4) == 0)
{
argc--;
}
#endif
auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::IncludeGUIOptions);
const optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv);
const optparse::Values& options =
#ifdef _WIN32
CommandLineParse::ParseArguments(parser.get(), utf8_argc, utf8_argv.data());
#else
CommandLineParse::ParseArguments(parser.get(), argc, argv);
#endif
const std::vector<std::string> args = parser->args();
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@ -120,7 +148,11 @@ int main(int argc, char* argv[])
QCoreApplication::setOrganizationDomain(QStringLiteral("dolphin-emu.org"));
QCoreApplication::setApplicationName(QStringLiteral("dolphin-emu"));
#ifdef _WIN32
QApplication app(__argc, __argv);
#else
QApplication app(argc, argv);
#endif
#ifdef _WIN32
// On Windows, Qt 5's default system font (MS Shell Dlg 2) is outdated.
@ -226,7 +258,7 @@ int main(int argc, char* argv[])
win.Show();
#if defined(USE_ANALYTICS) && USE_ANALYTICS
if (!SConfig::GetInstance().m_analytics_permission_asked)
if (!Config::Get(Config::MAIN_ANALYTICS_PERMISSION_ASKED))
{
ModalMessageBox analytics_prompt(&win);
@ -248,7 +280,7 @@ int main(int argc, char* argv[])
const int answer = analytics_prompt.exec();
SConfig::GetInstance().m_analytics_permission_asked = true;
Config::SetBase(Config::MAIN_ANALYTICS_PERMISSION_ASKED, true);
Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);
DolphinAnalytics::Instance().ReloadConfig();