diff --git a/Code/ui/scan_gobang.cpp b/Code/ui/scan_gobang.cpp index 24fc2f1fcca51620c4b5e33d81792b3f8159c2eb..b8ca0de8135c89264cb668ac4db589b9fa177a44 100644 --- a/Code/ui/scan_gobang.cpp +++ b/Code/ui/scan_gobang.cpp @@ -11,7 +11,9 @@ scan_gobang::scan_gobang(Gobang_Network *g_network, QWidget *parent) : /* 服务器给我 */ connect(g_network->t, SIGNAL(list_addItem(int, QString)), this, SLOT(list_addItem(int, QString))); - //connect(g_network->t,&tcp::creater_succeed, this,&scan_gobang::rx_string); + + /* 接收聊天消息 */ + connect(g_network->t,&tcp::creater_succeed, this,&scan_gobang::read_message); /* 初始化用户信息 */ init_user_info(g_network); @@ -141,9 +143,9 @@ bool scan_gobang::check_line(int start_i, int start_j, int dir_i, int dir_j) { return true; } /* -* 判断胜负 -* @param null -*/ + * 判断胜负 + * @param null + */ void scan_gobang::win_or_lose() { for(int i = 0; i < CHASS_NUM; i++) { for(int j = 0; j < CHASS_NUM; j++) { @@ -447,7 +449,7 @@ void scan_gobang::send_message() /* 显示到textBrowser */ ui->textBrowser->setText(textBrowser_string); - /* debug */ + /* debug 单机测试,变换棋子颜色*/ if (strTxtEdt == "1") { playStatus = true; } @@ -477,7 +479,22 @@ scan_gobang::~scan_gobang() delete ui; } -void scan_gobang::rx_string(QString str) +/* +* 接收信息 +* @param msg:接收到的信息 +*/ +void scan_gobang::read_message(QString msg) { - qDebug()<<"收到数据:"<textBrowser->setText(textBrowser_string); + + update(); } diff --git a/Code/ui/scan_gobang.h b/Code/ui/scan_gobang.h index 84aa2fe0ac7eadfc0f383c71a06c06525935d02f..eac1f2a39925103cff00d19b100c85a36ee5525e 100644 --- a/Code/ui/scan_gobang.h +++ b/Code/ui/scan_gobang.h @@ -45,32 +45,50 @@ private: signals: void signals_close_game(); public: + /* ɫ */ void setChessStatus(char color); private: + /* ²֣"" : "" */ void updata_ui_size(); public: void init_user_info(Gobang_Network *gobang_network); public: + /* ڳʼôڴС */ void init_window(); + + /* */ void init_input(); + + /* ʼ󶨲ۺ */ void init_button_clicked(); /* */ void draw_chess(char x,char y, char color); + /* ڴСıӦ */ void window_changed(); + + /* ʼã */ void draw_chessboard(); /* */ void draw_mouse(); + /* */ void clear_chess(); + + /* ,ѭ */ void update_chess(); + + /* жʤ */ void win_or_lose(); - // ťӦ + + /* 尴Ӧ */ void on_pushButton_clicked(); + /* ʾѡɫ */ void choose_color(); private: + /* Ϣ󶨷Ͱť */ void send_message(); public: @@ -89,6 +107,7 @@ private: void closeEvent(QCloseEvent *event); //ע⣺eventдIJۺevent() private: + /* ж */ bool check_line(int start_i, int start_j, int dir_i, int dir_j); private: Ui::scan_gobang *ui; @@ -111,7 +130,8 @@ private: int chess_width; private slots: - void rx_string(QString str); + /* ϢգϢ */ + void read_message(QString msg); };