author | unc0rr |
Sat, 18 Oct 2008 13:53:58 +0000 | |
changeset 1377 | a9e768739345 |
parent 1289 | 789db262d90d |
child 1390 | 914fa66aec05 |
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 |
||
1171 | 101 |
"QListWidget{" |
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 |
"}" |
|
1211 | 114 |
// "QListWidget::item:alternate{" |
115 |
// "background: #2f213a;" |
|
116 |
// "}" |
|
1171 | 117 |
|
1377 | 118 |
"QTextBrowser{" |
119 |
"border: solid;" |
|
120 |
"border-width: 3px;" |
|
121 |
"border-radius: 12px;" |
|
122 |
"border-color: #ffcc00;" |
|
123 |
"background-color: #0d0544;" |
|
124 |
"color: #ffcc00;" |
|
125 |
"font: bold 14px;" |
|
126 |
"}" |
|
127 |
||
1161 | 128 |
"QSpinBox{" |
129 |
"border: solid;" |
|
1214 | 130 |
"border-width: 3px;" |
1161 | 131 |
"border-radius: 12px;" |
1214 | 132 |
"border-color: #ffcc00;" |
1161 | 133 |
"background-color: #0d0544;" |
1214 | 134 |
"color: #ffcc00;" |
1161 | 135 |
"font: bold 14px;" |
136 |
"}" |
|
137 |
"QSpinBox:hover{" |
|
138 |
"border-color: yellow;" |
|
139 |
"}" |
|
1289 | 140 |
"QSpinBox::up-button{" |
141 |
"background: transparent;" |
|
142 |
"width: 16px;" |
|
143 |
"height: 10px;" |
|
144 |
"}" |
|
145 |
"QSpinBox::up-arrow{" |
|
146 |
"image: url(\":/res/spin_up.png\");" |
|
147 |
//"width: 5px;" |
|
148 |
//"height: 5px;" |
|
149 |
"}" |
|
150 |
"QSpinBox::down-button{" |
|
151 |
"background: transparent;" |
|
152 |
"width: 16px;" |
|
153 |
"height: 10px;" |
|
154 |
"}" |
|
155 |
"QSpinBox::down-arrow{" |
|
156 |
"image: url(\":/res/spin_down.png\");" |
|
157 |
"}" |
|
1161 | 158 |
|
1172 | 159 |
"QToolBox{" |
160 |
"border: solid;" |
|
1214 | 161 |
"border-width: 3px;" |
1172 | 162 |
"border-radius: 12px;" |
1214 | 163 |
"border-color: #ffcc00;" |
1252 | 164 |
//"background-color: #0d0544;" |
1172 | 165 |
"}" |
166 |
"QToolBox::tab{" |
|
1214 | 167 |
"color: #ffcc00;" |
1172 | 168 |
"font: bold 14px;" |
169 |
"}" |
|
170 |
"QToolBox:hover{" |
|
171 |
"border-color: yellow;" |
|
172 |
"}" |
|
173 |
||
1154 | 174 |
"QComboBox{" |
175 |
"border: solid;" |
|
1214 | 176 |
"border-width: 3px;" |
1161 | 177 |
"border-radius: 15px;" |
1214 | 178 |
"border-color: #ffcc00;" |
1154 | 179 |
"background-color: #0d0544;" |
1214 | 180 |
"color: #ffcc00;" |
1154 | 181 |
"font: bold 14px;" |
182 |
"padding: 3px;" |
|
183 |
// "text-align: center;" |
|
184 |
"}" |
|
185 |
"QComboBox:hover{" |
|
186 |
"border-color: yellow;" |
|
187 |
"}" |
|
188 |
"QComboBox:pressed{" |
|
189 |
"border-color: white;" |
|
190 |
"}" |
|
191 |
"QComboBox::drop-down{" |
|
192 |
"border: transparent;" |
|
193 |
"width: 25px;" |
|
194 |
"}" |
|
195 |
"QComboBox::down-arrow {" |
|
1155 | 196 |
"image: url(\":/res/dropdown.png\");" |
1154 | 197 |
"}" |
198 |
"QComboBox QAbstractItemView{" |
|
199 |
"border: solid transparent;" |
|
1214 | 200 |
"border-width: 3px;" |
1157 | 201 |
//"border-radius: 12px;" -- bad corners look |
1214 | 202 |
"border-color: #ffcc00;" |
1154 | 203 |
"background-color: #0d0544;" |
1214 | 204 |
"color: #ffcc00;" |
1154 | 205 |
"font: bold 14px;" |
206 |
"}" |
|
1155 | 207 |
|
1198 | 208 |
"IconedGroupBox{" |
209 |
"border: solid;" |
|
1214 | 210 |
"border-width: 3px;" |
1198 | 211 |
"border-radius: 16px;" |
1214 | 212 |
"border-color: #ffcc00;" |
1198 | 213 |
"background-color: #130f2c;" |
1214 | 214 |
"color: #ffcc00;" |
1198 | 215 |
"font: bold 14px;" |
1228 | 216 |
"padding: 2px;" |
1198 | 217 |
"}" |
1217 | 218 |
".QGroupBox,GameCFGWidget,TeamSelWidget{" |
1197 | 219 |
"background-image: url(\":/res/panelbg.png\");" |
220 |
"background-position: bottom center;" |
|
221 |
"background-repeat: repeat-x;" |
|
1155 | 222 |
"border: solid;" |
1214 | 223 |
"border-width: 3px;" |
1155 | 224 |
"border-radius: 16px;" |
1214 | 225 |
"border-color: #ffcc00;" |
1198 | 226 |
"background-color: #040200;" |
1199 | 227 |
"padding: 6px;" |
1214 | 228 |
"color: #ffcc00;" |
1155 | 229 |
"font: bold 14px;" |
1209 | 230 |
//"margin-top: 24px;" |
1201 | 231 |
"}" |
232 |
".QGroupBox::title{" |
|
233 |
"subcontrol-origin: margin;" |
|
234 |
"subcontrol-position: top left;" |
|
235 |
//"padding-left: 82px;" |
|
236 |
//"padding-top: 26px;" |
|
237 |
"text-align: left;" |
|
1155 | 238 |
"}" |
239 |
||
240 |
"QCheckBox{" |
|
1214 | 241 |
"color: #ffcc00;" |
1155 | 242 |
"font: bold 14px;" |
243 |
"}" |
|
244 |
"QCheckBox::indicator:checked{" |
|
245 |
"image: url(\":/res/checked.png\");" |
|
246 |
"}" |
|
247 |
"QCheckBox::indicator:unchecked{" |
|
248 |
"image: url(\":/res/unchecked.png\");" |
|
249 |
"}" |
|
1172 | 250 |
|
251 |
"QRadioButton{" |
|
1214 | 252 |
"color: #ffcc00;" |
1172 | 253 |
"font: bold 14px;" |
254 |
"}" |
|
1252 | 255 |
|
256 |
".QWidget{" |
|
257 |
"background: transparent;" |
|
258 |
"}" |
|
259 |
".QTabWidget{" |
|
260 |
//"background: transparent;" |
|
261 |
"background-color: #130f2c;" |
|
262 |
"}" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
263 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
264 |
); |
1150 | 265 |
|
579 | 266 |
bindir->cd("bin"); // workaround over NSIS installer |
267 |
||
268 |
cfgdir->setPath(cfgdir->homePath()); |
|
269 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
270 |
{ |
|
271 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
272 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
273 |
} |
|
274 |
cfgdir->cd(".hedgewars"); |
|
275 |
||
276 |
datadir->cd(bindir->absolutePath()); |
|
277 |
datadir->cd(*cDataDir); |
|
278 |
if(!datadir->cd("hedgewars/Data")) { |
|
279 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
280 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
281 |
"Please check your installation"). |
|
282 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
283 |
return 1; |
|
284 |
} |
|
285 |
||
286 |
QTranslator Translator; |
|
287 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
288 |
app.installTranslator(&Translator); |
|
289 |
||
290 |
Themes = new QStringList(); |
|
291 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
292 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
293 |
QTextStream stream(&themesfile); |
|
294 |
QString str; |
|
295 |
while (!stream.atEnd()) |
|
296 |
{ |
|
297 |
Themes->append(stream.readLine()); |
|
298 |
} |
|
299 |
themesfile.close(); |
|
300 |
} else { |
|
301 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
302 |
} |
|
303 |
||
1210 | 304 |
QDir tmpdir; |
305 |
tmpdir.cd(datadir->absolutePath()); |
|
306 |
tmpdir.cd("Maps"); |
|
307 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
|
308 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
|
309 |
||
579 | 310 |
HWForm *Form = new HWForm(); |
311 |
Form->show(); |
|
312 |
return app.exec(); |
|
313 |
} |