Commit a5fb9d3d authored by Ian Wadham's avatar Ian Wadham

Add animated demo at startup. Add hooks for other replays. Add Curse of the...

Add animated demo at startup.  Add hooks for other replays.  Add Curse of the Mummy game to the install.

svn path=/trunk/KDE/kdegames/kgoldrunner/; revision=959339
parent f166d617
......@@ -4,5 +4,20 @@
########### install files ###############
install( FILES game_cnt.txt game_ende.txt game_kgr.txt game_plws.txt game_plwv.txt game_sot.txt game_tute.txt game_tutea.txt game_wad.txt hi_kgr.dat hi_plws.dat hi_plwv.dat hi_wad.dat DESTINATION ${DATA_INSTALL_DIR}/kgoldrunner/system )
install( FILES game_CM.txt
game_cnt.txt
game_ende.txt
game_kgr.txt
game_plws.txt
game_plwv.txt
game_sot.txt
game_tute.txt
game_tutea.txt
game_wad.txt
hi_kgr.dat
hi_plws.dat
hi_plwv.dat
hi_wad.dat
rec_demo.txt
DESTINATION ${DATA_INSTALL_DIR}/kgoldrunner/system )
This diff is collapsed.
......@@ -138,10 +138,9 @@ KGoldrunner::KGoldrunner()
initStatusBar(); // IDW
// Connect the game actions to the menu and toolbar displays.
connect (game, SIGNAL (quitGame()), SLOT (close()));
connect (game, SIGNAL (setEditMenu (bool)), SLOT (setEditMenu (bool)));
connect (game, SIGNAL (hintAvailable (bool)), SLOT (adjustHintAction (bool)));
connect (game, SIGNAL (defaultEditObj()), SLOT (defaultEditObj()));
connect (game, SIGNAL (quitGame()), SLOT (close()));
connect (game, SIGNAL (setEditMenu (bool)), SLOT (setEditMenu (bool)));
connect (game, SIGNAL (hintAvailable(bool)), SLOT (adjustHintAction(bool)));
connect (game, SIGNAL (setAvail (const char *, const bool)),
SLOT (setAvail (const char *, const bool)));
......@@ -160,7 +159,7 @@ KGoldrunner::KGoldrunner()
// IDW toolBar ("editToolbar")->setAllowedAreas (Qt::TopToolBarArea);
// Set mouse control of the hero as the default.
game->setControlMode (MOUSE);
game->settings (MOUSE);
// Do NOT paint main widget yet (title, menu, status bar, blank playfield).
// Instead, queue a call to the "KGoldrunner_2" constructor extension.
......@@ -168,8 +167,8 @@ KGoldrunner::KGoldrunner()
kDebug() << "QMetaObject::invokeMethod (this, \"KGoldrunner_2\") done ... ";
// Show buttons to start the config'd game and level and other options.
game->quickStartDialog();
kDebug() << "game->quickStartDialog() done ... ";
// TODO - Remove. game->quickStartDialog();
// TODO - Remove. kDebug() << "game->quickStartDialog() done ... ";
kDebug() << "1st scan of event-queue ...";
}
......@@ -252,6 +251,29 @@ void KGoldrunner::setupActions()
actionCollection()->addAction (hintAction->objectName(), hintAction);
gameMapper->setMapping (hintAction, HINT);
a = KStandardGameAction::demo (gameMapper, SLOT (map()), this);
actionCollection()->addAction (a->objectName(), a);
gameMapper->setMapping (a, DEMO);
a = KStandardGameAction::solve (gameMapper, SLOT (map()), this);
actionCollection()->addAction (a->objectName(), a);
gameMapper->setMapping (a, SOLVE);
a->setToolTip (i18n ("Show how to win this level"));
a->setWhatsThis (i18n ("Play a recording of how to win this level, if "
"there is one available"));
a = gameAction ("instant_replay", INSTANT_REPLAY,
i18n ("&Instant Replay"),
i18n ("Instant replay"),
i18n ("Show a recording of the latest level played"),
QKeySequence()); // No key assigned.
a = gameAction ("replay_any", REPLAY_ANY,
i18n ("&Replay Any Level"),
i18n ("Replay any level"),
i18n ("Show a recording of any level played so far"),
QKeySequence()); // No key assigned.
killHero = gameAction ("kill_hero", KILL_HERO,
i18n ("&Kill Hero"),
i18n ("Kill Hero"),
......@@ -341,6 +363,7 @@ void KGoldrunner::setupActions()
/**************************** SETTINGS MENU ****************************/
/**************************************************************************/
KConfigGroup gameGroup (KGlobal::config(), "KDEGame");
QSignalMapper * settingMapper = new QSignalMapper (this);
connect (settingMapper, SIGNAL (mapped (int)), game, SLOT (settings (int)));
tempMapper = settingMapper;
......@@ -357,11 +380,19 @@ void KGoldrunner::setupActions()
i18n ("Play sound effects"),
i18n ("Play sound effects during the game"));
KConfigGroup gameGroup (KGlobal::config(), "KDEGame");
bool soundOnOff = gameGroup.readEntry ("Sound", false);
setSounds->setChecked (soundOnOff);
#endif
// Demo at start on/off.
KToggleAction * setDemo = settingAction ("options_demo", STARTUP_DEMO,
i18n ("&Demo At Start"),
i18n ("Run a demo when the game starts"),
i18n ("Run a demo when the game starts"));
bool demoOnOff = gameGroup.readEntry ("StartingDemo", true);
setDemo->setChecked (demoOnOff);
// Mouse Controls Hero
// Keyboard Controls Hero
// Laptop Hybrid
......@@ -384,8 +415,8 @@ void KGoldrunner::setupActions()
i18n ("Pointer controls hero; dig "
"using keyboard."),
i18n ("Use the the laptop's pointer device "
"to control the hero's moves, and use the "
"keyboard to dig left and right."));
"to control the hero's moves, and use "
"the keyboard to dig left and right."));
QActionGroup* controlGrp = new QActionGroup (this);
controlGrp->addAction (setMouse);
......@@ -494,7 +525,7 @@ void KGoldrunner::setupActions()
keyControl ("do_step", i18n ("Do a Step"), Qt::Key_Period, DO_STEP);
keyControl ("bug_fix", i18n ("Test Bug Fix"), Qt::Key_B, BUG_FIX);
keyControl ("show_positions", i18n ("Show Positions"), Qt::Key_D, S_POSNS);
keyControl ("show_positions", i18n ("Show Positions"), Qt::Key_W, S_POSNS);
keyControl ("logging", i18n ("Start Logging"), Qt::Key_G, LOGGING);
keyControl ("show_hero", i18n ("Show Hero"), Qt::Key_R, S_HERO);
keyControl ("show_obj", i18n ("Show Object"), Qt::Key_Slash, S_OBJ);
......@@ -519,7 +550,12 @@ QAction * KGoldrunner::gameAction (const QString & name,
ga->setText (text);
ga->setToolTip (toolTip);
ga->setWhatsThis (whatsThis);
ga->setShortcut (key);
if (! key.isEmpty()) {
// TODO - Shortcut for KAction "xxx" set with QShortcut::setShortcut()!
// TODO - See KAction documentation. [Runtime ERROR message]
// TODO - (xxx = kill_hero, increase_speed, decrease_speed)
ga->setShortcut (key);
}
connect (ga, SIGNAL (triggered (bool)), tempMapper, SLOT (map()));
tempMapper->setMapping (ga, code);
return ga;
......@@ -767,6 +803,7 @@ void KGoldrunner::setEditMenu (bool on_off)
setEditIcon ("hladderbg", HLADDER);
setEditIcon ("edherobg", HERO);
setEditIcon ("edenemybg", ENEMY);
setToggle ("brickbg", true); // Default edit-object is BRICK.
toolBar ("editToolbar")->show();
}
......
<?xml version="1.0" encoding="UTF-8"?>
<gui name="kgoldrunner"
version="9"
version="10"
xmlns="http://www.kde.org/standards/kxmlgui/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0
......@@ -10,6 +10,10 @@
<Action append="save_merge" name="save_edits" />
<Action append="misc_merge" name="kill_hero" />
</Menu>
<Menu name="move" >
<Action append="save_merge" name="instant_replay" />
<Action append="save_merge" name="replay_any" />
</Menu>
<Menu name="editor" > <text>&amp;Editor</text>
<Action name="create_level" />
<Action name="edit_any" />
......@@ -26,6 +30,7 @@
</Menu>
<Menu name="settings" >
<Action append="save_merge" name="options_sounds" />
<Action append="save_merge" name="options_demo" />
<Separator append="save_merge" />
<Action append="save_merge" name="mouse_mode" />
<Action append="save_merge" name="keyboard_mode" />
......
......@@ -38,7 +38,7 @@ KGrEditor::KGrEditor (KGrCanvas * theView,
systemDataDir (theSystemDir),
userDataDir (theUserDir),
gameList (pGameList),
editObj (BRICK),
editObj (BRICK), // Default edit-object.
shouldSave (false),
mouseDisabled (true)
{
......@@ -838,9 +838,7 @@ QString KGrEditor::getTitle()
// Set title string to "Game-name - NNN" or "Game-name - NNN - Level-name".
KGrGameData * gameData = gameList.at(gameIndex);
QString levelNumber;
levelNumber.setNum (editLevel);
levelNumber = levelNumber.rightJustified (3,'0');
QString levelNumber = QString::number(editLevel).rightJustified(3,'0');
// TODO - Make sure gameData->name.constData() results in Unicode display
// and not some weird UTF8 character stuff.
......@@ -858,15 +856,8 @@ QString KGrEditor::getTitle()
QString KGrEditor::getLevelFilePath (KGrGameData * gameData, int lev)
{
QString filePath;
filePath.setNum (lev); // Convert integer -> QString.
filePath = filePath.rightJustified (3,'0'); // Add 0-2 zeros at left.
filePath.append (".grl"); // Add KGoldrunner level-suffix.
filePath.prepend (gameData->prefix); // Add the game's file-prefix.
filePath.prepend (userDataDir + "levels/"); // Add user's directory path.
QString filePath = userDataDir + "levels/" + gameData->prefix +
QString::number(lev).rightJustified(3,'0') + ".grl";
return (filePath);
}
......
This diff is collapsed.
......@@ -47,22 +47,16 @@ public:
bool initGameLists();
// TODO - Needs to be public?
void quickStartDialog();
void setInitialTheme (const QString & themeFilepath);
int getLevel();
void setInitialTheme (const QString & themeFilepath);
bool inMouseMode(); // True if the game is in mouse mode.
// TODO - Needed?
bool inEditMode(); // True if the game is in editor mode.
bool saveOK(); // Check if edits were saved.
QString getTitle(); // Collection - Level NNN, Name.
void setEditObj (char newEditObj); // Set object for editor to paint.
QString getDirectory (Owner o);
// Flags to control author's debugging aids.
static bool bugFix;
static bool logging;
......@@ -70,18 +64,20 @@ public:
public slots:
void initGame(); // Do the game object's first painting.
void gameActions (int action);
void editActions (int action);
void editToolbarActions (int action);
void settings (int action);
void gameActions (const int action);
void editActions (const int action);
void editToolbarActions (const int action);
void settings (const int action);
void kbControl (int dirn);
void kbControl (const int dirn);
void incScore (const int n); // Update the score.
private:
// TODO - Only startAnyLevel() is used (from newGame...).
void startLevelOne(); // Start any game from level 1.
void startAnyLevel(); // Start any game from any level.
void startNextLevel(); // Start next level of current game.
// TODO - startLevel should NOT be a public slot.
void startLevel (int startingAt, int requestedLevel);
void toggleSoundsOnOff(); // Set sound enabled or disabled.
......@@ -91,26 +87,39 @@ public slots:
void setTimeScale (const int action);
void newGame (const int lev, const int gameIndex);
bool startDemo (const Owner demoOwner, const QString & pPrefix,
const int levelNo);
void finishDemo();
private slots:
void interruptDemo();
private:
void startTutorial(); // Start tutorial game.
void showHint(); // Show hint for current level.
QString getTitle(); // Collection - Level NNN, Name.
void showHighScores(); // Show high scores for current game.
void incScore (const int); // Update the score.
void showHiddenLadders(); // Show hidden ladders (nuggets gone).
void endLevel (const int result); // Hero completed the level or he died.
void herosDead(); // Hero was caught or he quit (key Q).
void freeze (const bool userAction, const bool on_off);
private slots:
void finalBreath(); // Hero is dead: re-start the level.
QString getDirectory (Owner o);
public slots:
void showHiddenLadders(); // Show hidden ladders (nuggets gone).
void herosDead(); // Hero was caught or he quit (key Q).
void levelCompleted(); // Hero completed the level.
void goUpOneLevel(); // Start next level.
void saveGame(); // Save game ID, score and level.
void loadGame(); // Re-load game, score and level.
private slots:
void endLevel (const int result); // Hero completed the level or he died.
void finalBreath(); // Hero is dead: re-start the level.
void goUpOneLevel(); // Start next level.
void heroStep (bool climbing); // The hero has put a foot on the floor.
void heroFalls (bool startStop); // The hero has started/stopped falling.
void heroDigs(); // The hero is digging.
......@@ -124,7 +133,6 @@ signals:
void hintAvailable (bool); // For main window to adjust menu text.
void setEditMenu (bool); // Enable/Disable edit menu items.
void defaultEditObj(); // Set default edit-toolbar button.
void gameFreeze (bool); // Do visual feedback in the GUI.
......@@ -161,6 +169,7 @@ private:
KGrLevelPlayer * levelPlayer; // Where the level is played.
KGrRecording * recording; // A recording of the play.
bool playback; // Play back or record?
bool startupDemo; // Startup demo running?
KGrCanvas * view; // Where the game is displayed.
QString systemDataDir; // System games are stored here.
......@@ -169,13 +178,16 @@ private:
float fTimeScale; // Speed as a float (0.2-2.0).
QList<KGrGameData *> gameList; // A list of available games.
KGrGameData * gameData; // Data for the current game.
int gameIndex; // The index in the game-list.
Owner owner; // The game's owner.
int level; // Current play/edit level.
QString prefix; // Prefix for game or demo file.
int level; // Current play/edit/demo level.
int levelMax; // Last level no in game/demo.
int gameLevel; // Copy of play/edit level no.
QString levelName; // Level name (optional).
QString levelHint; // Level hint (optional).
QString demoPrefix; // File-prefix for demo levels.
long lives; // Lives remaining.
long score; // Current score.
......@@ -207,9 +219,7 @@ private:
QVector<int> fx;
public slots:
void dbgControl (int code); // Authors' debugging aids.
void freeze (const bool userAction, const bool on_off);
void dbgControl (const int code); // Authors' debugging aids.
private:
KGrEditor * editor; // The level-editor object.
......@@ -223,7 +233,8 @@ private:
bool loadGameData (Owner);
void initRecording ();
void saveRecording ();
void loadRecording (const QString & prefix, const int levelNo);
void loadRecording (const QString & dir, const QString & prefix,
const int levelNo);
void loadSounds ();
/******************************************************************************/
......
......@@ -263,9 +263,7 @@ QString KGrGameIO::getFilePath
filePath = dir + "levels/level000.grl";
}
else {
QString num;
num.setNum (level); // Convert INT -> QString.
num = num.rightJustified (3,'0'); // Add 0-2 zeros at left.
QString num = QString::number (level).rightJustified (3,'0');
filePath = dir + "levels/" + prefix + num + ".grl";
}
......
......@@ -149,12 +149,14 @@ public:
QByteArray draws; ///< The random numbers used during play.
};
enum GameAction {NEW, LOAD, SAVE_GAME, PAUSE, HIGH_SCORE, HINT, KILL_HERO};
enum GameAction {NEW, LOAD, SAVE_GAME, PAUSE, HIGH_SCORE, KILL_HERO,
HINT, DEMO, SOLVE, INSTANT_REPLAY, REPLAY_ANY};
enum EditAction {CREATE_LEVEL, EDIT_ANY, SAVE_EDITS, MOVE_LEVEL,
DELETE_LEVEL, CREATE_GAME, EDIT_GAME};
enum Setting {PLAY_SOUNDS, // Sound effects on/off.
STARTUP_DEMO, // Starting demo on/off.
MOUSE, KEYBOARD, LAPTOP, // Game-control modes.
NORMAL_SPEED, BEGINNER_SPEED, // Preset game-speeds.
CHAMPION_SPEED,
......
......@@ -423,8 +423,9 @@ void KGrLevelPlayer::doDig (int button)
// Click to end demo/playback mode.
if (playback) {
playback = false;
return;
playback = false;
emit interruptDemo();
return;
}
uchar recordByte = 0;
......@@ -476,6 +477,8 @@ void KGrLevelPlayer::setDirectionByKey (Direction dirn)
}
if (playback) { // Any key ends demo/playback mode.
playback = false;
emit interruptDemo();
return;
}
if ((dirn == DIG_LEFT) || (dirn == DIG_RIGHT)) {
......@@ -666,6 +669,7 @@ void KGrLevelPlayer::tick (bool missed, int scaledTime)
else { // Make a "live" move and record it.
int i, j;
emit getMousePos (i, j);
// TODO - This causes a CRASH if keyboard-mode set and mouse is at 1,1.
setTarget (i, j);
}
......
......@@ -303,6 +303,7 @@ signals:
void deleteSprite (const int spriteId);
void gotGold (const int spriteId, const int i, const int j,
const bool hasGold, const bool lost);
void interruptDemo ();
private slots:
void tick (bool missed, int scaledTime);
......
......@@ -463,6 +463,7 @@ void KGrEnemy::checkForGold()
else if ((nuggets > 0) && (cell == FREE)) {
// Dropping gold is a random choice, but do not drop in thin air.
char below = grid->cellType (gridI, gridJ + 1);
// TODO - Do not drop above a BAR. Affects recording of Initiation 10.
if ((below != FREE) && (below != NUGGET)) {
random = levelPlayer->randomByte ((uchar) 100);
dbk << "Random" << random << "for DROP " << gridI << gridJ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment