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 |
|
|
74 |
datadir = new QDir(mydir);
|
|
75 |
datadir->cd("../share/hedgewars/Data");
|
|
76 |
|
|
77 |
HWForm *Form = new HWForm();
|
|
78 |
Form->show();
|
|
79 |
return app.exec();
|
|
80 |
}
|