diff --git a/NineChess/src/main.cpp b/NineChess/src/main.cpp index e98f8118..93180555 100644 --- a/NineChess/src/main.cpp +++ b/NineChess/src/main.cpp @@ -29,5 +29,6 @@ int main(int argc, char *argv[]) NineChessWindow w; w.show(); w.move((QApplication::desktop()->width() - w.width()) / 4, (QApplication::desktop()->height() - w.height()) / 2); + return a.exec(); } diff --git a/NineChess/src/ninechesswindow.cpp b/NineChess/src/ninechesswindow.cpp index 2a19650b..2cebe415 100644 --- a/NineChess/src/ninechesswindow.cpp +++ b/NineChess/src/ninechesswindow.cpp @@ -50,6 +50,8 @@ #include "gamecontroller.h" #include "gamescene.h" #include "graphicsconst.h" +#include "server.h" +#include "client.h" NineChessWindow::NineChessWindow(QWidget * parent) : QMainWindow(parent), @@ -88,7 +90,7 @@ NineChessWindow::NineChessWindow(QWidget * parent) : ui.gameView->setRenderHint(QPainter::Antialiasing); // 因功能限制,使部分功能不可用,将来再添加 - ui.actionInternet_I->setDisabled(true); + ui.actionInternet_I->setDisabled(false); ui.actionSetting_O->setDisabled(true); // 初始化游戏规则菜单 @@ -116,6 +118,9 @@ NineChessWindow::~NineChessWindow() } qDeleteAll(ruleActionList); + + delete server; + delete client; } void NineChessWindow::closeEvent(QCloseEvent *event) @@ -288,6 +293,10 @@ void NineChessWindow::initialize() QWidget::setWindowFlags(Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint); #endif // SHOW_MAXIMIZED_ON_LOAD + + // 网络 + server = new Server(); + client = new Client(); } void NineChessWindow::ruleInfo() @@ -750,6 +759,10 @@ void NineChessWindow::on_actionInternet_I_triggered() { ui.actionLocal_L->setChecked(false); ui.actionInternet_I->setChecked(true); + + + server->show(); + client->show(); } void NineChessWindow::on_actionEngine_E_triggered() diff --git a/NineChess/src/ninechesswindow.h b/NineChess/src/ninechesswindow.h index 89302dc9..dfaa0737 100644 --- a/NineChess/src/ninechesswindow.h +++ b/NineChess/src/ninechesswindow.h @@ -31,6 +31,9 @@ #include "ui_ninechesswindow.h" #include "config.h" +#include "server.h" +#include "client.h" + class GameScene; class GameController; @@ -112,6 +115,10 @@ private: // 定时器 QTimer autoRunTimer; + + // 网络 + Server *server; + Client *client; }; #endif // NINECHESSWINDOW_H