Git commit f20f59d52d116af84b9fcbb484efb56bcdf11ff3 by Luigi Toscano. Committed on 26/04/2017 at 19:36. Pushed by ltoscano into branch 'frameworks'.
Merge remote-tracking branch 'origin/master' into frameworks - adapt few imported kDebug as qCDebug(KGOLDRUNNER_LOG); - use the variable provided by ECM to set the target directory for the appdata file. M +37 -10 doc/index.docbook M +9 -1 gamedata/CMakeLists.txt M +1 -0 src/CMakeLists.txt M +60 -26 src/kgoldrunner.cpp M +1 -0 src/kgoldrunner.h M +188 -83 src/kgrgame.cpp M +40 -13 src/kgrgameio.cpp M +4 -25 src/kgrlevelplayer.cpp M +2 -2 src/kgrrenderer.cpp M +52 -14 src/kgrrunner.cpp M +2 -2 src/kgrscene.cpp M +4 -0 src/kgrselector.cpp M +1 -1 src/main.cpp M +1 -1 src/org.kde.kgoldrunner.desktop https://commits.kde.org/kgoldrunner/f20f59d52d116af84b9fcbb484efb56bcdf11ff3 diff --cc gamedata/CMakeLists.txt index fe6db5e,23b6737..8736c25 --- a/gamedata/CMakeLists.txt +++ b/gamedata/CMakeLists.txt @@@ -26,5 -28,11 +28,11 @@@ install( FILES game_blb.tx rec_demo.txt rec_GMGR.txt rec_GRII.txt + sol_blb.txt + sol_fd.txt + sol_kgr.txt + sol_plws.txt + sol_tute.txt + sol_tutea.txt - DESTINATION ${DATA_INSTALL_DIR}/kgoldrunner/system ) + DESTINATION ${KDE_INSTALL_DATADIR}/kgoldrunner/system ) diff --cc src/CMakeLists.txt index 4e36aaf,7706dcb..35cdab0 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@@ -39,16 -30,8 +39,17 @@@ install(TARGETS kgoldrunner ${KDE_INST ########### install files ############### -install( PROGRAMS org.kde.kgoldrunner.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) -install( FILES kgoldrunnerui.rc DESTINATION ${DATA_INSTALL_DIR}/kgoldrunner ) -install(FILES org.kde.kgoldrunner.appdata.xml DESTINATION ${SHARE_INSTALL_PREFIX}/metainfo/ ) +install(PROGRAMS org.kde.kgoldrunner.desktop DESTINATION ${KDE_INSTALL_APPDIR}) +install(FILES kgoldrunnerui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/kgoldrunner) ++install(FILES org.kde.kgoldrunner.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) + +ecm_install_icons(ICONS + 128-apps-kgoldrunner.png + 16-apps-kgoldrunner.png + 22-apps-kgoldrunner.png + 32-apps-kgoldrunner.png + 48-apps-kgoldrunner.png + 64-apps-kgoldrunner.png + DESTINATION ${KDE_INSTALL_ICONDIR} THEME hicolor +) -kde4_install_icons( ${ICON_INSTALL_DIR} ) diff --cc src/kgoldrunner.cpp index cfa2bbb,e209d5e..26abe08 --- a/src/kgoldrunner.cpp +++ b/src/kgoldrunner.cpp @@@ -115,7 -114,10 +115,7 @@@ KGoldrunner::KGoldrunner( /************************* SET UP THE USER INTERFACE ************************/ /******************************************************************************/ - // Tell the KMainWindow that the KGrCanvas object is the main widget. - // Get catalog for translation. - KGlobal::locale()->insertCatalog ( QLatin1String( "libkdegames" )); - + // Tell the KMainWindow that the KGrView object is the main widget. setCentralWidget (view); scene = view->gameScene (); @@@ -225,8 -230,18 +228,18 @@@ void KGoldrunner::setupActions( actionCollection()->addAction (saveGame->objectName(), saveGame); gameMapper->setMapping (saveGame, SAVE_GAME); saveGame->setText (i18n ("&Save Game...")); - saveGame->setShortcut (Qt::Key_S); // Alternate key. + actionCollection()->setDefaultShortcut(saveGame, Qt::Key_S); // Alternate key. + // The name of the solution-file is 'sol_<prefix>.txt', where <prefix> is + // the unique prefix belonging to the game involved (eg. plws, tute, etc.). + a = gameAction ("save_solution", SAVE_SOLUTION, + i18n ("Save A Solution..."), + i18n ("Save A Solution..."), + i18n ("Save a solution for a level into a file " + "called 'sol_<prefix>.txt' in your " + "user's data directory..."), + Qt::ShiftModifier + Qt::Key_S); + // Pause // Show High Scores // Get a Hint @@@ -648,9 -663,10 +661,10 @@@ void KGoldrunner::keyControl (const QSt const QKeySequence & shortcut, const int code, const bool mover) { - KAction * a = actionCollection()->addAction (name); + QAction * a = actionCollection()->addAction (name); a->setText (text); - a->setShortcut (shortcut); + actionCollection()->setDefaultShortcut(a, shortcut); + a->setAutoRepeat (false); // Avoid repeats of signals by QAction. // If this is a move-key, let keyPressEvent() through, instead of signal. if (mover) { diff --cc src/kgrgame.cpp index cb6e88f,2e894b1..b7cb7e7 --- a/src/kgrgame.cpp +++ b/src/kgrgame.cpp @@@ -112,11 -111,11 +112,11 @@@ KGrGame::KGrGame (KGrView * theView gameFrozen = false; dyingTimer = new QTimer (this); - connect (dyingTimer, SIGNAL (timeout()), SLOT (finalBreath())); + connect(dyingTimer, &QTimer::timeout, this, &KGrGame::finalBreath); // Initialise random number generator. - randomGen = new KRandomSequence (time (0)); - // kDebug() << "RANDOM NUMBER GENERATOR INITIALISED"; + randomGen = new KRandomSequence (std::time(nullptr)); - qCDebug(KGOLDRUNNER_LOG) << "RANDOM NUMBER GENERATOR INITIALISED"; ++ //qCDebug(KGOLDRUNNER_LOG) << "RANDOM NUMBER GENERATOR INITIALISED"; scene->setReplayMessage (i18n("Click anywhere to begin live play")); } @@@ -197,7 -200,7 +201,7 @@@ void KGrGame::gameActions (const int ac return; } level++; - qCDebug(KGOLDRUNNER_LOG) << "Game" << gameList.at(gameIndex)->name << "level" << level; - // kDebug() << "Game" << gameList.at(gameIndex)->name << "level" << level; ++ //qCDebug(KGOLDRUNNER_LOG) << "Game" << gameList.at(gameIndex)->name << "level" << level; newGame (level, gameIndex); showTutorialMessages (level); break; @@@ -329,8 -335,8 +336,8 @@@ void KGrGame::editActions (const int ac prefix = gameList.at (gameIndex)->prefix; level = lev; - qCDebug(KGOLDRUNNER_LOG) << "Saving to KConfigGroup"; - // kDebug() << "Saving to KConfigGroup"; - KConfigGroup gameGroup (KGlobal::config(), "KDEGame"); ++ //qCDebug(KGOLDRUNNER_LOG) << "Saving to KConfigGroup"; + KConfigGroup gameGroup (KSharedConfig::openConfig(), "KDEGame"); gameGroup.writeEntry ("GamePrefix", prefix); gameGroup.writeEntry ("Level_" + prefix, level); gameGroup.sync(); // Ensure that the entry goes to disk. @@@ -426,7 -432,7 +433,7 @@@ void KGrGame::initGame( "SndFile libraries were present when it was compiled and built."), "WarningNoSound"); #endif - qCDebug(KGOLDRUNNER_LOG) << "Entered, draw the initial graphics now ..."; - // kDebug() << "Entered, draw the initial graphics now ..."; ++ //qCDebug(KGOLDRUNNER_LOG) << "Entered, draw the initial graphics now ..."; // Get the most recent collection and level that was played by this user. // If he/she has never played before, set it to Tutorial, level 1. @@@ -434,7 -440,7 +441,7 @@@ QString prevGamePrefix = gameGroup.readEntry ("GamePrefix", "tute"); int prevLevel = gameGroup.readEntry ("Level_" + prevGamePrefix, 1); - qCDebug(KGOLDRUNNER_LOG)<< "Config() Game and Level" << prevGamePrefix << prevLevel; - // kDebug()<< "Config() Game and Level" << prevGamePrefix << prevLevel; ++ //qCDebug(KGOLDRUNNER_LOG)<< "Config() Game and Level" << prevGamePrefix << prevLevel; // Use that game and level, if it is among the current games. // Otherwise, use the first game in the list and level 1. @@@ -473,7 -479,7 +480,7 @@@ #ifdef KGAUDIO_BACKEND_OPENAL // Set up sounds, if required in config. soundOn = gameGroup.readEntry ("Sound", false); - qCDebug(KGOLDRUNNER_LOG) << "Sound" << soundOn; - // kDebug() << "Sound" << soundOn; ++ //qCDebug(KGOLDRUNNER_LOG) << "Sound" << soundOn; if (soundOn) { loadSounds(); effects->setMuted (false); @@@ -481,7 -487,7 +488,7 @@@ emit setToggle ("options_sounds", soundOn); stepsOn = gameGroup.readEntry ("StepSounds", false); - qCDebug(KGOLDRUNNER_LOG) << "StepSounds" << stepsOn; - // kDebug() << "StepSounds" << stepsOn; ++ //qCDebug(KGOLDRUNNER_LOG) << "StepSounds" << stepsOn; emit setToggle ("options_steps", stepsOn); #endif @@@ -511,7 -547,13 +548,13 @@@ bool KGrGame::startDemo (const Owner de { // Find the relevant file and the list of levels it contains. QString dir = (demoOwner == SYSTEM) ? systemDataDir : userDataDir; - QString filepath = dir + "rec_" + pPrefix + ".txt"; + QString filepath; + if (! getRecordingName (dir, pPrefix, filepath)) { - kDebug() << "No file found by getRecordingName() for" << dir << pPrefix; ++ qCDebug(KGOLDRUNNER_LOG) << "No file found by getRecordingName() for" << dir << pPrefix; + return false; + } + dbk1 << "Owner" << demoOwner << "type" << demoType + << pPrefix << levelNo << "filepath" << filepath; KConfig config (filepath, KConfig::SimpleConfig); QStringList demoList = config.groupList(); dbk1 << "DEMO LIST" << demoList.count() << demoList; @@@ -765,11 -807,11 +808,11 @@@ bool KGrGame::selectGame (const SelectA bool selected = sl->selectLevel (selectedGame, selectedLevel); delete sl; - qCDebug(KGOLDRUNNER_LOG) << "After dialog - programFreeze" << programFreeze; - qCDebug(KGOLDRUNNER_LOG) << "selected" << selected << "gameFrozen" << gameFrozen; - qCDebug(KGOLDRUNNER_LOG) << "selectedGame" << selectedGame - << "prefix" << gameList.at(selectedGame)->prefix - << "selectedLevel" << selectedLevel; - // kDebug() << "After dialog - programFreeze" << programFreeze; - // kDebug() << "selected" << selected << "gameFrozen" << gameFrozen; - // kDebug() << "selectedGame" << selectedGame - // << "prefix" << gameList.at(selectedGame)->prefix - // << "selectedLevel" << selectedLevel; ++ //qCDebug(KGOLDRUNNER_LOG) << "After dialog - programFreeze" << programFreeze; ++ //qCDebug(KGOLDRUNNER_LOG) << "selected" << selected << "gameFrozen" << gameFrozen; ++ //qCDebug(KGOLDRUNNER_LOG) << "selectedGame" << selectedGame ++ // << "prefix" << gameList.at(selectedGame)->prefix ++ // << "selectedLevel" << selectedLevel; // Unfreeze the game, but only if it was previously unfrozen. freeze (ProgramPause, false); return selected; @@@ -1021,9 -1084,9 +1083,9 @@@ void KGrGame::herosDead( void KGrGame::finalBreath() { - dbk << "Connecting fadeFinished()"; - // dbk << "Connecting fadeFinished()"; - connect (scene, SIGNAL (fadeFinished()), this, SLOT (repeatLevel())); - // dbk << "Calling scene->fadeOut()"; ++ //dbk << "Connecting fadeFinished()"; + connect(scene, &KGrScene::fadeFinished, this, &KGrGame::repeatLevel); - dbk << "Calling scene->fadeOut()"; ++ //dbk << "Calling scene->fadeOut()"; scene->fadeIn (false); } @@@ -1048,9 -1111,9 +1110,9 @@@ void KGrGame::levelCompleted( { playSound (CompletedSound); - dbk << "Connecting fadeFinished()"; - // dbk << "Connecting fadeFinished()"; - connect (scene, SIGNAL (fadeFinished()), this, SLOT (goUpOneLevel())); - // dbk << "Calling scene->fadeOut()"; ++ //dbk << "Connecting fadeFinished()"; + connect(scene, &KGrScene::fadeFinished, this, &KGrGame::goUpOneLevel); - dbk << "Calling scene->fadeOut()"; ++ //dbk << "Calling scene->fadeOut()"; scene->fadeIn (false); } @@@ -1137,7 -1200,7 +1199,7 @@@ void KGrGame::setTimeScale (const int a if (levelPlayer && (! playback)) { // Change speed during play, but not during a demo or replay. - qCDebug(KGOLDRUNNER_LOG) << "setTimeScale" << (timeScale); - // kDebug() << "setTimeScale" << (timeScale); ++ //qCDebug(KGOLDRUNNER_LOG) << "setTimeScale" << (timeScale); levelPlayer->setTimeScale (timeScale); } } @@@ -1174,8 -1237,8 +1236,8 @@@ void KGrGame::toggleSoundsOnOff (const void KGrGame::freeze (const bool userAction, const bool on_off) { QString type = userAction ? "UserAction" : "ProgramAction"; - qCDebug(KGOLDRUNNER_LOG) << "PAUSE:" << type << on_off; - qCDebug(KGOLDRUNNER_LOG) << "gameFrozen" << gameFrozen << "programFreeze" << programFreeze; - // kDebug() << "PAUSE:" << type << on_off; - // kDebug() << "gameFrozen" << gameFrozen << "programFreeze" << programFreeze; ++ //qCDebug(KGOLDRUNNER_LOG) << "PAUSE:" << type << on_off; ++ //qCDebug(KGOLDRUNNER_LOG) << "gameFrozen" << gameFrozen << "programFreeze" << programFreeze; #ifdef KGAUDIO_BACKEND_OPENAL if (on_off && effects) { // If pausing and sounds are loaded, cut @@@ -1187,23 -1250,23 +1249,23 @@@ // The program needs to freeze the game during a message, dialog, etc. if (on_off) { if (gameFrozen) { - if (programFreeze) { - qCDebug(KGOLDRUNNER_LOG) << "P: The program has already frozen the game."; - } - else { - qCDebug(KGOLDRUNNER_LOG) << "P: The user has already frozen the game."; - } - // if (programFreeze) { - // kDebug() << "P: The program has already frozen the game."; - // } - // else { - // kDebug() << "P: The user has already frozen the game."; - // } ++ //if (programFreeze) { ++ // qCDebug(KGOLDRUNNER_LOG) << "P: The program has already frozen the game."; ++ //} ++ //else { ++ // qCDebug(KGOLDRUNNER_LOG) << "P: The user has already frozen the game."; ++ //} return; // The game is already frozen. } programFreeze = false; } else if (! programFreeze) { - if (gameFrozen) { - qCDebug(KGOLDRUNNER_LOG) << "P: The user will keep the game frozen."; - } - else { - qCDebug(KGOLDRUNNER_LOG) << "P: The game is NOT frozen."; - } - // if (gameFrozen) { - // kDebug() << "P: The user will keep the game frozen."; - // } - // else { - // kDebug() << "P: The game is NOT frozen."; - // } ++ //if (gameFrozen) { ++ // qCDebug(KGOLDRUNNER_LOG) << "P: The user will keep the game frozen."; ++ //} ++ //else { ++ // qCDebug(KGOLDRUNNER_LOG) << "P: The game is NOT frozen."; ++ //} return; // The user will keep the game frozen. } // The program will succeed in freezing or unfreezing the game. @@@ -1223,8 -1286,8 +1285,8 @@@ if (levelPlayer) { levelPlayer->pause (on_off); } - qCDebug(KGOLDRUNNER_LOG) << "RESULT: gameFrozen" << gameFrozen - << "programFreeze" << programFreeze; - // kDebug() << "RESULT: gameFrozen" << gameFrozen - // << "programFreeze" << programFreeze; ++ //qCDebug(KGOLDRUNNER_LOG) << "RESULT: gameFrozen" << gameFrozen ++ // << "programFreeze" << programFreeze; } void KGrGame::showHint() @@@ -1995,9 -2087,8 +2088,8 @@@ bool KGrGame::initRecordingData (const recording->dateTime = QDateTime::currentDateTime() .toUTC() .toString (Qt::ISODate); - qCDebug(KGOLDRUNNER_LOG) << "Recording at" << recording->dateTime; - // kDebug() << "Recording at" << recording->dateTime; ++ //qCDebug(KGOLDRUNNER_LOG) << "Recording at" << recording->dateTime; - KGrGameData * gameData = gameList.at (gameIndex); recording->owner = gameData->owner; recording->rules = gameData->rules; recording->prefix = gameData->prefix; @@@ -2024,11 -2118,12 +2119,12 @@@ return true; } - void KGrGame::saveRecording() + void KGrGame::saveRecording (const QString & filetype) { - QString filename = userDataDir + "rec_" + prefix + ".txt"; - QString groupName = prefix + QString::number(level).rightJustified(3,'0'); - qCDebug(KGOLDRUNNER_LOG) << filename << groupName; + QString filename = userDataDir + filetype + prefix + ".txt"; + QString groupName = prefix + + QString::number(recording->level).rightJustified(3,'0'); - // kDebug() << filename << groupName; ++ //qCDebug(KGOLDRUNNER_LOG) << filename << groupName; KConfig config (filename, KConfig::SimpleConfig); KConfigGroup configGroup = config.group (groupName); @@@ -2083,10 -2173,14 +2174,14 @@@ bool KGrGame::loadRecording (const QString & dir, const QString & prefix, const int levelNo) { - qCDebug(KGOLDRUNNER_LOG) << prefix << levelNo; - QString filename = dir + "rec_" + prefix + ".txt"; - // kDebug() << prefix << levelNo; ++ //qCDebug(KGOLDRUNNER_LOG) << prefix << levelNo; + QString filename; + if (! getRecordingName (dir, prefix, filename)) { - kDebug() << "No file found by getRecordingName() for" << dir << prefix; ++ qCDebug(KGOLDRUNNER_LOG) << "No file found by getRecordingName() for" << dir << prefix; + return false; + } QString groupName = prefix + QString::number(levelNo).rightJustified(3,'0'); - qCDebug(KGOLDRUNNER_LOG) << filename << groupName; - kDebug() << "loadRecording" << filename << prefix << levelNo << groupName; ++ qCDebug(KGOLDRUNNER_LOG) << "loadRecording" << filename << prefix << levelNo << groupName; KConfig config (filename, KConfig::SimpleConfig); if (! config.hasGroup (groupName)) { @@@ -2126,8 -2224,12 +2225,12 @@@ } } if (index >= 0) { - // Get the current translation of the name of the game. + // Get digWhileFalling flag and current translation of name of game. + recording->digWhileFalling = gameList.at (index)->digWhileFalling; recording->gameName = gameList.at (index)->name; - // kDebug() << "GAME" << gameList.at (index)->name << levelNo ++ // qCDebug(KGOLDRUNNER_LOG) << "GAME" << gameList.at (index)->name << levelNo + // << "set digWhileFalling to" + // << gameList.at (index)->digWhileFalling; // Read the current level data. KGrGameIO io (view); @@@ -2140,6 -2246,10 +2247,10 @@@ i18n (levelData.name.constData()) : ""; recording->hint = (levelData.hint.size() > 0) ? i18n (levelData.hint.constData()) : ""; + recording->digWhileFalling = levelData.digWhileFalling; - // kDebug() << "LEVEL" << gameList.at (index)->name << levelNo ++ // qCDebug(KGOLDRUNNER_LOG) << "LEVEL" << gameList.at (index)->name << levelNo + // << "digWhileFalling is NOW" + // << levelData.digWhileFalling; } } } diff --cc src/kgrgameio.cpp index c673daa,d2b6f9f..07d74eb --- a/src/kgrgameio.cpp +++ b/src/kgrgameio.cpp @@@ -117,7 -112,26 +112,26 @@@ IOStatus KGrGameIO::fetchGameListDat gameName = removeNewline (textLine.right (textLine.size() - n)); g->name = i18n (gameName.constData()); } - // //qCDebug(KGOLDRUNNER_LOG) << "Skill:" << g->skill << "Name:" << g->name; + + // Check for further settings in this game. + // bool usedDwfOpt = false; // For debug. + while ((c = getALine (kgr3Format, textLine)) == '.') { + if (textLine.startsWith ("dwf ")) { + // Dig while falling is allowed in this game, or not. + g->digWhileFalling = textLine.endsWith (" false\n") ? + false : true; + // usedDwfOpt = true; // For debug. + } + } + + if (kgr3Format && (c == ' ')) { + gameName = removeNewline (textLine); + g->name = i18n (gameName.constData()); + c = getALine (kgr3Format, textLine); + } - // qDebug() << "Dig while falling" << g->digWhileFalling ++ //qCDebug(KGOLDRUNNER_LOG) << "Dig while falling" << g->digWhileFalling + // << "usedDwfOpt" << usedDwfOpt << "Game" << g->name; - // kDebug() << "Skill:" << g->skill << "Name:" << g->name; ++ //qCDebug(KGOLDRUNNER_LOG) << "Skill:" << g->skill << "Name:" << g->name; // Loop to accumulate lines of about-data. If kgr3Format, exit on // EOF or 'L' line. If not kgr3Format, exit on EOF or numeric line. @@@ -130,9 -143,10 +143,10 @@@ break; } g->about.append (textLine); + c = getALine (kgr3Format, textLine); } g->about = removeNewline (g->about); // Remove final '\n'. - // kDebug() << "Info about: [" + g->about + "]"; + // //qCDebug(KGOLDRUNNER_LOG) << "Info about: [" + g->about + "]"; if ((! kgr3Format) && (c != '\0')) { filePath = dir + filename; diff --cc src/kgrlevelplayer.cpp index 19c286c,461722e..3de17f9 --- a/src/kgrlevelplayer.cpp +++ b/src/kgrlevelplayer.cpp @@@ -71,30 -71,8 +71,8 @@@ KGrLevelPlayer::~KGrLevelPlayer( { qDeleteAll(dugBricks); dugBricks.clear(); //TODO: necessary? - // kDebug() << "LEVEL PLAYER BEING DELETED."; + //qCDebug(KGOLDRUNNER_LOG) << "LEVEL PLAYER BEING DELETED."; playerCount--; - - // TODO - Remove this debugging code. - if (recording) { - int ch = 0; - for (int i = 0; i <= (recIndex + 1); i ++) { - ch = (uchar)(recording->content.at(i)); - dbe1 "%03d ", ch); - if (ch == 0) - break; - } - dbe1 "\n%d bytes\n", recIndex + 1); - int j = 0; - while (j < recording->draws.size()) { - ch = (uchar)(recording->draws.at(j)); - dbe1 "%03d ", ch); - if (ch == 0) - break; - j++; - } - dbe1 "\n%d bytes\n", j); - } - } void KGrLevelPlayer::init (KGrView * view, diff --cc src/kgrrenderer.cpp index cd2f79e,d01e836..37d49c9 --- a/src/kgrrenderer.cpp +++ b/src/kgrrenderer.cpp @@@ -98,7 -99,7 +98,7 @@@ void KGrRenderer::matchThemes (const Kg void KGrRenderer::currentThemeChanged (const KgTheme* currentSetTheme) { - qCDebug(KGOLDRUNNER_LOG) << "KGrRenderer::currentThemeChanged()" << currentSetTheme->name(); - // qDebug() << "KGrRenderer::currentThemeChanged()" << currentSetTheme->name(); ++ //qCDebug(KGOLDRUNNER_LOG) << "KGrRenderer::currentThemeChanged()" << currentSetTheme->name(); matchThemes (currentSetTheme); m_scene->changeTheme(); @@@ -274,7 -275,7 +274,7 @@@ QString KGrRenderer::getBackgroundKey ( } } - qCDebug(KGOLDRUNNER_LOG) << "BACKGROUND pixmap key" << pixmapKey; - // qDebug() << "BACKGROUND pixmap key" << pixmapKey; ++ //qCDebug(KGOLDRUNNER_LOG) << "BACKGROUND pixmap key" << pixmapKey; return pixmapKey; } diff --cc src/kgrrunner.cpp index d98c7b6,3cf5127..b21d92b --- a/src/kgrrunner.cpp +++ b/src/kgrrunner.cpp @@@ -73,10 -73,10 +73,10 @@@ void KGrRunner::getRules( { pointsPerCell = rules->pointsPerCell(); turnAnywhere = rules->turnAnywhere(); - if (spriteId < 1) { - qCDebug(KGOLDRUNNER_LOG) << "pointsPerCell" << pointsPerCell - << "turnAnywhere" << turnAnywhere; - } - // if (spriteId < 1) { - // kDebug() << "pointsPerCell" << pointsPerCell - // << "turnAnywhere" << turnAnywhere; - // } ++ //if (spriteId < 1) { ++ // qCDebug(KGOLDRUNNER_LOG) << "pointsPerCell" << pointsPerCell ++ // << "turnAnywhere" << turnAnywhere; ++ //} } Situation KGrRunner::situation (const int scaledTime) @@@ -149,7 -149,10 +149,10 @@@ bool KGrRunner::setNextMovement (const interval = runTime; - KGrEnemy * onEnemy = levelPlayer->standOnEnemy (spriteId, gridX, gridY); + // if (spriteType == HERO) { - // kDebug() << "Calling standOnEnemy() for" << gridX << gridY; ++ // qCDebug(KGOLDRUNNER_LOG) << "Calling standOnEnemy() for" << gridX << gridY; + // } + onEnemy = levelPlayer->standOnEnemy (spriteId, gridX, gridY); bool canStand = (OK & dFlag [STAND]) || (OK == 0) || onEnemy; if ((dir == DOWN) && (cellType == BAR)) { canStand = false; @@@ -199,11 -202,14 +202,14 @@@ KGrHero::KGrHero (KGrLevelPlayer * pLev int i, int j, int pSpriteId, KGrRuleBook * pRules) : KGrRunner (pLevelPlayer, pGrid, i, j, pSpriteId, pRules, 0), - nuggets (0) // KGrLevelPlayer object will call hero->setNuggets(). + + // KGrLevelPlayer object will call setDigWhileFalling() and setNuggets(). + digWhileFalling (true), + nuggets (0) { - qCDebug(KGOLDRUNNER_LOG) << "THE HERO IS BORN at" << i << j << "sprite ID" << pSpriteId; - // kDebug() << "THE HERO IS BORN at" << i << j << "sprite ID" << pSpriteId; ++ //qCDebug(KGOLDRUNNER_LOG) << "THE HERO IS BORN at" << i << j << "sprite ID" << pSpriteId; rules->getHeroTimes (runTime, fallTime, enemyFallTime, trapTime); - qCDebug(KGOLDRUNNER_LOG) << "Hero run time" << runTime << "fall time" << fallTime; - // kDebug() << "Hero run time" << runTime << "fall time" << fallTime; ++ //qCDebug(KGOLDRUNNER_LOG) << "Hero run time" << runTime << "fall time" << fallTime; interval = runTime; } @@@ -231,7 -237,9 +237,9 @@@ HeroStatus KGrHero::run (const int scal // Check if we have fallen onto an enemy. If so, continue at enemy-speed. if (falling && (interval != enemyFallTime)) { - if (levelPlayer->standOnEnemy (spriteId, gridX, gridY)) { - // kDebug() << "Calling standOnEnemy() for" << gridX << gridY; ++ // qCDebug(KGOLDRUNNER_LOG) << "Calling standOnEnemy() for" << gridX << gridY; + onEnemy = levelPlayer->standOnEnemy (spriteId, gridX, gridY); + if (onEnemy != 0) { interval = enemyFallTime; // If MidCell, hero-speed animation overshoots, but looks OK. } @@@ -333,6 -341,36 +341,36 @@@ bool KGrHero::dig (const Direction digg i = gridI + relativeI; j = gridJ + 1; result = true; + + // If dig-while-falling is not allowed, prevent attempts to use it. + // The boolean defaults to true but can be read from a setting for + // the game, the specific level or a recording. So it can be false. + if (! digWhileFalling) { + // Work out where the hero WILL be standing when he digs. In the + // second case, he will dig the brick that is now right under him. + int nextGridI = (relativeI != 0) ? (gridI + relativeI/2) : + ((currDirection == LEFT) ? (gridI - 1) : (gridI + 1)); + Flags OK = grid->heroMoves (nextGridI, gridJ); + bool canStand = (OK & dFlag [STAND]) || (OK == 0); + bool enemyUnder = (onEnemy != 0); + // Must be on solid ground or on an enemy (standing or riding down). + if ((! canStand) && (nextGridI != gridI)) { + // If cannot move to next cell and stand, is an enemy under it? - // kDebug() << "Calling standOnEnemy() at gridX" << gridX ++ // qCDebug(KGOLDRUNNER_LOG) << "Calling standOnEnemy() at gridX" << gridX + // << "for" << (nextGridI * pointsPerCell) << gridY; + enemyUnder = (levelPlayer->standOnEnemy (spriteId, + nextGridI * pointsPerCell, gridY) != 0); + } + if ((! canStand) && (! enemyUnder)) { - kDebug() << "INVALID DIG: hero at" << gridI << gridJ ++ qCDebug(KGOLDRUNNER_LOG) << "INVALID DIG: hero at" << gridI << gridJ + << "nextGridI" << nextGridI << "relI" << relativeI + << "dirn" << currDirection << "brick at" << i << j + << "heroMoves" << ((int) OK) << "canStand" << canStand + << "enemyUnder" << enemyUnder; + emit invalidDig(); // Issue warning re dig while falling. + result = false; + } + } } if (result) { emit soundSignal (DigSound); @@@ -363,11 -401,11 +401,11 @@@ KGrEnemy::KGrEnemy (KGrLevelPlayer * pL rulesType = rules->getEnemyTimes (runTime, fallTime, trapTime); enemyFallTime = fallTime; interval = runTime; - qCDebug(KGOLDRUNNER_LOG) << "ENEMY" << pSpriteId << "IS BORN at" << i << j; - if (pSpriteId < 2) { - qCDebug(KGOLDRUNNER_LOG) << "Enemy run time " << runTime << "fall time" << fallTime; - qCDebug(KGOLDRUNNER_LOG) << "Enemy trap time" << trapTime << "Rules type" << rulesType; - } - // kDebug() << "ENEMY" << pSpriteId << "IS BORN at" << i << j; - // if (pSpriteId < 2) { - // kDebug() << "Enemy run time " << runTime << "fall time" << fallTime; - // kDebug() << "Enemy trap time" << trapTime << "Rules type" << rulesType; - // } ++ //qCDebug(KGOLDRUNNER_LOG) << "ENEMY" << pSpriteId << "IS BORN at" << i << j; ++ //if (pSpriteId < 2) { ++ // qCDebug(KGOLDRUNNER_LOG) << "Enemy run time " << runTime << "fall time" << fallTime; ++ // qCDebug(KGOLDRUNNER_LOG) << "Enemy trap time" << trapTime << "Rules type" << rulesType; ++ //} t.start(); // IDW } diff --cc src/kgrscene.cpp index dd97158,2da06e3..f05557e --- a/src/kgrscene.cpp +++ b/src/kgrscene.cpp @@@ -106,7 -108,7 +106,7 @@@ KGrScene::~KGrScene( void KGrScene::redrawScene () { - qCDebug(KGOLDRUNNER_LOG) << "REDRAW: m_sizeChanged" << m_sizeChanged << "m_themeChanged" << m_themeChanged; - // qDebug() << "REDRAW: m_sizeChanged" << m_sizeChanged << "m_themeChanged" << m_themeChanged; ++ //qCDebug(KGOLDRUNNER_LOG) << "REDRAW: m_sizeChanged" << m_sizeChanged << "m_themeChanged" << m_themeChanged; bool redrawToolbar = false; if (m_sizeChanged) { // Calculate what size of tile will fit in the view. @@@ -116,7 -118,7 +116,7 @@@ m_topLeftX = (size.width() - m_tilesWide * tileSize)/2.0; m_topLeftY = (size.height() - m_tilesHigh * tileSize)/2.0; setSceneRect (0, 0, size.width(), size.height()); - qCDebug(KGOLDRUNNER_LOG) << "SIZE" << size << "TL" << m_topLeftX << m_topLeftY << "TILE" << tileSize << "was" << m_tileSize << m_toolbarTileSize; - // qDebug() << "SIZE" << size << "TL" << m_topLeftX << m_topLeftY << "TILE" << tileSize << "was" << m_tileSize << m_toolbarTileSize; ++ //qCDebug(KGOLDRUNNER_LOG) << "SIZE" << size << "TL" << m_topLeftX << m_topLeftY << "TILE" << tileSize << "was" << m_tileSize << m_toolbarTileSize; // Make the fade-out/fade-in rectangle cover the playing area. m_spotlight->setRect (m_topLeftX + 2 * tileSize - 1,
