• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

ksquares

  • sources
  • kde-4.14
  • kdegames
  • ksquares
  • src
main.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006 by Matthew Williams <matt@milliams.com> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  ***************************************************************************/
9 
10 #include <KApplication>
11 #include <KAboutData>
12 #include <KCmdLineArgs>
13 #include <KLocale>
14 #include <KUser>
15 
16 #include <KDebug>
17 
18 #include "ksquareswindow.h"
19 #include "ksquaresdemowindow.h"
20 #include "settings.h"
21 
22 static const char description[] =
23  I18N_NOOP("Take it in turns to draw lines.\nIf you complete a squares, you get another go.");
24 
25 static const char version[] = "0.5";
26 
27 int main(int argc, char **argv)
28 {
29  KAboutData about("ksquares", 0, ki18n("KSquares"), version, ki18n(description),
30  KAboutData::License_GPL, ki18n("(C) 2006-2007 Matt Williams"), KLocalizedString(),
31  "http://games.kde.org/ksquares");
32  about.addAuthor( ki18n("Matt Williams"), ki18n("Original creator and maintainer"), "matt@milliams.com", "http://milliams.com" );
33  about.addCredit(ki18n("Fela Winkelmolen"), ki18n("Many patches and bugfixes"));
34  about.addCredit(ki18n("Tom Vincent Peters"), ki18n("Hard AI"));
35 
36  KCmdLineArgs::init(argc, argv, &about);
37 
38  KCmdLineOptions options;
39  options.add("demo", ki18n("Run game in demo (autoplay) mode"));
40  KCmdLineArgs::addCmdLineOptions( options );
41  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
42 
43  KApplication app;
44  KGlobal::locale()->insertCatalog( QLatin1String( "libkdegames" ));
45 
46  // default names for players
47  KConfigGroup cg(KGlobal::config(), "General");
48  if (cg.readEntry<bool>("initializeNames", true)) {
49  QStringList playerNames;
50  playerNames << KUser().property(KUser::FullName).toString();
51  playerNames << i18nc("default name of player", "Player %1", 2);
52  playerNames << i18nc("default name of player", "Player %1", 3);
53  playerNames << i18nc("default name of player", "Player %1", 4);
54  Settings::setPlayerNames(playerNames);
55  cg.writeEntry("initializeNames", false);
56  }
57 
58  if (args->isSet("demo"))
59  {
60  KSquaresDemoWindow *demoWindow = new KSquaresDemoWindow;
61  demoWindow->show();
62  demoWindow->gameNew();
63  }
64  else
65  {
66  KSquaresWindow *mainWindow = new KSquaresWindow;
67  mainWindow->show();
68  }
69  args->clear();
70 
71  return app.exec();
72 }
main
int main(int argc, char **argv)
Definition: main.cpp:27
KSquaresDemoWindow
Mainwindow class for demonstration mode.
Definition: ksquaresdemowindow.h:28
Settings::setPlayerNames
static void setPlayerNames(const QStringList &v)
Set Player Names.
Definition: settings.h:39
KSquaresDemoWindow::gameNew
void gameNew()
Definition: ksquaresdemowindow.cpp:46
ksquareswindow.h
ksquaresdemowindow.h
QStringList
settings.h
QLatin1String
KSquaresWindow
Mainwindow class.
Definition: ksquareswindow.h:31
description
static const char description[]
Definition: main.cpp:22
version
static const char version[]
Definition: main.cpp:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ksquares

Skip menu "ksquares"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal