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