main.cpp 2.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
/***************************************************************************
 *   Copyright (C) 2006 by Matthew Williams    <matt@milliams.com>         *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

10
11
12

#include <KAboutData>

13
#include <KUser>
14
15
16
17
18
#include <QApplication>
#include <KLocalizedString>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <kdelibs4configmigrator.h>
Laurent Montel's avatar
Laurent Montel committed
19
#include <KDBusService>
20

21
22
#include "ksquareswindow.h"
#include "ksquaresdemowindow.h"
23
#include "settings.h"
24

25
static const char description[] =
26
	I18N_NOOP("Take it in turns to draw lines.\nIf you complete a squares, you get another go.");
27

Tom Vincent Peters's avatar
Tom Vincent Peters committed
28
static const char version[] = "0.5";
29
30
31

int main(int argc, char **argv)
{
Laurent Montel's avatar
Laurent Montel committed
32
33
    QApplication app(argc, argv);

34
35
36
37
38
39
40
    Kdelibs4ConfigMigrator migrate(QLatin1String("ksquares"));
    migrate.setConfigFiles(QStringList() << QLatin1String("ksquaresrc"));
    migrate.setUiFiles(QStringList() << QLatin1String("ksquaresui.rc"));
    migrate.migrate();

	KAboutData about("ksquares", i18n("KSquares"), version, i18n(description),
		KAboutLicense::GPL, i18n("(C) 2006-2007 Matt Williams"), 
41
		"http://games.kde.org/ksquares");
42
43
44
	about.addAuthor( i18n("Matt Williams"), i18n("Original creator and maintainer"), "matt@milliams.com", "http://milliams.com" );
	about.addCredit(i18n("Fela Winkelmolen"), i18n("Many patches and bugfixes"));
	about.addCredit(i18n("Tom Vincent Peters"), i18n("Hard AI"));
45
	
46
47
48
49
50
    QCommandLineParser parser;
    KAboutData::setApplicationData(about);
    parser.addVersionOption();
    parser.addHelpOption();
        parser.addOption(QCommandLineOption(QStringList() <<  QLatin1String("demo"), i18n("Run game in demo (autoplay) mode")));
51

52
53
54
55
    //PORTING SCRIPT: adapt aboutdata variable if necessary
    about.setupCommandLine(&parser);
    parser.process(app);
    about.processCommandLine(&parser);
Laurent Montel's avatar
Laurent Montel committed
56
    KDBusService service;
57
	
58
	// default names for players
Laurent Montel's avatar
Laurent Montel committed
59
	KConfigGroup cg(KSharedConfig::openConfig(), "General");
60
61
	if (cg.readEntry<bool>("initializeNames", true)) {
		QStringList playerNames;
62
		playerNames << KUser().property(KUser::FullName).toString();
Andrius Štikonas's avatar
Andrius Štikonas committed
63
64
65
		playerNames << i18nc("default name of player", "Player %1", 2);
		playerNames << i18nc("default name of player", "Player %1", 3);
		playerNames << i18nc("default name of player", "Player %1", 4);
66
67
68
69
		Settings::setPlayerNames(playerNames);
		cg.writeEntry("initializeNames", false);
	}
	
70
	if (parser.isSet("demo"))
71
72
73
74
75
76
77
78
79
80
	{
		KSquaresDemoWindow *demoWindow = new KSquaresDemoWindow;
		demoWindow->show();
		demoWindow->gameNew();
	}
	else
	{
		KSquaresWindow *mainWindow = new KSquaresWindow;
		mainWindow->show();
	}
81
	
82
	
83
	return app.exec();
84
}