File indexing completed on 2024-05-12 04:04:33
0001 /* 0002 Copyright (C) 2002-2005, Jason Katz-Brown <jasonkb@mit.edu> 0003 0004 This program is free software; you can redistribute it and/or modify 0005 it under the terms of the GNU General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or 0007 (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 GNU General Public License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program; if not, write to the Free Software 0016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0017 */ 0018 0019 #include "kolf.h" 0020 #include "kolf_version.h" 0021 0022 #include <iostream> 0023 0024 #include <QApplication> 0025 #include <QCommandLineOption> 0026 #include <QCommandLineParser> 0027 #include <QDebug> 0028 #include <QFile> 0029 #include <QUrl> 0030 0031 #include <KAboutData> 0032 #include <KCrash> 0033 #include <KDBusService> 0034 #include <KLocalizedString> 0035 0036 using namespace std; 0037 0038 int main(int argc, char **argv) 0039 { 0040 QApplication app(argc, argv); 0041 0042 KLocalizedString::setApplicationDomain(QByteArrayLiteral("kolf")); 0043 0044 KAboutData aboutData( QStringLiteral("kolf"), 0045 i18n("Kolf"), 0046 QStringLiteral(KOLF_VERSION_STRING), 0047 i18n("KDE Minigolf Game"), 0048 KAboutLicense::GPL, 0049 i18n("(c) 2002-2010, Kolf developers"), 0050 QString(), 0051 QStringLiteral("https://apps.kde.org/kolf")); 0052 0053 aboutData.addAuthor(i18n("Stefan Majewsky"), i18n("Current maintainer"), QStringLiteral("majewsky@gmx.net")); 0054 aboutData.addAuthor(i18n("Jason Katz-Brown"), i18n("Former main author"), QStringLiteral("jasonkb@mit.edu")); 0055 aboutData.addAuthor(i18n("Niklas Knutsson"), i18n("Advanced putting mode")); 0056 aboutData.addAuthor(i18n("Rik Hemsley"), i18n("Border around course")); 0057 aboutData.addAuthor(i18n("Timo A. Hummel"), i18n("Some good sound effects"), QStringLiteral("timo.hummel@gmx.net")); 0058 0059 aboutData.addCredit(i18n("Rob Renaud"), i18n("Wall-bouncing help")); 0060 aboutData.addCredit(i18n("Aaron Seigo"), i18n("Suggestions, bug reports")); 0061 aboutData.addCredit(i18n("Erin Catto"), i18n("Developer of Box2D physics engine")); 0062 aboutData.addCredit(i18n("Ryan Cumming"), i18n("Vector class (Kolf 1)")); 0063 aboutData.addCredit(i18n("Daniel Matza-Brown"), i18n("Working wall-bouncing algorithm (Kolf 1)")); 0064 0065 KAboutData::setApplicationData(aboutData); 0066 QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("kolf"))); 0067 0068 KCrash::initialize(); 0069 0070 QCommandLineParser parser; 0071 parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("+file"), i18n("File"))); 0072 parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("course-info"), i18n("Print course information and exit"))); 0073 0074 aboutData.setupCommandLine(&parser); 0075 parser.process(app); 0076 aboutData.processCommandLine(&parser); 0077 0078 KDBusService service; 0079 0080 // I've actually added this for my web site uploaded courses display 0081 if (parser.isSet(QStringLiteral("course-info"))) 0082 { 0083 QString filename(parser.value(QStringLiteral("course-info"))); 0084 if (QFile::exists(filename)) 0085 { 0086 CourseInfo info; 0087 KolfGame::courseInfo(info, filename); 0088 0089 cout << info.name.toLatin1().constData() 0090 << " - " << i18n("By %1", info.author).toLatin1().constData() 0091 << " - " << i18n("%1 holes", info.holes).toLatin1().constData() 0092 << " - " << i18n("par %1", info.par).toLatin1().constData() 0093 << endl; 0094 0095 return 0; 0096 } 0097 else 0098 { 0099 qCritical() << i18n("Course %1 does not exist.", filename); 0100 } 0101 } 0102 0103 KolfWindow *top = new KolfWindow; 0104 0105 if (parser.positionalArguments().count() >= 1) 0106 { 0107 QUrl url = QUrl::fromUserInput(parser.positionalArguments().at(parser.positionalArguments().count() - 1)); 0108 top->openUrl(url); 0109 0110 } 0111 else 0112 top->closeGame(); 0113 0114 top->show(); 0115 0116 return app.exec(); 0117 } 0118