author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 21 Jan 2019 20:17:44 +0100 | |
changeset 14652 | 919754e1c269 |
parent 14321 | 0752148afc65 |
child 14670 | 56831f466d1d |
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> |
|
2034
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
23 |
#include <QRegExp> |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
24 |
#include <QMap> |
2898 | 25 |
#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
|
26 |
#include <QStringListModel> |
6579 | 27 |
#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
|
28 |
#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
|
29 |
#include <QLabel> |
11488 | 30 |
#include <QLibraryInfo> |
13178
b4f48e7a4953
seems to help styling some - some CSS tweaks may still be needed - lobby for example
nemo
parents:
12897
diff
changeset
|
31 |
#include <QStyle> |
b4f48e7a4953
seems to help styling some - some CSS tweaks may still be needed - lobby for example
nemo
parents:
12897
diff
changeset
|
32 |
#include <QStyleFactory> |
1146 | 33 |
|
579 | 34 |
#include "hwform.h" |
35 |
#include "hwconsts.h" |
|
6721
7dbf8a0c1f5d
- Register HWTeam metatype so HWTeam objects could be passed via queued connections
unc0rr
parents:
6700
diff
changeset
|
36 |
#include "newnetclient.h" |
579 | 37 |
|
6930 | 38 |
#include "DataManager.h" |
7768 | 39 |
#include "FileEngine.h" |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8722
diff
changeset
|
40 |
#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
|
41 |
|
9711
7d0329f37181
To prevent that weird crash, you need to initialize SDL before Qt
unc0rr
parents:
9163
diff
changeset
|
42 |
#include "SDLInteraction.h" |
7d0329f37181
To prevent that weird crash, you need to initialize SDL before Qt
unc0rr
parents:
9163
diff
changeset
|
43 |
|
3333 | 44 |
#ifdef _WIN32 |
45 |
#include <Shlobj.h> |
|
8355 | 46 |
#elif defined __APPLE__ |
47 |
#include "CocoaInitializer.h" |
|
12661 | 48 |
|
49 |
#endif |
|
50 |
||
51 |
#ifdef Q_OS_WIN |
|
52 |
#include <QSplashScreen> |
|
3333 | 53 |
#endif |
54 |
||
13086
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
55 |
#include <QMessageBox> |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
56 |
|
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
|
57 |
// 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
|
58 |
#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
|
59 |
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
|
60 |
#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
|
61 |
static FileEngineHandler * engine = NULL; |
6579 | 62 |
|
63 |
//Determines the day of easter in year |
|
64 |
//from http://aa.usno.navy.mil/faq/docs/easter.php,adapted to C/C++ |
|
65 |
QDate calculateEaster(long year) |
|
66 |
{ |
|
67 |
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
|
68 |
|
6579 | 69 |
c = year/100; |
70 |
n = year - 19*(year/19); |
|
71 |
k = (c - 17)/25; |
|
72 |
i = c - c/4 - (c - k)/3 + 19*n + 15; |
|
73 |
i = i - 30*(i/30); |
|
74 |
i = i - (i/28)*(1 - (i/28)*(29/(i + 1))*((21 - n)/11)); |
|
75 |
j = year + year/4 + i + 2 - c + c/4; |
|
76 |
j = j - 7*(j/7); |
|
77 |
l = i - j; |
|
78 |
m = 3 + (l + 40)/44; |
|
79 |
d = l + 28 - 31*(m / 4); |
|
80 |
||
81 |
return QDate(year, m, d); |
|
82 |
} |
|
83 |
||
84 |
//Checks season and assigns it to the variable season in "hwconsts.h" |
|
85 |
void checkSeason() |
|
86 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
87 |
QDate date = QDate::currentDate(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
88 |
|
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
89 |
//Christmas? |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
90 |
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
|
91 |
&& date.day() <= 26) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
92 |
season = SEASON_CHRISTMAS; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
93 |
//Hedgewars birthday? |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
94 |
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
|
95 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
96 |
season = SEASON_HWBDAY; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
97 |
years_since_foundation = date.year() - 2004; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
98 |
} |
13304 | 99 |
else if (date.month() == 4 && date.day() == 1) |
100 |
{ |
|
101 |
season = SEASON_APRIL1; |
|
102 |
} |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
103 |
//Easter? |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
104 |
else if (calculateEaster(date.year()) == date) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
105 |
season = SEASON_EASTER; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
106 |
else |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
107 |
season = SEASON_NONE; |
6579 | 108 |
} |
8385
9e8924ff9813
Convert feedback page to dialog (+some fixes from unC0Rr)
dag10
parents:
8355
diff
changeset
|
109 |
|
6579 | 110 |
|
579 | 111 |
bool checkForDir(const QString & dir) |
112 |
{ |
|
8206 | 113 |
QDir tmpdir(dir); |
114 |
if (!tmpdir.exists()) |
|
115 |
if (!tmpdir.mkpath(dir)) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
116 |
{ |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8722
diff
changeset
|
117 |
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
|
118 |
return false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
119 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
120 |
return true; |
579 | 121 |
} |
122 |
||
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
|
123 |
// 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
|
124 |
// 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
|
125 |
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
|
126 |
{ |
8187
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
127 |
#ifdef __APPLE__ |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
128 |
if (cocoaInit != NULL) |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
129 |
{ |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
130 |
delete cocoaInit; |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
131 |
cocoaInit = NULL; |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
132 |
} |
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
|
133 |
#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
|
134 |
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
|
135 |
{ |
becac012d502
Moved FileEngineHandler instance in main() to be a pointer released "atexit". (Fixes issue 509)
dag10 <gottlieb.drew@gmail.com>
parents:
8385
diff
changeset
|
136 |
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
|
137 |
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
|
138 |
} |
8187
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
139 |
} |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
140 |
|
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
141 |
// Simple Message handler that suppresses Qt debug and info messages (qDebug, qInfo). |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
142 |
// Used when printing command line help (--help) or related error to keep console clean. |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
143 |
void restrictedMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
144 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
145 |
Q_UNUSED(context) |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
146 |
QByteArray localMsg = msg.toLocal8Bit(); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
147 |
switch (type) { |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
148 |
case QtWarningMsg: |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
149 |
case QtCriticalMsg: |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
150 |
case QtFatalMsg: |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
151 |
fprintf(stderr, "%s\n", localMsg.constData()); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
152 |
break; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
153 |
default: |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
154 |
break; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
155 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
156 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
157 |
|
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
158 |
QString getUsage() |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
159 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
160 |
return QString( |
10407 | 161 |
"%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
|
162 |
"\n" |
10407 | 163 |
"%4:\n" |
164 |
" --help %5\n" |
|
165 |
" --config-dir=PATH %6\n" |
|
166 |
" --data-dir=PATH %7\n" |
|
167 |
"\n" |
|
168 |
"%8" |
|
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
169 |
"\n" |
14279
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
170 |
).arg( |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
171 |
//: “Usage” as in “how the command-line syntax works”. Shown when running “hedgewars --help” in command-line |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
172 |
HWApplication::tr("Usage", "command-line") |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
173 |
).arg( |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
174 |
//: Name of a command-line argument, shown when running “hedgewars --help” in command-line. “OPTION” as in “command-line option” |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
175 |
HWApplication::tr("OPTION", "command-line") |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
176 |
).arg( |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
177 |
//: Name of a command-line argument, shown when running “hedgewars --help” in command-line |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
178 |
HWApplication::tr("CONNECTSTRING", "command-line") |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
179 |
).arg( |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
180 |
//: “Options” as in “command-line options” |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
181 |
HWApplication::tr("Options", "command-line") |
20b08e59730d
Add a few translator comments to some not-so-obvious strings
Wuzzy <Wuzzy2@mail.ru>
parents:
13517
diff
changeset
|
182 |
).arg(HWApplication::tr("Display this help", "command-line")) |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
183 |
.arg(HWApplication::tr("Custom path for configuration data and user data", "command-line")) |
10407 | 184 |
.arg(HWApplication::tr("Custom path to the game data folder", "command-line")) |
10486 | 185 |
.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
|
186 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
187 |
|
13178
b4f48e7a4953
seems to help styling some - some CSS tweaks may still be needed - lobby for example
nemo
parents:
12897
diff
changeset
|
188 |
int main(int argc, char *argv[]) { |
13180
3961f9d0c7e4
Fix buggy Qt5 style detection causing segfault on Arch Linux w/ qt5-style-plugins
Wuzzy <Wuzzy2@mail.ru>
parents:
13179
diff
changeset
|
189 |
|
8406
8a834943609d
Accidentally left atexit() inside a mac-only section in last revision (rbecac012d502)
dag10 <gottlieb.drew@gmail.com>
parents:
8405
diff
changeset
|
190 |
// 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
|
191 |
atexit(closeResources); |
8a834943609d
Accidentally left atexit() inside a mac-only section in last revision (rbecac012d502)
dag10 <gottlieb.drew@gmail.com>
parents:
8405
diff
changeset
|
192 |
|
8187
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
193 |
#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
|
194 |
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
|
195 |
#endif |
fa725fe25708
GCI2012: Find Out What is Causing This Problem (frontend leaks on OS X)
Drew Gottlieb
parents:
8117
diff
changeset
|
196 |
|
5252 | 197 |
HWApplication app(argc, argv); |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
198 |
app.setAttribute(Qt::AA_DontShowIconsInMenus,false); |
7130 | 199 |
|
12661 | 200 |
// file engine, to be initialized later |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
201 |
engine = NULL; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
202 |
|
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
203 |
/* |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
204 |
This is for messages frelated to translatable command-line arguments. |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
205 |
If it is non-zero, will print out a message after loading locale |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
206 |
and exit. |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
207 |
*/ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
208 |
enum cmdMsgStateEnum { |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
209 |
cmdMsgNone, |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
210 |
cmdMsgHelp, |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
211 |
cmdMsgMalformedArg, |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
212 |
cmdMsgUnknownArg, |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
213 |
}; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
214 |
enum cmdMsgStateEnum cmdMsgState = cmdMsgNone; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
215 |
QString cmdMsgStateStr; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
216 |
|
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
217 |
// parse arguments |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
218 |
QStringList arguments = app.arguments(); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
219 |
QMap<QString, QString> parsedArgs; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
220 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
221 |
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
|
222 |
while(i != arguments.end()) |
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 |
QString arg = *i; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
225 |
|
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 |
QRegExp opt("--(\\S+)=(.+)"); |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
228 |
if(opt.exactMatch(arg)) |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
229 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
230 |
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
|
231 |
i = arguments.erase(i); |
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 |
else |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
234 |
{ |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
235 |
if(arg.startsWith("--")) { |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
236 |
if(arg == "--help") |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
237 |
{ |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
238 |
cmdMsgState = cmdMsgHelp; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
239 |
qInstallMessageHandler(restrictedMessageHandler); |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
240 |
} |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
241 |
else |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
242 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
243 |
// argument is something wrong |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
244 |
cmdMsgState = cmdMsgMalformedArg; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
245 |
cmdMsgStateStr = arg; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
246 |
qInstallMessageHandler(restrictedMessageHandler); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
247 |
break; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
248 |
} |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
249 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
250 |
|
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
251 |
// 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
|
252 |
// (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
|
253 |
++i; |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
254 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
255 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
256 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
257 |
|
14321
0752148afc65
Use that enum consistently in main.cpp
Wuzzy <Wuzzy2@mail.ru>
parents:
14318
diff
changeset
|
258 |
if(cmdMsgState == cmdMsgNone) |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
259 |
{ |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
260 |
if(parsedArgs.contains("data-dir")) |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
261 |
{ |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
262 |
QFileInfo f(parsedArgs["data-dir"]); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
263 |
parsedArgs.remove("data-dir"); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
264 |
if(!f.exists()) |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
265 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
266 |
qWarning() << "WARNING: Cannot open data-dir=" << f.absoluteFilePath(); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
267 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
268 |
*cDataDir = f.absoluteFilePath(); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
269 |
custom_data = true; |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
270 |
} |
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
271 |
|
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
272 |
if(parsedArgs.contains("config-dir")) |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
273 |
{ |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
274 |
QFileInfo f(parsedArgs["config-dir"]); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
275 |
parsedArgs.remove("config-dir"); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
276 |
cfgdir->setPath(f.absoluteFilePath()); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
277 |
custom_config = true; |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
278 |
} |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
279 |
else |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
280 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
281 |
cfgdir->setPath(QDir::homePath()); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
282 |
custom_config = false; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
283 |
} |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
284 |
|
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
285 |
if (!parsedArgs.isEmpty()) |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
286 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
287 |
cmdMsgState = cmdMsgUnknownArg; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
288 |
qInstallMessageHandler(restrictedMessageHandler); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
289 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
290 |
|
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
291 |
// end of parameter parsing |
13517
873b7d32bc97
Detect Qt style after parameter parsing
Wuzzy <Wuzzy2@mail.ru>
parents:
13516
diff
changeset
|
292 |
|
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
293 |
// Select Qt style |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
294 |
/* Qt5 Base removed Motif, Plastique. These are now in the Qt style plugins |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
295 |
(Ubuntu: qt5-style-plugins, which was NOT backported by Debian/Ubuntu to stable/LTS). |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
296 |
Windows appears to render best of the remaining options but still isn't quite right. */ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
297 |
|
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
298 |
// Try setting Plastique if available |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
299 |
QStyle* coreStyle; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
300 |
coreStyle = QStyleFactory::create("Plastique"); |
13517
873b7d32bc97
Detect Qt style after parameter parsing
Wuzzy <Wuzzy2@mail.ru>
parents:
13516
diff
changeset
|
301 |
if(coreStyle != 0) { |
873b7d32bc97
Detect Qt style after parameter parsing
Wuzzy <Wuzzy2@mail.ru>
parents:
13516
diff
changeset
|
302 |
QApplication::setStyle(coreStyle); |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
303 |
qDebug("Qt style set: Plastique"); |
13517
873b7d32bc97
Detect Qt style after parameter parsing
Wuzzy <Wuzzy2@mail.ru>
parents:
13516
diff
changeset
|
304 |
} else { |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
305 |
// Use Windows as fallback. |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
306 |
// FIXME: Under Windows style, some widgets like scrollbars don't render as nicely |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
307 |
coreStyle = QStyleFactory::create("Windows"); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
308 |
if(coreStyle != 0) { |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
309 |
QApplication::setStyle(coreStyle); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
310 |
qDebug("Qt style set: Windows"); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
311 |
} else { |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
312 |
// Windows style should not be missing in Qt5 Base. If it does, something went terribly wrong! |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
313 |
qWarning("No Qt style could be set! Using the default one."); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
314 |
} |
13517
873b7d32bc97
Detect Qt style after parameter parsing
Wuzzy <Wuzzy2@mail.ru>
parents:
13516
diff
changeset
|
315 |
} |
873b7d32bc97
Detect Qt style after parameter parsing
Wuzzy <Wuzzy2@mail.ru>
parents:
13516
diff
changeset
|
316 |
} |
12661 | 317 |
|
318 |
#ifdef Q_OS_WIN |
|
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
319 |
// Splash screen for Windows |
12661 | 320 |
QPixmap pixmap(":/res/splash.png"); |
321 |
QSplashScreen splash(pixmap); |
|
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
322 |
if(cmdMsgState == cmdMsgNone) |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
323 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
324 |
splash.show(); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
325 |
} |
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
|
326 |
#endif |
12661 | 327 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
328 |
QDateTime now = QDateTime::currentDateTime(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
329 |
srand(now.toTime_t()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
330 |
rand(); |
579 | 331 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
332 |
Q_INIT_RESOURCE(hedgewars); |
579 | 333 |
|
6721
7dbf8a0c1f5d
- Register HWTeam metatype so HWTeam objects could be passed via queued connections
unc0rr
parents:
6700
diff
changeset
|
334 |
qRegisterMetaType<HWTeam>("HWTeam"); |
7dbf8a0c1f5d
- Register HWTeam metatype so HWTeam objects could be passed via queued connections
unc0rr
parents:
6700
diff
changeset
|
335 |
|
8323
ab0b618bdf13
get executable directory at runtime rather than configure time
koda
parents:
8316
diff
changeset
|
336 |
bindir->cd(QCoreApplication::applicationDirPath()); |
579 | 337 |
|
8323
ab0b618bdf13
get executable directory at runtime rather than configure time
koda
parents:
8316
diff
changeset
|
338 |
if(custom_config == false) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
339 |
{ |
1965 | 340 |
#ifdef __APPLE__ |
3758 | 341 |
checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
342 |
cfgdir->cd("Library/Application Support/Hedgewars"); |
3333 | 343 |
#elif defined _WIN32 |
344 |
char path[1024]; |
|
345 |
if(!SHGetFolderPathA(0, CSIDL_PERSONAL, NULL, 0, path)) |
|
346 |
{ |
|
347 |
cfgdir->cd(path); |
|
3758 | 348 |
checkForDir(cfgdir->absolutePath() + "/Hedgewars"); |
3333 | 349 |
cfgdir->cd("Hedgewars"); |
350 |
} |
|
3758 | 351 |
else // couldn't retrieve documents folder? almost impossible, but in case fall back to classic path |
3333 | 352 |
{ |
9094 | 353 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars"); |
354 |
cfgdir->cd(".hedgewars"); |
|
3333 | 355 |
} |
2428 | 356 |
#else |
9094 | 357 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars"); |
358 |
cfgdir->cd(".hedgewars"); |
|
2428 | 359 |
#endif |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
360 |
} |
3758 | 361 |
|
362 |
if (checkForDir(cfgdir->absolutePath())) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
363 |
{ |
3758 | 364 |
// alternative loading/lookup paths |
365 |
checkForDir(cfgdir->absolutePath() + "/Data"); |
|
366 |
||
367 |
// config/save paths |
|
368 |
checkForDir(cfgdir->absolutePath() + "/Demos"); |
|
13212
e9e4cc867b6e
Add default directory DrawnMaps to put hand-drawn maps into
Wuzzy <Wuzzy2@mail.ru>
parents:
13188
diff
changeset
|
369 |
checkForDir(cfgdir->absolutePath() + "/DrawnMaps"); |
3758 | 370 |
checkForDir(cfgdir->absolutePath() + "/Saves"); |
371 |
checkForDir(cfgdir->absolutePath() + "/Screenshots"); |
|
372 |
checkForDir(cfgdir->absolutePath() + "/Teams"); |
|
3914 | 373 |
checkForDir(cfgdir->absolutePath() + "/Logs"); |
7180 | 374 |
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
|
375 |
checkForDir(cfgdir->absolutePath() + "/VideoTemp"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
376 |
} |
579 | 377 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
378 |
datadir->cd(bindir->absolutePath()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
379 |
datadir->cd(*cDataDir); |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8722
diff
changeset
|
380 |
if (!datadir->cd("Data")) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
381 |
{ |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8722
diff
changeset
|
382 |
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
|
383 |
return 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
384 |
} |
579 | 385 |
|
13086
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
386 |
bool isProbablyNewPlayer = false; |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
387 |
|
7931 | 388 |
// setup PhysFS |
10405
469ce70ba163
fix for < LocutusOfBorg1> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760776
sheepluva
parents:
10108
diff
changeset
|
389 |
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
|
390 |
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
|
391 |
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
|
392 |
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
|
393 |
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
|
394 |
engine->mountPacks(); |
7772 | 395 |
|
11488 | 396 |
QTranslator TranslatorHedgewars; |
397 |
QTranslator TranslatorQt; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
398 |
{ |
8918
512753ea4b1b
Switch to 'settings.ini'. Copies old ini file if necessary on startup.
unc0rr
parents:
8882
diff
changeset
|
399 |
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
|
400 |
settings.setIniCodec("UTF-8"); |
512753ea4b1b
Switch to 'settings.ini'. Copies old ini file if necessary on startup.
unc0rr
parents:
8882
diff
changeset
|
401 |
|
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
|
402 |
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
|
403 |
if (cc.isEmpty()) |
9027
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
404 |
{ |
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
405 |
cc = QLocale::system().name(); |
13274
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
406 |
qDebug("Detected system locale: %s", qPrintable(cc)); |
9027
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
407 |
|
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
408 |
// 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
|
409 |
if(cc == "C") |
12897
fc47fc4af6bd
Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents:
12661
diff
changeset
|
410 |
cc = HWApplication::inputMethod()->locale().name(); |
9027
4b8e326251b3
Use old method of locale detection, fallback to new one in case of problems
unc0rr
parents:
8918
diff
changeset
|
411 |
} |
13274
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
412 |
else |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
413 |
{ |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
414 |
qDebug("Configured frontend locale: %s", qPrintable(cc)); |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
415 |
} |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
416 |
QLocale::setDefault(cc); |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
417 |
QString defaultLocaleName = QLocale().name(); |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
418 |
qDebug("Frontend uses locale: %s", qPrintable(defaultLocaleName)); |
6167 | 419 |
|
13274
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
420 |
if (defaultLocaleName != "C") |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
421 |
{ |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
422 |
// Load locale files into translators |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
423 |
if (!TranslatorHedgewars.load(QLocale(), "hedgewars", "_", QString("physfs://Locale"))) |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
424 |
qWarning("Failed to install Hedgewars translation (%s)", qPrintable(defaultLocaleName)); |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
425 |
if (!TranslatorQt.load(QLocale(), "qt", "_", QString(QLibraryInfo::location(QLibraryInfo::TranslationsPath)))) |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
426 |
qWarning("Failed to install Qt translation (%s)", qPrintable(defaultLocaleName)); |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
427 |
app.installTranslator(&TranslatorHedgewars); |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
428 |
app.installTranslator(&TranslatorQt); |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
429 |
} |
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13212
diff
changeset
|
430 |
app.setLayoutDirection(QLocale().textDirection()); |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
431 |
|
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
432 |
// Handle command line messages |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
433 |
switch(cmdMsgState) |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
434 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
435 |
case cmdMsgHelp: |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
436 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
437 |
printf("%s", getUsage().toUtf8().constData()); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
438 |
return 0; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
439 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
440 |
case cmdMsgMalformedArg: |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
441 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
442 |
fprintf(stderr, "%s\n\n%s", |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
443 |
HWApplication::tr("Malformed option argument: %1", "command-line").arg(cmdMsgStateStr).toUtf8().constData(), |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
444 |
getUsage().toUtf8().constData()); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
445 |
return 1; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
446 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
447 |
case cmdMsgUnknownArg: |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
448 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
449 |
foreach (const QString & key, parsedArgs.keys()) |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
450 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
451 |
fprintf(stderr, "%s\n", |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
452 |
HWApplication::tr("Unknown option argument: %1", "command-line").arg(QString("--") + key).toUtf8().constData()); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
453 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
454 |
fprintf(stderr, "\n%s", getUsage().toUtf8().constData()); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
455 |
return 1; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
456 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
457 |
default: |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
458 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
459 |
break; |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
460 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
461 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
462 |
|
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
463 |
// Heuristic to figure out if the user is (probably) a first-time player. |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
464 |
// If nickname is not set, then probably yes. |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
465 |
// The hidden setting firstLaunch is, if present, used to force HW to |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
466 |
// treat iself as if it were launched the first time. |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
467 |
QString nick = settings.value("net/nick", QString()).toString(); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
468 |
if (settings.contains("frontend/firstLaunch")) |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
469 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
470 |
isProbablyNewPlayer = settings.value("frontend/firstLaunch").toBool(); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
471 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
472 |
else |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
473 |
{ |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
474 |
isProbablyNewPlayer = nick.isNull(); |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
475 |
} |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
476 |
|
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
477 |
// Set firstLaunch to false to make sure we remember we have been launched before. |
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
478 |
settings.setValue("frontend/firstLaunch", false); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
479 |
} |
2898 | 480 |
|
5756 | 481 |
#ifdef _WIN32 |
11851 | 482 |
// Win32 registry setup (used for external software detection etc. |
483 |
// don't set it if running in "portable" mode with a custom config dir) |
|
3932 | 484 |
if(!custom_config) |
3679 | 485 |
{ |
3932 | 486 |
QSettings registry_hklm("HKEY_LOCAL_MACHINE", QSettings::NativeFormat); |
487 |
registry_hklm.setValue("Software/Hedgewars/Frontend", bindir->absolutePath().replace("/", "\\") + "\\hedgewars.exe"); |
|
488 |
registry_hklm.setValue("Software/Hedgewars/Path", bindir->absolutePath().replace("/", "\\")); |
|
3679 | 489 |
} |
490 |
#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
|
491 |
|
13516
d44ca1f04bbe
Fix SDLInteraction strings not being translated
Wuzzy <Wuzzy2@mail.ru>
parents:
13304
diff
changeset
|
492 |
SDLInteraction::instance(); |
d44ca1f04bbe
Fix SDLInteraction strings not being translated
Wuzzy <Wuzzy2@mail.ru>
parents:
13304
diff
changeset
|
493 |
|
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
|
494 |
QString style = ""; |
6579 | 495 |
QString fname; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
496 |
|
6579 | 497 |
checkSeason(); |
498 |
//For each season, there is an extra stylesheet |
|
499 |
//Todo: change background for easter and birthday |
|
500 |
//(simply replace res/BackgroundBirthday.png and res/BackgroundEaster.png |
|
501 |
//with an appropriate background |
|
502 |
switch (season) |
|
503 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
504 |
case SEASON_CHRISTMAS : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
505 |
fname = "christmas.css"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
506 |
break; |
13304 | 507 |
case SEASON_APRIL1 : |
508 |
fname = "april1.css"; |
|
509 |
break; |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
510 |
case SEASON_EASTER : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
511 |
fname = "easter.css"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
512 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
513 |
case SEASON_HWBDAY : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
514 |
fname = "birthday.css"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
515 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
516 |
default : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6600
diff
changeset
|
517 |
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
|
518 |
break; |
6579 | 519 |
} |
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
|
520 |
|
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
|
521 |
// load external stylesheet if there is any |
8049 | 522 |
QFile extFile("physfs://css/" + fname); |
2898 | 523 |
|
6579 | 524 |
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
|
525 |
|
7724 | 526 |
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
|
527 |
|
affa860f2983
BOOOOooOM <headshot>! removing default stylesheets from c++ code and adding them as text files to the qt resources
sheepluva
parents:
6177
diff
changeset
|
528 |
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
7724 | 529 |
style.append(file.readAll()); |
2377 | 530 |
|
8651 | 531 |
qWarning("Starting Hedgewars %s-r%d (%s)", qPrintable(*cVersionString), cRevisionString->toInt(), qPrintable(*cHashString)); |
532 |
||
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
|
533 |
app.form = new HWForm(NULL, style); |
12661 | 534 |
#ifdef Q_OS_WIN |
14321
0752148afc65
Use that enum consistently in main.cpp
Wuzzy <Wuzzy2@mail.ru>
parents:
14318
diff
changeset
|
535 |
if(cmdMsgState == cmdMsgNone) |
14318
d688455cad8f
QTfrontend: Translate and clean console output when using --help or bad cmd line arg
Wuzzy <Wuzzy2@mail.ru>
parents:
14279
diff
changeset
|
536 |
splash.finish(app.form); |
12661 | 537 |
#endif |
5252 | 538 |
app.form->show(); |
12661 | 539 |
|
13086
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
540 |
// Show welcome message for (suspected) first-time player and |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
541 |
// point towards the Training menu. |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
542 |
if(isProbablyNewPlayer) { |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
543 |
QMessageBox questionTutorialMsg(app.form); |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
544 |
questionTutorialMsg.setIcon(QMessageBox::Question); |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
545 |
questionTutorialMsg.setWindowTitle(QMessageBox::tr("Welcome to Hedgewars")); |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
546 |
questionTutorialMsg.setText(QMessageBox::tr("Welcome to Hedgewars!\n\nYou seem to be new around here. Would you like to play some training missions first to learn the basics of Hedgewars?")); |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
547 |
questionTutorialMsg.setWindowModality(Qt::WindowModal); |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
548 |
questionTutorialMsg.addButton(QMessageBox::Yes); |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
549 |
questionTutorialMsg.addButton(QMessageBox::No); |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
550 |
|
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
551 |
int answer = questionTutorialMsg.exec(); |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
552 |
if (answer == QMessageBox::Yes) { |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
553 |
app.form->GoToTraining(); |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
554 |
} |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
555 |
} |
8d569c7b36a2
Frontend: Lead first-time player to training page on start
Wuzzy <Wuzzy2@mail.ru>
parents:
12661
diff
changeset
|
556 |
|
8722
2dead6b84bca
this should supposedly add hwplay:// schemes to windows, after user presses file association
koda
parents:
8715
diff
changeset
|
557 |
if (app.urlString) |
2dead6b84bca
this should supposedly add hwplay:// schemes to windows, after user presses file association
koda
parents:
8715
diff
changeset
|
558 |
app.fakeEvent(); |
8223
14d9a3c33650
backout rea7541f77944 since development of frontlib is on another branch
koda
parents:
8206
diff
changeset
|
559 |
return app.exec(); |
2845 | 560 |
} |