]> Shamusworld >> Repos - warehouse-man-deluxe/blobdiff - src/mainwin.cpp
Converted from Qt4 to Qt5.
[warehouse-man-deluxe] / src / mainwin.cpp
index 010f27f7d63f78ab6652bfd87743b3f5c4d4d8f4..18f78b3ca9bb7146dfe198103213339aed28e314 100644 (file)
@@ -16,6 +16,7 @@
 #include <stdlib.h>                    // For rand()
 #include <time.h>                      // For time()
 #include "gameboard.h"
+#include "editorwindow.h"      // Actual mouse/drawing window
 #include "gamewidget.h"                // Actual mouse/drawing window
 //#include "resource.h"
 //#include "optiondlg.h"               // Options dialog class
 
 MainWin::MainWin()
 {
+       // We create the EditorWindow 1st because the GameWidget will crash if there
+       // is no level data loaded...
+       editorWindow = new EditorWindow(this);
        gameWidget = new GameWidget(this);
        setCentralWidget(gameWidget);
        gameWidget->setFocusPolicy(Qt::StrongFocus);    // Without this, it gets no keys
        setWindowTitle("Warehouse Man Deluxe");
        setWindowIcon(QIcon(":/wmd-icon.png"));
 
+       editorWindow->show();
+
        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()));
+       connect(newGame, SIGNAL(triggered()), this, SLOT(HandleNewGame()));
 
        undoAction = CreateAction(tr("&Undo"), tr(""), tr(""), QIcon(), QKeySequence(tr("ctrl+z")));
        connect(undoAction, SIGNAL(triggered()), this, SLOT(HandleUndo()));
@@ -58,6 +64,11 @@ MainWin::MainWin()
 //     connect(gameBoard, SIGNAL(UpdateScore(int)), this, SLOT(OnUpdateScore(int)));
        connect(gameWidget, SIGNAL(GameWasWon()), this, SLOT(WeHaveAWinner()));
 
+       // Connect editor to game widget...
+       connect(editorWindow, SIGNAL(SetupLevel(Level *)), gameWidget,
+               SLOT(HandlePlayGameFromEditor(Level *)));
+
+
        QMenu * menu = menuBar()->addMenu(tr("&Game"));
        menu->addAction(newGame);
        menu->addSeparator();
@@ -122,6 +133,7 @@ MainWin::MainWin()
 MainWin::~MainWin()
 {
 //     ShutDownAudio();
+       delete editorWindow;
 }
 
 
@@ -211,7 +223,7 @@ void MainWin::OnUpdateScore(int n)
                s = QString(tr("Score: %1")).arg(n);
 
        gameBoard->score->setText(s);
-printf("OUS: n=%i, s=%s\n", n, s.toAscii().data());
+printf("OUS: n=%i, s=%s\n", n, s.toUtf8().data());
 }
 */
 
@@ -270,9 +282,17 @@ void MainWin::ResetGame(void)
 }
 
 
+void MainWin::HandleNewGame(void)
+{
+//     ResetGame();
+       gameWidget->level = 0;
+       gameWidget->NextLevel();
+}
+
+
 void MainWin::AboutGame(void)
 {
-       QMessageBox::about(this, tr("About Warehouse Man Deluxe"), tr("Warehouse Man Deluxe Version 1.0\n\nCopyright (C) 2014 Underground Software\n\nWritten by James L. Hammons"));
+       QMessageBox::about(this, tr("About Warehouse Man Deluxe"), tr("Warehouse Man Deluxe Version 1.0\n\nCopyright (C) 2014 Underground Software\n\nWritten by James Hammons"));
 }