Commit 421259a8 authored by Parker Coates's avatar Parker Coates
Browse files

Initial (half-assed) implementation of a game type details dialog,

Feedback welcome.

svn path=/trunk/KDE/kdegames/killbots/; revision=912715
parent 4ce6b557
......@@ -14,6 +14,7 @@ set( killbots_SRCS
optionspage.cpp
render.cpp
ruleset.cpp
rulesetdetailsdialog.cpp
rulesetselector.cpp
scene.cpp
sprite.cpp
......
/*
* Killbots
* Copyright (C) 2006-2008 Parker Coates <parker.coates@gmail.com>
* Copyright (C) 2006-2009 Parker Coates <parker.coates@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -94,158 +94,6 @@ Killbots::MainWindow::~MainWindow()
}
void Killbots::MainWindow::setupActions()
{
KStandardGameAction::gameNew( m_engine, SLOT(requestNewGame()), actionCollection() );
KStandardGameAction::highscores( this, SLOT(showHighscores()), actionCollection() );
KStandardGameAction::quit( kapp, SLOT(quit()), actionCollection() );
KStandardAction::keyBindings( this, SLOT(configureShortcuts()), actionCollection() );
KStandardAction::preferences( this, SLOT(configurePreferences()), actionCollection() );
createMappedAction( actionCollection(),
TeleportSafely,
"teleport_safely",
i18n("Teleport Safely"),
i18nc("Shortcut for teleport safely. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "T"),
Qt::Key_Plus,
i18n("Teleport to a safe location"),
"games-solve"
);
createMappedAction( actionCollection(),
Teleport,
"teleport",
i18n("Teleport"),
i18nc("Shortcut for teleport. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "R"),
Qt::Key_Minus,
i18n("Teleport to a random location"),
"roll"
);
createMappedAction( actionCollection(),
TeleportSafelyIfPossible,
"teleport_sip",
i18n("Teleport, Safely If Possible"),
i18nc("Shortcut for teleport safely if possible. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "Space"),
Qt::Key_0,
i18n("Teleport safely if that action is enabled, otherwise teleport randomly")
);
createMappedAction( actionCollection(),
SonicScrewdriver,
"screwdriver",
i18n("Sonic Screwdriver"),
i18nc("Shortcut for sonicscrewdriver. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "F"),
Qt::Key_Period,
i18n("Destroy all enemies in neighboring cells"),
"edit-bomb"
);
createMappedAction( actionCollection(),
WaitOutRound,
"wait_out_round",
i18n("Wait Out Round"),
i18nc("Shortcut for wait out round. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "V"),
Qt::Key_Asterisk,
i18n("Risk remaining in place until the end of the round for bonuses"),
"process-stop"
);
// Keyboard Actions - these are shown in Configure Shortcuts but not in Configure Toolbars
createMappedAction( m_keyboardActions,
UpLeft,
"move_up_left",
i18n("Move Up and Left"),
i18nc("Shortcut for move up and left. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "Q"),
Qt::Key_7
);
createMappedAction( m_keyboardActions,
Up,
"move_up",
i18n("Move Up"),
i18nc("Shortcut for move up. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "W"),
Qt::Key_8
);
createMappedAction( m_keyboardActions,
UpRight,
"move_up_right",
i18n("Move Up and Right"),
i18nc("Shortcut for move up and right. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "E"),
Qt::Key_9
);
createMappedAction( m_keyboardActions,
Left,
"move_left",
i18n("Move Left"),
i18nc("Shortcut for move left. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "A"),
Qt::Key_4
);
createMappedAction( m_keyboardActions,
Hold,
"stand_still",
i18n("Stand Still"),
i18nc("Shortcut for stand still. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "S"),
Qt::Key_5
);
createMappedAction( m_keyboardActions,
Right,
"move_right",
i18n("Move Right"),
i18nc("Shortcut for move right. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "D"),
Qt::Key_6
);
createMappedAction( m_keyboardActions,
DownLeft,
"move_down_left",
i18n("Move Down and Left"),
i18nc("Shortcut for move down and left. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "Z"),
Qt::Key_1
);
createMappedAction( m_keyboardActions,
Down,
"move_down",
i18n("Move Down"),
i18nc("Shortcut for move down. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "X"),
Qt::Key_2
);
createMappedAction( m_keyboardActions,
DownRight,
"move_down_right",
i18n("Move Down and Right"),
i18nc("Shortcut for move down and right. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "C"),
Qt::Key_3
);
connect( m_keyboardMapper, SIGNAL(mapped(int)), m_engine, SLOT(requestAction(int)) );
m_keyboardActions->associateWidget(this);
}
KAction * Killbots::MainWindow::createMappedAction( KActionCollection * collection,
int mapping,
const QString & internalName,
const QString & displayName,
const QString & translatedShortcut,
const QKeySequence & alternateShortcut,
const QString & toolTip,
const QString & icon
)
{
KAction * action = new KAction( displayName, collection );
action->setObjectName( internalName );
action->setShortcut( KShortcut( QKeySequence( translatedShortcut ), alternateShortcut ) );
if ( !toolTip.isEmpty() )
action->setToolTip( toolTip );
if ( !icon.isEmpty() )
action->setIcon( KIcon( icon ) );
connect( action, SIGNAL(triggered()), m_keyboardMapper, SLOT(map()) );
m_keyboardMapper->setMapping( action, mapping );
collection->addAction( internalName, action );
return action;
}
void Killbots::MainWindow::configureShortcuts()
{
KShortcutsDialog dialog( KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this );
......@@ -384,4 +232,156 @@ void Killbots::MainWindow::showHighscores()
m_scoreDialog->exec();
}
KAction * Killbots::MainWindow::createMappedAction( KActionCollection * collection,
int mapping,
const QString & internalName,
const QString & displayName,
const QString & translatedShortcut,
const QKeySequence & alternateShortcut,
const QString & toolTip,
const QString & icon
)
{
KAction * action = new KAction( displayName, collection );
action->setObjectName( internalName );
action->setShortcut( KShortcut( QKeySequence( translatedShortcut ), alternateShortcut ) );
if ( !toolTip.isEmpty() )
action->setToolTip( toolTip );
if ( !icon.isEmpty() )
action->setIcon( KIcon( icon ) );
connect( action, SIGNAL(triggered()), m_keyboardMapper, SLOT(map()) );
m_keyboardMapper->setMapping( action, mapping );
collection->addAction( internalName, action );
return action;
}
void Killbots::MainWindow::setupActions()
{
KStandardGameAction::gameNew( m_engine, SLOT(requestNewGame()), actionCollection() );
KStandardGameAction::highscores( this, SLOT(showHighscores()), actionCollection() );
KStandardGameAction::quit( kapp, SLOT(quit()), actionCollection() );
KStandardAction::keyBindings( this, SLOT(configureShortcuts()), actionCollection() );
KStandardAction::preferences( this, SLOT(configurePreferences()), actionCollection() );
createMappedAction( actionCollection(),
TeleportSafely,
"teleport_safely",
i18n("Teleport Safely"),
i18nc("Shortcut for teleport safely. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "T"),
Qt::Key_Plus,
i18n("Teleport to a safe location"),
"games-solve"
);
createMappedAction( actionCollection(),
Teleport,
"teleport",
i18n("Teleport"),
i18nc("Shortcut for teleport. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "R"),
Qt::Key_Minus,
i18n("Teleport to a random location"),
"roll"
);
createMappedAction( actionCollection(),
TeleportSafelyIfPossible,
"teleport_sip",
i18n("Teleport, Safely If Possible"),
i18nc("Shortcut for teleport safely if possible. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "Space"),
Qt::Key_0,
i18n("Teleport safely if that action is enabled, otherwise teleport randomly")
);
createMappedAction( actionCollection(),
SonicScrewdriver,
"screwdriver",
i18n("Sonic Screwdriver"),
i18nc("Shortcut for sonicscrewdriver. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "F"),
Qt::Key_Period,
i18n("Destroy all enemies in neighboring cells"),
"edit-bomb"
);
createMappedAction( actionCollection(),
WaitOutRound,
"wait_out_round",
i18n("Wait Out Round"),
i18nc("Shortcut for wait out round. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "V"),
Qt::Key_Asterisk,
i18n("Risk remaining in place until the end of the round for bonuses"),
"process-stop"
);
// Keyboard Actions - these are shown in Configure Shortcuts but not in Configure Toolbars
createMappedAction( m_keyboardActions,
UpLeft,
"move_up_left",
i18n("Move Up and Left"),
i18nc("Shortcut for move up and left. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "Q"),
Qt::Key_7
);
createMappedAction( m_keyboardActions,
Up,
"move_up",
i18n("Move Up"),
i18nc("Shortcut for move up. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "W"),
Qt::Key_8
);
createMappedAction( m_keyboardActions,
UpRight,
"move_up_right",
i18n("Move Up and Right"),
i18nc("Shortcut for move up and right. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "E"),
Qt::Key_9
);
createMappedAction( m_keyboardActions,
Left,
"move_left",
i18n("Move Left"),
i18nc("Shortcut for move left. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "A"),
Qt::Key_4
);
createMappedAction( m_keyboardActions,
Hold,
"stand_still",
i18n("Stand Still"),
i18nc("Shortcut for stand still. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "S"),
Qt::Key_5
);
createMappedAction( m_keyboardActions,
Right,
"move_right",
i18n("Move Right"),
i18nc("Shortcut for move right. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "D"),
Qt::Key_6
);
createMappedAction( m_keyboardActions,
DownLeft,
"move_down_left",
i18n("Move Down and Left"),
i18nc("Shortcut for move down and left. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "Z"),
Qt::Key_1
);
createMappedAction( m_keyboardActions,
Down,
"move_down",
i18n("Move Down"),
i18nc("Shortcut for move down. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "X"),
Qt::Key_2
);
createMappedAction( m_keyboardActions,
DownRight,
"move_down_right",
i18n("Move Down and Right"),
i18nc("Shortcut for move down and right. See http://websvn.kde.org/trunk/KDE/kdegames/killbots/README.translators?view=markup", "C"),
Qt::Key_3
);
connect( m_keyboardMapper, SIGNAL(mapped(int)), m_engine, SLOT(requestAction(int)) );
m_keyboardActions->associateWidget(this);
}
#include "moc_mainwindow.cpp"
/*
* Killbots
* Copyright (C) 2006-2008 Parker Coates <parker.coates@gmail.com>
* Copyright (C) 2006-2009 Parker Coates <parker.coates@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......
......@@ -16,53 +16,68 @@
<entry name="Rows" type="Int">
<min>6</min>
<default>16</default>
<label>Number of rows in game grid</label>
</entry>
<entry name="Columns" type="Int">
<min>6</min>
<default>16</default>
<label>Number of columns in game grid</label>
</entry>
<entry name="EnemiesAtGameStart" type="Double">
<default>8</default>
<label>Number of regular enemies in first round</label>
</entry>
<entry name="EnemiesAddedEachRound" type="Double">
<default>4</default>
<label>Number of regular enemies added in each new round</label>
</entry>
<entry name="FastEnemiesAtGameStart" type="Double">
<default>-4</default>
<label>Number of fast enemies in first round</label>
</entry>
<entry name="FastEnemiesAddedEachRound" type="Double">
<default>2</default>
<label>Number of fast enemies added in each new round</label>
</entry>
<entry name="EnergyEnabled" type="Bool">
<default>true</default>
<label>Player can accumulate energy</label>
</entry>
<entry name="EnergyAtGameStart" type="Int">
<min>0</min>
<default>0</default>
<label>Energy at start of first round</label>
</entry>
<entry name="EnergyAddedEachRound" type="Int">
<default>0</default>
<label>Energy awarded for completing a round</label>
</entry>
<entry name="MaxEnergyAtGameStart" type="Double">
<min>0</min>
<default>12</default>
<label>Maximum energy cap in first round</label>
</entry>
<entry name="MaxEnergyAddedEachRound" type="Double">
<default>0</default>
<label>Increase in maximum energy cap for each new round</label>
</entry>
<entry name="SafeTeleportEnabled" type="Bool">
<default>true</default>
<label>Player can perform safe teleports</label>
</entry>
<entry name="CostOfSafeTeleport" type="Int">
<min>1</min>
<default>1</default>
<label>The cost of performing a safe teleport</label>
</entry>
<entry name="SonicScrewdriverEnabled" type="Bool">
<default>false</default>
<label>Player can use sonic screwdriver</label>
</entry>
<entry name="CostOfSonicScrewdriver" type="Int">
<min>1</min>
<default>1</default>
<label>Cost of using sonic screwdriver</label>
</entry>
<entry name="PushableJunkheaps" type="Enum">
<choices name="JunkheapsThatCanBePushed">
......@@ -71,39 +86,49 @@
<choice name="Many"/>
</choices>
<default>Many</default>
<label>Number of junkheaps that can be pushed at once</label>
</entry>
<entry name="SquaskKillsEnabled" type="Bool">
<default>true</default>
<label>Player can destroy enemies with a pushed junkheap</label>
</entry>
<entry name="JunkheapsAtGameStart" type="Double">
<default>0</default>
<label>Junkheaps placed on grid at start of first round</label>
</entry>
<entry name="JunkheapsAddedEachRound" type="Double">
<default>0</default>
<label>Junkheaps added to the grid for each new round</label>
</entry>
<entry name="PointsPerEnemyKilled" type="Int">
<min>0</min>
<default>5</default>
<label>Points awarded for each regular enemy destroyed</label>
</entry>
<entry name="PointsPerFastEnemyKilled" type="Int">
<min>0</min>
<default>10</default>
<label>Points awarded for each fast enemy destroyed</label>
</entry>
<entry name="WaitKillPointBonus" type="Int">
<min>0</min>
<default>0</default>
<label>Points awarded for each enemy destroyed while waiting out the round</label>
</entry>
<entry name="WaitKillEnergyBonus" type="Int">
<min>0</min>
<default>1</default>
<label>Energy awarded for each enemy destroyed while waiting out the round</label>
</entry>
<entry name="SquashKillPointBonus" type="Int">
<min>0</min>
<default>0</default>
<label>Points awarded for each enemy destroyed with a pushed junkheap</label>
</entry>
<entry name="SquashKillEnergyBonus" type="Int">
<min>0</min>
<default>1</default>
<label>Energy awarded for each enemy destroyed with a pushed junkheap</label>
</entry>
</group>
</kcfg>
......@@ -6,7 +6,7 @@ Singleton=false
MemberVariables=private
Mutators=false
ItemAccessors=false
SetUserTexts=false
SetUserTexts=true
GlobalEnums=false
UseEnumTypes=true
ForceStringFilename=true
/*
* Killbots
* Copyright (C) 2006-2009 Parker Coates <parker.coates@gmail.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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses>
* or write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "rulesetdetailsdialog.h"
#include "ruleset.h"
#include <KDE/KLocale>
#include <QtGui/QFormLayout>
#include <QtGui/QLabel>
#include <QtGui/QScrollArea>
Killbots::RulesetDetailsDialog::RulesetDetailsDialog( const Ruleset * ruleset, QWidget * parent )
: KDialog( parent )
{
const QStringList maskedItems = QStringList() << "Name" << "Author" << "AuthorContact" << "Description";
const QStringList junkheapEnumText = QStringList()
<< i18nc("Quantity of junkheaps that can be pushed", "None")
<< i18nc("Quantity of junkheaps that can be pushed", "One")
<< i18nc("Quantity of junkheaps that can be pushed", "Many");
// QScrollArea * scroll = new QScrollArea( this );
QWidget * widget = new QWidget();
QFormLayout * layout = new QFormLayout( widget );
foreach( const KConfigSkeletonItem * item, ruleset->items() )
{
if ( !maskedItems.contains( item->name() ) )
{
QString labelText = item->label().isEmpty() ? item->name() : item->label();
labelText = i18nc( "%1 is a pretranslated string that we're turning into a label", "%1:", labelText );
QString valueText;
if ( dynamic_cast<const KCoreConfigSkeleton::ItemBool *>( item ) )
valueText = item->property().toBool() ? i18n("Yes") : i18n("No");
else if ( item->name() == "PushableJunkheaps" )
valueText = junkheapEnumText.at( item->property().toInt() );
else
valueText = item->property().toString();
layout->addRow( new QLabel( labelText ), new QLabel( valueText ) );
}
}
// scroll->setWidget( widget );
// scroll->setAlignment( Qt::AlignHCenter | Qt:: AlignTop );
// setMainWidget( scroll );
setMainWidget( widget );
setButtons( KDialog::Close );
setCaption( i18n("Details of %1 Game Type", ruleset->name() ) );
}
/*
* Killbots
* Copyright (C) 2006-2009 Parker Coates <parker.coates@gmail.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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses>
* or write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KILLBOTS_RULESETDETAILSDIALOG_H
#define KILLBOTS_RULESETDETAILSDIALOG_H
#include <KDE/KDialog>
namespace Killbots {
class Ruleset;
class RulesetDetailsDialog : public KDialog
{
public:
RulesetDetailsDialog( const Ruleset * ruleset, QWidget * parent = 0 );
};
}
#endif // KILLBOTS_RULESETDETAILSDIALOG_H
/*
* Killbots
* Copyright (C) 2006-2008 Parker Coates <parker.coates@gmail.com>
* Copyright (C) 2006-2009 Parker Coates <parker.coates@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -21,6 +21,7 @@
#include "rulesetselector.h"
#include "ruleset.h"
#include "rulesetdetailsdialog.h"
#include "settings.h"
#include <KDE/KDebug>
......@@ -32,7 +33,9 @@
#include <QtGui/QLabel>
#include <QtGui/QLayout>
#include <QtGui/QListWidget>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include <QtGui/QTableWidget>
Killbots::RulesetSelector::RulesetSelector( QWidget * parent )
: QWidget( parent ),
......@@ -71,6 +74,8 @@ Killbots::RulesetSelector::RulesetSelector( QWidget * parent )
m_description->setAlignment( Qt::AlignLeft | Qt::AlignTop );
m_description->setWordWrap( true );
QPushButton * detailsButton = new QPushButton( i18n("Details...") );
QGridLayout * boxLayout = new QGridLayout( groupBox );
boxLayout->setColumnStretch( 1, 10 );
boxLayout->setRowStretch( 4, 10 );
......@@ -80,6 +85,7 @@ Killbots::RulesetSelector::RulesetSelector( QWidget * parent )
boxLayout->addWidget( m_authorContact, 2, 1 );
boxLayout->addWidget( descriptionLabel, 3, 0 );
boxLayout->addWidget( m_description, 3, 1 );
boxLayout->addWidget( detailsButton, 4, 1, Qt::AlignLeft );
QVBoxLayout * layout = new QVBoxLayout( this );
layout->setMargin( 0 );
......@@ -88,6 +94,7 @@ Killbots::RulesetSelector::RulesetSelector( QWidget * parent )
layout->addWidget( groupBox, 10 );
connect( m_listWidget, SIGNAL(currentTextChanged(QString)), this, SLOT(selectionChanged(QString)) );
connect( detailsButton, SIGNAL(clicked()), this, SLOT(showDetailsDialog()) );
findRulesets();
}
......@@ -133,12 +140,14 @@ void Killbots::RulesetSelector::findRulesets()