author | unc0rr |
Wed, 06 Aug 2008 12:48:45 +0000 | |
changeset 1157 | c2e02c52dcad |
parent 1155 | ffd0a34171f1 |
child 1160 | 216dc01354a2 |
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> |
|
23 |
#include <QFileInfo> |
|
24 |
#include <QDateTime> |
|
25 |
#include <QTextStream> |
|
1146 | 26 |
#include <QDesktopWidget> |
27 |
||
579 | 28 |
#include "hwform.h" |
29 |
#include "hwconsts.h" |
|
30 |
||
31 |
bool checkForDir(const QString & dir) |
|
32 |
{ |
|
33 |
QDir tmpdir; |
|
34 |
if (!tmpdir.exists(dir)) |
|
35 |
if (!tmpdir.mkdir(dir)) |
|
36 |
{ |
|
37 |
QMessageBox::critical(0, |
|
38 |
QObject::tr("Error"), |
|
39 |
QObject::tr("Cannot create directory %1").arg(dir), |
|
40 |
QObject::tr("OK")); |
|
41 |
return false; |
|
42 |
} |
|
43 |
return true; |
|
44 |
} |
|
45 |
||
46 |
int main(int argc, char *argv[]) |
|
47 |
{ |
|
48 |
QApplication app(argc, argv); |
|
49 |
||
50 |
QDateTime now = QDateTime::currentDateTime(); |
|
51 |
QDateTime zero; |
|
52 |
srand(now.secsTo(zero)); |
|
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( |
1154 | 58 |
".HWForm{" |
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 |
|
65 |
"QPushButton{" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
66 |
"border: solid;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
67 |
"border-width: 4px;" |
1157 | 68 |
"border-radius: 10px;" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
69 |
"border-color: orange;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
70 |
"background-origin: content;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
71 |
"}" |
1153 | 72 |
"QPushButton:hover{" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
73 |
"border-color: yellow;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
74 |
"}" |
1153 | 75 |
"QPushButton:pressed{" |
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
76 |
"border-color: white;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
77 |
"}" |
1154 | 78 |
|
79 |
"QComboBox{" |
|
80 |
"border: solid;" |
|
81 |
"border-width: 4px;" |
|
82 |
"border-radius: 16px;" |
|
83 |
"border-color: orange;" |
|
84 |
"background-color: #0d0544;" |
|
85 |
"color: orange;" |
|
86 |
"font: bold 14px;" |
|
87 |
"padding: 3px;" |
|
88 |
// "text-align: center;" |
|
89 |
"}" |
|
90 |
"QComboBox:hover{" |
|
91 |
"border-color: yellow;" |
|
92 |
"}" |
|
93 |
"QComboBox:pressed{" |
|
94 |
"border-color: white;" |
|
95 |
"}" |
|
96 |
"QComboBox::drop-down{" |
|
97 |
"border: transparent;" |
|
98 |
"width: 25px;" |
|
99 |
"}" |
|
100 |
"QComboBox::down-arrow {" |
|
1155 | 101 |
"image: url(\":/res/dropdown.png\");" |
1154 | 102 |
"}" |
103 |
"QComboBox QAbstractItemView{" |
|
104 |
"border: solid transparent;" |
|
105 |
"border-width: 4px;" |
|
1157 | 106 |
//"border-radius: 12px;" -- bad corners look |
1154 | 107 |
"border-color: orange;" |
108 |
"background-color: #0d0544;" |
|
109 |
"color: orange;" |
|
110 |
"font: bold 14px;" |
|
111 |
"}" |
|
1155 | 112 |
|
113 |
"QGroupBox{" |
|
114 |
"border: solid;" |
|
115 |
"border-width: 4px;" |
|
116 |
"border-radius: 16px;" |
|
117 |
"border-color: orange;" |
|
1157 | 118 |
"background-color: #130f2c;" |
1155 | 119 |
"color: orange;" |
120 |
"font: bold 14px;" |
|
121 |
"padding: 3px;" |
|
1157 | 122 |
"margin-top: 60px;" |
123 |
"margin-left: 16px;" |
|
124 |
// "padding-top: 6px;" |
|
1155 | 125 |
"}" |
1157 | 126 |
"QGroupBox::indicator{" |
127 |
"image: url(\":/res/graphicsicon.png\");" |
|
1155 | 128 |
"}" |
1157 | 129 |
"QGroupBox::title{" |
130 |
"subcontrol-origin: margin;" |
|
131 |
"subcontrol-position: top left;" |
|
132 |
"text-align: center;" |
|
1155 | 133 |
"}" |
134 |
||
135 |
"QCheckBox{" |
|
136 |
"color: orange;" |
|
137 |
"font: bold 14px;" |
|
138 |
"}" |
|
139 |
"QCheckBox::indicator:checked{" |
|
140 |
"image: url(\":/res/checked.png\");" |
|
141 |
"}" |
|
142 |
"QCheckBox::indicator:unchecked{" |
|
143 |
"image: url(\":/res/unchecked.png\");" |
|
144 |
"}" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
145 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
146 |
); |
1150 | 147 |
|
579 | 148 |
bindir->cd("bin"); // workaround over NSIS installer |
149 |
||
150 |
cfgdir->setPath(cfgdir->homePath()); |
|
151 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
152 |
{ |
|
153 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
154 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
155 |
} |
|
156 |
cfgdir->cd(".hedgewars"); |
|
157 |
||
158 |
datadir->cd(bindir->absolutePath()); |
|
159 |
datadir->cd(*cDataDir); |
|
160 |
if(!datadir->cd("hedgewars/Data")) { |
|
161 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
162 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
163 |
"Please check your installation"). |
|
164 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
165 |
return 1; |
|
166 |
} |
|
167 |
||
168 |
QTranslator Translator; |
|
169 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
170 |
app.installTranslator(&Translator); |
|
171 |
||
172 |
Themes = new QStringList(); |
|
173 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
174 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
175 |
QTextStream stream(&themesfile); |
|
176 |
QString str; |
|
177 |
while (!stream.atEnd()) |
|
178 |
{ |
|
179 |
Themes->append(stream.readLine()); |
|
180 |
} |
|
181 |
themesfile.close(); |
|
182 |
} else { |
|
183 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
184 |
} |
|
185 |
||
186 |
HWForm *Form = new HWForm(); |
|
187 |
Form->show(); |
|
188 |
return app.exec(); |
|
189 |
} |