-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
128 lines (123 loc) · 4.53 KB
/
Copy pathmainwindow.cpp
File metadata and controls
128 lines (123 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "mainwindow.h"
#include "./ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::MainWindow(Backend *backend, QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow), m_backend(backend)
{
ui->setupUi(this);
// execute backend function openPayday
connect(ui->launchButton, &QPushButton::clicked, this, &MainWindow::onPushButtonClicked);
// default options
ui->epicMMButton->setChecked(true);
ui->normalButton->setChecked(true);
connect(m_backend, &Backend::configReady, [this](const QJsonObject &result)
{
for (const QString &key : result.keys())
{
if (key == "mm")
{
if (result.value(key) == "steam")
{
ui->steamMMButton->setChecked(true);
}
else
{
ui->epicMMButton->setChecked(true);
}
}
else if (key == "profile")
{
if (result.value(key) == "rush")
{
ui->rushButton->setChecked(true);
}
else
{
ui->normalButton->setChecked(true);
}
}
} });
setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
backend->loadConfig();
// for every button in groupButton
for (int i = 0; i < ui->buttonGroup->buttons().size(); i++)
{
// printf("Button %d\n", ui->buttonGroup->buttons().at(i)->objectName().toInt());
// qDebug() << ui->buttonGroup->buttons().at(i)->objectName().toInt();
}
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::onPushButtonClicked()
{
m_backend->deleteAllFolder("../mods");
m_backend->deleteAllFolder("../assets/mod_overrides");
std::string args = " -skip_intro";
QJsonObject config;
for (int i = 0; i < ui->groupBoxMM->children().size(); i++)
{
// if it's a radio button
if (ui->groupBoxMM->children().at(i)->metaObject()->className() == QString("QRadioButton"))
{
// cast it to a radio button
QRadioButton *radioButton = qobject_cast<QRadioButton *>(ui->groupBoxMM->children().at(i));
// if it's checked
if (radioButton->isChecked() && radioButton->objectName() == "steamMMButton")
{
// add -steammm to args
args += " -steamMM";
config.insert("mm", "steam");
qDebug() << "steam";
}
else if (radioButton->isChecked() && radioButton->objectName() == "epicMMButton")
{
config.insert("mm", "epic");
}
}
}
QString profileFolder;
QString overrideFolder;
for (int i = 0; i < ui->groupBoxProfile->children().size(); i++)
{
// if it's a radio button
if (ui->groupBoxProfile->children().at(i)->metaObject()->className() == QString("QRadioButton"))
{
if (ui->groupBoxProfile->children().at(i)->objectName() == "rushButton")
{
// cast it to a radio button
QRadioButton *radioButton = qobject_cast<QRadioButton *>(ui->groupBoxProfile->children().at(i));
// if it's checked
if (radioButton->isChecked())
{
profileFolder = "mods_rush";
overrideFolder = "mod_overrides_rush";
config.insert("profile", "rush");
}
}
else if (ui->groupBoxProfile->children().at(i)->objectName() == "normalButton")
{
// cast it to a radio button
QRadioButton *radioButton = qobject_cast<QRadioButton *>(ui->groupBoxProfile->children().at(i));
// if it's checked
if (radioButton->isChecked())
{
profileFolder = "mods_normal";
overrideFolder = "mod_overrides_normal";
config.insert("profile", "normal");
}
}
}
}
m_backend->moveAllFiles(profileFolder, "../mods");
m_backend->moveAllFiles(overrideFolder, "../assets/mod_overrides");
m_backend->startExe("C:\\Program Files (x86)\\Steam\\steamapps\\common\\PAYDAY 2", "payday2_win32_release.exe", args.c_str());
m_backend->saveConfig(config);
// close window
close();
}