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