author | unc0rr |
Sun, 26 Oct 2008 14:45:07 +0000 | |
changeset 1418 | 69df8f2a7cba |
parent 1416 | 60b86d6fe9ae |
child 1425 | 7ee750565e2d |
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;" |
|
121 |
"font: bold 14px;" |
|
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 |
"}" |
|
1155 | 203 |
|
1198 | 204 |
"IconedGroupBox{" |
205 |
"border: solid;" |
|
1214 | 206 |
"border-width: 3px;" |
1198 | 207 |
"border-radius: 16px;" |
1214 | 208 |
"border-color: #ffcc00;" |
1198 | 209 |
"background-color: #130f2c;" |
1214 | 210 |
"color: #ffcc00;" |
1198 | 211 |
"font: bold 14px;" |
1228 | 212 |
"padding: 2px;" |
1198 | 213 |
"}" |
1217 | 214 |
".QGroupBox,GameCFGWidget,TeamSelWidget{" |
1197 | 215 |
"background-image: url(\":/res/panelbg.png\");" |
216 |
"background-position: bottom center;" |
|
217 |
"background-repeat: repeat-x;" |
|
1155 | 218 |
"border: solid;" |
1214 | 219 |
"border-width: 3px;" |
1155 | 220 |
"border-radius: 16px;" |
1214 | 221 |
"border-color: #ffcc00;" |
1198 | 222 |
"background-color: #040200;" |
1199 | 223 |
"padding: 6px;" |
1214 | 224 |
"color: #ffcc00;" |
1155 | 225 |
"font: bold 14px;" |
1209 | 226 |
//"margin-top: 24px;" |
1201 | 227 |
"}" |
228 |
".QGroupBox::title{" |
|
229 |
"subcontrol-origin: margin;" |
|
230 |
"subcontrol-position: top left;" |
|
231 |
//"padding-left: 82px;" |
|
232 |
//"padding-top: 26px;" |
|
233 |
"text-align: left;" |
|
1155 | 234 |
"}" |
235 |
||
236 |
"QCheckBox{" |
|
1214 | 237 |
"color: #ffcc00;" |
1155 | 238 |
"font: bold 14px;" |
239 |
"}" |
|
240 |
"QCheckBox::indicator:checked{" |
|
241 |
"image: url(\":/res/checked.png\");" |
|
242 |
"}" |
|
243 |
"QCheckBox::indicator:unchecked{" |
|
244 |
"image: url(\":/res/unchecked.png\");" |
|
245 |
"}" |
|
1172 | 246 |
|
247 |
"QRadioButton{" |
|
1214 | 248 |
"color: #ffcc00;" |
1172 | 249 |
"font: bold 14px;" |
250 |
"}" |
|
1252 | 251 |
|
252 |
".QWidget{" |
|
253 |
"background: transparent;" |
|
254 |
"}" |
|
255 |
".QTabWidget{" |
|
256 |
//"background: transparent;" |
|
257 |
"background-color: #130f2c;" |
|
258 |
"}" |
|
1413 | 259 |
|
260 |
"QMenu{" |
|
261 |
"background-color: #ffcc00;" |
|
262 |
"margin: 3px;" |
|
263 |
"}" |
|
264 |
"QMenu::item{" |
|
265 |
"background-color: #0d0544;" |
|
266 |
"border: 1px solid transparent;" |
|
267 |
"font: bold;" |
|
268 |
"color: #ffcc00;" |
|
269 |
"padding: 2px 25px 2px 20px;" |
|
270 |
"}" |
|
271 |
"QMenu::item:selected{" |
|
272 |
"border-color: yellow;" |
|
273 |
"background-color: #2d2564;" |
|
274 |
"}" |
|
275 |
"QMenu::indicator{" |
|
276 |
"width: 16px;" |
|
277 |
"height: 16px;" |
|
278 |
"}" |
|
279 |
"QMenu::indicator:non-exclusive:checked{" |
|
280 |
"image: url(\":/res/checked.png\");" |
|
281 |
"}" |
|
282 |
"QMenu::indicator:non-exclusive:unchecked{" |
|
283 |
"image: url(\":/res/unchecked.png\");" |
|
284 |
"}" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
285 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
286 |
); |
1150 | 287 |
|
579 | 288 |
bindir->cd("bin"); // workaround over NSIS installer |
289 |
||
290 |
cfgdir->setPath(cfgdir->homePath()); |
|
291 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
292 |
{ |
|
293 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
294 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
295 |
} |
|
296 |
cfgdir->cd(".hedgewars"); |
|
297 |
||
298 |
datadir->cd(bindir->absolutePath()); |
|
299 |
datadir->cd(*cDataDir); |
|
300 |
if(!datadir->cd("hedgewars/Data")) { |
|
301 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
302 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
303 |
"Please check your installation"). |
|
304 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
305 |
return 1; |
|
306 |
} |
|
307 |
||
308 |
QTranslator Translator; |
|
309 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
310 |
app.installTranslator(&Translator); |
|
311 |
||
312 |
Themes = new QStringList(); |
|
313 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
314 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
315 |
QTextStream stream(&themesfile); |
|
316 |
QString str; |
|
317 |
while (!stream.atEnd()) |
|
318 |
{ |
|
319 |
Themes->append(stream.readLine()); |
|
320 |
} |
|
321 |
themesfile.close(); |
|
322 |
} else { |
|
323 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
324 |
} |
|
325 |
||
1210 | 326 |
QDir tmpdir; |
327 |
tmpdir.cd(datadir->absolutePath()); |
|
328 |
tmpdir.cd("Maps"); |
|
329 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
|
330 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
|
331 |
||
579 | 332 |
HWForm *Form = new HWForm(); |
333 |
Form->show(); |
|
334 |
return app.exec(); |
|
335 |
} |