author | displacer |
Sat, 25 Nov 2006 11:56:37 +0000 | |
changeset 274 | 94bd2577ebbb |
parent 261 | 21b03fe1cc28 |
permissions | -rw-r--r-- |
119 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
146 | 3 |
* Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
119 | 4 |
* |
187 | 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 |
|
119 | 8 |
* |
187 | 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. |
|
119 | 13 |
* |
187 | 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 |
|
119 | 17 |
*/ |
18 |
||
19 |
#include <QApplication> |
|
20 |
#include <QTranslator> |
|
21 |
#include <QLocale> |
|
22 |
#include <QMessageBox> |
|
23 |
#include <QFileInfo> |
|
146 | 24 |
#include <QDateTime> |
119 | 25 |
#include "hwform.h" |
26 |
#include "hwconsts.h" |
|
27 |
||
28 |
QDir * bindir; |
|
29 |
QDir * cfgdir; |
|
30 |
QDir * datadir; |
|
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 |
||
119 | 47 |
int main(int argc, char *argv[]) |
48 |
{ |
|
49 |
QApplication app(argc, argv); |
|
50 |
||
146 | 51 |
QDateTime now = QDateTime::currentDateTime(); |
52 |
QDateTime zero; |
|
53 |
srand(now.secsTo(zero)); |
|
54 |
||
119 | 55 |
Q_INIT_RESOURCE(hedgewars); |
56 |
||
57 |
QTranslator Translator; |
|
58 |
Translator.load(":/translations/hedgewars_" + QLocale::system().name()); |
|
59 |
app.installTranslator(&Translator); |
|
60 |
||
61 |
QDir mydir("${HEDGEWARS_BINDIR}"); |
|
123 | 62 |
mydir.cd("bin"); |
148 | 63 |
|
119 | 64 |
bindir = new QDir(mydir); |
65 |
cfgdir = new QDir(); |
|
66 |
||
67 |
cfgdir->setPath(cfgdir->homePath()); |
|
148 | 68 |
if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) |
119 | 69 |
{ |
148 | 70 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); |
119 | 71 |
} |
72 |
cfgdir->cd(".hedgewars"); |
|
73 |
||
261 | 74 |
datadir = new QDir("${HEDGEWARS_DATADIR}"); |
274
94bd2577ebbb
data dir initial check (test for wrong installation)
displacer
parents:
261
diff
changeset
|
75 |
if(!datadir->cd("hedgewars/Data")) { |
94bd2577ebbb
data dir initial check (test for wrong installation)
displacer
parents:
261
diff
changeset
|
76 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
94bd2577ebbb
data dir initial check (test for wrong installation)
displacer
parents:
261
diff
changeset
|
77 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
94bd2577ebbb
data dir initial check (test for wrong installation)
displacer
parents:
261
diff
changeset
|
78 |
"Please check your installation"). |
94bd2577ebbb
data dir initial check (test for wrong installation)
displacer
parents:
261
diff
changeset
|
79 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
94bd2577ebbb
data dir initial check (test for wrong installation)
displacer
parents:
261
diff
changeset
|
80 |
return 1; |
94bd2577ebbb
data dir initial check (test for wrong installation)
displacer
parents:
261
diff
changeset
|
81 |
} |
119 | 82 |
|
83 |
HWForm *Form = new HWForm(); |
|
84 |
Form->show(); |
|
85 |
return app.exec(); |
|
86 |
} |