author | unc0rr |
Tue, 05 Aug 2008 21:12:26 +0000 | |
changeset 1153 | 825931b81ad4 |
parent 1152 | c72b939c00df |
child 1154 | 03cc0ab9c013 |
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( |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
58 |
".HWForm{" |
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 |
"}" |
1153 | 64 |
// "PageMain > QPushButton{" |
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;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
68 |
"border-radius: 8px;" |
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 |
// "PageMain > QPushButton:hover{" |
73 |
"QPushButton:hover{" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
74 |
"border-color: yellow;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
75 |
"}" |
1153 | 76 |
// "PageMain > QPushButton:pressed{" |
77 |
"QPushButton:pressed{" |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
78 |
"border-color: white;" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
79 |
"}" |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
80 |
) |
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1150
diff
changeset
|
81 |
); |
1150 | 82 |
|
579 | 83 |
bindir->cd("bin"); // workaround over NSIS installer |
84 |
||
85 |
cfgdir->setPath(cfgdir->homePath()); |
|
86 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
|
87 |
{ |
|
88 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
|
89 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); |
|
90 |
} |
|
91 |
cfgdir->cd(".hedgewars"); |
|
92 |
||
93 |
datadir->cd(bindir->absolutePath()); |
|
94 |
datadir->cd(*cDataDir); |
|
95 |
if(!datadir->cd("hedgewars/Data")) { |
|
96 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
|
97 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
|
98 |
"Please check your installation"). |
|
99 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
|
100 |
return 1; |
|
101 |
} |
|
102 |
||
103 |
QTranslator Translator; |
|
104 |
Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); |
|
105 |
app.installTranslator(&Translator); |
|
106 |
||
107 |
Themes = new QStringList(); |
|
108 |
QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); |
|
109 |
if (themesfile.open(QIODevice::ReadOnly)) { |
|
110 |
QTextStream stream(&themesfile); |
|
111 |
QString str; |
|
112 |
while (!stream.atEnd()) |
|
113 |
{ |
|
114 |
Themes->append(stream.readLine()); |
|
115 |
} |
|
116 |
themesfile.close(); |
|
117 |
} else { |
|
118 |
QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); |
|
119 |
} |
|
120 |
||
121 |
HWForm *Form = new HWForm(); |
|
122 |
Form->show(); |
|
123 |
return app.exec(); |
|
124 |
} |