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