author | unc0rr |
Sun, 26 Oct 2008 13:00:35 +0000 | |
changeset 1415 | 6fbfee0e113a |
parent 1413 | 6393a1d5ac18 |
child 1416 | 60b86d6fe9ae |
permissions | -rw-r--r-- |
579 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
579 | 3 |
* Copyright (c) 2005-2007 Andrey Korotaev <unC0Rr@gmail.com> |
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QApplication> |
|
20 |
#include <QTranslator> |
|
21 |
#include <QLocale> |
|
22 |
#include <QMessageBox> |
|
23 |
#include <QFileInfo> |
|
24 |
#include <QDateTime> |
|
25 |
#include <QTextStream> |
|
1146 | 26 |
#include <QDesktopWidget> |
27 |
||
579 | 28 |
#include "hwform.h" |
29 |
#include "hwconsts.h" |
|
30 |
||
31 |
bool checkForDir(const QString & dir) |
|
32 |
{ |
|
33 |
QDir tmpdir; |
|
34 |
if (!tmpdir.exists(dir)) |
|
35 |
if (!tmpdir.mkdir(dir)) |
|
36 |
{ |
|
37 |
QMessageBox::critical(0, |
|
38 |
QObject::tr("Error"), |
|
39 |
QObject::tr("Cannot create directory %1").arg(dir), |
|
40 |
QObject::tr("OK")); |
|
41 |
return false; |
|
42 |
} |
|
43 |
return true; |
|
44 |
} |
|
45 |
||
46 |
int main(int argc, char *argv[]) |
|
47 |
{ |
|
48 |
QApplication app(argc, argv); |
|
49 |
||
50 |
QDateTime now = QDateTime::currentDateTime(); |
|
51 |
QDateTime zero; |
|
52 |
srand(now.secsTo(zero)); |
|
1215 | 53 |
rand(); |
579 | 54 |
|
55 |
Q_INIT_RESOURCE(hedgewars); |
|
56 |
||
1146 | 57 |
qApp->setStyleSheet |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
58 |
(QString( |
1219
89babaafe99d
Make dialogs and messageboxes be customized like main form
unc0rr
parents:
1217
diff
changeset
|
59 |
"HWForm,QDialog{" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
60 |
"background-image: url(\":/res/Background.png\");" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
61 |
"background-position: bottom center;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
62 |
"background-repeat: repeat-x;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
63 |
"background-color: #870c8f;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
64 |
"}" |
1154 | 65 |
|
66 |
"QPushButton{" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
67 |
"border: solid;" |
1214 | 68 |
"border-width: 3px;" |
1157 | 69 |
"border-radius: 10px;" |
1214 | 70 |
"border-color: #ffcc00;" |
1168 | 71 |
"background-origin: margin;" |
72 |
"background-position: top left;" |
|
1167 | 73 |
"background-color: #00351d;" |
1214 | 74 |
"color: #ffcc00;" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
75 |
"}" |
1153 | 76 |
"QPushButton:hover{" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
77 |
"border-color: yellow;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
78 |
"}" |
1153 | 79 |
"QPushButton:pressed{" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
80 |
"border-color: white;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
81 |
"}" |
1154 | 82 |
|
1160 | 83 |
"QLineEdit{" |
84 |
"border: solid;" |
|
1214 | 85 |
"border-width: 3px;" |
1160 | 86 |
"border-radius: 12px;" |
1214 | 87 |
"border-color: #ffcc00;" |
1160 | 88 |
"background-color: #0d0544;" |
1214 | 89 |
"color: #ffcc00;" |
1160 | 90 |
"font: bold 14px;" |
91 |
"}" |
|
92 |
"QLineEdit:hover{" |
|
93 |
"border-color: yellow;" |
|
94 |
"}" |
|
95 |
||
1172 | 96 |
"QLabel{" |
1214 | 97 |
"color: #ffcc00;" |
1172 | 98 |
"font: bold 14px;" |
99 |
"}" |
|
100 |
||
1390 | 101 |
"QListWidget,QTableView{" |
1171 | 102 |
"border: solid;" |
1214 | 103 |
"border-width: 3px;" |
1171 | 104 |
"border-radius: 12px;" |
1214 | 105 |
"border-color: #ffcc00;" |
1171 | 106 |
"background-color: #0d0544;" |
1211 | 107 |
// "alternate-background-color: #2f213a;" //what's it? |
1214 | 108 |
"color: #ffcc00;" |
1171 | 109 |
"font: bold 14px;" |
110 |
"}" |
|
111 |
"QListWidget:hover{" |
|
112 |
"border-color: yellow;" |
|
113 |
"}" |
|
114 |
||
1377 | 115 |
"QTextBrowser{" |
116 |
"border: solid;" |
|
117 |
"border-width: 3px;" |
|
118 |
"border-radius: 12px;" |
|
119 |
"border-color: #ffcc00;" |
|
120 |
"background-color: #0d0544;" |
|
121 |
"color: #ffcc00;" |
|
122 |
"font: bold 14px;" |
|
123 |
"}" |
|
124 |
||
1161 | 125 |
"QSpinBox{" |
126 |
"border: solid;" |
|
1214 | 127 |
"border-width: 3px;" |
1161 | 128 |
"border-radius: 12px;" |
1214 | 129 |
"border-color: #ffcc00;" |
1161 | 130 |
"background-color: #0d0544;" |
1214 | 131 |
"color: #ffcc00;" |
1161 | 132 |
"font: bold 14px;" |
133 |
"}" |
|
134 |
"QSpinBox:hover{" |
|
135 |
"border-color: yellow;" |
|
136 |
"}" |
|
1289 | 137 |
"QSpinBox::up-button{" |
138 |
"background: transparent;" |
|
139 |
"width: 16px;" |
|
140 |
"height: 10px;" |
|
141 |
"}" |
|
142 |
"QSpinBox::up-arrow{" |
|
143 |
"image: url(\":/res/spin_up.png\");" |
|
144 |
//"width: 5px;" |
|
145 |
//"height: 5px;" |
|
146 |
"}" |
|
147 |
"QSpinBox::down-button{" |
|
148 |
"background: transparent;" |
|
149 |
"width: 16px;" |
|
150 |
"height: 10px;" |
|
151 |
"}" |
|
152 |
"QSpinBox::down-arrow{" |
|
153 |
"image: url(\":/res/spin_down.png\");" |
|
154 |
"}" |
|
1161 | 155 |
|
1172 | 156 |
"QToolBox{" |
157 |
"border: solid;" |
|
1214 | 158 |
"border-width: 3px;" |
1172 | 159 |
"border-radius: 12px;" |
1214 | 160 |
"border-color: #ffcc00;" |
1252 | 161 |
//"background-color: #0d0544;" |
1172 | 162 |
"}" |
163 |
"QToolBox::tab{" |
|
1214 | 164 |
"color: #ffcc00;" |
1172 | 165 |
"font: bold 14px;" |
166 |
"}" |
|
167 |
"QToolBox:hover{" |
|
168 |
"border-color: yellow;" |
|
169 |
"}" |
|
170 |
||
1154 | 171 |
"QComboBox{" |
172 |
"border: solid;" |
|
1214 | 173 |
"border-width: 3px;" |
1161 | 174 |
"border-radius: 15px;" |
1214 | 175 |
"border-color: #ffcc00;" |
1154 | 176 |
"background-color: #0d0544;" |
1214 | 177 |
"color: #ffcc00;" |
1154 | 178 |
"font: bold 14px;" |
179 |
"padding: 3px;" |
|
180 |
// "text-align: center;" |
|
181 |
"}" |
|
182 |
"QComboBox:hover{" |
|
183 |
"border-color: yellow;" |
|
184 |
"}" |
|
185 |
"QComboBox:pressed{" |
|
186 |
"border-color: white;" |
|
187 |
"}" |
|
188 |
"QComboBox::drop-down{" |
|
189 |
"border: transparent;" |
|
190 |
"width: 25px;" |
|
191 |
"}" |
|
192 |
"QComboBox::down-arrow {" |
|
1155 | 193 |
"image: url(\":/res/dropdown.png\");" |
1154 | 194 |
"}" |
195 |
"QComboBox QAbstractItemView{" |
|
196 |
"border: solid transparent;" |
|
1214 | 197 |
"border-width: 3px;" |
1157 | 198 |
//"border-radius: 12px;" -- bad corners look |
1214 | 199 |
"border-color: #ffcc00;" |
1154 | 200 |
"background-color: #0d0544;" |
1214 | 201 |
"color: #ffcc00;" |
1154 | 202 |
"font: bold 14px;" |
203 |
"}" |
|
1155 | 204 |
|
1198 | 205 |
"IconedGroupBox{" |
206 |
"border: solid;" |
|
1214 | 207 |
"border-width: 3px;" |
1198 | 208 |
"border-radius: 16px;" |
1214 | 209 |
"border-color: #ffcc00;" |
1198 | 210 |
"background-color: #130f2c;" |
1214 | 211 |
"color: #ffcc00;" |
1198 | 212 |
"font: bold 14px;" |
1228 | 213 |
"padding: 2px;" |
1198 | 214 |
"}" |
1217 | 215 |
".QGroupBox,GameCFGWidget,TeamSelWidget{" |
1197 | 216 |
"background-image: url(\":/res/panelbg.png\");" |
217 |
"background-position: bottom center;" |
|
218 |
"background-repeat: repeat-x;" |
|
1155 | 219 |
"border: solid;" |
1214 | 220 |
"border-width: 3px;" |
1155 | 221 |
"border-radius: 16px;" |
1214 | 222 |
"border-color: #ffcc00;" |
1198 | 223 |
"background-color: #040200;" |
1199 | 224 |
"padding: 6px;" |
1214 | 225 |
"color: #ffcc00;" |
1155 | 226 |
"font: bold 14px;" |
1209 | 227 |
//"margin-top: 24px;" |
1201 | 228 |
"}" |
229 |
".QGroupBox::title{" |
|
230 |
"subcontrol-origin: margin;" |
|
231 |
"subcontrol-position: top left;" |
|
232 |
//"padding-left: 82px;" |
|
233 |
//"padding-top: 26px;" |
|
234 |
"text-align: left;" |
|
1155 | 235 |
"}" |
236 |
||
237 |
"QCheckBox{" |
|
1214 | 238 |
"color: #ffcc00;" |
1155 | 239 |
"font: bold 14px;" |
240 |
"}" |
|
241 |
"QCheckBox::indicator:checked{" |
|
242 |
"image: url(\":/res/checked.png\");" |
|
243 |
"}" |
|
244 |
"QCheckBox::indicator:unchecked{" |
|
245 |
"image: url(\":/res/unchecked.png\");" |
|
246 |
"}" |
|
1172 | 247 |
|
248 |
"QRadioButton{" |
|
1214 | 249 |
"color: #ffcc00;" |
1172 | 250 |
"font: bold 14px;" |
251 |
"}" |
|
1252 | 252 |
|
253 |
".QWidget{" |
|
254 |
"background: transparent;" |
|
255 |
"}" |
|
256 |
".QTabWidget{" |
|
257 |
//"background: transparent;" |
|
258 |
"background-color: #130f2c;" |
|
259 |
"}" |
|
1413 | 260 |
|
261 |
"QMenu{" |
|
262 |
"background-color: #ffcc00;" |
|
263 |
"margin: 3px;" |
|
264 |
"}" |
|
265 |
"QMenu::item{" |
|
266 |
"background-color: #0d0544;" |
|
267 |
"border: 1px solid transparent;" |
|
268 |
"font: bold;" |
|
269 |
"color: #ffcc00;" |
|
270 |
"padding: 2px 25px 2px 20px;" |
|
271 |
"}" |
|
272 |
"QMenu::item:selected{" |
|
273 |
"border-color: yellow;" |
|
274 |
"background-color: #2d2564;" |
|
275 |
"}" |
|
276 |
"QMenu::indicator{" |
|
277 |
"width: 16px;" |
|
278 |
"height: 16px;" |
|
279 |
"}" |
|
280 |
"QMenu::indicator:non-exclusive:checked{" |
|
281 |
"image: url(\":/res/checked.png\");" |
|
282 |
"}" |
|
283 |
"QMenu::indicator:non-exclusive:unchecked{" |
|
284 |
"image: url(\":/res/unchecked.png\");" |
|
285 |
"}" |
|
1415
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
286 |
|
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
287 |
"QScrollBar:vertical{" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
288 |
"background-color: #000000;" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
289 |
"border: 2px #ffcc00;" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
290 |
"width: 16px;" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
291 |
"margin: 22px 0 22px 0;" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
292 |
"}" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
293 |
"QScrollBar::handle:vertical{" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
294 |
"border: 1px #ffcc00;" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
295 |
"background-color: #0d0544;" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
296 |
"min-height: 16px;" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
297 |
"}" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
298 |
"QScrollBar::up-arrow:vertical{" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
299 |
"image: url(\":/res/spin_up.png\");" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
300 |
"width: 16px;" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
301 |
"height: 16px;" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
302 |
"}" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
303 |
"QScrollBar::down-arrow:vertical{" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
304 |
"image: url(\":/res/spin_down.png\");" |
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1413
diff
changeset
|
305 |
"}" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
306 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
307 |
); |
1150 | 308 |
|
579 | 309 |
bindir->cd("bin"); // workaround over NSIS installer |
310 |
||
311 |
cfgdir->setPath(cfgdir->homePath()); |
|
312 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
313 |
{ |
|
314 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
315 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
316 |
} |
|
317 |
cfgdir->cd(".hedgewars"); |
|
318 |
||
319 |
datadir->cd(bindir->absolutePath()); |
|
320 |
datadir->cd(*cDataDir); |
|
321 |
if(!datadir->cd("hedgewars/Data")) { |
|
322 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
323 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
324 |
"Please check your installation"). |
|
325 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
326 |
return 1; |
|
327 |
} |
|
328 |
||
329 |
QTranslator Translator; |
|
330 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
331 |
app.installTranslator(&Translator); |
|
332 |
||
333 |
Themes = new QStringList(); |
|
334 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
335 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
336 |
QTextStream stream(&themesfile); |
|
337 |
QString str; |
|
338 |
while (!stream.atEnd()) |
|
339 |
{ |
|
340 |
Themes->append(stream.readLine()); |
|
341 |
} |
|
342 |
themesfile.close(); |
|
343 |
} else { |
|
344 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
345 |
} |
|
346 |
||
1210 | 347 |
QDir tmpdir; |
348 |
tmpdir.cd(datadir->absolutePath()); |
|
349 |
tmpdir.cd("Maps"); |
|
350 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
|
351 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
|
352 |
||
579 | 353 |
HWForm *Form = new HWForm(); |
354 |
Form->show(); |
|
355 |
return app.exec(); |
|
356 |
} |