author | unc0rr |
Sun, 15 Mar 2009 14:36:14 +0000 | |
changeset 1893 | 85c61bc5e160 |
parent 1577 | e3e37c730dc0 |
child 1894 | ba54441631da |
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 |
"}" |
|
1172 | 136 |
|
1893 | 137 |
"QTabBar::tab {" |
138 |
"border-top: solid;" |
|
139 |
"border-left: solid;" |
|
140 |
"border-right: solid;" |
|
141 |
"border-width: 3px;" |
|
142 |
"border-radius: 0;" |
|
143 |
"border-top-left-radius: 6px;" |
|
144 |
"border-top-right-radius: 6px;" |
|
145 |
"border-color: #ffcc00;" |
|
146 |
"padding: 3px;" |
|
147 |
"}" |
|
148 |
"QTabBar::tab:!selected {" |
|
149 |
"color: #0d0544;" |
|
150 |
"background-color: #ffcc00;" |
|
151 |
"}" |
|
1289 | 152 |
"QSpinBox::up-button{" |
153 |
"background: transparent;" |
|
154 |
"width: 16px;" |
|
155 |
"height: 10px;" |
|
1893 | 156 |
"}" |
157 |
||
158 |
"QSpinBox::up-arrow {" |
|
1289 | 159 |
"image: url(\":/res/spin_up.png\");" |
1893 | 160 |
"}" |
161 |
||
162 |
"QSpinBox::down-arrow {" |
|
163 |
"image: url(\":/res/spin_down.png\");" |
|
164 |
"}" |
|
165 |
||
166 |
"QSpinBox::down-button {" |
|
1289 | 167 |
"background: transparent;" |
168 |
"width: 16px;" |
|
169 |
"height: 10px;" |
|
1172 | 170 |
"}" |
171 |
||
1893 | 172 |
"QComboBox {" |
1161 | 173 |
"border-radius: 15px;" |
1154 | 174 |
"padding: 3px;" |
1893 | 175 |
"}" |
1154 | 176 |
"QComboBox:pressed{" |
177 |
"border-color: white;" |
|
1893 | 178 |
"}" |
1154 | 179 |
"QComboBox::drop-down{" |
180 |
"border: transparent;" |
|
181 |
"width: 25px;" |
|
1893 | 182 |
"}" |
1154 | 183 |
"QComboBox::down-arrow {" |
1155 | 184 |
"image: url(\":/res/dropdown.png\");" |
1893 | 185 |
"}" |
186 |
"QComboBox QAbstractItemView {" |
|
1154 | 187 |
"border: solid transparent;" |
1893 | 188 |
"}" |
1425 | 189 |
|
1893 | 190 |
"VertScrArea {" |
1425 | 191 |
"background-image: url(\":/res/panelbg.png\");" |
192 |
"background-position: bottom center;" |
|
193 |
"background-repeat: repeat-x;" |
|
1893 | 194 |
"}" |
1425 | 195 |
|
1893 | 196 |
"IconedGroupBox {" |
1198 | 197 |
"border-radius: 16px;" |
1228 | 198 |
"padding: 2px;" |
1893 | 199 |
"}" |
200 |
||
1201 | 201 |
".QGroupBox::title{" |
202 |
"subcontrol-origin: margin;" |
|
203 |
"subcontrol-position: top left;" |
|
204 |
//"padding-left: 82px;" |
|
205 |
//"padding-top: 26px;" |
|
206 |
"text-align: left;" |
|
1155 | 207 |
"}" |
208 |
||
209 |
"QCheckBox::indicator:checked{" |
|
210 |
"image: url(\":/res/checked.png\");" |
|
211 |
"}" |
|
212 |
"QCheckBox::indicator:unchecked{" |
|
213 |
"image: url(\":/res/unchecked.png\");" |
|
214 |
"}" |
|
1172 | 215 |
|
1252 | 216 |
".QWidget{" |
217 |
"background: transparent;" |
|
218 |
"}" |
|
1893 | 219 |
|
220 |
"QTabWidget::pane {" |
|
221 |
"border-top-width: 2px;" |
|
222 |
"}" |
|
1413 | 223 |
|
224 |
"QMenu{" |
|
225 |
"background-color: #ffcc00;" |
|
226 |
"margin: 3px;" |
|
1893 | 227 |
"}" |
228 |
"QMenu::item {" |
|
1413 | 229 |
"background-color: #0d0544;" |
230 |
"border: 1px solid transparent;" |
|
231 |
"font: bold;" |
|
232 |
"padding: 2px 25px 2px 20px;" |
|
1893 | 233 |
"}" |
234 |
"QMenu::item:selected {" |
|
1413 | 235 |
"background-color: #2d2564;" |
1893 | 236 |
"}" |
237 |
"QMenu::indicator {" |
|
1413 | 238 |
"width: 16px;" |
239 |
"height: 16px;" |
|
1893 | 240 |
"}" |
1413 | 241 |
"QMenu::indicator:non-exclusive:checked{" |
242 |
"image: url(\":/res/checked.png\");" |
|
1893 | 243 |
"}" |
1413 | 244 |
"QMenu::indicator:non-exclusive:unchecked{" |
245 |
"image: url(\":/res/unchecked.png\");" |
|
1893 | 246 |
"}" |
1450 | 247 |
|
248 |
"QToolTip{" |
|
249 |
"background-color: #0d0544;" |
|
1893 | 250 |
"}" |
1438 | 251 |
|
252 |
":disabled{" |
|
253 |
"color: #a0a0a0;" |
|
1893 | 254 |
"}" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
255 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
256 |
); |
1150 | 257 |
|
579 | 258 |
bindir->cd("bin"); // workaround over NSIS installer |
259 |
||
260 |
cfgdir->setPath(cfgdir->homePath()); |
|
261 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
262 |
{ |
|
263 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
264 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
265 |
} |
|
266 |
cfgdir->cd(".hedgewars"); |
|
267 |
||
268 |
datadir->cd(bindir->absolutePath()); |
|
269 |
datadir->cd(*cDataDir); |
|
270 |
if(!datadir->cd("hedgewars/Data")) { |
|
271 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
272 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
273 |
"Please check your installation"). |
|
274 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
275 |
return 1; |
|
276 |
} |
|
277 |
||
278 |
QTranslator Translator; |
|
279 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
280 |
app.installTranslator(&Translator); |
|
281 |
||
282 |
Themes = new QStringList(); |
|
283 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
284 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
285 |
QTextStream stream(&themesfile); |
|
286 |
QString str; |
|
287 |
while (!stream.atEnd()) |
|
288 |
{ |
|
289 |
Themes->append(stream.readLine()); |
|
290 |
} |
|
291 |
themesfile.close(); |
|
292 |
} else { |
|
293 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
294 |
} |
|
295 |
||
1210 | 296 |
QDir tmpdir; |
297 |
tmpdir.cd(datadir->absolutePath()); |
|
298 |
tmpdir.cd("Maps"); |
|
299 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
|
300 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
|
301 |
||
579 | 302 |
HWForm *Form = new HWForm(); |
303 |
Form->show(); |
|
304 |
return app.exec(); |
|
305 |
} |