|
|
@ -44,24 +44,24 @@ KGrGame::KGrGame (KGrCanvas * theView, TQString theSystemDir, TQString theUserDi
|
|
|
|
userDataDir = theUserDir;
|
|
|
|
userDataDir = theUserDir;
|
|
|
|
|
|
|
|
|
|
|
|
// Set the game-editor OFF, but available.
|
|
|
|
// Set the game-editor OFF, but available.
|
|
|
|
editMode = FALSE;
|
|
|
|
editMode = false;
|
|
|
|
paintEditObj = FALSE;
|
|
|
|
paintEditObj = false;
|
|
|
|
editObj = BRICK;
|
|
|
|
editObj = BRICK;
|
|
|
|
shouldSave = FALSE;
|
|
|
|
shouldSave = false;
|
|
|
|
|
|
|
|
|
|
|
|
enemies.setAutoDelete(TRUE);
|
|
|
|
enemies.setAutoDelete(true);
|
|
|
|
|
|
|
|
|
|
|
|
hero = new KGrHero (view, 0, 0); // The hero is born ... Yay !!!
|
|
|
|
hero = new KGrHero (view, 0, 0); // The hero is born ... Yay !!!
|
|
|
|
hero->setPlayfield (&playfield);
|
|
|
|
hero->setPlayfield (&playfield);
|
|
|
|
|
|
|
|
|
|
|
|
setBlankLevel (TRUE); // Fill the playfield with blank walls.
|
|
|
|
setBlankLevel (true); // Fill the playfield with blank walls.
|
|
|
|
|
|
|
|
|
|
|
|
enemy = NULL;
|
|
|
|
enemy = NULL;
|
|
|
|
newLevel = TRUE; // Next level will be a new one.
|
|
|
|
newLevel = true; // Next level will be a new one.
|
|
|
|
loading = TRUE; // Stop input until it is loaded.
|
|
|
|
loading = true; // Stop input until it is loaded.
|
|
|
|
|
|
|
|
|
|
|
|
modalFreeze = FALSE;
|
|
|
|
modalFreeze = false;
|
|
|
|
messageFreeze = FALSE;
|
|
|
|
messageFreeze = false;
|
|
|
|
|
|
|
|
|
|
|
|
connect (hero, TQ_SIGNAL (gotNugget(int)), TQ_SLOT (incScore(int)));
|
|
|
|
connect (hero, TQ_SIGNAL (gotNugget(int)), TQ_SLOT (incScore(int)));
|
|
|
|
connect (hero, TQ_SIGNAL (caughtHero()), TQ_SLOT (herosDead()));
|
|
|
|
connect (hero, TQ_SIGNAL (caughtHero()), TQ_SLOT (herosDead()));
|
|
|
@ -74,7 +74,7 @@ KGrGame::KGrGame (KGrCanvas * theView, TQString theSystemDir, TQString theUserDi
|
|
|
|
// Get the mouse position every 40 msec. It is used to steer the hero.
|
|
|
|
// Get the mouse position every 40 msec. It is used to steer the hero.
|
|
|
|
mouseSampler = new TQTimer (this);
|
|
|
|
mouseSampler = new TQTimer (this);
|
|
|
|
connect (mouseSampler, TQ_SIGNAL(timeout()), TQ_SLOT (readMousePos ()));
|
|
|
|
connect (mouseSampler, TQ_SIGNAL(timeout()), TQ_SLOT (readMousePos ()));
|
|
|
|
mouseSampler->start (40, FALSE);
|
|
|
|
mouseSampler->start (40, false);
|
|
|
|
|
|
|
|
|
|
|
|
srand(1); // initialisiere Random-Generator
|
|
|
|
srand(1); // initialisiere Random-Generator
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -104,7 +104,7 @@ void KGrGame::startNextLevel()
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::startLevel (int startingAt, int requestedLevel)
|
|
|
|
void KGrGame::startLevel (int startingAt, int requestedLevel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (! saveOK (FALSE)) { // Check unsaved work.
|
|
|
|
if (! saveOK (false)) { // Check unsaved work.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Use dialog box to select game and level: startingAt = ID_FIRST or ID_ANY.
|
|
|
|
// Use dialog box to select game and level: startingAt = ID_FIRST or ID_ANY.
|
|
|
@ -135,8 +135,8 @@ void KGrGame::herosDead()
|
|
|
|
if (--lives > 0) {
|
|
|
|
if (--lives > 0) {
|
|
|
|
// Still some life left, so PAUSE and then re-start the level.
|
|
|
|
// Still some life left, so PAUSE and then re-start the level.
|
|
|
|
emit showLives (lives);
|
|
|
|
emit showLives (lives);
|
|
|
|
KGrObject::frozen = TRUE; // Freeze the animation and let
|
|
|
|
KGrObject::frozen = true; // Freeze the animation and let
|
|
|
|
dyingTimer->start (1500, TRUE); // the player see what happened.
|
|
|
|
dyingTimer->start (1500, true); // the player see what happened.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
// Game over: display the "ENDE" screen.
|
|
|
|
// Game over: display the "ENDE" screen.
|
|
|
@ -150,10 +150,10 @@ void KGrGame::herosDead()
|
|
|
|
enemies.clear(); // Stop the enemies catching the hero again ...
|
|
|
|
enemies.clear(); // Stop the enemies catching the hero again ...
|
|
|
|
view->deleteEnemySprites();
|
|
|
|
view->deleteEnemySprites();
|
|
|
|
unfreeze(); // ... NOW we can unfreeze.
|
|
|
|
unfreeze(); // ... NOW we can unfreeze.
|
|
|
|
newLevel = TRUE;
|
|
|
|
newLevel = true;
|
|
|
|
level = 0;
|
|
|
|
level = 0;
|
|
|
|
loadLevel (level); // Display the "ENDE" screen.
|
|
|
|
loadLevel (level); // Display the "ENDE" screen.
|
|
|
|
newLevel = FALSE;
|
|
|
|
newLevel = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -165,7 +165,7 @@ void KGrGame::finalBreath()
|
|
|
|
enemyCount = 0; // Hero is dead: re-start the level.
|
|
|
|
enemyCount = 0; // Hero is dead: re-start the level.
|
|
|
|
loadLevel (level);
|
|
|
|
loadLevel (level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
KGrObject::frozen = FALSE; // Unfreeze the game, but don't move yet.
|
|
|
|
KGrObject::frozen = false; // Unfreeze the game, but don't move yet.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::showHiddenLadders()
|
|
|
|
void KGrGame::showHiddenLadders()
|
|
|
@ -204,9 +204,9 @@ void KGrGame::goUpOneLevel()
|
|
|
|
enemyCount = 0;
|
|
|
|
enemyCount = 0;
|
|
|
|
enemies.clear();
|
|
|
|
enemies.clear();
|
|
|
|
view->deleteEnemySprites();
|
|
|
|
view->deleteEnemySprites();
|
|
|
|
newLevel = TRUE;
|
|
|
|
newLevel = true;
|
|
|
|
loadLevel (level);
|
|
|
|
loadLevel (level);
|
|
|
|
newLevel = FALSE;
|
|
|
|
newLevel = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::loseNugget()
|
|
|
|
void KGrGame::loseNugget()
|
|
|
@ -226,17 +226,17 @@ int KGrGame::getLevel() // Return the current game-level.
|
|
|
|
|
|
|
|
|
|
|
|
bool KGrGame::inMouseMode()
|
|
|
|
bool KGrGame::inMouseMode()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (mouseMode); // Return TRUE if game is under mouse control.
|
|
|
|
return (mouseMode); // Return true if game is under mouse control.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KGrGame::inEditMode()
|
|
|
|
bool KGrGame::inEditMode()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (editMode); // Return TRUE if the game-editor is active.
|
|
|
|
return (editMode); // Return true if the game-editor is active.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KGrGame::isLoading()
|
|
|
|
bool KGrGame::isLoading()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (loading); // Return TRUE if a level is being loaded.
|
|
|
|
return (loading); // Return true if a level is being loaded.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::setMouseMode (bool on_off)
|
|
|
|
void KGrGame::setMouseMode (bool on_off)
|
|
|
@ -247,33 +247,33 @@ void KGrGame::setMouseMode (bool on_off)
|
|
|
|
void KGrGame::freeze()
|
|
|
|
void KGrGame::freeze()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((! modalFreeze) && (! messageFreeze)) {
|
|
|
|
if ((! modalFreeze) && (! messageFreeze)) {
|
|
|
|
emit gameFreeze (TRUE); // Do visual feedback in the GUI.
|
|
|
|
emit gameFreeze (true); // Do visual feedback in the GUI.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
KGrObject::frozen = TRUE; // Halt the game, by blocking all timer events.
|
|
|
|
KGrObject::frozen = true; // Halt the game, by blocking all timer events.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::unfreeze()
|
|
|
|
void KGrGame::unfreeze()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((! modalFreeze) && (! messageFreeze)) {
|
|
|
|
if ((! modalFreeze) && (! messageFreeze)) {
|
|
|
|
emit gameFreeze (FALSE);// Do visual feedback in the GUI.
|
|
|
|
emit gameFreeze (false);// Do visual feedback in the GUI.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
KGrObject::frozen = FALSE; // Restart the game. Because frozen == FALSE,
|
|
|
|
KGrObject::frozen = false; // Restart the game. Because frozen == false,
|
|
|
|
restart(); // the game goes on running after the next step.
|
|
|
|
restart(); // the game goes on running after the next step.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::setMessageFreeze (bool on_off)
|
|
|
|
void KGrGame::setMessageFreeze (bool on_off)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (on_off) { // Freeze the game action during a message.
|
|
|
|
if (on_off) { // Freeze the game action during a message.
|
|
|
|
messageFreeze = FALSE;
|
|
|
|
messageFreeze = false;
|
|
|
|
if (! KGrObject::frozen) {
|
|
|
|
if (! KGrObject::frozen) {
|
|
|
|
messageFreeze = TRUE;
|
|
|
|
messageFreeze = true;
|
|
|
|
freeze();
|
|
|
|
freeze();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // Unfreeze the game action after a message.
|
|
|
|
else { // Unfreeze the game action after a message.
|
|
|
|
if (messageFreeze) {
|
|
|
|
if (messageFreeze) {
|
|
|
|
unfreeze();
|
|
|
|
unfreeze();
|
|
|
|
messageFreeze = FALSE;
|
|
|
|
messageFreeze = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -318,19 +318,19 @@ void KGrGame::setBlankLevel(bool playable)
|
|
|
|
void KGrGame::newGame (const int lev, const int gameIndex)
|
|
|
|
void KGrGame::newGame (const int lev, const int gameIndex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Ignore player input from keyboard or mouse while the screen is set up.
|
|
|
|
// Ignore player input from keyboard or mouse while the screen is set up.
|
|
|
|
loading = TRUE; // "loadLevel (level)" will reset it.
|
|
|
|
loading = true; // "loadLevel (level)" will reset it.
|
|
|
|
|
|
|
|
|
|
|
|
if (editMode) {
|
|
|
|
if (editMode) {
|
|
|
|
emit setEditMenu (FALSE); // Disable edit menu items and toolbar.
|
|
|
|
emit setEditMenu (false); // Disable edit menu items and toolbar.
|
|
|
|
|
|
|
|
|
|
|
|
editMode = FALSE;
|
|
|
|
editMode = false;
|
|
|
|
paintEditObj = FALSE;
|
|
|
|
paintEditObj = false;
|
|
|
|
editObj = BRICK;
|
|
|
|
editObj = BRICK;
|
|
|
|
|
|
|
|
|
|
|
|
view->setHeroVisible (TRUE);
|
|
|
|
view->setHeroVisible (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
newLevel = TRUE;
|
|
|
|
newLevel = true;
|
|
|
|
level = lev;
|
|
|
|
level = lev;
|
|
|
|
collnIndex = gameIndex;
|
|
|
|
collnIndex = gameIndex;
|
|
|
|
collection = collections.at (collnIndex);
|
|
|
|
collection = collections.at (collnIndex);
|
|
|
@ -348,26 +348,26 @@ void KGrGame::newGame (const int lev, const int gameIndex)
|
|
|
|
enemies.clear();
|
|
|
|
enemies.clear();
|
|
|
|
view->deleteEnemySprites();
|
|
|
|
view->deleteEnemySprites();
|
|
|
|
|
|
|
|
|
|
|
|
newLevel = TRUE;;
|
|
|
|
newLevel = true;;
|
|
|
|
loadLevel (level);
|
|
|
|
loadLevel (level);
|
|
|
|
newLevel = FALSE;
|
|
|
|
newLevel = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::startTutorial()
|
|
|
|
void KGrGame::startTutorial()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (! saveOK (FALSE)) { // Check unsaved work.
|
|
|
|
if (! saveOK (false)) { // Check unsaved work.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int i, index;
|
|
|
|
int i, index;
|
|
|
|
int imax = collections.count();
|
|
|
|
int imax = collections.count();
|
|
|
|
bool found = FALSE;
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
index = 0;
|
|
|
|
for (i = 0; i < imax; i++) {
|
|
|
|
for (i = 0; i < imax; i++) {
|
|
|
|
index = i; // Index within owner.
|
|
|
|
index = i; // Index within owner.
|
|
|
|
if (collections.at(i)->prefix == "tute") {
|
|
|
|
if (collections.at(i)->prefix == "tute") {
|
|
|
|
found = TRUE;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -410,7 +410,7 @@ int KGrGame::loadLevel (int levelNo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Ignore player input from keyboard or mouse while the screen is set up.
|
|
|
|
// Ignore player input from keyboard or mouse while the screen is set up.
|
|
|
|
loading = TRUE;
|
|
|
|
loading = true;
|
|
|
|
|
|
|
|
|
|
|
|
nuggets = 0;
|
|
|
|
nuggets = 0;
|
|
|
|
enemyCount=0;
|
|
|
|
enemyCount=0;
|
|
|
@ -494,7 +494,7 @@ int KGrGame::loadLevel (int levelNo)
|
|
|
|
connect (view, TQ_SIGNAL(mouseClick(int)), TQ_SLOT(doDig(int)));
|
|
|
|
connect (view, TQ_SIGNAL(mouseClick(int)), TQ_SLOT(doDig(int)));
|
|
|
|
|
|
|
|
|
|
|
|
// Re-enable player input.
|
|
|
|
// Re-enable player input.
|
|
|
|
loading = FALSE;
|
|
|
|
loading = false;
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -515,17 +515,17 @@ bool KGrGame::openLevelFile (int levelNo, TQFile & openlevel)
|
|
|
|
i18n("Cannot find file '%1'. Please make sure '%2' has been "
|
|
|
|
i18n("Cannot find file '%1'. Please make sure '%2' has been "
|
|
|
|
"run in the '%3' folder.")
|
|
|
|
"run in the '%3' folder.")
|
|
|
|
.arg(filePath).arg("tar xf levels.tar").arg(systemDataDir.myStr()));
|
|
|
|
.arg(filePath).arg("tar xf levels.tar").arg(systemDataDir.myStr()));
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20>ffne Level zum lesen
|
|
|
|
// <20>ffne Level zum lesen
|
|
|
|
if (! openlevel.open (IO_ReadOnly)) {
|
|
|
|
if (! openlevel.open (IO_ReadOnly)) {
|
|
|
|
KGrMessage::information (view, i18n("Load Level"),
|
|
|
|
KGrMessage::information (view, i18n("Load Level"),
|
|
|
|
i18n("Cannot open file '%1' for read-only.").arg(filePath));
|
|
|
|
i18n("Cannot open file '%1' for read-only.").arg(filePath));
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (TRUE);
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::changeObject (unsigned char kind, int i, int j)
|
|
|
|
void KGrGame::changeObject (unsigned char kind, int i, int j)
|
|
|
@ -544,7 +544,7 @@ void KGrGame::changeObject (unsigned char kind, int i, int j)
|
|
|
|
case HERO: createObject(new KGrFree (FREE,i,j,view),FREE,i,j);
|
|
|
|
case HERO: createObject(new KGrFree (FREE,i,j,view),FREE,i,j);
|
|
|
|
hero->init(i,j);
|
|
|
|
hero->init(i,j);
|
|
|
|
startI = i; startJ = j;
|
|
|
|
startI = i; startJ = j;
|
|
|
|
hero->started = FALSE;
|
|
|
|
hero->started = false;
|
|
|
|
hero->showFigure();
|
|
|
|
hero->showFigure();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ENEMY: createObject(new KGrFree (FREE,i,j,view),FREE,i,j);
|
|
|
|
case ENEMY: createObject(new KGrFree (FREE,i,j,view),FREE,i,j);
|
|
|
@ -826,14 +826,14 @@ void KGrGame::saveGame() // Save game ID, score and level.
|
|
|
|
file2.close();
|
|
|
|
file2.close();
|
|
|
|
|
|
|
|
|
|
|
|
TQDir dir;
|
|
|
|
TQDir dir;
|
|
|
|
dir.rename (file2.name(), file1.name(), TRUE);
|
|
|
|
dir.rename (file2.name(), file1.name(), true);
|
|
|
|
KGrMessage::information (view, i18n("Save Game"),
|
|
|
|
KGrMessage::information (view, i18n("Save Game"),
|
|
|
|
i18n("Your game has been saved."));
|
|
|
|
i18n("Your game has been saved."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::loadGame() // Re-load game, score and level.
|
|
|
|
void KGrGame::loadGame() // Re-load game, score and level.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (! saveOK (FALSE)) { // Check unsaved work.
|
|
|
|
if (! saveOK (false)) { // Check unsaved work.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -853,9 +853,9 @@ void KGrGame::loadGame() // Re-load game, score and level.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Halt the game during the loadGame() dialog.
|
|
|
|
// Halt the game during the loadGame() dialog.
|
|
|
|
modalFreeze = FALSE;
|
|
|
|
modalFreeze = false;
|
|
|
|
if (!KGrObject::frozen) {
|
|
|
|
if (!KGrObject::frozen) {
|
|
|
|
modalFreeze = TRUE;
|
|
|
|
modalFreeze = true;
|
|
|
|
freeze();
|
|
|
|
freeze();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -868,7 +868,7 @@ void KGrGame::loadGame() // Re-load game, score and level.
|
|
|
|
s = lg->getCurrentText();
|
|
|
|
s = lg->getCurrentText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool found = FALSE;
|
|
|
|
bool found = false;
|
|
|
|
TQString pr;
|
|
|
|
TQString pr;
|
|
|
|
int lev;
|
|
|
|
int lev;
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
@ -876,14 +876,14 @@ void KGrGame::loadGame() // Re-load game, score and level.
|
|
|
|
|
|
|
|
|
|
|
|
if (! s.isNull()) {
|
|
|
|
if (! s.isNull()) {
|
|
|
|
pr = s.mid (21, 7); // Get the collection prefix.
|
|
|
|
pr = s.mid (21, 7); // Get the collection prefix.
|
|
|
|
pr = pr.left (pr.find (" ", 0, FALSE));
|
|
|
|
pr = pr.left (pr.find (" ", 0, false));
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < imax; i++) { // Find the collection.
|
|
|
|
for (i = 0; i < imax; i++) { // Find the collection.
|
|
|
|
if (collections.at(i)->prefix == pr) {
|
|
|
|
if (collections.at(i)->prefix == pr) {
|
|
|
|
collection = collections.at(i);
|
|
|
|
collection = collections.at(i);
|
|
|
|
collnIndex = i;
|
|
|
|
collnIndex = i;
|
|
|
|
owner = collections.at(i)->owner;
|
|
|
|
owner = collections.at(i)->owner;
|
|
|
|
found = TRUE;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -906,7 +906,7 @@ void KGrGame::loadGame() // Re-load game, score and level.
|
|
|
|
// Unfreeze the game, but only if it was previously unfrozen.
|
|
|
|
// Unfreeze the game, but only if it was previously unfrozen.
|
|
|
|
if (modalFreeze) {
|
|
|
|
if (modalFreeze) {
|
|
|
|
unfreeze();
|
|
|
|
unfreeze();
|
|
|
|
modalFreeze = FALSE;
|
|
|
|
modalFreeze = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delete lg;
|
|
|
|
delete lg;
|
|
|
@ -918,7 +918,7 @@ void KGrGame::loadGame() // Re-load game, score and level.
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::checkHighScore()
|
|
|
|
void KGrGame::checkHighScore()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool prevHigh = TRUE;
|
|
|
|
bool prevHigh = true;
|
|
|
|
TQ_INT16 prevLevel = 0;
|
|
|
|
TQ_INT16 prevLevel = 0;
|
|
|
|
TQ_INT32 prevScore = 0;
|
|
|
|
TQ_INT32 prevScore = 0;
|
|
|
|
TQString thisUser = i18n("Unknown");
|
|
|
|
TQString thisUser = i18n("Unknown");
|
|
|
@ -938,7 +938,7 @@ void KGrGame::checkHighScore()
|
|
|
|
if (! high1.exists()) {
|
|
|
|
if (! high1.exists()) {
|
|
|
|
high1.setName (systemDataDir + "hi_" + collection->prefix + ".dat");
|
|
|
|
high1.setName (systemDataDir + "hi_" + collection->prefix + ".dat");
|
|
|
|
if (! high1.exists()) {
|
|
|
|
if (! high1.exists()) {
|
|
|
|
prevHigh = FALSE;
|
|
|
|
prevHigh = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -953,7 +953,7 @@ void KGrGame::checkHighScore()
|
|
|
|
|
|
|
|
|
|
|
|
// Read previous users, levels and scores from the high score file.
|
|
|
|
// Read previous users, levels and scores from the high score file.
|
|
|
|
s1.setDevice (&high1);
|
|
|
|
s1.setDevice (&high1);
|
|
|
|
bool found = FALSE;
|
|
|
|
bool found = false;
|
|
|
|
highCount = 0;
|
|
|
|
highCount = 0;
|
|
|
|
while (! s1.endData()) {
|
|
|
|
while (! s1.endData()) {
|
|
|
|
char * prevUser;
|
|
|
|
char * prevUser;
|
|
|
@ -966,7 +966,7 @@ void KGrGame::checkHighScore()
|
|
|
|
delete prevDate;
|
|
|
|
delete prevDate;
|
|
|
|
highCount++;
|
|
|
|
highCount++;
|
|
|
|
if (score > prevScore) {
|
|
|
|
if (score > prevScore) {
|
|
|
|
found = TRUE; // We have a high score.
|
|
|
|
found = true; // We have a high score.
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -992,7 +992,7 @@ void KGrGame::checkHighScore()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Dialog to ask the user to enter their name.
|
|
|
|
// Dialog to ask the user to enter their name.
|
|
|
|
TQDialog * hsn = new TQDialog (view, "hsNameDialog", TRUE,
|
|
|
|
TQDialog * hsn = new TQDialog (view, "hsNameDialog", true,
|
|
|
|
WStyle_Customize | WStyle_NormalBorder | WStyle_Title);
|
|
|
|
WStyle_Customize | WStyle_NormalBorder | WStyle_Title);
|
|
|
|
|
|
|
|
|
|
|
|
int margin = 10;
|
|
|
|
int margin = 10;
|
|
|
@ -1023,7 +1023,7 @@ void KGrGame::checkHighScore()
|
|
|
|
connect (hsnUser, TQ_SIGNAL (returnPressed ()), hsn, TQ_SLOT (accept ()));
|
|
|
|
connect (hsnUser, TQ_SIGNAL (returnPressed ()), hsn, TQ_SLOT (accept ()));
|
|
|
|
connect (OK, TQ_SIGNAL (clicked ()), hsn, TQ_SLOT (accept ()));
|
|
|
|
connect (OK, TQ_SIGNAL (clicked ()), hsn, TQ_SLOT (accept ()));
|
|
|
|
|
|
|
|
|
|
|
|
while (TRUE) {
|
|
|
|
while (true) {
|
|
|
|
hsn->exec();
|
|
|
|
hsn->exec();
|
|
|
|
thisUser = hsnUser->text();
|
|
|
|
thisUser = hsnUser->text();
|
|
|
|
if (thisUser.length() > 0)
|
|
|
|
if (thisUser.length() > 0)
|
|
|
@ -1050,7 +1050,7 @@ void KGrGame::checkHighScore()
|
|
|
|
|
|
|
|
|
|
|
|
if (prevHigh) {
|
|
|
|
if (prevHigh) {
|
|
|
|
high1.reset();
|
|
|
|
high1.reset();
|
|
|
|
bool scoreRecorded = FALSE;
|
|
|
|
bool scoreRecorded = false;
|
|
|
|
highCount = 0;
|
|
|
|
highCount = 0;
|
|
|
|
while ((! s1.endData()) && (highCount < 10)) {
|
|
|
|
while ((! s1.endData()) && (highCount < 10)) {
|
|
|
|
char * prevUser;
|
|
|
|
char * prevUser;
|
|
|
@ -1067,7 +1067,7 @@ void KGrGame::checkHighScore()
|
|
|
|
s2 << (TQ_INT16) level;
|
|
|
|
s2 << (TQ_INT16) level;
|
|
|
|
s2 << (TQ_INT32) score;
|
|
|
|
s2 << (TQ_INT32) score;
|
|
|
|
s2 << hsDate.myStr();
|
|
|
|
s2 << hsDate.myStr();
|
|
|
|
scoreRecorded = TRUE;
|
|
|
|
scoreRecorded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (highCount < 10) {
|
|
|
|
if (highCount < 10) {
|
|
|
|
highCount++;
|
|
|
|
highCount++;
|
|
|
@ -1102,7 +1102,7 @@ void KGrGame::checkHighScore()
|
|
|
|
|
|
|
|
|
|
|
|
TQDir dir;
|
|
|
|
TQDir dir;
|
|
|
|
dir.rename (high2.name(),
|
|
|
|
dir.rename (high2.name(),
|
|
|
|
userDataDir + "hi_" + collection->prefix + ".dat", TRUE);
|
|
|
|
userDataDir + "hi_" + collection->prefix + ".dat", true);
|
|
|
|
KGrMessage::information (view, i18n("Save High Score"),
|
|
|
|
KGrMessage::information (view, i18n("Save High Score"),
|
|
|
|
i18n("Your high score has been saved."));
|
|
|
|
i18n("Your high score has been saved."));
|
|
|
|
|
|
|
|
|
|
|
@ -1144,7 +1144,7 @@ void KGrGame::showHighScores()
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQDialog * hs = new TQDialog (view, "hsDialog", TRUE,
|
|
|
|
TQDialog * hs = new TQDialog (view, "hsDialog", true,
|
|
|
|
WStyle_Customize | WStyle_NormalBorder | WStyle_Title);
|
|
|
|
WStyle_Customize | WStyle_NormalBorder | WStyle_Title);
|
|
|
|
|
|
|
|
|
|
|
|
int margin = 10;
|
|
|
|
int margin = 10;
|
|
|
@ -1164,8 +1164,8 @@ void KGrGame::showHighScores()
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
TQFont f = TDEGlobalSettings::fixedFont(); // KDE version.
|
|
|
|
TQFont f = TDEGlobalSettings::fixedFont(); // KDE version.
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
f. setFixedPitch (TRUE);
|
|
|
|
f. setFixedPitch (true);
|
|
|
|
f. setBold (TRUE);
|
|
|
|
f. setBold (true);
|
|
|
|
hsColHeader-> setFont (f);
|
|
|
|
hsColHeader-> setFont (f);
|
|
|
|
|
|
|
|
|
|
|
|
TQLabel * hsLine [10];
|
|
|
|
TQLabel * hsLine [10];
|
|
|
@ -1182,7 +1182,7 @@ void KGrGame::showHighScores()
|
|
|
|
OK-> setAccel (Key_Return);
|
|
|
|
OK-> setAccel (Key_Return);
|
|
|
|
|
|
|
|
|
|
|
|
// Set up the format for the high-score lines.
|
|
|
|
// Set up the format for the high-score lines.
|
|
|
|
f. setBold (FALSE);
|
|
|
|
f. setBold (false);
|
|
|
|
TQString line;
|
|
|
|
TQString line;
|
|
|
|
const char * hsFormat = "%2d. %-30.30s %3d %7ld %s";
|
|
|
|
const char * hsFormat = "%2d. %-30.30s %3d %7ld %s";
|
|
|
|
|
|
|
|
|
|
|
@ -1250,7 +1250,7 @@ void KGrGame::restart()
|
|
|
|
|
|
|
|
|
|
|
|
temp = KGrObject::frozen;
|
|
|
|
temp = KGrObject::frozen;
|
|
|
|
|
|
|
|
|
|
|
|
KGrObject::frozen = FALSE; // Temporarily restart the game, by re-running
|
|
|
|
KGrObject::frozen = false; // Temporarily restart the game, by re-running
|
|
|
|
// any timer events that have been blocked.
|
|
|
|
// any timer events that have been blocked.
|
|
|
|
|
|
|
|
|
|
|
|
readMousePos(); // Set hero's direction.
|
|
|
|
readMousePos(); // Set hero's direction.
|
|
|
@ -1270,7 +1270,7 @@ void KGrGame::restart()
|
|
|
|
((KGrBrick *)playfield[i][j])->doStep();
|
|
|
|
((KGrBrick *)playfield[i][j])->doStep();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KGrObject::frozen = temp; // If frozen was TRUE, halt again, which gives a
|
|
|
|
KGrObject::frozen = temp; // If frozen was true, halt again, which gives a
|
|
|
|
// single-step effect, otherwise go on running.
|
|
|
|
// single-step effect, otherwise go on running.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1323,7 +1323,7 @@ void KGrGame::showObjectState()
|
|
|
|
void KGrGame::bugFix()
|
|
|
|
void KGrGame::bugFix()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (KGrObject::frozen) { // Toggle a bug fix on/off dynamically.
|
|
|
|
if (KGrObject::frozen) { // Toggle a bug fix on/off dynamically.
|
|
|
|
KGrObject::bugFixed = (KGrObject::bugFixed) ? FALSE : TRUE;
|
|
|
|
KGrObject::bugFixed = (KGrObject::bugFixed) ? false : true;
|
|
|
|
printf ("%s", (KGrObject::bugFixed) ? "\n" : "");
|
|
|
|
printf ("%s", (KGrObject::bugFixed) ? "\n" : "");
|
|
|
|
printf (">>> Bug fix is %s\n", (KGrObject::bugFixed) ? "ON" : "OFF\n");
|
|
|
|
printf (">>> Bug fix is %s\n", (KGrObject::bugFixed) ? "ON" : "OFF\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1332,7 +1332,7 @@ void KGrGame::bugFix()
|
|
|
|
void KGrGame::startLogging()
|
|
|
|
void KGrGame::startLogging()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (KGrObject::frozen) { // Toggle logging on/off dynamically.
|
|
|
|
if (KGrObject::frozen) { // Toggle logging on/off dynamically.
|
|
|
|
KGrObject::logging = (KGrObject::logging) ? FALSE : TRUE;
|
|
|
|
KGrObject::logging = (KGrObject::logging) ? false : true;
|
|
|
|
printf ("%s", (KGrObject::logging) ? "\n" : "");
|
|
|
|
printf ("%s", (KGrObject::logging) ? "\n" : "");
|
|
|
|
printf (">>> Logging is %s\n", (KGrObject::logging) ? "ON" : "OFF\n");
|
|
|
|
printf (">>> Logging is %s\n", (KGrObject::logging) ? "ON" : "OFF\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1351,7 +1351,7 @@ void KGrGame::createLevel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
|
|
|
|
if (! saveOK (FALSE)) { // Check unsaved work.
|
|
|
|
if (! saveOK (false)) { // Check unsaved work.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1364,7 +1364,7 @@ void KGrGame::createLevel()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Ignore player input from keyboard or mouse while the screen is set up.
|
|
|
|
// Ignore player input from keyboard or mouse while the screen is set up.
|
|
|
|
loading = TRUE;
|
|
|
|
loading = true;
|
|
|
|
|
|
|
|
|
|
|
|
level = 0;
|
|
|
|
level = 0;
|
|
|
|
initEdit();
|
|
|
|
initEdit();
|
|
|
@ -1392,7 +1392,7 @@ void KGrGame::createLevel()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Re-enable player input.
|
|
|
|
// Re-enable player input.
|
|
|
|
loading = FALSE;
|
|
|
|
loading = false;
|
|
|
|
|
|
|
|
|
|
|
|
view->updateCanvas(); // Show the edit area.
|
|
|
|
view->updateCanvas(); // Show the edit area.
|
|
|
|
view->update(); // Show the level name.
|
|
|
|
view->update(); // Show the level name.
|
|
|
@ -1400,7 +1400,7 @@ void KGrGame::createLevel()
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::updateLevel()
|
|
|
|
void KGrGame::updateLevel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (! saveOK (FALSE)) { // Check unsaved work.
|
|
|
|
if (! saveOK (false)) { // Check unsaved work.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1429,7 +1429,7 @@ void KGrGame::updateLevel()
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::updateNext()
|
|
|
|
void KGrGame::updateNext()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (! saveOK (FALSE)) { // Check unsaved work.
|
|
|
|
if (! saveOK (false)) { // Check unsaved work.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
level++;
|
|
|
|
level++;
|
|
|
@ -1445,7 +1445,7 @@ void KGrGame::loadEditLevel (int lev)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Ignore player input from keyboard or mouse while the screen is set up.
|
|
|
|
// Ignore player input from keyboard or mouse while the screen is set up.
|
|
|
|
loading = TRUE;
|
|
|
|
loading = true;
|
|
|
|
|
|
|
|
|
|
|
|
level = lev;
|
|
|
|
level = lev;
|
|
|
|
initEdit();
|
|
|
|
initEdit();
|
|
|
@ -1498,7 +1498,7 @@ void KGrGame::loadEditLevel (int lev)
|
|
|
|
showEditLevel(); // Reconnect signals.
|
|
|
|
showEditLevel(); // Reconnect signals.
|
|
|
|
|
|
|
|
|
|
|
|
// Re-enable player input.
|
|
|
|
// Re-enable player input.
|
|
|
|
loading = FALSE;
|
|
|
|
loading = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::editNameAndHint()
|
|
|
|
void KGrGame::editNameAndHint()
|
|
|
@ -1512,7 +1512,7 @@ void KGrGame::editNameAndHint()
|
|
|
|
if (nh->exec() == TQDialog::Accepted) {
|
|
|
|
if (nh->exec() == TQDialog::Accepted) {
|
|
|
|
levelName = nh->getName();
|
|
|
|
levelName = nh->getName();
|
|
|
|
levelHint = nh->getHint();
|
|
|
|
levelHint = nh->getHint();
|
|
|
|
shouldSave = TRUE;
|
|
|
|
shouldSave = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delete nh;
|
|
|
|
delete nh;
|
|
|
@ -1530,7 +1530,7 @@ bool KGrGame::saveLevelFile()
|
|
|
|
if (! editMode) {
|
|
|
|
if (! editMode) {
|
|
|
|
KGrMessage::information (view, i18n("Save Level"),
|
|
|
|
KGrMessage::information (view, i18n("Save Level"),
|
|
|
|
i18n("Inappropriate action: you are not editing a level."));
|
|
|
|
i18n("Inappropriate action: you are not editing a level."));
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Save the current collection index.
|
|
|
|
// Save the current collection index.
|
|
|
@ -1548,7 +1548,7 @@ bool KGrGame::saveLevelFile()
|
|
|
|
// Pop up dialog box, which could change the collection or level or both.
|
|
|
|
// Pop up dialog box, which could change the collection or level or both.
|
|
|
|
selectedLevel = selectLevel (action, selectedLevel);
|
|
|
|
selectedLevel = selectLevel (action, selectedLevel);
|
|
|
|
if (selectedLevel == 0)
|
|
|
|
if (selectedLevel == 0)
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
|
|
|
|
|
|
|
|
// Get the new collection (if changed).
|
|
|
|
// Get the new collection (if changed).
|
|
|
|
int n = collnIndex;
|
|
|
|
int n = collnIndex;
|
|
|
@ -1559,10 +1559,10 @@ bool KGrGame::saveLevelFile()
|
|
|
|
|
|
|
|
|
|
|
|
if ((action == SL_SAVE) && (n == N) && (selectedLevel == level)) {
|
|
|
|
if ((action == SL_SAVE) && (n == N) && (selectedLevel == level)) {
|
|
|
|
// This is a normal edit: the old file is to be re-written.
|
|
|
|
// This is a normal edit: the old file is to be re-written.
|
|
|
|
isNew = FALSE;
|
|
|
|
isNew = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
isNew = TRUE;
|
|
|
|
isNew = true;
|
|
|
|
// Check if the file is to be inserted in or appended to the collection.
|
|
|
|
// Check if the file is to be inserted in or appended to the collection.
|
|
|
|
if (levelFile.exists()) {
|
|
|
|
if (levelFile.exists()) {
|
|
|
|
switch (KGrMessage::warning (view, i18n("Save Level"),
|
|
|
|
switch (KGrMessage::warning (view, i18n("Save Level"),
|
|
|
@ -1572,10 +1572,10 @@ bool KGrGame::saveLevelFile()
|
|
|
|
|
|
|
|
|
|
|
|
case 0: if (! reNumberLevels (n, selectedLevel,
|
|
|
|
case 0: if (! reNumberLevels (n, selectedLevel,
|
|
|
|
collections.at(n)->nLevels, +1)) {
|
|
|
|
collections.at(n)->nLevels, +1)) {
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 1: return (FALSE);
|
|
|
|
case 1: return (false);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1585,7 +1585,7 @@ bool KGrGame::saveLevelFile()
|
|
|
|
if (! levelFile.open (IO_WriteOnly)) {
|
|
|
|
if (! levelFile.open (IO_WriteOnly)) {
|
|
|
|
KGrMessage::information (view, i18n("Save Level"),
|
|
|
|
KGrMessage::information (view, i18n("Save Level"),
|
|
|
|
i18n("Cannot open file '%1' for output.").arg(filePath));
|
|
|
|
i18n("Cannot open file '%1' for output.").arg(filePath));
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Save the level.
|
|
|
|
// Save the level.
|
|
|
@ -1622,7 +1622,7 @@ bool KGrGame::saveLevelFile()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
levelFile.close ();
|
|
|
|
levelFile.close ();
|
|
|
|
shouldSave = FALSE;
|
|
|
|
shouldSave = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (isNew) {
|
|
|
|
if (isNew) {
|
|
|
|
collections.at(n)->nLevels++;
|
|
|
|
collections.at(n)->nLevels++;
|
|
|
@ -1633,7 +1633,7 @@ bool KGrGame::saveLevelFile()
|
|
|
|
emit showLevel (level);
|
|
|
|
emit showLevel (level);
|
|
|
|
view->setTitle (getTitle()); // Display new title.
|
|
|
|
view->setTitle (getTitle()); // Display new title.
|
|
|
|
view->updateCanvas(); // Show the edit area.
|
|
|
|
view->updateCanvas(); // Show the edit area.
|
|
|
|
return (TRUE);
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::moveLevelFile ()
|
|
|
|
void KGrGame::moveLevelFile ()
|
|
|
@ -1690,7 +1690,7 @@ void KGrGame::moveLevelFile ()
|
|
|
|
filePath1 = getFilePath (USER, collections.at(fromC), fromL);
|
|
|
|
filePath1 = getFilePath (USER, collections.at(fromC), fromL);
|
|
|
|
filePath2 = filePath1;
|
|
|
|
filePath2 = filePath1;
|
|
|
|
filePath2 = filePath2.append (".tmp");
|
|
|
|
filePath2 = filePath2.append (".tmp");
|
|
|
|
dir.rename (filePath1, filePath2, TRUE);
|
|
|
|
dir.rename (filePath1, filePath2, true);
|
|
|
|
|
|
|
|
|
|
|
|
if (toC == fromC) { // Same collection.
|
|
|
|
if (toC == fromC) { // Same collection.
|
|
|
|
if (toL < fromL) { // Decrease level.
|
|
|
|
if (toL < fromL) { // Decrease level.
|
|
|
@ -1725,7 +1725,7 @@ void KGrGame::moveLevelFile ()
|
|
|
|
|
|
|
|
|
|
|
|
// Rename the saved "fromL" file to become "toL".
|
|
|
|
// Rename the saved "fromL" file to become "toL".
|
|
|
|
filePath1 = getFilePath (USER, collections.at(toC), toL);
|
|
|
|
filePath1 = getFilePath (USER, collections.at(toC), toL);
|
|
|
|
dir.rename (filePath2, filePath1, TRUE);
|
|
|
|
dir.rename (filePath2, filePath1, true);
|
|
|
|
|
|
|
|
|
|
|
|
level = toL;
|
|
|
|
level = toL;
|
|
|
|
collection = collections.at(toC);
|
|
|
|
collection = collections.at(toC);
|
|
|
@ -1801,9 +1801,9 @@ void KGrGame::deleteLevelFile ()
|
|
|
|
enemyCount = 0; // Load level in play mode.
|
|
|
|
enemyCount = 0; // Load level in play mode.
|
|
|
|
enemies.clear();
|
|
|
|
enemies.clear();
|
|
|
|
view->deleteEnemySprites();
|
|
|
|
view->deleteEnemySprites();
|
|
|
|
newLevel = TRUE;;
|
|
|
|
newLevel = true;;
|
|
|
|
loadLevel (level);
|
|
|
|
loadLevel (level);
|
|
|
|
newLevel = FALSE;
|
|
|
|
newLevel = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
createLevel(); // No levels left in collection.
|
|
|
|
createLevel(); // No levels left in collection.
|
|
|
@ -1855,10 +1855,10 @@ void KGrGame::editCollection (int action)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool allAlpha = TRUE;
|
|
|
|
bool allAlpha = true;
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
if (! isalpha(ecPrefix.myChar(i))) {
|
|
|
|
if (! isalpha(ecPrefix.myChar(i))) {
|
|
|
|
allAlpha = FALSE;
|
|
|
|
allAlpha = false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1869,13 +1869,13 @@ void KGrGame::editCollection (int action)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool duplicatePrefix = FALSE;
|
|
|
|
bool duplicatePrefix = false;
|
|
|
|
KGrCollection * c;
|
|
|
|
KGrCollection * c;
|
|
|
|
int imax = collections.count();
|
|
|
|
int imax = collections.count();
|
|
|
|
for (int i = 0; i < imax; i++) {
|
|
|
|
for (int i = 0; i < imax; i++) {
|
|
|
|
c = collections.at(i);
|
|
|
|
c = collections.at(i);
|
|
|
|
if ((c->prefix == ecPrefix) && (i != n)) {
|
|
|
|
if ((c->prefix == ecPrefix) && (i != n)) {
|
|
|
|
duplicatePrefix = TRUE;
|
|
|
|
duplicatePrefix = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1921,7 +1921,7 @@ bool KGrGame::saveOK (bool exiting)
|
|
|
|
bool result;
|
|
|
|
bool result;
|
|
|
|
TQString option2 = i18n("&Go on editing");
|
|
|
|
TQString option2 = i18n("&Go on editing");
|
|
|
|
|
|
|
|
|
|
|
|
result = TRUE;
|
|
|
|
result = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (editMode) {
|
|
|
|
if (editMode) {
|
|
|
|
if (exiting) { // If window is closing,
|
|
|
|
if (exiting) { // If window is closing,
|
|
|
@ -1930,14 +1930,14 @@ bool KGrGame::saveOK (bool exiting)
|
|
|
|
for (j = 1; j <= FIELDHEIGHT; j++)
|
|
|
|
for (j = 1; j <= FIELDHEIGHT; j++)
|
|
|
|
for (i = 1; i <= FIELDWIDTH; i++) { // Check cell changes.
|
|
|
|
for (i = 1; i <= FIELDWIDTH; i++) { // Check cell changes.
|
|
|
|
if ((shouldSave) || (editObjArray[i][j] != lastSaveArray[i][j])) {
|
|
|
|
if ((shouldSave) || (editObjArray[i][j] != lastSaveArray[i][j])) {
|
|
|
|
// If shouldSave == TRUE, level name or hint was edited.
|
|
|
|
// If shouldSave == true, level name or hint was edited.
|
|
|
|
switch (KGrMessage::warning (view, i18n("Editor"),
|
|
|
|
switch (KGrMessage::warning (view, i18n("Editor"),
|
|
|
|
i18n("You have not saved your work. Do "
|
|
|
|
i18n("You have not saved your work. Do "
|
|
|
|
"you want to save it now?"),
|
|
|
|
"you want to save it now?"),
|
|
|
|
i18n("&Save"), i18n("&Don't Save"), option2)) {
|
|
|
|
i18n("&Save"), i18n("&Don't Save"), option2)) {
|
|
|
|
case 0: result = saveLevelFile(); break;// Save and continue.
|
|
|
|
case 0: result = saveLevelFile(); break;// Save and continue.
|
|
|
|
case 1: shouldSave = FALSE; break; // Continue: don't save.
|
|
|
|
case 1: shouldSave = false; break; // Continue: don't save.
|
|
|
|
case 2: result = FALSE; break; // Go back to editing.
|
|
|
|
case 2: result = false; break; // Go back to editing.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (result);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1950,15 +1950,15 @@ void KGrGame::initEdit()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (! editMode) {
|
|
|
|
if (! editMode) {
|
|
|
|
|
|
|
|
|
|
|
|
editMode = TRUE;
|
|
|
|
editMode = true;
|
|
|
|
emit setEditMenu (TRUE); // Enable edit menu items and toolbar.
|
|
|
|
emit setEditMenu (true); // Enable edit menu items and toolbar.
|
|
|
|
|
|
|
|
|
|
|
|
// We were previously in play mode: stop the hero running or falling.
|
|
|
|
// We were previously in play mode: stop the hero running or falling.
|
|
|
|
hero->init (1, 1);
|
|
|
|
hero->init (1, 1);
|
|
|
|
view->setHeroVisible (FALSE);
|
|
|
|
view->setHeroVisible (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
paintEditObj = FALSE;
|
|
|
|
paintEditObj = false;
|
|
|
|
|
|
|
|
|
|
|
|
// Set the default object and button.
|
|
|
|
// Set the default object and button.
|
|
|
|
editObj = BRICK;
|
|
|
|
editObj = BRICK;
|
|
|
@ -1977,12 +1977,12 @@ void KGrGame::initEdit()
|
|
|
|
emit showScore (0);
|
|
|
|
emit showScore (0);
|
|
|
|
|
|
|
|
|
|
|
|
deleteLevel();
|
|
|
|
deleteLevel();
|
|
|
|
setBlankLevel(FALSE); // Fill playfield with Editable objects.
|
|
|
|
setBlankLevel(false); // Fill playfield with Editable objects.
|
|
|
|
|
|
|
|
|
|
|
|
view->setTitle (getTitle());// Show title of level.
|
|
|
|
view->setTitle (getTitle());// Show title of level.
|
|
|
|
view->updateCanvas(); // Show the edit area.
|
|
|
|
view->updateCanvas(); // Show the edit area.
|
|
|
|
|
|
|
|
|
|
|
|
shouldSave = FALSE; // Used to flag editing of name or hint.
|
|
|
|
shouldSave = false; // Used to flag editing of name or hint.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::deleteLevel()
|
|
|
|
void KGrGame::deleteLevel()
|
|
|
@ -2058,16 +2058,16 @@ bool KGrGame::reNumberLevels (int cIndex, int first, int last, int inc)
|
|
|
|
while (i != n) {
|
|
|
|
while (i != n) {
|
|
|
|
file1 = getFilePath (USER, collections.at(cIndex), i);
|
|
|
|
file1 = getFilePath (USER, collections.at(cIndex), i);
|
|
|
|
file2 = getFilePath (USER, collections.at(cIndex), i - step);
|
|
|
|
file2 = getFilePath (USER, collections.at(cIndex), i - step);
|
|
|
|
if (! dir.rename (file1, file2, TRUE)) { // Allow absolute paths.
|
|
|
|
if (! dir.rename (file1, file2, true)) { // Allow absolute paths.
|
|
|
|
KGrMessage::information (view, i18n("Save Level"),
|
|
|
|
KGrMessage::information (view, i18n("Save Level"),
|
|
|
|
i18n("Cannot rename file '%1' to '%2'.")
|
|
|
|
i18n("Cannot rename file '%1' to '%2'.")
|
|
|
|
.arg(file1).arg(file2));
|
|
|
|
.arg(file1).arg(file2));
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i = i + step;
|
|
|
|
i = i + step;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (TRUE);
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::setLevel (int lev)
|
|
|
|
void KGrGame::setLevel (int lev)
|
|
|
@ -2092,7 +2092,7 @@ void KGrGame::doEdit (int button)
|
|
|
|
switch (button) {
|
|
|
|
switch (button) {
|
|
|
|
case TQt::LeftButton:
|
|
|
|
case TQt::LeftButton:
|
|
|
|
case TQt::RightButton:
|
|
|
|
case TQt::RightButton:
|
|
|
|
paintEditObj = TRUE;
|
|
|
|
paintEditObj = true;
|
|
|
|
insertEditObj (i, j);
|
|
|
|
insertEditObj (i, j);
|
|
|
|
view->updateCanvas();
|
|
|
|
view->updateCanvas();
|
|
|
|
oldI = i;
|
|
|
|
oldI = i;
|
|
|
@ -2115,7 +2115,7 @@ void KGrGame::endEdit (int button)
|
|
|
|
switch (button) {
|
|
|
|
switch (button) {
|
|
|
|
case TQt::LeftButton:
|
|
|
|
case TQt::LeftButton:
|
|
|
|
case TQt::RightButton:
|
|
|
|
case TQt::RightButton:
|
|
|
|
paintEditObj = FALSE;
|
|
|
|
paintEditObj = false;
|
|
|
|
if ((i != oldI) || (j != oldJ)) {
|
|
|
|
if ((i != oldI) || (j != oldJ)) {
|
|
|
|
insertEditObj (i, j);
|
|
|
|
insertEditObj (i, j);
|
|
|
|
view->updateCanvas();
|
|
|
|
view->updateCanvas();
|
|
|
@ -2135,9 +2135,9 @@ int KGrGame::selectLevel (int action, int requestedLevel)
|
|
|
|
int selectedLevel = 0; // 0 = no selection (Cancel) or invalid.
|
|
|
|
int selectedLevel = 0; // 0 = no selection (Cancel) or invalid.
|
|
|
|
|
|
|
|
|
|
|
|
// Halt the game during the dialog.
|
|
|
|
// Halt the game during the dialog.
|
|
|
|
modalFreeze = FALSE;
|
|
|
|
modalFreeze = false;
|
|
|
|
if (! KGrObject::frozen) {
|
|
|
|
if (! KGrObject::frozen) {
|
|
|
|
modalFreeze = TRUE;
|
|
|
|
modalFreeze = true;
|
|
|
|
freeze();
|
|
|
|
freeze();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2199,7 +2199,7 @@ int KGrGame::selectLevel (int action, int requestedLevel)
|
|
|
|
// Unfreeze the game, but only if it was previously unfrozen.
|
|
|
|
// Unfreeze the game, but only if it was previously unfrozen.
|
|
|
|
if (modalFreeze) {
|
|
|
|
if (modalFreeze) {
|
|
|
|
unfreeze();
|
|
|
|
unfreeze();
|
|
|
|
modalFreeze = FALSE;
|
|
|
|
modalFreeze = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delete sl;
|
|
|
|
delete sl;
|
|
|
@ -2210,11 +2210,11 @@ bool KGrGame::ownerOK (Owner o)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Check that this owner has at least one collection.
|
|
|
|
// Check that this owner has at least one collection.
|
|
|
|
KGrCollection * c;
|
|
|
|
KGrCollection * c;
|
|
|
|
bool OK = FALSE;
|
|
|
|
bool OK = false;
|
|
|
|
|
|
|
|
|
|
|
|
for (c = collections.first(); c != 0; c = collections.next()) {
|
|
|
|
for (c = collections.first(); c != 0; c = collections.next()) {
|
|
|
|
if (c->owner == o) {
|
|
|
|
if (c->owner == o) {
|
|
|
|
OK = TRUE;
|
|
|
|
OK = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2335,10 +2335,10 @@ void KGrThumbNail::drawContents (TQPainter * p) // Activated via "paintEvent".
|
|
|
|
bool KGrGame::initCollections ()
|
|
|
|
bool KGrGame::initCollections ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Initialise the list of collections of levels (i.e. the list of games).
|
|
|
|
// Initialise the list of collections of levels (i.e. the list of games).
|
|
|
|
collections.setAutoDelete(TRUE);
|
|
|
|
collections.setAutoDelete(true);
|
|
|
|
owner = SYSTEM; // Use system levels initially.
|
|
|
|
owner = SYSTEM; // Use system levels initially.
|
|
|
|
if (! loadCollections (SYSTEM)) // Load system collections list.
|
|
|
|
if (! loadCollections (SYSTEM)) // Load system collections list.
|
|
|
|
return (FALSE); // If no collections, abort.
|
|
|
|
return (false); // If no collections, abort.
|
|
|
|
loadCollections (USER); // Load user collections list.
|
|
|
|
loadCollections (USER); // Load user collections list.
|
|
|
|
// If none, don't worry.
|
|
|
|
// If none, don't worry.
|
|
|
|
|
|
|
|
|
|
|
@ -2349,7 +2349,7 @@ bool KGrGame::initCollections ()
|
|
|
|
collection = collections.at (collnIndex);
|
|
|
|
collection = collections.at (collnIndex);
|
|
|
|
level = 1; // Default start is at level 1.
|
|
|
|
level = 1; // Default start is at level 1.
|
|
|
|
|
|
|
|
|
|
|
|
return (TRUE);
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGrGame::mapCollections()
|
|
|
|
void KGrGame::mapCollections()
|
|
|
@ -2401,7 +2401,7 @@ void KGrGame::mapCollections()
|
|
|
|
// Get the name of the file found on disk.
|
|
|
|
// Get the name of the file found on disk.
|
|
|
|
fileName1 = file->fileName();
|
|
|
|
fileName1 = file->fileName();
|
|
|
|
|
|
|
|
|
|
|
|
while (TRUE) {
|
|
|
|
while (true) {
|
|
|
|
// Work out what the file name should be, based on the level no.
|
|
|
|
// Work out what the file name should be, based on the level no.
|
|
|
|
fileName2.setNum (lev); // Convert to TQString.
|
|
|
|
fileName2.setNum (lev); // Convert to TQString.
|
|
|
|
fileName2 = fileName2.rightJustify (3,'0'); // Add zeros.
|
|
|
|
fileName2 = fileName2.rightJustify (3,'0'); // Add zeros.
|
|
|
@ -2459,13 +2459,13 @@ bool KGrGame::loadCollections (Owner o)
|
|
|
|
i18n("Cannot find game info file '%1'.")
|
|
|
|
i18n("Cannot find game info file '%1'.")
|
|
|
|
.arg(filePath));
|
|
|
|
.arg(filePath));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (! c.open (IO_ReadOnly)) {
|
|
|
|
if (! c.open (IO_ReadOnly)) {
|
|
|
|
KGrMessage::information (view, i18n("Load Game Info"),
|
|
|
|
KGrMessage::information (view, i18n("Load Game Info"),
|
|
|
|
i18n("Cannot open file '%1' for read-only.").arg(filePath));
|
|
|
|
i18n("Cannot open file '%1' for read-only.").arg(filePath));
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQCString line = "";
|
|
|
|
TQCString line = "";
|
|
|
@ -2515,14 +2515,14 @@ bool KGrGame::loadCollections (Owner o)
|
|
|
|
i18n("Format error in game info file '%1'.")
|
|
|
|
i18n("Format error in game info file '%1'.")
|
|
|
|
.arg(filePath));
|
|
|
|
.arg(filePath));
|
|
|
|
c.close();
|
|
|
|
c.close();
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line = "";
|
|
|
|
line = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
c.close();
|
|
|
|
c.close();
|
|
|
|
return (TRUE);
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KGrGame::saveCollections (Owner o)
|
|
|
|
bool KGrGame::saveCollections (Owner o)
|
|
|
@ -2532,7 +2532,7 @@ bool KGrGame::saveCollections (Owner o)
|
|
|
|
if (o != USER) {
|
|
|
|
if (o != USER) {
|
|
|
|
KGrMessage::information (view, i18n("Save Game Info"),
|
|
|
|
KGrMessage::information (view, i18n("Save Game Info"),
|
|
|
|
i18n("You can only modify user games."));
|
|
|
|
i18n("You can only modify user games."));
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
filePath = ((o == SYSTEM)? systemDataDir : userDataDir) + "games.dat";
|
|
|
|
filePath = ((o == SYSTEM)? systemDataDir : userDataDir) + "games.dat";
|
|
|
@ -2543,7 +2543,7 @@ bool KGrGame::saveCollections (Owner o)
|
|
|
|
if (! c.open (IO_WriteOnly)) {
|
|
|
|
if (! c.open (IO_WriteOnly)) {
|
|
|
|
KGrMessage::information (view, i18n("Save Game Info"),
|
|
|
|
KGrMessage::information (view, i18n("Save Game Info"),
|
|
|
|
i18n("Cannot open file '%1' for output.").arg(filePath));
|
|
|
|
i18n("Cannot open file '%1' for output.").arg(filePath));
|
|
|
|
return (FALSE);
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Save the collections.
|
|
|
|
// Save the collections.
|
|
|
@ -2581,7 +2581,7 @@ bool KGrGame::saveCollections (Owner o)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
c.close();
|
|
|
|
c.close();
|
|
|
|
return (TRUE);
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
@ -2591,12 +2591,12 @@ bool KGrGame::saveCollections (Owner o)
|
|
|
|
void KGrGame::myMessage (TQWidget * parent, TQString title, TQString contents)
|
|
|
|
void KGrGame::myMessage (TQWidget * parent, TQString title, TQString contents)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Halt the game while the message is displayed.
|
|
|
|
// Halt the game while the message is displayed.
|
|
|
|
setMessageFreeze (TRUE);
|
|
|
|
setMessageFreeze (true);
|
|
|
|
|
|
|
|
|
|
|
|
KGrMessage::wrapped (parent, title, contents);
|
|
|
|
KGrMessage::wrapped (parent, title, contents);
|
|
|
|
|
|
|
|
|
|
|
|
// Unfreeze the game, but only if it was previously unfrozen.
|
|
|
|
// Unfreeze the game, but only if it was previously unfrozen.
|
|
|
|
setMessageFreeze (FALSE);
|
|
|
|
setMessageFreeze (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|