author | unc0rr |
Fri, 24 Oct 2008 13:03:06 +0000 | |
changeset 1406 | 08b9c28419f1 |
parent 1390 | 914fa66aec05 |
child 1413 | 6393a1d5ac18 |
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 |
"}" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
260 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
261 |
); |
1150 | 262 |
|
579 | 263 |
bindir->cd("bin"); // workaround over NSIS installer |
264 |
||
265 |
cfgdir->setPath(cfgdir->homePath()); |
|
266 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
267 |
{ |
|
268 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
269 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
270 |
} |
|
271 |
cfgdir->cd(".hedgewars"); |
|
272 |
||
273 |
datadir->cd(bindir->absolutePath()); |
|
274 |
datadir->cd(*cDataDir); |
|
275 |
if(!datadir->cd("hedgewars/Data")) { |
|
276 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
277 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
278 |
"Please check your installation"). |
|
279 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
280 |
return 1; |
|
281 |
} |
|
282 |
||
283 |
QTranslator Translator; |
|
284 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
285 |
app.installTranslator(&Translator); |
|
286 |
||
287 |
Themes = new QStringList(); |
|
288 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
289 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
290 |
QTextStream stream(&themesfile); |
|
291 |
QString str; |
|
292 |
while (!stream.atEnd()) |
|
293 |
{ |
|
294 |
Themes->append(stream.readLine()); |
|
295 |
} |
|
296 |
themesfile.close(); |
|
297 |
} else { |
|
298 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
299 |
} |
|
300 |
||
1210 | 301 |
QDir tmpdir; |
302 |
tmpdir.cd(datadir->absolutePath()); |
|
303 |
tmpdir.cd("Maps"); |
|
304 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
|
305 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
|
306 |
||
579 | 307 |
HWForm *Form = new HWForm(); |
308 |
Form->show(); |
|
309 |
return app.exec(); |
|
310 |
} |