Skip to content

Commit

Permalink
feat: network matchmaking implementation and optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
XMuli committed Dec 14, 2023
1 parent ef852b4 commit 0b188d8
Show file tree
Hide file tree
Showing 20 changed files with 375 additions and 242 deletions.
2 changes: 1 addition & 1 deletion AboutAuthor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019~2020 偕臧 All rights reserved.
* Copyright (C) 2019~2024 偕臧 All rights reserved.
*
* Author: xmuli(偕臧) [email protected]
*
Expand Down
14 changes: 7 additions & 7 deletions AboutAuthor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019~2020 偕臧 All rights reserved.
* Copyright (C) 2019~2024 偕臧 All rights reserved.
*
* Author: xmuli(偕臧) [email protected]
*
Expand All @@ -25,24 +25,24 @@
#include <QDialog>
#include <QFont>

namespace Ui {
class AboutAuthor;
namespace Ui
{
class AboutAuthor;
}

class AboutAuthor : public QDialog
{
Q_OBJECT

public:
explicit AboutAuthor(QWidget *parent = 0);
explicit AboutAuthor(QWidget* parent = 0);
~AboutAuthor();

protected:
virtual void paintEvent(QPaintEvent *event) override;
virtual void paintEvent(QPaintEvent* event) override;

private:
Ui::AboutAuthor *ui;
QWidget * QDialog;
Ui::AboutAuthor* ui;
};

#endif // ABOUTAUTHOR_H
23 changes: 14 additions & 9 deletions AboutAuthor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="chooseresource.qrc">:/images/Alipay.png</pixmap>
<pixmap resource="resources/res.qrc">:/images/Alipay.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
Expand Down Expand Up @@ -106,7 +106,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="chooseresource.qrc">:/images/WeChat.png</pixmap>
<pixmap resource="resources/res.qrc">:/images/WeChat.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
Expand Down Expand Up @@ -145,19 +145,25 @@
<widget class="QTextBrowser" name="textBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt;作者:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt; &lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli&quot;&gt;&lt;span style=&quot; font-family:'华文楷体'; text-decoration: underline; color:#007af4;&quot;&gt;偕臧&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt; Copyri © 2019-2022&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt; &lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli&quot;&gt;&lt;span style=&quot; font-family:'华文楷体'; text-decoration: underline; color:#007af4;&quot;&gt;偕臧&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt; Copyri © 2019-2024&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'华文楷体'; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;贡献者: &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/Bruce-Ch&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;Bruce-Ch&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/BlueArvin&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;BlueArvin&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/Ubuntuser2012&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;Ubuntuser2012&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/kira-yamatoo&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;kira-yamatoo&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/hmsjy2017&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;hmsjy2017&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/zjuyk&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;zjuyk&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/ryanfortner&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;ryanfortner&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;项目:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; 关于 &lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli/chineseChess&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;ChinessChess&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; 此开源项目,兴趣之做;说明都在这里 [&lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli/chineseChess/blob/master/README.zh_CN.md&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;中文&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; | &lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli/chineseChess/blob/master/README.md&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;English&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;]&lt;/span&gt;&lt;/p&gt;
Expand All @@ -169,7 +175,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; 所有参与贡献的,亦都会留名在此。​热爱开源,热爱生命,热爱生活。&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;Bolg: &lt;/span&gt;&lt;a href=&quot;https://ifmet.cn&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;ifmet.cn&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;Bolg: &lt;/span&gt;&lt;a href=&quot;https://xmuli.tech&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;xmuli.tech&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;Gmail: [email protected]&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
Expand All @@ -187,8 +193,7 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<resources>
<include location="chooseresource.qrc"/>
<include location="chooseresource.qrc"/>
<include location="resources/res.qrc"/>
</resources>
<connections>
<connection>
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
cmake_minimum_required(VERSION 3.5)

set(project_name ChineseChess)
set(project_version_major 7)
set(project_version_minor 0)
set(project_version_major 6)
set(project_version_minor 2)
set(project_version_path 0)
set(project_version ${project_version_major}.${project_version_minor}.${project_version_path})
project(${project_name} VERSION ${project_version} LANGUAGES CXX)

add_definitions(-DXBUILD_TIME="2023.12.13")
add_definitions(-DXBUILD_TIME="2023.12.14")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
Expand Down
62 changes: 20 additions & 42 deletions ChessBoard.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019~2020 偕臧 All rights reserved.
* Copyright (C) 2019~2024 偕臧 All rights reserved.
*
* Author: xmuli(偕臧) [email protected]
*
Expand All @@ -21,6 +21,7 @@
*/
#include "ChessBoard.h"
#include "ui_ChessBoard.h"
#include <mutex>

ChessBoard::ChessBoard(QWidget *parent) :
QMainWindow(parent),
Expand Down Expand Up @@ -409,31 +410,11 @@ bool ChessBoard:: isGeneral()
return false;
}

void ChessBoard::setNetworkGroupShow(const bool &show)
void ChessBoard::showNetworkGui(const bool &show)
{
ui->networkGroup->setVisible(show);
}

/*!
* \brief ChessBoard::setNetworkGroupText
* \param group group的名称
* \param input 输入栏 IP+prot
* \param btn 按钮的名称,监听或者连接
* \param statue 连接结果的名称
*/
void ChessBoard::setNetworkGroupText(const QString &group, const QString &input, const QString &btn, const QString &statue)
{
ui->networkGroup->setTitle(group);
ui->lineEdit->setText(input);
ui->btnTcpConnect->setText(btn);
ui->labConnectStatus->setText(statue);
}

void ChessBoard::setstatusText(const QString &statue)
{
ui->labConnectStatus->setText(statue);
}

//鼠标按下事件
//void ChessBoard::mousePressEvent(QMouseEvent *ev)
//{
Expand Down Expand Up @@ -810,6 +791,13 @@ void ChessBoard::clickPieces(int id, int &row, int &col)
else {
tryMoveStone(id, row, col);
}

// 初次按下时,自启动计时器
std::once_flag flag;
std::call_once(flag, [&]() {
m_bIsStart = false;
on_pushButton_start_clicked();
});
}

void ChessBoard::trySelectStone(int id)
Expand Down Expand Up @@ -948,17 +936,17 @@ void ChessBoard::updateTime()
void ChessBoard::on_pushButton_start_clicked()
{
if(!m_bIsStart) //尚未开始 开始计时
{
m_timer->start(1000);
ui->pushButton_start->setText("暂停");
}
else //已经开始,暂停
{
m_timer->stop();
ui->pushButton_start->setText("继续");
}
{
m_timer->start(1000);
ui->pushButton_start->setText("暂停");
}
else //已经开始,暂停
{
m_timer->stop();
ui->pushButton_start->setText("继续");
}

m_bIsStart = !m_bIsStart;
m_bIsStart = !m_bIsStart;
}

void ChessBoard::on_pushButton_reset_clicked()
Expand Down Expand Up @@ -1001,14 +989,4 @@ void ChessBoard::on_pushButton_toMenu_clicked()
emit this->toMenu();
}

void ChessBoard::on_lineEdit_textChanged(const QString &arg1)
{
emit sigLineEditTextChanged(arg1);
}


void ChessBoard::on_btnTcpConnect_released()
{
emit sigBtnTcpConnectReleased();
}

Loading

0 comments on commit 0b188d8

Please sign in to comment.