-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.h
277 lines (242 loc) · 10 KB
/
MainWindow.h
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMessageBox>
#include <QDir>
#include <QDebug>
#include <QPixmap>
#include <QBitmap>
#include <QProcess>
#include <QFileInfo>
#include <QTableView>
#include <QtSql>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlQueryModel>
#include <QDesktopServices>
#include <QAction>
#include <QMenu>
#include <QCloseEvent>
#include <QSystemTrayIcon>
#include <QLineEdit>
#include "Classes/Downloader.h"
#include "Classes/FindInHomeDir.h"
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class Model: public QSqlQueryModel
{
QVariant data(const QModelIndex &index, int role) const
{
if (role==Qt::TextAlignmentRole)
return Qt::AlignCenter;
return QSqlQueryModel::data(index, role);
}
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
// Get remote file size
void RequestFileSize(const QString &url);
QNetworkAccessManager *m_netmanager;
QNetworkReply *m_reply;
public slots:
void FileSize();
signals:
void signalTestGameDataInstall();
protected:
// Minimized to tray
void closeEvent(QCloseEvent *event);
private slots:
// slot for trayicon activated
void slotIconActivated(QSystemTrayIcon::ActivationReason reason);
void slotCloseFromTray();
// slots for signals
void slotCurrentUnpackFile(QString strCurrentFile);
void slotUnpackEnd();
void slotCopyDir(QString strCurrentFile);
void slotCopyDirEnd();
void slotOnDownloadEnd();
void slotTestGameInstall();
void slotTestGameDataInstall();
void slotSetDownloadLabel(QString strLabel);
// Metod's to start downloading
void DownloadLevel(QString strSqlTable, QString strGameDirPath);
void DownloadMod(QString strSqlTable);
// Slots to update download progress
void slotOnUpdateProgressBar(qint64 bytesReceived, qint64 bytesTotal);
// Download from MediaFire
void GetDynamicUrlModDataFromMediaFire(QString strUrlMediaFire);
void onFinishModDataMediaFire(QNetworkReply *reply);
void GetDynamicUrlLevelDataFromMediaFire(QString strUrlMediaFire);
void onFinishLevelMediaFire(QNetworkReply *reply);
// ********
// Ui slots
// ********
// Change screenshots ant row index slots
void on_tableWidget_fe_official_pressed(const QModelIndex &index);
void on_tableWidget_se_official_pressed(const QModelIndex &index);
void on_table_fe_bestmaps_pressed(const QModelIndex &index);
void on_table_se_bestmaps_pressed(const QModelIndex &index);
void on_table_fe_usersmaps_pressed(const QModelIndex &index);
void on_table_se_usersmaps_pressed(const QModelIndex &index);
void on_table_se_hqmaps_pressed(const QModelIndex &index);
void on_table_fe_mods_pressed(const QModelIndex &index);
void on_table_se_mods_pressed(const QModelIndex &index);
void on_tabWidget_internal_fe_currentChanged(int index);
void on_tabWidget_internal_se_currentChanged(int index);
// Start levels and mods slits
void on_pushButton_fe_bestmaps_start_level_clicked();
void on_pushButton_fe_official_start_level_clicked();
void on_pushButton_fe_usersmap_start_level_clicked();
void on_pushButton_fe_mods_sttart_mod_clicked();
void on_pushButton_se_official_start_level_clicked();
void on_pushButton_se_bestmaps_start_level_clicked();
void on_pushButton_se_hqmaps_start_level_clicked();
void on_pushButton_se_usersmaps_start_level_clicked();
void on_pushButton_se_mods_start_mod_clicked();
// Main page slots
void on_pushButton_install_clicked();
void on_pushButton_install_gamedata_clicked();
void on_pushButton_update_db_clicked();
// Download conten slots
void on_pushButton_fe_bestmaps_download_clicked();
void on_pushButton_fe_usersmap_download_clicked();
void on_pushButton_fe_mods_download_clicked();
void on_pushButton_se_bestmaps_download_clicked();
void on_pushButton_se_hqmaps_download_clicked();
void on_pushButton_se_usersmaps_download_clicked();
void on_pushButton_se_mods_download_clicked();
// XPLUS state changed slots
void on_checkBox_fe_official_use_xplus_stateChanged(int arg);
void on_checkBox_fe_bestmaps_use_xplus_stateChanged(int arg);
void on_checkBox_fe_usersmap_use_xplus_stateChanged(int arg);
void on_checkBox_se_official_use_xplus_stateChanged(int arg);
void on_checkBox_se_bestmaps_use_xplus_stateChanged(int arg);
void on_checkBox_se_hqmaps_use_xplus_stateChanged(int arg);
void on_checkBox_se_usersmaps_use_xplus_stateChanged(int arg);
// Difficulity combobox slots
void on_comboBox_fe_official_difficulty_currentIndexChanged(int index);
void on_comboBox_fe_bestmaps_difficulty_currentIndexChanged(int index);
void on_comboBox_fe_usersmaps_difficulty_currentIndexChanged(int index);
void on_comboBox_fe_mods_difficulty_currentIndexChanged(int index);
void on_comboBox_se_official_difficulty_currentIndexChanged(int index);
void on_comboBox_se_bestmaps_difficulty_currentIndexChanged(int index);
void on_comboBox_se_hqmaps_difficulty_currentIndexChanged(int index);
void on_comboBox_se_usersmaps_difficulty_currentIndexChanged(int index);
void on_comboBox_se_mods_difficulty_currentIndexChanged(int index);
// Cancel download
// void on_pushButton_add_user_map_clicked();
void on_pushButton_fe_bestmaps_download_cancel_clicked();
void on_pushButton_fe_usersmap_download_cancel_clicked();
void on_pushButton_fe_mods_download_cancel_clicked();
void on_pushButton_se_bestmaps_download_cancel_clicked();
void on_pushButton_se_hqmaps_download_cancel_clicked();
void on_pushButton_se_usersmaps_download_cancel_clicked();
void on_pushButton_se_mods_download_cancel_clicked();
// Themes change
void on_comboBox_themes_currentIndexChanged(int index);
// Downloads Server change
void on_comboBox_server_currentIndexChanged(int index);
private:
// ui
Ui::MainWindow *ui;
QMenu *menu;
QAction *viewWindow;
QAction *hideWindow;
QAction *quitAction;
QSystemTrayIcon *trayIcon;
// Internal funcrions
void SetVars();
bool SearchDB();
void ReScanLocalDB();
void HideProgressBars();
void HideLabelsText();
int TestDBupdateNeed();
void MakeDifficultyScript(int iDifficulty, QString strPath);
void StartLevel(QString strSqlTable, int iXPLUS, int iDifficulty);
void StartMod(QString strSqlTable, int iDifficulty);
void FillTable(QString strSqlTable, QString strTableView);
void ForceFillingAllTable();
void MsgBox(int iType, QString strMessage);
void SleepMSecs(int iMsecs);
void SetImagesFromSql(QString strSqlTable,QString strLabelImg1,QString strLabelImg2);
void FE_UseXPLUS(int arg, int iTable, bool bInstalled);
void SE_UseXPLUS(int arg, int iTable, bool bInstalled);
void GetDistroFlag();
void SetComboBoxText();
QString exec(const char* cmd);
// Used classes and vars
Downloader m_downloader; // download class
#ifdef PLATFORM_UNIX
FindInHomeDir m_findinhome;
#endif
CopyDir m_copydir;
QProcess *process;
QMessageBox *msgBox;
QString strMSG;
// Path's
QString strExecDirPath;
QString strGameDirFEpath;
QString strGameDirSEpath;
QString strHomeDirPath;
QString strRunnerDBPath;
QString strRunnerDirPath;
QString strEngineDirPath;
// Path's suffix
#ifdef PLATFORM_WIN32
QString strRunnerDirPathSuffix = + "/AppData/Local/Serious-Runner";
#else
QString strRunnerDirPathSuffix = "/.local/share/Serious-Runner";
QString strEngineDirPathSuffix = "/.local/share/Serious-Engine";
#endif
// Flags
bool bUseSystemPath = false;
bool bFirstRun = false;
bool bInstallGameOk = false;
bool bInstallGameDataOk = false;
bool bFE_XPLUSInstallOk = false;
bool bSE_XPLUSInstallOk = false;
bool bCloseFromTray = false;
bool bUpdateDB = false;
int iDistoFlag = 0;
int iTheme = 0;
int iServer = 0;
int iGameIndex = 0;
// Indexes for tables and progress bar
int iTableRowIndex;
int iProgressBarIndex = 0;
int iUnpackProgressIndex = 0;
int iCopyDirProgressIndex = 0;
// Remote DB size
int iRemoteSizeDB = 0;
// XPLUS and Difficulity
int iFE_StartWithXplus[3] = {0,0,0};
int iSE_StartWithXplus[4] = {0,0,0,0};
int iFE_StartWithDifficulty[4] = {0,0,0,0};
int iSE_StartWithDifficulty[5] = {0,0,0,0,0};
// MediaFire urls
QString strUrlMediaFire[2];
// DB tables for Status scan
QString strDBTablesForScan[7] = {"fe_bestmaps", "fe_usersmaps", "fe_mods", "se_bestmaps", "se_hqmaps", "se_usersmaps", "se_mods"};
// Tables middle Names
QString strTablesMiddleNames[9] = {"fe_official", "fe_bestmaps", "fe_usersmaps", "fe_mods", "se_official", "se_bestmaps", "se_hqmaps", "se_usersmaps", "se_mods"};
// Games gro files
QString strFEfiles[6] {"1_00c.gro", "1_00c_Logo.gro", "1_00c_scripts.gro", "1_00_ExtraTools.gro", "1_00_music.gro", "1_04_patch.gro"};
QString strSEfiles[8] {"1_04_patch.gro", "1_07_tools.gro", "SE1_00.gro", "SE1_00_Extra.gro", "SE1_00_ExtraTools.gro", "SE1_00_Levels.gro", "SE1_00_Logo.gro", "SE1_00_Music.gro"};
// Download url
QString strRunnerDBurl = "https://raw.githubusercontent.com/tx00100xt/Serious-Runner/main/DB/seriousrunner.db";
QString strGameSettingsUrl = "https://raw.githubusercontent.com/tx00100xt/serioussam-maps/main/Settings/SeriousSamSettings.tar.xz";
//QString strGameSettingsUrl = "https://archive.org/download/serious-sam-settings/SeriousSamSettings.tar.xz";
//QString strRunnerDBurl = "https://archive.org/download/seriousrunner/seriousrunner.db";
};
#endif // MAINWINDOW_H