author | unc0rr |
Sun, 15 Mar 2009 14:47:59 +0000 | |
changeset 1894 | ba54441631da |
parent 1893 | 85c61bc5e160 |
child 1897 | e9dcb47013c7 |
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> |
|
1416
60b86d6fe9ae
Force plastique style, as others don't fully support stylesheets
unc0rr
parents:
1415
diff
changeset
|
23 |
#include <QPlastiqueStyle> |
1146 | 24 |
|
579 | 25 |
#include "hwform.h" |
26 |
#include "hwconsts.h" |
|
27 |
||
28 |
bool checkForDir(const QString & dir) |
|
29 |
{ |
|
30 |
QDir tmpdir; |
|
31 |
if (!tmpdir.exists(dir)) |
|
32 |
if (!tmpdir.mkdir(dir)) |
|
33 |
{ |
|
34 |
QMessageBox::critical(0, |
|
35 |
QObject::tr("Error"), |
|
36 |
QObject::tr("Cannot create directory %1").arg(dir), |
|
37 |
QObject::tr("OK")); |
|
38 |
return false; |
|
39 |
} |
|
40 |
return true; |
|
41 |
} |
|
42 |
||
43 |
int main(int argc, char *argv[]) |
|
44 |
{ |
|
45 |
QApplication app(argc, argv); |
|
46 |
||
1416
60b86d6fe9ae
Force plastique style, as others don't fully support stylesheets
unc0rr
parents:
1415
diff
changeset
|
47 |
app.setStyle(new QPlastiqueStyle); |
60b86d6fe9ae
Force plastique style, as others don't fully support stylesheets
unc0rr
parents:
1415
diff
changeset
|
48 |
|
579 | 49 |
QDateTime now = QDateTime::currentDateTime(); |
50 |
QDateTime zero; |
|
51 |
srand(now.secsTo(zero)); |
|
1215 | 52 |
rand(); |
579 | 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( |
1219
89babaafe99d
Make dialogs and messageboxes be customized like main form
unc0rr
parents:
1217
diff
changeset
|
58 |
"HWForm,QDialog{" |
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 |
|
1893 | 65 |
"QPushButton, QLineEdit, QLabel, QHeaderView, " |
66 |
"QListWidget, QTableView, QTextBrowser, QSpinBox, " |
|
67 |
"QToolBox::tab, QToolBox::tab QWidget, QComboBox, " |
|
68 |
"QComboBox QAbstractItemView, IconedGroupBox, .QGroupBox, " |
|
69 |
"GameCFGWidget, TeamSelWidget, SelWeaponWidget, " |
|
70 |
"QCheckBox, QRadioButton, QMenu::item, QTabBar::tab:selected {" |
|
71 |
"color: #ffcc00;" |
|
72 |
"}" |
|
73 |
||
74 |
"QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, " |
|
75 |
"QComboBox QAbstractItemView, QMenu::item {" |
|
76 |
"background-color: #0d0544;" |
|
77 |
"}" |
|
78 |
||
79 |
"QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, " |
|
80 |
"QTextBrowser, QSpinBox, QToolBox, QComboBox, " |
|
81 |
"QComboBox QAbstractItemView, IconedGroupBox, " |
|
82 |
".QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, QTabWidget::pane {" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
83 |
"border: solid;" |
1214 | 84 |
"border-width: 3px;" |
1893 | 85 |
"border-color: #ffcc00;" |
86 |
"}" |
|
87 |
||
88 |
"QPushButton:hover, QLineEdit:hover, QListWidget:hover, " |
|
89 |
"QSpinBox:hover, QToolBox:hover, QComboBox:hover {" |
|
90 |
"border-color: yellow;" |
|
91 |
"}" |
|
92 |
||
93 |
"QLineEdit, QListWidget,QTableView, QTextBrowser, " |
|
94 |
"QSpinBox, QToolBox { " |
|
95 |
"border-radius: 12px;" |
|
96 |
"}" |
|
97 |
||
98 |
"QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, " |
|
99 |
"QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, " |
|
100 |
"IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, " |
|
101 |
"SelWeaponWidget, QCheckBox, QRadioButton {" |
|
102 |
"font: bold 14px;" |
|
103 |
"}" |
|
104 |
||
105 |
".QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget {" |
|
106 |
"background-image: url(\":/res/panelbg.png\");" |
|
107 |
"background-position: bottom center;" |
|
108 |
"background-repeat: repeat-x;" |
|
109 |
"border-radius: 16px;" |
|
110 |
"background-color: #040200;" |
|
111 |
"padding: 6px;" |
|
112 |
"}" |
|
113 |
||
114 |
"IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" |
|
115 |
"background-color: #130f2c;" |
|
116 |
"}" |
|
117 |
||
118 |
||
119 |
"QPushButton {" |
|
1157 | 120 |
"border-radius: 10px;" |
1168 | 121 |
"background-origin: margin;" |
122 |
"background-position: top left;" |
|
1167 | 123 |
"background-color: #00351d;" |
1893 | 124 |
"}" |
125 |
||
126 |
"QPushButton:pressed{" |
|
127 |
"border-color: white;" |
|
128 |
"}" |
|
1154 | 129 |
|
1893 | 130 |
"QHeaderView {" |
131 |
"border-radius: 0;" |
|
132 |
"border-width: 0;" |
|
133 |
"border-bottom-width: 3px;" |
|
134 |
"background-color: #00351d;" |
|
135 |
"}" |
|
1894 | 136 |
"QTableView {" |
137 |
"alternate-background-color: #2f213a;" |
|
138 |
"}" |
|
1172 | 139 |
|
1893 | 140 |
"QTabBar::tab {" |
141 |
"border-top: solid;" |
|
142 |
"border-left: solid;" |
|
143 |
"border-right: solid;" |
|
144 |
"border-width: 3px;" |
|
145 |
"border-radius: 0;" |
|
146 |
"border-top-left-radius: 6px;" |
|
147 |
"border-top-right-radius: 6px;" |
|
148 |
"border-color: #ffcc00;" |
|
149 |
"padding: 3px;" |
|
150 |
"}" |
|
151 |
"QTabBar::tab:!selected {" |
|
152 |
"color: #0d0544;" |
|
153 |
"background-color: #ffcc00;" |
|
154 |
"}" |
|
1289 | 155 |
"QSpinBox::up-button{" |
156 |
"background: transparent;" |
|
157 |
"width: 16px;" |
|
158 |
"height: 10px;" |
|
1893 | 159 |
"}" |
160 |
||
161 |
"QSpinBox::up-arrow {" |
|
1289 | 162 |
"image: url(\":/res/spin_up.png\");" |
1893 | 163 |
"}" |
164 |
||
165 |
"QSpinBox::down-arrow {" |
|
166 |
"image: url(\":/res/spin_down.png\");" |
|
167 |
"}" |
|
168 |
||
169 |
"QSpinBox::down-button {" |
|
1289 | 170 |
"background: transparent;" |
171 |
"width: 16px;" |
|
172 |
"height: 10px;" |
|
1172 | 173 |
"}" |
174 |
||
1893 | 175 |
"QComboBox {" |
1161 | 176 |
"border-radius: 15px;" |
1154 | 177 |
"padding: 3px;" |
1893 | 178 |
"}" |
1154 | 179 |
"QComboBox:pressed{" |
180 |
"border-color: white;" |
|
1893 | 181 |
"}" |
1154 | 182 |
"QComboBox::drop-down{" |
183 |
"border: transparent;" |
|
184 |
"width: 25px;" |
|
1893 | 185 |
"}" |
1154 | 186 |
"QComboBox::down-arrow {" |
1155 | 187 |
"image: url(\":/res/dropdown.png\");" |
1893 | 188 |
"}" |
189 |
"QComboBox QAbstractItemView {" |
|
1154 | 190 |
"border: solid transparent;" |
1893 | 191 |
"}" |
1425 | 192 |
|
1893 | 193 |
"VertScrArea {" |
1425 | 194 |
"background-image: url(\":/res/panelbg.png\");" |
195 |
"background-position: bottom center;" |
|
196 |
"background-repeat: repeat-x;" |
|
1893 | 197 |
"}" |
1425 | 198 |
|
1893 | 199 |
"IconedGroupBox {" |
1198 | 200 |
"border-radius: 16px;" |
1228 | 201 |
"padding: 2px;" |
1893 | 202 |
"}" |
203 |
||
1201 | 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::indicator:checked{" |
|
213 |
"image: url(\":/res/checked.png\");" |
|
214 |
"}" |
|
215 |
"QCheckBox::indicator:unchecked{" |
|
216 |
"image: url(\":/res/unchecked.png\");" |
|
217 |
"}" |
|
1172 | 218 |
|
1252 | 219 |
".QWidget{" |
220 |
"background: transparent;" |
|
221 |
"}" |
|
1893 | 222 |
|
223 |
"QTabWidget::pane {" |
|
224 |
"border-top-width: 2px;" |
|
225 |
"}" |
|
1413 | 226 |
|
227 |
"QMenu{" |
|
228 |
"background-color: #ffcc00;" |
|
229 |
"margin: 3px;" |
|
1893 | 230 |
"}" |
231 |
"QMenu::item {" |
|
1413 | 232 |
"background-color: #0d0544;" |
233 |
"border: 1px solid transparent;" |
|
234 |
"font: bold;" |
|
235 |
"padding: 2px 25px 2px 20px;" |
|
1893 | 236 |
"}" |
237 |
"QMenu::item:selected {" |
|
1413 | 238 |
"background-color: #2d2564;" |
1893 | 239 |
"}" |
240 |
"QMenu::indicator {" |
|
1413 | 241 |
"width: 16px;" |
242 |
"height: 16px;" |
|
1893 | 243 |
"}" |
1413 | 244 |
"QMenu::indicator:non-exclusive:checked{" |
245 |
"image: url(\":/res/checked.png\");" |
|
1893 | 246 |
"}" |
1413 | 247 |
"QMenu::indicator:non-exclusive:unchecked{" |
248 |
"image: url(\":/res/unchecked.png\");" |
|
1893 | 249 |
"}" |
1450 | 250 |
|
251 |
"QToolTip{" |
|
252 |
"background-color: #0d0544;" |
|
1893 | 253 |
"}" |
1438 | 254 |
|
255 |
":disabled{" |
|
256 |
"color: #a0a0a0;" |
|
1893 | 257 |
"}" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
258 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
259 |
); |
1150 | 260 |
|
579 | 261 |
bindir->cd("bin"); // workaround over NSIS installer |
262 |
||
263 |
cfgdir->setPath(cfgdir->homePath()); |
|
264 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
265 |
{ |
|
266 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
267 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
268 |
} |
|
269 |
cfgdir->cd(".hedgewars"); |
|
270 |
||
271 |
datadir->cd(bindir->absolutePath()); |
|
272 |
datadir->cd(*cDataDir); |
|
273 |
if(!datadir->cd("hedgewars/Data")) { |
|
274 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
275 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
276 |
"Please check your installation"). |
|
277 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
278 |
return 1; |
|
279 |
} |
|
280 |
||
281 |
QTranslator Translator; |
|
282 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
283 |
app.installTranslator(&Translator); |
|
284 |
||
285 |
Themes = new QStringList(); |
|
286 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
287 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
288 |
QTextStream stream(&themesfile); |
|
289 |
QString str; |
|
290 |
while (!stream.atEnd()) |
|
291 |
{ |
|
292 |
Themes->append(stream.readLine()); |
|
293 |
} |
|
294 |
themesfile.close(); |
|
295 |
} else { |
|
296 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
297 |
} |
|
298 |
||
1210 | 299 |
QDir tmpdir; |
300 |
tmpdir.cd(datadir->absolutePath()); |
|
301 |
tmpdir.cd("Maps"); |
|
302 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
|
303 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
|
304 |
||
579 | 305 |
HWForm *Form = new HWForm(); |
306 |
Form->show(); |
|
307 |
return app.exec(); |
|
308 |
} |