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