author | unc0rr |
Sat, 11 Apr 2009 10:40:41 +0000 | |
changeset 1954 | 038c18bc58a1 |
parent 1940 | bbdca883b5f9 |
child 1965 | 340bfd438ca5 |
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()); |
|
253 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
254 |
{ |
|
255 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
256 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
257 |
} |
|
258 |
cfgdir->cd(".hedgewars"); |
|
259 |
||
260 |
datadir->cd(bindir->absolutePath()); |
|
261 |
datadir->cd(*cDataDir); |
|
262 |
if(!datadir->cd("hedgewars/Data")) { |
|
263 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
264 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
265 |
"Please check your installation"). |
|
266 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
267 |
return 1; |
|
268 |
} |
|
269 |
||
270 |
QTranslator Translator; |
|
271 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
272 |
app.installTranslator(&Translator); |
|
273 |
||
274 |
Themes = new QStringList(); |
|
275 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
276 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
277 |
QTextStream stream(&themesfile); |
|
278 |
QString str; |
|
279 |
while (!stream.atEnd()) |
|
280 |
{ |
|
281 |
Themes->append(stream.readLine()); |
|
282 |
} |
|
283 |
themesfile.close(); |
|
284 |
} else { |
|
285 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
286 |
} |
|
287 |
||
1210 | 288 |
QDir tmpdir; |
289 |
tmpdir.cd(datadir->absolutePath()); |
|
290 |
tmpdir.cd("Maps"); |
|
291 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
|
292 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
|
293 |
||
579 | 294 |
HWForm *Form = new HWForm(); |
295 |
Form->show(); |
|
296 |
return app.exec(); |
|
297 |
} |