author | unc0rr |
Thu, 05 Oct 2006 16:33:18 +0000 | |
changeset 183 | 57c2ef19f719 |
parent 173 | 004493dd60e4 |
child 184 | f97a7a3dc8f6 |
permissions | -rw-r--r-- |
21 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
128 | 3 |
* Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
21 | 4 |
* |
183 | 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 |
|
21 | 8 |
* |
183 | 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. |
|
21 | 13 |
* |
183 | 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 |
|
21 | 17 |
*/ |
18 |
||
19 |
#include <QApplication> |
|
52
ae2950c5465c
- Rename frontend to hedgewars and compile it to engine directory
unc0rr
parents:
21
diff
changeset
|
20 |
#include <QTranslator> |
ae2950c5465c
- Rename frontend to hedgewars and compile it to engine directory
unc0rr
parents:
21
diff
changeset
|
21 |
#include <QLocale> |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
22 |
#include <QMessageBox> |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
23 |
#include <QFileInfo> |
127 | 24 |
#include <QDateTime> |
21 | 25 |
#include "hwform.h" |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
26 |
#include "hwconsts.h" |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
27 |
|
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
28 |
QDir * bindir; |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
29 |
QDir * cfgdir; |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
30 |
QDir * datadir; |
21 | 31 |
|
148 | 32 |
bool checkForDir(const QString & dir) |
33 |
{ |
|
34 |
QDir tmpdir; |
|
35 |
if (!tmpdir.exists(dir)) |
|
36 |
if (!tmpdir.mkdir(dir)) |
|
37 |
{ |
|
38 |
QMessageBox::critical(0, |
|
39 |
QObject::tr("Error"), |
|
40 |
QObject::tr("Cannot create directory %1").arg(dir), |
|
41 |
QObject::tr("OK")); |
|
42 |
return false; |
|
43 |
} |
|
44 |
return true; |
|
45 |
} |
|
46 |
||
21 | 47 |
int main(int argc, char *argv[]) |
48 |
{ |
|
49 |
QApplication app(argc, argv); |
|
52
ae2950c5465c
- Rename frontend to hedgewars and compile it to engine directory
unc0rr
parents:
21
diff
changeset
|
50 |
|
127 | 51 |
QDateTime now = QDateTime::currentDateTime(); |
52 |
QDateTime zero; |
|
53 |
srand(now.secsTo(zero)); |
|
54 |
||
109 | 55 |
Q_INIT_RESOURCE(hedgewars); |
56 |
||
57 |
QTranslator Translator; |
|
58 |
Translator.load(":/translations/hedgewars_" + QLocale::system().name()); |
|
59 |
app.installTranslator(&Translator); |
|
60 |
||
173 | 61 |
QDir mydir("."); |
123 | 62 |
mydir.cd("bin"); |
127 | 63 |
|
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
64 |
bindir = new QDir(mydir); |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
65 |
cfgdir = new QDir(); |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
66 |
|
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
67 |
cfgdir->setPath(cfgdir->homePath()); |
148 | 68 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
69 |
{ |
148 | 70 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
71 |
} |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
72 |
cfgdir->cd(".hedgewars"); |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
73 |
|
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
74 |
datadir = new QDir(mydir); |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
75 |
datadir->cd("../share/hedgewars/Data"); |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
76 |
|
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
52
diff
changeset
|
77 |
HWForm *Form = new HWForm(); |
21 | 78 |
Form->show(); |
79 |
return app.exec(); |
|
80 |
} |