ps.h
:: Ships ()
{
}
Ships :: checkKilled (int array [10] [10])
{
} :: ~ Ships ()
{
}
Файл startwidget.h
# ifndef STARTWIDGET_H
# define STARTWIDGET_H
# include lt; QtGui gt;
# include lt; QFile gt;
# include lt; QApplication gt;
# include putname.h
# include selectmode.h
# include mainwindow.h
StartWidget: public QWidget
{_ OBJECT: ();
~ StartWidget ();
* newGame; * loadGame; * quitGame; * layout; * PN; * SM; * MW; mode; load; pName [2]; i;
: SWSignal ();
slots: setName (); setMode (); getCfg (); showMW (); setSecondName (); checkFile (); Exit ();
: output (); paintEvent (QPaintEvent * event);
};
# endif//STARTWIDGET_H
Файл startwidget.cpp
# include startwidget.h
:: StartWidget ()
{= new QPushButton (tr ( Нова гра ));=new QPushButton (tr ( Завантажити гру ));=new QPushButton (tr ( Вихід )); =new QVBoxLayout;=new PutName;=new SelectMode;=new MainWindow;
gt; setModal (true); gt; setModal (true);=0;=0;=0;
(500,500); ();
:: connect (quitGame, SIGNAL (clicked ()), this, SLOT (Exit ())); :: connect (newGame, SIGNAL (clicked ()), this, SLOT (setMode ( ))); :: connect (loadGame, SIGNAL (clicked ()), this, SLOT (checkFile ())); :: connect (SM, SIGNAL (SMSignal ()), this, SLOT (setName ())); :: connect (MW, SIGNAL (loadGame ()), this, SLOT (checkFile ())); :: connect (MW, SIGNAL (startNew ()), this, SLOT (setMode ()));
}
StartWidget :: output ()
{font;.setPointSizeF(18);.setBold(true);gt;setFont(font);gt;setStyleSheet(laquo;background-color: yellow );
gt; setFont (font); gt; setStyleSheet ( background-color: yellow );
gt; setFont (font); gt; setStyleSheet ( background-color: yellow );
gt; setFixedSize (200, 70); gt; setFixedSize (200, 70); gt; setFixedSize (200, 70);
gt; setAlignment (Qt :: AlignCenter); gt; setSpacing (30); gt; addWidget (newGame, Qt :: AlignCenter); gt; addWidget (loadGame, Qt :: AlignCenter); gt ; addWidget (quitGame, Qt :: AlignCenter);
(layout);
}
StartWidget :: paintEvent (QPaintEvent * event)
{path=QApplication::applicationDirPath()+laquo;/sea.jpegraquo;;background(path);painter(this);.fillRect(0, 0, 500, 500, QBrush (Qt :: black, background)) ;. end ();
} StartWidget :: setName ()
{(SM- gt; man- gt; isChecked ())
{ gt; label- gt; setText ( Введіть ім'я першого гравця: ); gt; show (); :: connect (PN, SIGNAL (PNSignal ()), this, SLOT (getCfg ())); :: connect (PN- gt; button, SIGNAL (clicked ()), this, SLOT (setSecondName ()));
}
{[1]= Комп'ютер raquo ;;=1; gt; label- gt; setText ( Введіть Ваше ім'я: ); gt; show (); :: connect (PN , SIGNAL (PNSignal ()), this, SLOT (getCfg ())); :: connect (PN- gt; button, SIGNAL (clicked ()), this, SLOT (showMW ())); gt; edit- gt ; clear ();
}
}
StartWidget :: setSecondName ()
{(! PN- gt; edit- gt; text (). isEmpty ())
{:: disconnect (PN- gt; button, SIGNAL (clicked ()), this, SLOT (setSecondName ())); ++; gt; edit- gt; clear (); gt ; label- gt; setText ( Введіть ім'я другого гравця: ); gt; show (); :: connect (PN, SIGNAL (PNSignal ()), this, SLOT (getCfg ())); :: connect (PN- gt; button, SIGNAL (clicked ()), this, SLOT (showMW ())); gt; edit- gt; clear ();
}
}
StartWidget :: setMode ()
{:: disconnect (PN, SIGNAL (PNSignal ()), this, SLOT (checkFile ())); gt; edit- gt; clear (); gt; show ();
} StartWidget :: getCfg ()
{[i]=PN- gt; playerName;
}
StartWidget :: showMW ()