author | unc0rr |
Tue, 12 Aug 2008 09:37:44 +0000 | |
changeset 1194 | 32e854874df2 |
parent 1193 | 2911384169b4 |
child 1195 | a9d237442958 |
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 |
|
175 |
"QGroupBox{" |
|
176 |
"border: solid;" |
|
177 |
"border-width: 4px;" |
|
178 |
"border-radius: 16px;" |
|
179 |
"border-color: orange;" |
|
1157 | 180 |
"background-color: #130f2c;" |
1155 | 181 |
"color: orange;" |
182 |
"font: bold 14px;" |
|
183 |
"padding: 3px;" |
|
1194 | 184 |
"margin-top: 56px;" |
185 |
"margin-left: 12px;" |
|
186 |
"padding-top: 10px;" |
|
1155 | 187 |
"}" |
1157 | 188 |
"QGroupBox::title{" |
189 |
"subcontrol-origin: margin;" |
|
190 |
"subcontrol-position: top left;" |
|
1193 | 191 |
"padding-left: 82px;" |
192 |
"padding-top: 26px;" |
|
193 |
"text-align: left;" |
|
1155 | 194 |
"}" |
195 |
||
196 |
"QCheckBox{" |
|
197 |
"color: orange;" |
|
198 |
"font: bold 14px;" |
|
199 |
"}" |
|
200 |
"QCheckBox::indicator:checked{" |
|
201 |
"image: url(\":/res/checked.png\");" |
|
202 |
"}" |
|
203 |
"QCheckBox::indicator:unchecked{" |
|
204 |
"image: url(\":/res/unchecked.png\");" |
|
205 |
"}" |
|
1172 | 206 |
|
207 |
"QRadioButton{" |
|
208 |
"color: orange;" |
|
209 |
"font: bold 14px;" |
|
210 |
"}" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
211 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
212 |
); |
1150 | 213 |
|
579 | 214 |
bindir->cd("bin"); // workaround over NSIS installer |
215 |
||
216 |
cfgdir->setPath(cfgdir->homePath()); |
|
217 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
218 |
{ |
|
219 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
220 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
221 |
} |
|
222 |
cfgdir->cd(".hedgewars"); |
|
223 |
||
224 |
datadir->cd(bindir->absolutePath()); |
|
225 |
datadir->cd(*cDataDir); |
|
226 |
if(!datadir->cd("hedgewars/Data")) { |
|
227 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
228 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
229 |
"Please check your installation"). |
|
230 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
231 |
return 1; |
|
232 |
} |
|
233 |
||
234 |
QTranslator Translator; |
|
235 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
236 |
app.installTranslator(&Translator); |
|
237 |
||
238 |
Themes = new QStringList(); |
|
239 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
240 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
241 |
QTextStream stream(&themesfile); |
|
242 |
QString str; |
|
243 |
while (!stream.atEnd()) |
|
244 |
{ |
|
245 |
Themes->append(stream.readLine()); |
|
246 |
} |
|
247 |
themesfile.close(); |
|
248 |
} else { |
|
249 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
250 |
} |
|
251 |
||
252 |
HWForm *Form = new HWForm(); |
|
253 |
Form->show(); |
|
254 |
return app.exec(); |
|
255 |
} |