author | koda |
Fri, 25 Mar 2016 11:27:53 -0400 | |
branch | 0.9.22 |
changeset 11622 | 02657dddb5d8 |
parent 11046 | 47a8c19ecb60 |
child 11362 | ed5a6478e710 |
permissions | -rw-r--r-- |
579 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
579 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
579 | 17 |
*/ |
18 |
||
5252 | 19 |
#include "HWApplication.h" |
20 |
||
579 | 21 |
#include <QTranslator> |
22 |
#include <QLocale> |
|
1416
60b86d6fe9ae
Force plastique style, as others don't fully support stylesheets
unc0rr
parents:
1415
diff
changeset
|
23 |
#include <QPlastiqueStyle> |
2034
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
24 |
#include <QRegExp> |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
25 |
#include <QMap> |
2898 | 26 |
#include <QSettings> |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
27 |
#include <QStringListModel> |
6579 | 28 |
#include <QDate> |
8337
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
29 |
#include <QDesktopWidget> |
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
30 |
#include <QLabel> |
1146 | 31 |
|
579 | 32 |
#include "hwform.h" |
33 |
#include "hwconsts.h" |
|
6721
7dbf8a0c1f5d
- Register HWTeam metatype so HWTeam objects could be passed via queued connections
unc0rr
parents:
6700
diff
changeset
|
34 |
#include "newnetclient.h" |
579 | 35 |
|
6930 | 36 |
#include "DataManager.h" |
7768 | 37 |
#include "FileEngine.h" |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8722
diff
changeset
|
38 |
#include "MessageDialog.h" |
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6129
diff
changeset
|
39 |
|
3333 | 40 |
#ifdef _WIN32 |
41 |
#include <Shlobj.h> |
|
8355 | 42 |
#elif defined __APPLE__ |
43 |
#include "CocoaInitializer.h" |
|
3333 | 44 |
#endif |
45 |
||
8405
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
46 |
// Program resources |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
47 |
#ifdef __APPLE__ |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
48 |
static CocoaInitializer * cocoaInit = NULL; |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
49 |
#endif |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
50 |
static FileEngineHandler * engine = NULL; |
6579 | 51 |
|
52 |
//Determines the day of easter in year |
|
53 |
//from http://aa.usno.navy.mil/faq/docs/easter.php,adapted to C/C++ |
|
54 |
QDate calculateEaster(long year) |
|
55 |
{ |
|
56 |
int c, n, k, i, j, l, m, d; |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
57 |
|
6579 | 58 |
c = year/100; |
59 |
n = year - 19*(year/19); |
|
60 |
k = (c - 17)/25; |
|
61 |
i = c - c/4 - (c - k)/3 + 19*n + 15; |
|
62 |
i = i - 30*(i/30); |
|
63 |
i = i - (i/28)*(1 - (i/28)*(29/(i + 1))*((21 - n)/11)); |
|
64 |
j = year + year/4 + i + 2 - c + c/4; |
|
65 |
j = j - 7*(j/7); |
|
66 |
l = i - j; |
|
67 |
m = 3 + (l + 40)/44; |
|
68 |
d = l + 28 - 31*(m / 4); |
|
69 |
||
70 |
return QDate(year, m, d); |
|
71 |
} |
|
72 |
||
73 |
//Checks season and assigns it to the variable season in "hwconsts.h" |
|
74 |
void checkSeason() |
|
75 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
76 |
QDate date = QDate::currentDate(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
77 |
|
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
78 |
//Christmas? |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
79 |
if (date.month() == 12 && date.day() >= 24 |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
80 |
&& date.day() <= 26) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
81 |
season = SEASON_CHRISTMAS; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
82 |
//Hedgewars birthday? |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
83 |
else if (date.month() == 10 && date.day() == 31) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
84 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
85 |
season = SEASON_HWBDAY; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
86 |
years_since_foundation = date.year() - 2004; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
87 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
88 |
//Easter? |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
89 |
else if (calculateEaster(date.year()) == date) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
90 |
season = SEASON_EASTER; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
91 |
else |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
92 |
season = SEASON_NONE; |
6579 | 93 |
} |
8385
9e8924ff9813
Convert feedback page to dialog (+some fixes from unC0Rr)
dag10
parents:
8355
diff
changeset
|
94 |
|
6579 | 95 |
|
579 | 96 |
bool checkForDir(const QString & dir) |
97 |
{ |
|
8206 | 98 |
QDir tmpdir(dir); |
99 |
if (!tmpdir.exists()) |
|
100 |
if (!tmpdir.mkpath(dir)) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
101 |
{ |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8722
diff
changeset
|
102 |
MessageDialog::ShowErrorMessage(HWApplication::tr("Cannot create directory %1").arg(dir)); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
103 |
return false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
104 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
105 |
return true; |
579 | 106 |
} |
107 |
||
8405
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
108 |
// Guaranteed to be the last thing ran in the application's life time. |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
109 |
// Closes resources that need to exist as long as possible. |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
110 |
void closeResources(void) |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
111 |
{ |
8187
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
112 |
#ifdef __APPLE__ |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
113 |
if (cocoaInit != NULL) |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
114 |
{ |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
115 |
delete cocoaInit; |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
116 |
cocoaInit = NULL; |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
117 |
} |
8405
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
118 |
#endif |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
119 |
if (engine != NULL) |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
120 |
{ |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
121 |
delete engine; |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
122 |
engine = NULL; |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
123 |
} |
8187
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
124 |
} |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
125 |
|
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
126 |
QString getUsage() |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
127 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
128 |
return QString( |
10407 | 129 |
"%1: hedgewars [%2...] [%3]\n" |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
130 |
"\n" |
10407 | 131 |
"%4:\n" |
132 |
" --help %5\n" |
|
133 |
" --config-dir=PATH %6\n" |
|
134 |
" --data-dir=PATH %7\n" |
|
135 |
"\n" |
|
136 |
"%8" |
|
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
137 |
"\n" |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
138 |
).arg(HWApplication::tr("Usage", "command-line")) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
139 |
.arg(HWApplication::tr("OPTION", "command-line")) |
10407 | 140 |
.arg(HWApplication::tr("CONNECTSTRING", "command-line")) |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
141 |
.arg(HWApplication::tr("Options", "command-line")) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
142 |
.arg(HWApplication::tr("Display this help", "command-line")) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
143 |
.arg(HWApplication::tr("Custom path for configuration data and user data", "command-line")) |
10407 | 144 |
.arg(HWApplication::tr("Custom path to the game data folder", "command-line")) |
10486 | 145 |
.arg(HWApplication::tr("Hedgewars can use a %1 (e.g. \"%2\") to connect on start.", "command-line").arg(HWApplication::tr("CONNECTSTRING", "command-line")).arg(QString("hwplay://") + NETGAME_DEFAULT_SERVER)); |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
146 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
147 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
148 |
int main(int argc, char *argv[]) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
149 |
{ |
8406
8a834943609d
Accidentally left atexit() inside a mac-only section in last revision (rbecac012d502)
dag10 <gottlieb.drew@gmail.com>
parents:
8405
diff
changeset
|
150 |
// Since we're calling this first, closeResources() will be the last thing called after main() returns. |
8a834943609d
Accidentally left atexit() inside a mac-only section in last revision (rbecac012d502)
dag10 <gottlieb.drew@gmail.com>
parents:
8405
diff
changeset
|
151 |
atexit(closeResources); |
8a834943609d
Accidentally left atexit() inside a mac-only section in last revision (rbecac012d502)
dag10 <gottlieb.drew@gmail.com>
parents:
8405
diff
changeset
|
152 |
|
8187
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
153 |
#ifdef __APPLE__ |
8406
8a834943609d
Accidentally left atexit() inside a mac-only section in last revision (rbecac012d502)
dag10 <gottlieb.drew@gmail.com>
parents:
8405
diff
changeset
|
154 |
cocoaInit = new CocoaInitializer(); // Creates the autoreleasepool preventing cocoa object leaks on OS X. |
8187
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
155 |
#endif |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
156 |
|
5252 | 157 |
HWApplication app(argc, argv); |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
158 |
app.setAttribute(Qt::AA_DontShowIconsInMenus,false); |
7130 | 159 |
|
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
160 |
// file engine and splash. to be initialized later |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
161 |
engine = NULL; |
8337
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
162 |
QLabel *splash = NULL; |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
163 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
164 |
// parse arguments |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
165 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
166 |
QStringList arguments = app.arguments(); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
167 |
QMap<QString, QString> parsedArgs; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
168 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
169 |
QList<QString>::iterator i = arguments.begin(); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
170 |
while(i != arguments.end()) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
171 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
172 |
QString arg = *i; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
173 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
174 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
175 |
QRegExp opt("--(\\S+)=(.+)"); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
176 |
if(opt.exactMatch(arg)) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
177 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
178 |
parsedArgs[opt.cap(1)] = opt.cap(2); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
179 |
i = arguments.erase(i); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
180 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
181 |
else |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
182 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
183 |
if(arg.startsWith("--")) { |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
184 |
if(arg == "--help") |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
185 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
186 |
printf("%s", getUsage().toUtf8().constData()); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
187 |
return 0; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
188 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
189 |
// argument is something wrong |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
190 |
fprintf(stderr, "%s\n\n%s", |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
191 |
HWApplication::tr("Malformed option argument: %1", "command-line").arg(arg).toUtf8().constData(), |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
192 |
getUsage().toUtf8().constData()); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
193 |
return 1; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
194 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
195 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
196 |
// if not starting with --, then always skip |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
197 |
// (because we can't determine if executable path/call or not - on windows) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
198 |
++i; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
199 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
200 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
201 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
202 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
203 |
if(parsedArgs.contains("data-dir")) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
204 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
205 |
QFileInfo f(parsedArgs["data-dir"]); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
206 |
parsedArgs.remove("data-dir"); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
207 |
if(!f.exists()) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
208 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
209 |
qWarning() << "WARNING: Cannot open DATA_PATH=" << f.absoluteFilePath(); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
210 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
211 |
*cDataDir = f.absoluteFilePath(); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
212 |
custom_data = true; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
213 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
214 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
215 |
if(parsedArgs.contains("config-dir")) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
216 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
217 |
QFileInfo f(parsedArgs["config-dir"]); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
218 |
parsedArgs.remove("config-dir"); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
219 |
cfgdir->setPath(f.absoluteFilePath()); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
220 |
custom_config = true; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
221 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
222 |
else |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
223 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
224 |
cfgdir->setPath(QDir::homePath()); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
225 |
custom_config = false; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
226 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
227 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
228 |
if (!parsedArgs.isEmpty()) { |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
229 |
foreach (const QString & key, parsedArgs.keys()) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
230 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
231 |
fprintf(stderr, "%s\n", HWApplication::tr("Unknown option argument: %1", "command-line").arg(QString("--") + key).toUtf8().constData()); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
232 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
233 |
fprintf(stderr, "\n%s", getUsage().toUtf8().constData()); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
234 |
return 1; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
235 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
236 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
237 |
// end of parameter parsing |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
238 |
|
9163
67334acaaac7
port all Q_WS_* to Q_OS_* so that we are forward compatible with Qt5
koda
parents:
9094
diff
changeset
|
239 |
#if defined Q_OS_WIN |
8337
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
240 |
QPixmap pixmap(":res/splash.png"); |
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
241 |
splash = new QLabel(0, Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint); |
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
242 |
splash->setAttribute(Qt::WA_TranslucentBackground); |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8722
diff
changeset
|
243 |
const QRect deskSize = HWApplication::desktop()->screenGeometry(-1); |
8337
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
244 |
QPoint splashCenter = QPoint( (deskSize.width() - pixmap.width())/2, |
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
245 |
(deskSize.height() - pixmap.height())/2 ); |
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
246 |
splash->move(splashCenter); |
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
247 |
splash->setPixmap(pixmap); |
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
248 |
splash->show(); |
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
249 |
#endif |
7772 | 250 |
app.setStyle(new QPlastiqueStyle()); |
2377 | 251 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
252 |
QDateTime now = QDateTime::currentDateTime(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
253 |
srand(now.toTime_t()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
254 |
rand(); |
579 | 255 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
256 |
Q_INIT_RESOURCE(hedgewars); |
579 | 257 |
|
6721
7dbf8a0c1f5d
- Register HWTeam metatype so HWTeam objects could be passed via queued connections
unc0rr
parents:
6700
diff
changeset
|
258 |
qRegisterMetaType<HWTeam>("HWTeam"); |
7dbf8a0c1f5d
- Register HWTeam metatype so HWTeam objects could be passed via queued connections
unc0rr
parents:
6700
diff
changeset
|
259 |
|
8323
ab0b618bdf13
get executable directory at runtime rather than configure time
koda
parents:
8316
diff
changeset
|
260 |
bindir->cd(QCoreApplication::applicationDirPath()); |
579 | 261 |
|
8323
ab0b618bdf13
get executable directory at runtime rather than configure time
koda
parents:
8316
diff
changeset
|
262 |
if(custom_config == false) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
263 |
{ |
1965 | 264 |
#ifdef __APPLE__ |
3758 | 265 |
checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
266 |
cfgdir->cd("Library/Application Support/Hedgewars"); |
3333 | 267 |
#elif defined _WIN32 |
268 |
char path[1024]; |
|
269 |
if(!SHGetFolderPathA(0, CSIDL_PERSONAL, NULL, 0, path)) |
|
270 |
{ |
|
271 |
cfgdir->cd(path); |
|
3758 | 272 |
checkForDir(cfgdir->absolutePath() + "/Hedgewars"); |
3333 | 273 |
cfgdir->cd("Hedgewars"); |
274 |
} |
|
3758 | 275 |
else // couldn't retrieve documents folder? almost impossible, but in case fall back to classic path |
3333 | 276 |
{ |
9094 | 277 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars"); |
278 |
cfgdir->cd(".hedgewars"); |
|
3333 | 279 |
} |
2428 | 280 |
#else |
9094 | 281 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars"); |
282 |
cfgdir->cd(".hedgewars"); |
|
2428 | 283 |
#endif |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
284 |
} |
3758 | 285 |
|
286 |
if (checkForDir(cfgdir->absolutePath())) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
287 |
{ |
3758 | 288 |
// alternative loading/lookup paths |
289 |
checkForDir(cfgdir->absolutePath() + "/Data"); |
|
290 |
||
291 |
// config/save paths |
|
292 |
checkForDir(cfgdir->absolutePath() + "/Demos"); |
|
293 |
checkForDir(cfgdir->absolutePath() + "/Saves"); |
|
294 |
checkForDir(cfgdir->absolutePath() + "/Screenshots"); |
|
295 |
checkForDir(cfgdir->absolutePath() + "/Teams"); |
|
3914 | 296 |
checkForDir(cfgdir->absolutePath() + "/Logs"); |
7180 | 297 |
checkForDir(cfgdir->absolutePath() + "/Videos"); |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
298 |
checkForDir(cfgdir->absolutePath() + "/VideoTemp"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
299 |
} |
579 | 300 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
301 |
datadir->cd(bindir->absolutePath()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
302 |
datadir->cd(*cDataDir); |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8722
diff
changeset
|
303 |
if (!datadir->cd("Data")) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
304 |
{ |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8722
diff
changeset
|
305 |
MessageDialog::ShowFatalMessage(HWApplication::tr("Failed to open data directory:\n%1\n\nPlease check your installation!").arg(datadir->absolutePath()+"/Data")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
306 |
return 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
307 |
} |
579 | 308 |
|
7931 | 309 |
// setup PhysFS |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
310 |
engine = new FileEngineHandler(argv[0]); |
8405
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
311 |
engine->mount(datadir->absolutePath()); |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
312 |
engine->mount(cfgdir->absolutePath() + "/Data"); |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
313 |
engine->mount(cfgdir->absolutePath()); |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
314 |
engine->setWriteDir(cfgdir->absolutePath()); |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
315 |
engine->mountPacks(); |
7772 | 316 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
317 |
QTranslator Translator; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
318 |
{ |
8918
512753ea4b1b
Switch to 'settings.ini'. Copies old ini file if necessary on startup.
unc0rr
parents:
8882
diff
changeset
|
319 |
QSettings settings(DataManager::instance().settingsFileName(), QSettings::IniFormat); |
512753ea4b1b
Switch to 'settings.ini'. Copies old ini file if necessary on startup.
unc0rr
parents:
8882
diff
changeset
|
320 |
settings.setIniCodec("UTF-8"); |
512753ea4b1b
Switch to 'settings.ini'. Copies old ini file if necessary on startup.
unc0rr
parents:
8882
diff
changeset
|
321 |
|
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
322 |
QString cc = settings.value("misc/locale", QString()).toString(); |
8882
73d6d7f27945
fix 'failed to install translation' message when misc/locale in hedgewars.ini is empty (which is *always* when 'system default' is selected)
koda
parents:
8799
diff
changeset
|
323 |
if (cc.isEmpty()) |
9027
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
324 |
{ |
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
325 |
cc = QLocale::system().name(); |
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
326 |
|
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
327 |
// Fallback to current input locale if "C" locale is returned |
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
328 |
if(cc == "C") |
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
329 |
cc = HWApplication::keyboardInputLocale().name(); |
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
330 |
} |
6167 | 331 |
|
332 |
// load locale file into translator |
|
8882
73d6d7f27945
fix 'failed to install translation' message when misc/locale in hedgewars.ini is empty (which is *always* when 'system default' is selected)
koda
parents:
8799
diff
changeset
|
333 |
if (!Translator.load(QString("physfs://Locale/hedgewars_%1").arg(cc))) |
73d6d7f27945
fix 'failed to install translation' message when misc/locale in hedgewars.ini is empty (which is *always* when 'system default' is selected)
koda
parents:
8799
diff
changeset
|
334 |
qWarning("Failed to install translation (%s)", qPrintable(cc)); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
335 |
app.installTranslator(&Translator); |
10488 | 336 |
app.setLayoutDirection(QLocale(cc).textDirection()); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
337 |
} |
2898 | 338 |
|
5756 | 339 |
#ifdef _WIN32 |
3679 | 340 |
// Win32 registry setup (used for xfire detection etc. - don't set it if we're running in "portable" mode with a custom config dir) |
3932 | 341 |
if(!custom_config) |
3679 | 342 |
{ |
3932 | 343 |
QSettings registry_hklm("HKEY_LOCAL_MACHINE", QSettings::NativeFormat); |
344 |
registry_hklm.setValue("Software/Hedgewars/Frontend", bindir->absolutePath().replace("/", "\\") + "\\hedgewars.exe"); |
|
345 |
registry_hklm.setValue("Software/Hedgewars/Path", bindir->absolutePath().replace("/", "\\")); |
|
3679 | 346 |
} |
347 |
#endif |
|
6178
affa860f2983
BOOOOooOM <headshot>! removing default stylesheets from c++ code and adding them as text files to the qt resources
sheepluva
parents:
6177
diff
changeset
|
348 |
|
affa860f2983
BOOOOooOM <headshot>! removing default stylesheets from c++ code and adding them as text files to the qt resources
sheepluva
parents:
6177
diff
changeset
|
349 |
QString style = ""; |
6579 | 350 |
QString fname; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
351 |
|
6579 | 352 |
checkSeason(); |
353 |
//For each season, there is an extra stylesheet |
|
354 |
//Todo: change background for easter and birthday |
|
355 |
//(simply replace res/BackgroundBirthday.png and res/BackgroundEaster.png |
|
356 |
//with an appropriate background |
|
357 |
switch (season) |
|
358 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
359 |
case SEASON_CHRISTMAS : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
360 |
fname = "christmas.css"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
361 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
362 |
case SEASON_EASTER : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
363 |
fname = "easter.css"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
364 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
365 |
case SEASON_HWBDAY : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
366 |
fname = "birthday.css"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
367 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
368 |
default : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
369 |
fname = "qt.css"; |
8337
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
370 |
break; |
6579 | 371 |
} |
6178
affa860f2983
BOOOOooOM <headshot>! removing default stylesheets from c++ code and adding them as text files to the qt resources
sheepluva
parents:
6177
diff
changeset
|
372 |
|
6176
19ef039a8474
frontend will use the data file misc/qt_style.css instead of hardcoded stylesheet - if the file exists
sheepluva
parents:
6174
diff
changeset
|
373 |
// load external stylesheet if there is any |
8049 | 374 |
QFile extFile("physfs://css/" + fname); |
2898 | 375 |
|
6579 | 376 |
QFile resFile(":/res/css/" + fname); |
6178
affa860f2983
BOOOOooOM <headshot>! removing default stylesheets from c++ code and adding them as text files to the qt resources
sheepluva
parents:
6177
diff
changeset
|
377 |
|
7724 | 378 |
QFile & file = (extFile.exists() ? extFile : resFile); |
6178
affa860f2983
BOOOOooOM <headshot>! removing default stylesheets from c++ code and adding them as text files to the qt resources
sheepluva
parents:
6177
diff
changeset
|
379 |
|
affa860f2983
BOOOOooOM <headshot>! removing default stylesheets from c++ code and adding them as text files to the qt resources
sheepluva
parents:
6177
diff
changeset
|
380 |
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
7724 | 381 |
style.append(file.readAll()); |
2377 | 382 |
|
8651 | 383 |
qWarning("Starting Hedgewars %s-r%d (%s)", qPrintable(*cVersionString), cRevisionString->toInt(), qPrintable(*cHashString)); |
384 |
||
6178
affa860f2983
BOOOOooOM <headshot>! removing default stylesheets from c++ code and adding them as text files to the qt resources
sheepluva
parents:
6177
diff
changeset
|
385 |
app.form = new HWForm(NULL, style); |
5252 | 386 |
app.form->show(); |
8337
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
387 |
if(splash) |
bf237f7f1d94
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
koda
parents:
8323
diff
changeset
|
388 |
splash->close(); |
8722
2dead6b84bca
this should supposedly add hwplay:// schemes to windows, after user presses file association
koda
parents:
8715
diff
changeset
|
389 |
if (app.urlString) |
2dead6b84bca
this should supposedly add hwplay:// schemes to windows, after user presses file association
koda
parents:
8715
diff
changeset
|
390 |
app.fakeEvent(); |
8223
14d9a3c33650
backout rea7541f77944 since development of frontlib is on another branch
koda
parents:
8206
diff
changeset
|
391 |
return app.exec(); |
2845 | 392 |
} |