forked from strangergwenn/UnrealUpdater
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (63 loc) · 1.92 KB
/
Copy pathmain.cpp
File metadata and controls
76 lines (63 loc) · 1.92 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
/**
* This work is distributed under the Lesser General Public License,
* see LICENSE for details
*
* @author Gwennaël ARBONA
**/
#include <QApplication>
#include <QRegExp>
#include "common.h"
#include "updater.h"
/*----------------------------------------------
Main program
----------------------------------------------*/
/*--- Main program ---*/
int main(int argc, char *argv[])
{
// Config directory
QDir tempDir(".");
tempDir.mkpath(UU_CONFIG_DIR);
QString path = QDir::currentPath();
// Standard launch
if (!QFile::exists(UU_LOCK_FILE))
{
QApplication a(argc, argv);
// First launch
if (!QFile::exists(UU_UPDATER_INSTALLED))
{
QMessageBox msgBox;
msgBox.setText("The game will be installed in " + path + "/.\n"
+ "To change this, press Cancel, then copy this program in the right folder.");
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
int ret = msgBox.exec();
if (ret == QMessageBox::Cancel)
{
return 0;
}
}
// Normal launch
Updater w;
w.show();
return a.exec();
}
// Ignore multi-launch
else
{
return 0;
}
}
/*--- Parse _text_, *text*, !text! to HTML --*/
QString TextToHtml(QString data)
{
QRegExp rxH("\\*(.*)\\*");
QRegExp rxM("_(.*)_");
QRegExp rxI("!(.*)!");
rxH.setMinimal(true);
rxM.setMinimal(true);
rxI.setMinimal(true);
data.replace(rxH, QString(HTML_TITLE_S) + QString("\\1") + QString(HTML_TITLE_E));
data.replace(rxM, QString(HTML_MEDIUM_S) + QString("\\1") + QString(HTML_MEDIUM_E));
data.replace(rxI, QString(HTML_IT_S) + QString("\\1") + QString(HTML_IT_E));
data.replace("\n", "<br/>");
return data;
}