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