forked from d-karl/Rocket-League-Chroma-Control
/
mainwindow.cpp
100 lines (82 loc) · 3.49 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "rllogparser.h"
#include "attachtorllog.h"
#include <QtCore>
#include <iostream>
#include <string>
#include <QFileDialog>
using namespace std;
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "RLCC", "RLCC");
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
mainController = new MainController(this);
mainController->startUpApp();
connect(ui->LaunchButon, SIGNAL(clicked()), this, SLOT(launchButtonPressed()));
connect(ui->DonationButton, SIGNAL(clicked()), this, SLOT(donationButtonPressed()));
connect(mainController->attachWorker, SIGNAL(rocketLeagueRunning(bool)), this, SLOT(rocketLeagueStart(bool)));
connect(ui->helpButton, SIGNAL(clicked()), this, SLOT(helpButtonPressed()));
connect(ui->setPathButton, SIGNAL(clicked()), this, SLOT(setPathButtonPressed()));
QVariant pathVar = settings.value("RLPath");
if (!pathVar.isNull()) {
ui->LaunchButon->setEnabled(true);
}
// QString string = "test";
// std::wstring testerino = string.toStdWString();
}
std::wstring donationURL = L"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NTYNPG42JQJ3G";
std::wstring threadURL = L"https://insider.razerzone.com/index.php?threads/rocket-league-chroma-control.11637/";
void MainWindow::rocketLeagueStart(bool start) {
if (start) {
ui->LaunchButon->setEnabled(false);
}
}
void MainWindow::launchButtonPressed() {
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
QVariant path = settings.value("RLPath");
if (!path.isNull()) {
QString pathFromIni = path.toString();
pathFromIni.replace(QString("/"), QString("\\"));
wstring RLFolder = pathFromIni.toStdWString();
if (!CreateProcess(RLFolder.c_str(), L"RocketLeague.exe -log", NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
{
std::wstring error = L"Could not start Rocket League, tried path you set for RocketLeague.exe: ";
error.append(RLFolder);
MessageBox(0, error.c_str(), L"Whoops...!", MB_OK);
}
} else {
MessageBox(0, L"No path set! Please use the \"Set RL Path\" button before hitting launch.", L"Whoops...!", MB_OK);
}
}
void MainWindow::setPathButtonPressed() {
QString RLFileName = QFileDialog::getOpenFileName(this, tr("Locate RocketLeague.exe"),
"/home",
tr("RocketLeague.exe (RocketLeague.exe)"));
if (RLFileName.isNull()) {
MessageBox(0, L"RLCC cannot launch RL until you locate RocketLeague.exe\n\n"
"Normally, it is located inside your steam directory: \"steamapps\\common\\rocketleague\\Binaries\\Win32\"\n\n"
"If you cannot find it try Windows search", L"Cannot launch RL", MB_OK);
} else {
settings.setValue("RLPath", RLFileName);
ui->LaunchButon->setEnabled(true);
}
}
void MainWindow::helpButtonPressed() {
ShellExecute(0, 0, threadURL.c_str(), 0, 0 , SW_SHOW );
}
void MainWindow::donationButtonPressed() {
MessageBox(0, L"OMG! Wow! Thanks!\n(Seriously, glad you enjoy my little program, thanks for considering)", L"Wow!", MB_OK);
ShellExecute(0, 0, donationURL.c_str(), 0, 0 , SW_SHOW );
}
MainWindow::~MainWindow()
{
delete ui;
delete mainController;
}