author | unc0rr |
Fri, 17 Apr 2009 19:58:21 +0000 | |
changeset 2001 | d909152bdc21 |
parent 1969 | 3b04393b1291 |
child 2034 | decdf48cffd7 |
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 |
|
1897 | 65 |
"* {" |
1893 | 66 |
"color: #ffcc00;" |
67 |
"}" |
|
68 |
||
69 |
"QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, " |
|
70 |
"QComboBox QAbstractItemView, QMenu::item {" |
|
71 |
"background-color: #0d0544;" |
|
72 |
"}" |
|
73 |
||
74 |
"QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, " |
|
75 |
"QTextBrowser, QSpinBox, QToolBox, QComboBox, " |
|
76 |
"QComboBox QAbstractItemView, IconedGroupBox, " |
|
1897 | 77 |
".QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, " |
78 |
"QTabWidget::pane, QTabBar::tab {" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
79 |
"border: solid;" |
1214 | 80 |
"border-width: 3px;" |
1893 | 81 |
"border-color: #ffcc00;" |
82 |
"}" |
|
83 |
||
84 |
"QPushButton:hover, QLineEdit:hover, QListWidget:hover, " |
|
85 |
"QSpinBox:hover, QToolBox:hover, QComboBox:hover {" |
|
86 |
"border-color: yellow;" |
|
87 |
"}" |
|
88 |
||
89 |
"QLineEdit, QListWidget,QTableView, QTextBrowser, " |
|
90 |
"QSpinBox, QToolBox { " |
|
91 |
"border-radius: 12px;" |
|
92 |
"}" |
|
93 |
||
94 |
"QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, " |
|
95 |
"QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, " |
|
96 |
"IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, " |
|
97 |
"SelWeaponWidget, QCheckBox, QRadioButton {" |
|
98 |
"font: bold 14px;" |
|
99 |
"}" |
|
100 |
||
101 |
".QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget {" |
|
102 |
"background-image: url(\":/res/panelbg.png\");" |
|
103 |
"background-position: bottom center;" |
|
104 |
"background-repeat: repeat-x;" |
|
105 |
"border-radius: 16px;" |
|
106 |
"background-color: #040200;" |
|
107 |
"padding: 6px;" |
|
108 |
"}" |
|
109 |
||
110 |
"IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" |
|
111 |
"background-color: #130f2c;" |
|
112 |
"}" |
|
113 |
||
114 |
||
115 |
"QPushButton {" |
|
1157 | 116 |
"border-radius: 10px;" |
1168 | 117 |
"background-origin: margin;" |
118 |
"background-position: top left;" |
|
1167 | 119 |
"background-color: #00351d;" |
1893 | 120 |
"}" |
121 |
||
122 |
"QPushButton:pressed{" |
|
123 |
"border-color: white;" |
|
124 |
"}" |
|
1154 | 125 |
|
1893 | 126 |
"QHeaderView {" |
127 |
"border-radius: 0;" |
|
128 |
"border-width: 0;" |
|
129 |
"border-bottom-width: 3px;" |
|
130 |
"background-color: #00351d;" |
|
131 |
"}" |
|
1894 | 132 |
"QTableView {" |
133 |
"alternate-background-color: #2f213a;" |
|
134 |
"}" |
|
1172 | 135 |
|
1893 | 136 |
"QTabBar::tab {" |
1897 | 137 |
"border-bottom-width: 0;" |
1893 | 138 |
"border-radius: 0;" |
139 |
"border-top-left-radius: 6px;" |
|
140 |
"border-top-right-radius: 6px;" |
|
141 |
"padding: 3px;" |
|
142 |
"}" |
|
143 |
"QTabBar::tab:!selected {" |
|
144 |
"color: #0d0544;" |
|
145 |
"background-color: #ffcc00;" |
|
146 |
"}" |
|
1289 | 147 |
"QSpinBox::up-button{" |
148 |
"background: transparent;" |
|
149 |
"width: 16px;" |
|
150 |
"height: 10px;" |
|
1893 | 151 |
"}" |
152 |
||
153 |
"QSpinBox::up-arrow {" |
|
1289 | 154 |
"image: url(\":/res/spin_up.png\");" |
1893 | 155 |
"}" |
156 |
||
157 |
"QSpinBox::down-arrow {" |
|
158 |
"image: url(\":/res/spin_down.png\");" |
|
159 |
"}" |
|
160 |
||
161 |
"QSpinBox::down-button {" |
|
1289 | 162 |
"background: transparent;" |
163 |
"width: 16px;" |
|
164 |
"height: 10px;" |
|
1172 | 165 |
"}" |
166 |
||
1893 | 167 |
"QComboBox {" |
1161 | 168 |
"border-radius: 15px;" |
1154 | 169 |
"padding: 3px;" |
1893 | 170 |
"}" |
1154 | 171 |
"QComboBox:pressed{" |
172 |
"border-color: white;" |
|
1893 | 173 |
"}" |
1154 | 174 |
"QComboBox::drop-down{" |
175 |
"border: transparent;" |
|
176 |
"width: 25px;" |
|
1893 | 177 |
"}" |
1154 | 178 |
"QComboBox::down-arrow {" |
1155 | 179 |
"image: url(\":/res/dropdown.png\");" |
1893 | 180 |
"}" |
1425 | 181 |
|
1893 | 182 |
"VertScrArea {" |
1425 | 183 |
"background-image: url(\":/res/panelbg.png\");" |
184 |
"background-position: bottom center;" |
|
185 |
"background-repeat: repeat-x;" |
|
1893 | 186 |
"}" |
1425 | 187 |
|
1893 | 188 |
"IconedGroupBox {" |
1198 | 189 |
"border-radius: 16px;" |
1228 | 190 |
"padding: 2px;" |
1893 | 191 |
"}" |
192 |
||
1201 | 193 |
".QGroupBox::title{" |
194 |
"subcontrol-origin: margin;" |
|
195 |
"subcontrol-position: top left;" |
|
196 |
//"padding-left: 82px;" |
|
197 |
//"padding-top: 26px;" |
|
198 |
"text-align: left;" |
|
1155 | 199 |
"}" |
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 |
|
1252 | 208 |
".QWidget{" |
209 |
"background: transparent;" |
|
210 |
"}" |
|
1893 | 211 |
|
212 |
"QTabWidget::pane {" |
|
213 |
"border-top-width: 2px;" |
|
214 |
"}" |
|
1413 | 215 |
|
216 |
"QMenu{" |
|
217 |
"background-color: #ffcc00;" |
|
218 |
"margin: 3px;" |
|
1893 | 219 |
"}" |
220 |
"QMenu::item {" |
|
1413 | 221 |
"background-color: #0d0544;" |
222 |
"border: 1px solid transparent;" |
|
223 |
"font: bold;" |
|
224 |
"padding: 2px 25px 2px 20px;" |
|
1893 | 225 |
"}" |
226 |
"QMenu::item:selected {" |
|
1413 | 227 |
"background-color: #2d2564;" |
1893 | 228 |
"}" |
229 |
"QMenu::indicator {" |
|
1413 | 230 |
"width: 16px;" |
231 |
"height: 16px;" |
|
1893 | 232 |
"}" |
1413 | 233 |
"QMenu::indicator:non-exclusive:checked{" |
234 |
"image: url(\":/res/checked.png\");" |
|
1893 | 235 |
"}" |
1413 | 236 |
"QMenu::indicator:non-exclusive:unchecked{" |
237 |
"image: url(\":/res/unchecked.png\");" |
|
1893 | 238 |
"}" |
1450 | 239 |
|
240 |
"QToolTip{" |
|
241 |
"background-color: #0d0544;" |
|
1893 | 242 |
"}" |
1438 | 243 |
|
244 |
":disabled{" |
|
245 |
"color: #a0a0a0;" |
|
1893 | 246 |
"}" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
247 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
248 |
); |
1150 | 249 |
|
579 | 250 |
bindir->cd("bin"); // workaround over NSIS installer |
251 |
||
252 |
cfgdir->setPath(cfgdir->homePath()); |
|
1965 | 253 |
#ifdef __APPLE__ |
254 |
if (checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars")) |
|
255 |
{ |
|
256 |
checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Demos"); |
|
257 |
checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Saves"); |
|
258 |
} |
|
1969 | 259 |
cfgdir->cd("Library/Application Support/Hedgewars"); |
1965 | 260 |
#else |
579 | 261 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
262 |
{ |
|
263 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
264 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
265 |
} |
|
266 |
cfgdir->cd(".hedgewars"); |
|
1965 | 267 |
#endif |
579 | 268 |
|
269 |
datadir->cd(bindir->absolutePath()); |
|
270 |
datadir->cd(*cDataDir); |
|
271 |
if(!datadir->cd("hedgewars/Data")) { |
|
272 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
273 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
274 |
"Please check your installation"). |
|
275 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
276 |
return 1; |
|
277 |
} |
|
278 |
||
279 |
QTranslator Translator; |
|
280 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
281 |
app.installTranslator(&Translator); |
|
282 |
||
283 |
Themes = new QStringList(); |
|
284 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
285 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
286 |
QTextStream stream(&themesfile); |
|
287 |
QString str; |
|
288 |
while (!stream.atEnd()) |
|
289 |
{ |
|
290 |
Themes->append(stream.readLine()); |
|
291 |
} |
|
292 |
themesfile.close(); |
|
293 |
} else { |
|
294 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
295 |
} |
|
296 |
||
1210 | 297 |
QDir tmpdir; |
298 |
tmpdir.cd(datadir->absolutePath()); |
|
299 |
tmpdir.cd("Maps"); |
|
300 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
|
301 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
|
302 |
||
579 | 303 |
HWForm *Form = new HWForm(); |
304 |
Form->show(); |
|
305 |
return app.exec(); |
|
306 |
} |