айл mainwindow.cpp
# include mainwindow.h
:: MainWindow ()
{();=new PlayerField ();=new PlayerField ();=new EnemyField ();=new SelectionShips ();=new QDockWidget (tr ( Поле гравця )); =new QDockWidget (tr ( Поле ворога ));=new QDockWidget ();
}
MainWindow :: menu ()
{= menuBar()-gt;addMenu(tr(laquo;amp;Играraquo;));gt;addAction(tr(laquo;amp;Новаяraquo;), this, SLOT (startNewGame ())); gt; addAction (tr ( amp; Зберегти ), this, SLOT (saveGame ())); gt; addAction (tr ( amp; Завантажити ), this, SLOT (MWLoad ())); gt; addAction (tr ( amp; Вихід ), this, SLOT (quit ()));
=menuBar () - gt; addMenu (tr ( amp; Довідка )); gt; addAction (tr ( amp; Про програму ), this, SLOT (about () )); gt; addAction (tr ( amp; Як грати ), this, SLOT (help ()));
}
MainWindow :: newGameWidget ()
{str=PN1 + розставляє свої кораблі raquo ;;=new PlayerField (); - gt; deckColor=Qt :: darkCyan; (Pfield, PF1, PN1); (Qt :: LeftDockWidgetArea, Pfield);
(); (Qt :: LeftDockWidgetArea, StartGame); (gMode!=1)
{= new PlayerField (); - gt; deckColor=Qt :: darkCyan;
(Efield, PF2, PN2); (Qt :: RightDockWidgetArea, Efield); gt; setEnabled (false); - gt; blackout (Qt :: black, Qt :: white, Qt :: red);
(sShip- gt; start, SIGNAL (clicked ()), this, SLOT (secondDock ())); (PF1);
}
{= new EnemyField (); gt; deckColor=Qt :: white; (Efield, EF, PN2); (Qt :: RightDockWidgetArea, Efield);
(sShip- gt; start, SIGNAL (clicked ()), this, SLOT (closeSelectionShips ())); (sShip- gt; start, SIGNAL (clicked ()), this, SLOT ( unblockMenu ())); (sShip- gt; start, SIGNAL (clicked ()), EF, SLOT (autoBuild ())); (PF1);
}
:: information (NULL, Увага! raquo ;, tr (str.toStdString (). c_str ()));
} MainWindow :: secondDock ()
{ gt; setEnabled (true);
(); - gt; blackout (Qt :: black, Qt :: white, Qt :: red); - gt; blackout (Qt :: white, Qt :: black, Qt :: red); str=PN2 + розставляє свої кораблі raquo ;;
QMessageBox :: information (NULL, Увага! raquo ;, tr (str.toStdString (). c_str ()));
(); (Qt :: RightDockWidgetArea, StartGame);
(PF2); (sShip- gt; start, SIGNAL (clicked ()), this, SLOT (closeSelectionShips ())); (sShip- gt; start, SIGNAL (clicked ()), this, SLOT (unblockMenu ()));
}
MainWindow :: loadWidgets (QDockWidget * amp; wdgt, PlayerField * amp; var, QString fieldName)
{ gt; close ();=new QDockWidget(tr(fieldName.toStdString().c_str()));gt;setFeatures(QDockWidget::NoDockWidgetFeatures);gt;setFixedSize(400, 400);
gt; loadField (Qt :: black, Qt :: white, Qt :: darkCyan, Qt :: red); gt; setWidget (var);
}
MainWindow :: loadWidgets (QDockWidget * amp; wdgt, EnemyField * amp; var, QString fieldName)
{ gt; close ();=new QDockWidget(tr(fieldName.toStdString().c_str()));gt;setFeatures(QDockWidget::NoDockWidgetFeatures);gt;setFixedSize(400, 400);
gt; loadField (Qt :: black, Qt :: white, Qt :: white, Qt :: red); gt; setWidget (var);
}
MainWindow :: choice ()
{ gt; close ();=new QDockWidget (tr ( Виберіть корабель: )); gt; setFeatures (QDockWidget :: NoDockWidgetFeatures);=new SelectionShips (); gt; setWidget (sShip);
}
MainWindow :: connection (PlayerField * var)
{(sShip- gt; fourBtn, SIGNAL (clicked ()), var, SLOT (four ())); (sShip- gt; fourBtn, SIGNAL (clicked ()), this, SLOT (blockMenu ())); (sShip- gt; threeBtn, SIGNAL (clicked ()), var, SLOT (three ())); (sShip- gt; threeBtn, SIGNAL (clicked ()), this, SLOT (blockMenu ())); (sShip- gt; twoBtn, SIGNAL (clicked ()), var, SLOT (two ())); (sShip- gt; twoBtn, SIGNAL (clicked ()), this, SLOT (blockMenu () )); (sShip- gt; oneBtn, SIGNAL (clicked ()), var, SLOT (one ())); (sShip- gt; oneBtn, SIGNAL (clicked ()), this, SLOT (blockMenu ())) ; (var, SIGNAL (completed ()), this, SLOT (decrement ()));
}
MainWindow :: blockMenu ()
{gt;actions()(0)-gt;setEnabled(false);gt;actions()(1)-gt;setEnabled(false);gt;actions()(2)-gt;setEnabled(false);
}
MainWindow :...