From: Shamus Hammons Date: Wed, 2 Apr 2014 19:20:08 +0000 (-0500) Subject: Added undo move system, various improvements. X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=warehouse-man-deluxe;a=commitdiff_plain;h=af4549443047a8b46809a541674d04745f7b5037 Added undo move system, various improvements. --- diff --git a/.gitignore b/.gitignore index c465c5f..5f5cedd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ obj/ Makefile warehousemandeluxe res/*.xcf +pix/ \ No newline at end of file diff --git a/res/bg_marble_g.bmp b/res/bg_marble_g.bmp new file mode 100644 index 0000000..475715d Binary files /dev/null and b/res/bg_marble_g.bmp differ diff --git a/res/resources.qrc b/res/resources.qrc index c527ba4..658fb46 100644 --- a/res/resources.qrc +++ b/res/resources.qrc @@ -1,6 +1,7 @@ wmd-icon.png + bg_marble_g.bmp diff --git a/src/boards.cpp b/src/boards.cpp index df1ee50..d8c2a42 100644 --- a/src/boards.cpp +++ b/src/boards.cpp @@ -174,8 +174,86 @@ static const struct { }; +static const struct { + unsigned int width, height; + unsigned char state[9 * 7 + 1]; } board013 = { 9, 7, + " @@@@@ " + "@@@@ @@" + "@ X X X @" + "@o......@" + "@ X X X @" + "@@@@ @@" + " @@@@@ " +}; + + +static const struct { + unsigned int width, height; + unsigned char state[8 * 7 + 1]; } board014 = { 8, 7, + " @@@@@ " + "@@@ o@ " + "@ X. @@" + "@ .X. @" + "@@@ +X @" + " @ @@" + " @@@@@ " +}; + + +static const struct { + unsigned int width, height; + unsigned char state[8 * 7 + 1]; } board015 = { 8, 7, + "@@@@@@@ " + "@ .X. @@" + "@ X X @" + "@ .X. @" + "@ @@@ @@" + "@ o @ " + "@@@@@@@ " +}; + + +static const struct { + unsigned int width, height; + unsigned char state[10 * 7 + 1]; } board016 = { 10, 7, + " @@@@@@ " + " @@@ @ " + "@@. X@@ @@" + "@..X X o@" + "@.. X X @@" + "@@@@@@ @ " + " @@@@ " +}; + + +static const struct { + unsigned int width, height; + unsigned char state[7 * 7 + 1]; } board017 = { 7, 7, + " @@@@@ " + "@@ . @@" + "@ X.X @" + "@ .Xo@" + "@ X.X @" + "@@ . @@" + " @@@@@ " +}; + + +static const struct { + unsigned int width, height; + unsigned char state[12 * 6 + 1]; } board018 = { 12, 6, + " @@@@@@@@@@ " + "@@ @o @@" + "@ X ....X @" + "@ X@@@@ X @" + "@ @ @ @@" + "@@@@@ @@@@ " +}; + + const void * boards[] = { &board001, &board002, &board003, &board004, &board005, &board006, &board007, &board008, - &board009, &board010, &board011, &board012, //&board013, &board014, &board015, &board016, + &board009, &board010, &board011, &board012, &board013, &board014, &board015, &board016, + &board017, &board018, //&board019, &board020, &board021, &board022, &board023, &board024, }; diff --git a/src/boards.h b/src/boards.h index 6264de4..fde5fcc 100644 --- a/src/boards.h +++ b/src/boards.h @@ -14,7 +14,7 @@ struct Board { unsigned char state[]; // Board data }; -#define NUMBER_OF_BOARDS 12 +#define NUMBER_OF_BOARDS 18 extern const void * boards[]; #endif // __BOARDS_H__ diff --git a/src/gameboard.cpp b/src/gameboard.cpp index b18fe9a..0656e74 100644 --- a/src/gameboard.cpp +++ b/src/gameboard.cpp @@ -88,6 +88,7 @@ void GameBoard::ResetGame(void) { memcpy(board, initialBoard, boardLength); playerX = initialX, playerY = initialY; + numMoves = 0; } @@ -100,7 +101,7 @@ int GameBoard::MovePlayerN(void) char cell1 = board[playerX + ((playerY - 1) * width)] & ~GTBoxSpot; char cell2 = board[playerX + ((playerY - 2) * width)] & ~GTBoxSpot; - return Move(playerY, -1, cell1, cell2); + return Move(0, -1, cell1, cell2); } @@ -113,7 +114,7 @@ int GameBoard::MovePlayerS(void) char cell1 = board[playerX + ((playerY + 1) * width)] & ~GTBoxSpot; char cell2 = board[playerX + ((playerY + 2) * width)] & ~GTBoxSpot; - return Move(playerY, +1, cell1, cell2); + return Move(0, +1, cell1, cell2); } @@ -126,7 +127,7 @@ int GameBoard::MovePlayerE(void) char cell1 = board[(playerX + 1) + (playerY * width)] & ~GTBoxSpot; char cell2 = board[(playerX + 2) + (playerY * width)] & ~GTBoxSpot; - return Move(playerX, +1, cell1, cell2); + return Move(+1, 0, cell1, cell2); } @@ -139,26 +140,34 @@ int GameBoard::MovePlayerW(void) char cell1 = board[(playerX - 1) + (playerY * width)] & ~GTBoxSpot; char cell2 = board[(playerX - 2) + (playerY * width)] & ~GTBoxSpot; - return Move(playerX, -1, cell1, cell2); + return Move(-1, 0, cell1, cell2); } -int GameBoard::Move(int & var, int direction, char cell1, char cell2) +int GameBoard::Move(int dx, int dy, char cell1, char cell2) { // Player is moving into an unoccupied space... if (cell1 == GTSpace) { - var += direction; +// var += direction; + playerX += dx, playerY += dy; + undo[numMoves].dx = dx, undo[numMoves].dy = dy, undo[numMoves].type = PMWalk; + numMoves++; return PMWalk; } // Player is pushing a box into an unoccupied space... else if ((cell1 == GTBox) && (cell2 == GTSpace)) { - var += direction; +// var += direction; + playerX += dx, playerY += dy; board[playerX + (playerY * width)] &= GTBoxSpot; - var += direction; +// var += direction; + playerX += dx, playerY += dy; board[playerX + (playerY * width)] |= GTBox; - var -= direction; +// var -= direction; + playerX -= dx, playerY -= dy; + undo[numMoves].dx = dx, undo[numMoves].dy = dy, undo[numMoves].type = PMPush; + numMoves++; return PMPush; } @@ -203,3 +212,31 @@ bool GameBoard::IsBoxWOfPlayer(void) } +bool GameBoard::UndoLastMove(int & dx, int & dy, int & type) +{ + if (numMoves == 0) + return false; + + numMoves--; + dx = undo[numMoves].dx; + dy = undo[numMoves].dy; + type = undo[numMoves].type; + + // Undo the box's move (if any) + if (type == PMPush) + { + int boxPosition = (playerX + dx) + ((playerY + dy) * width); + int newBoxPosition = playerX + (playerY * width); + + board[boxPosition] &= GTBoxSpot; +// board[newBoxPosition] &= GTBoxSpot; // This is extraneous + board[newBoxPosition] |= GTBox; + } + + // Undo the player's move + playerX += -dx; + playerY += -dy; + + return true; +} + diff --git a/src/gameboard.h b/src/gameboard.h index 4452e25..9f59480 100644 --- a/src/gameboard.h +++ b/src/gameboard.h @@ -4,6 +4,11 @@ enum { GTSpace=0x00, GTWall=0x01, GTBox=0x02, GTBoxSpot=0x04 }; enum { PMInvalid, PMWalk, PMPush }; +struct UndoMove +{ + int dx, dy, type; +}; + class GameBoard { public: @@ -23,9 +28,10 @@ class GameBoard bool IsBoxSOfPlayer(void); bool IsBoxEOfPlayer(void); bool IsBoxWOfPlayer(void); + bool UndoLastMove(int &, int &, int &); private: - int Move(int & var, int direction, char, char); + int Move(int dx, int dy, char, char); public: int playerX, playerY; // Player X/Y are zero-based @@ -36,6 +42,8 @@ class GameBoard char * initialBoard; int initialX, initialY; int boardLength; + int numMoves; + UndoMove undo[8192]; // 8K moves ought to be enough for anybody }; #endif // __GAMEBOARD_H__ diff --git a/src/gamewidget.cpp b/src/gamewidget.cpp index 4a30922..1b815f0 100644 --- a/src/gamewidget.cpp +++ b/src/gamewidget.cpp @@ -21,8 +21,9 @@ GameWidget::GameWidget(QWidget * parent/*= 0*/): QWidget(parent), animating(false), boxMoving(false) // score(new QLabel) { + CreateBackground(); // score->setTextFormat(Qt::PlainText); - setFixedSize(580, 520); +// setFixedSize(580, 520); // gameBoard = new GameBoard(1); } @@ -44,7 +45,8 @@ void GameWidget::paintEvent(QPaintEvent * /*event*/) // QRect rcUpdate = dc.m_ps.rcPaint; // Update rect... // QRect rcUpdate = QRect(0, 0, 580, 520); // Update rect? - maxLength = 60; + painter.translate(QPoint(offsetX, offsetY)); +// maxLength = 60; int ptr = 0; for(int y=0; yheight; y++) @@ -54,24 +56,25 @@ void GameWidget::paintEvent(QPaintEvent * /*event*/) int tile = gameBoard->board[ptr++]; painter.setPen(QPen(Qt::black, 2.0, Qt::SolidLine)); painter.setBrush(QBrush(Qt::black)); + int tileType = tile & (~GTBoxSpot); - if (tile == GTWall) + if (tileType == GTWall) { painter.setBrush(QBrush(Qt::white)); painter.drawRect(x * maxLength, y * maxLength, maxLength, maxLength); } - else if (tile == GTBox) + else if ((tileType == GTBox) + && (!(boxMoving && (movingBoxPositionX == x) && (movingBoxPositionY == y)))) { - if (!(boxMoving && (movingBoxPositionX == x) && (movingBoxPositionY == y))) - { - painter.setBrush(QBrush(Qt::red)); - painter.drawRect(x * maxLength, y * maxLength, maxLength, maxLength); - } + painter.setBrush(QBrush(tile & GTBoxSpot ? Qt::green : Qt::red)); + painter.drawRect(x * maxLength, y * maxLength, maxLength, maxLength); } +#if 0 else if (tile == GTBoxSpot) { painter.setBrush(QBrush(Qt::magenta)); - painter.drawRect((x * maxLength) + 20, (y * maxLength) + 20, maxLength - 40, maxLength - 40); +// painter.drawRect((x * maxLength) + 20, (y * maxLength) + 20, maxLength - 40, maxLength - 40); + painter.drawRect((x * maxLength) + (int)(20.0/60.0*(float)maxLength), (y * maxLength) + (int)(20.0/60.0*(float)maxLength), maxLength - (int)(40.0/60.0*(float)maxLength), maxLength - (int)(40.0/60.0*(float)maxLength)); } else if (tile == (GTBox | GTBoxSpot)) { @@ -83,21 +86,38 @@ void GameWidget::paintEvent(QPaintEvent * /*event*/) else { painter.setBrush(QBrush(Qt::magenta)); - painter.drawRect((x * maxLength) + 20, (y * maxLength) + 20, maxLength - 40, maxLength - 40); +// painter.drawRect((x * maxLength) + 20, (y * maxLength) + 20, maxLength - 40, maxLength - 40); + painter.drawRect((x * maxLength) + (int)(20.0/60.0*(float)maxLength), (y * maxLength) + (int)(20.0/60.0*(float)maxLength), maxLength - (int)(40.0/60.0*(float)maxLength), maxLength - (int)(40.0/60.0*(float)maxLength)); + } + } +#endif + else if ((tileType == GTSpace) + || ((tileType == GTBox) && (boxMoving && (movingBoxPositionX == x) && (movingBoxPositionY == y)))) + { + painter.setBrush(QBrush(QPixmap(":/bg_marble_g.bmp"))); + painter.drawRect(x * maxLength, y * maxLength, maxLength, maxLength); + + if (tile & GTBoxSpot) + { + painter.setBrush(QBrush(Qt::magenta)); +// painter.drawRect((x * maxLength) + 20, (y * maxLength) + 20, maxLength - 40, maxLength - 40); + painter.drawRect((x * maxLength) + (int)(20.0/60.0*(float)maxLength), (y * maxLength) + (int)(20.0/60.0*(float)maxLength), maxLength - (int)(40.0/60.0*(float)maxLength), maxLength - (int)(40.0/60.0*(float)maxLength)); } } if ((gameBoard->playerX == x) && (gameBoard->playerY == y) && !animating) { painter.setBrush(QBrush(Qt::yellow)); - painter.drawEllipse((x * maxLength) + 10, (y * maxLength) + 10, maxLength - 20, maxLength - 20); +// painter.drawEllipse((x * maxLength) + 10, (y * maxLength) + 10, maxLength - 20, maxLength - 20); + painter.drawEllipse((x * maxLength) + (int)(10.0/60.0*(float)maxLength), (y * maxLength) + (int)(10.0/60.0*(float)maxLength), maxLength - (int)(20.0/60.0*(float)maxLength), maxLength - (int)(20.0/60.0*(float)maxLength)); } } if (animating) { painter.setBrush(QBrush(Qt::yellow)); - painter.drawEllipse(playerX + 10, playerY + 10, maxLength - 20, maxLength - 20); +// painter.drawEllipse(playerX + 10, playerY + 10, maxLength - 20, maxLength - 20); + painter.drawEllipse(playerX + (int)(10.0/60.0*(float)maxLength), playerY + (int)(10.0/60.0*(float)maxLength), maxLength - (int)(20.0/60.0*(float)maxLength), maxLength - (int)(20.0/60.0*(float)maxLength)); } if (boxMoving) @@ -106,44 +126,6 @@ void GameWidget::paintEvent(QPaintEvent * /*event*/) painter.drawRect(boxX, boxY, maxLength, maxLength); } } - - -#if 0 - DrawBoard(&painter, rcUpdate); - - // Draw the "loose" cards.... - - if (hitStack) - { - for(int i=stackStart.y(); i<19; i++) - { - int card = solBoard[stackStart.x()][i]; - - if (card != -1) - { - if (solBoard[stackStart.x()][i + 1] == -1) // Draw full card - cdtDraw(&painter, stackPos.x(), stackPos.y() + ((i - stackStart.y()) * 18), - myDeck.GetCardAtPos(card), FACEUP); - else // Draw partial card - cdtDraw(&painter, stackPos.x(), stackPos.y() + ((i - stackStart.y()) * 18), - myDeck.GetCardAtPos(card), FACEUP, 20); - } - } - } - - if (hitDiscard) - cdtDraw(&painter, stackPos.x(), stackPos.y(), myDeck.GetCardAtPos(stack2[stack2p]), - FACEUP); - - if (nHitAce != 0) - cdtDraw(&painter, stackPos.x(), stackPos.y(), nAce[nHitAce - 1], FACEUP); - - if (m_bFreeCard) // For card animations... - { - for(SCardInfo * pCard=m_pFirstCard; pCard; pCard=pCard->pNext) - cdtDraw(&painter, pCard->nXPos, pCard->nYPos, pCard->nCard, FACEUP); - } -#endif } @@ -151,7 +133,6 @@ void GameWidget::mousePressEvent(QMouseEvent * event) { if (event->button() == Qt::LeftButton) { -// OnLButtonDown(event->pos()); event->accept(); } } @@ -161,7 +142,6 @@ void GameWidget::mouseMoveEvent(QMouseEvent * event) { if (event->buttons() & Qt::LeftButton) { -// OnMouseMove(event->pos()); event->accept(); } } @@ -171,7 +151,6 @@ void GameWidget::mouseReleaseEvent(QMouseEvent * event) { if (event->button() == Qt::LeftButton) { -// OnLButtonUp(event->pos()); event->accept(); } } @@ -181,7 +160,6 @@ void GameWidget::mouseDoubleClickEvent(QMouseEvent * event) { if (event->button() == Qt::LeftButton) { -// OnLButtonDblClk(event->pos()); event->accept(); } } @@ -236,7 +214,7 @@ void GameWidget::keyPressEvent(QKeyEvent * event) return; animating = true; - update(); +// update(); if (boxMoving) { @@ -274,30 +252,32 @@ void GameWidget::keyPressEvent(QKeyEvent * event) } -void GameWidget::keyReleaseEvent(QKeyEvent * event) +void GameWidget::keyReleaseEvent(QKeyEvent * /*event*/) { } -void GameWidget::NextLevel(void) +void GameWidget::resizeEvent(QResizeEvent * /*event*/) { - level++; - delete gameBoard; - gameBoard = new GameBoard(level); - update(); -} +// QSize s = event->size(); +//printf("Size of window is: %i x %i\n", s.width(), s.height()); +//printf("Size of game grid is: %i x %i\n", gameBoard->width, gameBoard->height); +#if 0 + // Find the constraints + float boxSizeX = s.width() / gameBoard->width; + float boxSizeY = s.height() / gameBoard->height; -void GameWidget::ResetLevel(void) -{ - gameBoard->ResetGame(); - update(); + maxLength = (int)(boxSizeX > boxSizeY ? boxSizeY : boxSizeX); +#else + ResizeGrid(); +#endif } -#if 0 -bool GameWidget::CreateBackground(void) +void GameWidget::CreateBackground(void) { +#if 0 char BGRes[27][64] = { ":/res/grfttile.bmp", ":/res/cloth_6.bmp", @@ -334,9 +314,90 @@ bool GameWidget::CreateBackground(void) setPalette(pal); return true; // Ignore errors for now... +#else +// QPalette pal = palette(); +// pal.setBrush(backgroundRole(), QBrush(QPixmap(":/bg_marble_g.bmp"))); +// setAutoFillBackground(true); +// setPalette(pal); +#endif } +void GameWidget::NextLevel(void) +{ + level++; + delete gameBoard; + gameBoard = new GameBoard(level); + ResizeGrid(); + update(); +} + + +void GameWidget::ResetLevel(void) +{ + gameBoard->ResetGame(); + update(); +} + + +void GameWidget::UndoLastMove(void) +{ + int dx, dy, type; + + float deltaX = 0, deltaY = 0; + float px = (float)(gameBoard->playerX * maxLength); + float py = (float)(gameBoard->playerY * maxLength); + float bx = px, by = py; + + // Return if nothing to undo + if (!gameBoard->UndoLastMove(dx, dy, type)) + return; + + deltaX = (float)-dx; + deltaY = (float)-dy; + + if (type == PMPush) + boxMoving = true; + + animating = true; +// update(); + + if (boxMoving) + { +// movingBoxPositionX = gameBoard->playerX + (int)deltaX; +// movingBoxPositionY = gameBoard->playerY + (int)deltaY; + movingBoxPositionX = gameBoard->playerX + dx; + movingBoxPositionY = gameBoard->playerY + dy; +// bx += deltaX * (float)maxLength; +// by += deltaY * (float)maxLength; + bx += (float)(dx * maxLength); + by += (float)(dy * maxLength); + } + + int steps = 15; + float stepSize = (float)maxLength / (float)steps; + deltaX *= stepSize, deltaY *= stepSize; + + for(int i=0; iwidth; + float boxSizeY = s.height() / gameBoard->height; + + maxLength = (int)(boxSizeX > boxSizeY ? boxSizeY : boxSizeX); + + offsetX = (s.width() - (maxLength * gameBoard->width)) / 2; + offsetY = (s.height() - (maxLength * gameBoard->height)) / 2; +} + + // // Halt processing for 'count' milliseconds // diff --git a/src/gamewidget.h b/src/gamewidget.h index f58bafd..28ff3b4 100644 --- a/src/gamewidget.h +++ b/src/gamewidget.h @@ -21,21 +21,19 @@ class GameWidget: public QWidget void mouseDoubleClickEvent(QMouseEvent * event); void keyPressEvent(QKeyEvent * event); void keyReleaseEvent(QKeyEvent * event); + void resizeEvent(QResizeEvent * event); signals: void UpdateScore(int); void GameWasWon(void); public: + void CreateBackground(void); void NextLevel(void); void ResetLevel(void); + void UndoLastMove(void); /* void DrawBoard(QPainter * painter, QRect r); - bool CreateBackground(void); - void OnLButtonDown(QPoint point); - void OnLButtonUp(QPoint point); - void OnMouseMove(QPoint point); - void OnLButtonDblClk(QPoint point); void HandleAutoRemove(void); void AnimateCards(int nCard, int nAce, int nTabX, int nTabY); bool IsValidMoveToAce(int nAceM); @@ -44,6 +42,7 @@ class GameWidget: public QWidget bool PlayerWon(void); void HandleStatistics(void);*/ private: + void ResizeGrid(void); void Pause(int); public: @@ -58,6 +57,7 @@ class GameWidget: public QWidget int boxX, boxY; int movingBoxPositionX; int movingBoxPositionY; + int offsetX, offsetY; }; #endif // __GAMEWIDGET_H__ diff --git a/src/mainwin.cpp b/src/mainwin.cpp index 8ba6ded..9b8fb29 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -15,6 +15,7 @@ #include // For rand() #include // For time() +#include "gameboard.h" #include "gamewidget.h" // Actual mouse/drawing window //#include "resource.h" //#include "optiondlg.h" // Options dialog class @@ -32,14 +33,14 @@ MainWin::MainWin() newGame = CreateAction(tr("&New"), tr("New Game"), tr("Start a new game of Warehouse Man Deluxe"), QIcon(), QKeySequence(tr("ctrl+n"))); // connect(newGame, SIGNAL(triggered()), this, SLOT(OnNewGame())); - gamePlay = CreateAction(tr("&Play"), tr(""), tr(""), QIcon(), QKeySequence(tr("ctrl+a"))); -// connect(gamePlay, SIGNAL(triggered()), this, SLOT(OnGamePlay())); - - helpUndo = CreateAction(tr("&Undo"), tr(""), tr(""), QIcon(), QKeySequence(tr("ctrl+z"))); -// connect(helpUndo, SIGNAL(triggered()), this, SLOT(OnHelpUndo())); + undoAction = CreateAction(tr("&Undo"), tr(""), tr(""), QIcon(), QKeySequence(tr("ctrl+z"))); + connect(undoAction, SIGNAL(triggered()), this, SLOT(HandleUndo())); resetLevel = CreateAction(tr("&Reset Level"), tr("Reset Level"), tr("Start the current level over"), QIcon(), QKeySequence(tr("ctrl+r"))); - connect(resetLevel, SIGNAL(triggered()), this, SLOT(ResetCurrentLevel())); + connect(resetLevel, SIGNAL(triggered()), this, SLOT(HandleReset())); + + skipLevel = CreateAction(tr("&Skip Level"), tr("Skip Level"), tr("Skip the current level"), QIcon(), QKeySequence(tr("ctrl+k"))); + connect(skipLevel, SIGNAL(triggered()), this, SLOT(HandleSkipLevel())); gameOptions = CreateAction(tr("&Options..."), tr("Options"), tr("Configure Warehouse Man Deluxe's options"), QIcon(), QKeySequence(tr("ctrl+o"))); // connect(gameOptions, SIGNAL(triggered()), this, SLOT(OnGameOptions())); @@ -60,9 +61,10 @@ MainWin::MainWin() QMenu * menu = menuBar()->addMenu(tr("&Game")); menu->addAction(newGame); menu->addSeparator(); - menu->addAction(gamePlay); - menu->addAction(helpUndo); +// menu->addAction(gamePlay); + menu->addAction(undoAction); menu->addAction(resetLevel); + menu->addAction(skipLevel); menu->addSeparator(); menu->addAction(gameOptions); menu->addAction(gameStats); @@ -78,6 +80,8 @@ MainWin::MainWin() QSettings settings("Underground Software", "Warehouse Man Deluxe"); QPoint mainWinPosition = settings.value("pos", QPoint(200, 100)).toPoint(); move(mainWinPosition); + QSize mainWinSize = settings.value("size", QSize(500, 500)).toSize(); + resize(mainWinSize); /* nCardBack = settings.value("CardBack", BACK4).toInt(); m_nBackground = settings.value("Background", 0).toInt(); @@ -167,6 +171,7 @@ void MainWin::closeEvent(QCloseEvent * event) QSettings settings("Underground Software", "Warehouse Man Deluxe"); settings.setValue("pos", pos()); + settings.setValue("size", size()); /* settings.setValue("CardBack", nCardBack); @@ -278,12 +283,24 @@ void MainWin::WeHaveAWinner(void) } -void MainWin::ResetCurrentLevel(void) +void MainWin::HandleReset(void) { gameWidget->ResetLevel(); } +void MainWin::HandleSkipLevel(void) +{ + gameWidget->NextLevel(); +} + + +void MainWin::HandleUndo(void) +{ + gameWidget->UndoLastMove(); +} + + #if 0 void MainWin::OnNewGame(void) { @@ -377,7 +394,7 @@ void MainWin::OnGameStats(void) } -void MainWin::OnHelpUndo(void) +void MainWin::OnundoAction(void) { if (m_bCanUndo) { diff --git a/src/mainwin.h b/src/mainwin.h index 854e58a..9338343 100644 --- a/src/mainwin.h +++ b/src/mainwin.h @@ -25,28 +25,28 @@ class MainWin: public QMainWindow protected slots: void closeEvent(QCloseEvent * event); -// void QuitGame(void); void AboutGame(void); void WeHaveAWinner(void); - void ResetCurrentLevel(void); + void HandleReset(void); + void HandleSkipLevel(void); + void HandleUndo(void); /* void OnNewGame(void); void OnGameOptions(void); void OnGameStats(void); - void OnHelpUndo(void); - void OnUpdateScore(int); - void OnGamePlay(void); - void OnAppAbout(void);*/ + void OnUpdateScore(int);*/ private: GameWidget * gameWidget; QAction * newGame; - QAction * gamePlay; - QAction * helpUndo; + QAction * undoAction; + QAction * gameOptions; QAction * gameStats; + QAction * appExit; QAction * appAbout; QAction * resetLevel; + QAction * skipLevel; }; #endif // __MAINWIN_H__