author | unc0rr |
Sun, 22 Mar 2009 14:35:45 +0000 | |
changeset 1907 | a104432e8301 |
parent 1897 | e9dcb47013c7 |
child 1940 | bbdca883b5f9 |
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 |
"}" |
181 |
"QComboBox QAbstractItemView {" |
|
1154 | 182 |
"border: solid transparent;" |
1893 | 183 |
"}" |
1425 | 184 |
|
1893 | 185 |
"VertScrArea {" |
1425 | 186 |
"background-image: url(\":/res/panelbg.png\");" |
187 |
"background-position: bottom center;" |
|
188 |
"background-repeat: repeat-x;" |
|
1893 | 189 |
"}" |
1425 | 190 |
|
1893 | 191 |
"IconedGroupBox {" |
1198 | 192 |
"border-radius: 16px;" |
1228 | 193 |
"padding: 2px;" |
1893 | 194 |
"}" |
195 |
||
1201 | 196 |
".QGroupBox::title{" |
197 |
"subcontrol-origin: margin;" |
|
198 |
"subcontrol-position: top left;" |
|
199 |
//"padding-left: 82px;" |
|
200 |
//"padding-top: 26px;" |
|
201 |
"text-align: left;" |
|
1155 | 202 |
"}" |
203 |
||
204 |
"QCheckBox::indicator:checked{" |
|
205 |
"image: url(\":/res/checked.png\");" |
|
206 |
"}" |
|
207 |
"QCheckBox::indicator:unchecked{" |
|
208 |
"image: url(\":/res/unchecked.png\");" |
|
209 |
"}" |
|
1172 | 210 |
|
1252 | 211 |
".QWidget{" |
212 |
"background: transparent;" |
|
213 |
"}" |
|
1893 | 214 |
|
215 |
"QTabWidget::pane {" |
|
216 |
"border-top-width: 2px;" |
|
217 |
"}" |
|
1413 | 218 |
|
219 |
"QMenu{" |
|
220 |
"background-color: #ffcc00;" |
|
221 |
"margin: 3px;" |
|
1893 | 222 |
"}" |
223 |
"QMenu::item {" |
|
1413 | 224 |
"background-color: #0d0544;" |
225 |
"border: 1px solid transparent;" |
|
226 |
"font: bold;" |
|
227 |
"padding: 2px 25px 2px 20px;" |
|
1893 | 228 |
"}" |
229 |
"QMenu::item:selected {" |
|
1413 | 230 |
"background-color: #2d2564;" |
1893 | 231 |
"}" |
232 |
"QMenu::indicator {" |
|
1413 | 233 |
"width: 16px;" |
234 |
"height: 16px;" |
|
1893 | 235 |
"}" |
1413 | 236 |
"QMenu::indicator:non-exclusive:checked{" |
237 |
"image: url(\":/res/checked.png\");" |
|
1893 | 238 |
"}" |
1413 | 239 |
"QMenu::indicator:non-exclusive:unchecked{" |
240 |
"image: url(\":/res/unchecked.png\");" |
|
1893 | 241 |
"}" |
1450 | 242 |
|
243 |
"QToolTip{" |
|
244 |
"background-color: #0d0544;" |
|
1893 | 245 |
"}" |
1438 | 246 |
|
247 |
":disabled{" |
|
248 |
"color: #a0a0a0;" |
|
1893 | 249 |
"}" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
250 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
251 |
); |
1150 | 252 |
|
579 | 253 |
bindir->cd("bin"); // workaround over NSIS installer |
254 |
||
255 |
cfgdir->setPath(cfgdir->homePath()); |
|
256 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
257 |
{ |
|
258 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
259 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
260 |
} |
|
261 |
cfgdir->cd(".hedgewars"); |
|
262 |
||
263 |
datadir->cd(bindir->absolutePath()); |
|
264 |
datadir->cd(*cDataDir); |
|
265 |
if(!datadir->cd("hedgewars/Data")) { |
|
266 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
267 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
268 |
"Please check your installation"). |
|
269 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
270 |
return 1; |
|
271 |
} |
|
272 |
||
273 |
QTranslator Translator; |
|
274 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
275 |
app.installTranslator(&Translator); |
|
276 |
||
277 |
Themes = new QStringList(); |
|
278 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
279 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
280 |
QTextStream stream(&themesfile); |
|
281 |
QString str; |
|
282 |
while (!stream.atEnd()) |
|
283 |
{ |
|
284 |
Themes->append(stream.readLine()); |
|
285 |
} |
|
286 |
themesfile.close(); |
|
287 |
} else { |
|
288 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
289 |
} |
|
290 |
||
1210 | 291 |
QDir tmpdir; |
292 |
tmpdir.cd(datadir->absolutePath()); |
|
293 |
tmpdir.cd("Maps"); |
|
294 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
|
295 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
|
296 |
||
579 | 297 |
HWForm *Form = new HWForm(); |
298 |
Form->show(); |
|
299 |
return app.exec(); |
|
300 |
} |