diff --git a/CGAssistant/chatform.cpp b/CGAssistant/chatform.cpp index d10a363..cf2a3f2 100644 --- a/CGAssistant/chatform.cpp +++ b/CGAssistant/chatform.cpp @@ -16,7 +16,7 @@ ChatForm::ChatForm(QWidget *parent) : ui->textEdit_chat->document()->setMaximumBlockCount(m_ChatMaxLines); QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(OnAutoChat())); + connect(timer, SIGNAL(timeout()), this, SLOT(OnTimer())); timer->start(1000); } @@ -25,11 +25,22 @@ ChatForm::~ChatForm() delete ui; } -void ChatForm::OnAutoChat() +void ChatForm::OnTimer() { if(g_CGAInterface->IsConnected()) { - g_CGAInterface->SetBlockChatMsgs((int)ui->checkBox_BlockChatMsgs->checkState()); + switch(ui->checkBox_BlockChatMsgs->checkState()) + { + case Qt::CheckState::Checked: + g_CGAInterface->SetBlockChatMsgs(2); + break; + case Qt::CheckState::PartiallyChecked: + g_CGAInterface->SetBlockChatMsgs(1); + break; + case Qt::CheckState::Unchecked: + g_CGAInterface->SetBlockChatMsgs(0); + break; + } } } @@ -165,20 +176,17 @@ bool ChatForm::ParseChatSettings(const QJsonValue &val) if(obj.contains("blockchatmsgs")) { int val = obj.take("blockchatmsgs").toInt(); - if(1) + if(val == 2) { - if(val == 2) - { - ui->checkBox_BlockChatMsgs->setCheckState(Qt::CheckState::Checked); - } - else if(val == 1) - { - ui->checkBox_BlockChatMsgs->setCheckState(Qt::CheckState::PartiallyChecked); - } - else if(val == 0) - { - ui->checkBox_BlockChatMsgs->setCheckState(Qt::CheckState::Unchecked); - } + ui->checkBox_BlockChatMsgs->setCheckState(Qt::CheckState::Checked); + } + else if(val == 1) + { + ui->checkBox_BlockChatMsgs->setCheckState(Qt::CheckState::PartiallyChecked); + } + else if(val == 0) + { + ui->checkBox_BlockChatMsgs->setCheckState(Qt::CheckState::Unchecked); } } @@ -194,7 +202,18 @@ void ChatForm::on_checkBox_BlockAllChatMsgs_stateChanged(int state) { if(g_CGAInterface->IsConnected()) { - g_CGAInterface->SetBlockChatMsgs(state); + switch(state) + { + case Qt::CheckState::Checked: + g_CGAInterface->SetBlockChatMsgs(2); + break; + case Qt::CheckState::PartiallyChecked: + g_CGAInterface->SetBlockChatMsgs(1); + break; + case Qt::CheckState::Unchecked: + g_CGAInterface->SetBlockChatMsgs(0); + break; + } } } diff --git a/CGAssistant/chatform.h b/CGAssistant/chatform.h index dd908ec..a63853c 100644 --- a/CGAssistant/chatform.h +++ b/CGAssistant/chatform.h @@ -32,7 +32,7 @@ private slots: void on_checkBox_BlockAllChatMsgs_stateChanged(int state); - void OnAutoChat(); + void OnTimer(); private: Ui::ChatForm *ui; QSharedPointer m_player; diff --git a/CGAssistant/chatform.ui b/CGAssistant/chatform.ui index fa6143a..3a3fac5 100644 --- a/CGAssistant/chatform.ui +++ b/CGAssistant/chatform.ui @@ -48,6 +48,9 @@ 0 + + <html><head/><body><p>Partially Checked: Block chat from non-teammates.</p><p>Fully Checked: Block chat from all players.</p></body></html> + Qt::LeftToRight diff --git a/CGAssistant/lang.qm b/CGAssistant/lang.qm index 687a7da..935a6a8 100644 Binary files a/CGAssistant/lang.qm and b/CGAssistant/lang.qm differ diff --git a/CGAssistant/lang.ts b/CGAssistant/lang.ts index e4dcf8a..d828271 100644 --- a/CGAssistant/lang.ts +++ b/CGAssistant/lang.ts @@ -862,7 +862,15 @@ Chat database will not work properly. Block all chat messages - 屏蔽所有聊天消息 + 屏蔽所有聊天消息 + + + <html><head/><body><p>Partially Checked: Block chat from non-teammates.</p><p>Fully Checked: Block chat from all players.</p></body></html> + <html><head/><body><p>半勾状态:屏蔽来自非队友的聊天消息。</p><p>完全勾选:屏蔽来自任何玩家的聊天消息。</p></body></html> + + + Block chat messages + @@ -1013,7 +1021,7 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/logo.png" /></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;"><br /></p> -<p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;">当前版本:2023-09-28</span></p> +<p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;">当前版本:2024-02-25</span></p> <p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;">下载最新版本:群号 300303705</span></p> <p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;">或 </span><a href="https://github.com/hzqst/CGAssistant/"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; text-decoration: underline; color:#005980; background-color:transparent;">https://github.com/hzqst/CGAssistantJS/</span></a></p> <p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><a href="https://github.com/hzqst/CGAssistantJS/issues"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; text-decoration: underline; color:#005980; background-color:transparent;">或 </span></a><a href="https://github.com/hzqst/CGAssistant/"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; text-decoration: underline; color:#005980; background-color:transparent;">https://gitee.com/hzqst/CGAssistantJS/</span></a></p></body></html> @@ -1794,15 +1802,15 @@ error: %1 Nothing - + MagicSealing - 魔法封印 + 魔法封印 FieldStatus %1%2 - + 场地状态 %1%2 @@ -1947,7 +1955,7 @@ Check "chrome://inspect" in chrome to debug the node process. <html><head/><body><p>Full-Checked: auto restart script no matter what.</p><p>Semi-Checked: auto restart script only when not in battle status.</p></body></html> - <html><head/><body><p>完全勾选:战斗和非战斗状态下均自动重启脚本。</p><p>半勾状态:只在非战斗状态下自动重启脚本。</p></body></html> + <html><head/><body><p>完全勾选:战斗和非战斗状态下均自动重启脚本。</p><p>半勾状态:只在非战斗状态下自动重启脚本。</p></body></html> Freeze Duration @@ -1955,7 +1963,7 @@ Check "chrome://inspect" in chrome to debug the node process. Freeze Duration in Seconds. - 人物静止自动停止脚本的超时时间,以秒为单位。 + 人物静止自动停止脚本的超时时间,以秒为单位。 Stop script when injury. @@ -1967,11 +1975,19 @@ Check "chrome://inspect" in chrome to debug the node process. Stop script when player freeze. - 人物一定时间超过一定时间静止不动时自动停止脚本。 + 人物一定时间超过一定时间静止不动时自动停止脚本。 Freeze Duration: %1 s 静止超时时间:%1秒 + + <html><head/><body><p>Full-Checked: Restart script no matter what.</p><p>Partially-Checked: Restart script only when current player is not in battle status.</p></body></html> + <html><head/><body><p>完全勾选:战斗和非战斗状态下均自动重启脚本。</p><p>半勾状态:只在非战斗状态下自动重启脚本。</p></body></html> + + + <html><head/><body><p>Full-Checked: Stop script when current player's position stays unchanged for &lt;Freeze Duration&gt; seconds no matter what.</p><p>Partially-Checked: Stop script when current player's position stays unchanged for &lt;Freeze Duration&gt; seconds only if current player is not in battle state.</p></body></html> + <html><head/><body><p>当前坐标和地图在"静止超时时间"内没有任何变化就自动登出并停止脚本。</p><p>完全勾选:战斗和非战斗状态下都会自动停止脚本。</p><p>半勾状态:只在非战斗状态下自动停止脚本。</p></body></html> + diff --git a/CGAssistant/main.cpp b/CGAssistant/main.cpp index 6a66ead..da52212 100644 --- a/CGAssistant/main.cpp +++ b/CGAssistant/main.cpp @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) QCommandLineOption scriptfreezestop("scriptfreezestop"); - QCommandLineOption scriptautoterm("scriptautoterm"); + QCommandLineOption scriptfreezestop2("scriptfreezestop2"); QCommandLineOption injuryprotect("injuryprotect"); @@ -116,8 +116,6 @@ int main(int argc, char *argv[]) QCommandLineOption chatmaxlines("chatmaxlines", "", "chatmaxlines", "100"); - QCommandLineOption blockchatmsgs("blockchatmsgs", "", "blockchatmsgs"); - QCommandLineParser parser; parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); @@ -143,9 +141,9 @@ int main(int argc, char *argv[]) parser.addOption(createcharaname); parser.addOption(loadscript); parser.addOption(scriptfreezestop); + parser.addOption(scriptfreezestop2); parser.addOption(scriptautorestart); parser.addOption(scriptautorestart2); - parser.addOption(scriptautoterm); parser.addOption(injuryprotect); parser.addOption(soulprotect); parser.addOption(loadsettings); @@ -153,7 +151,6 @@ int main(int argc, char *argv[]) parser.addOption(consolemaxlines); parser.addOption(scriptfreezeduration); parser.addOption(chatmaxlines); - parser.addOption(blockchatmsgs); parser.process(a); QTranslator translator; @@ -291,20 +288,12 @@ int main(int argc, char *argv[]) w.NotifyFillLoadScript(parser.value(loadscript), parser.isSet(scriptautorestart2) ? 2 : ( parser.isSet(scriptautorestart) ? 1 : 0 ) , - parser.isSet(scriptfreezestop) ? true : false, + parser.isSet(scriptfreezestop2) ? 2 : ( parser.isSet(scriptfreezestop) ? 1 : 0 ), parser.isSet(injuryprotect) ? true : false, parser.isSet(soulprotect) ? true : false, parser.value(consolemaxlines).toInt(), parser.value(scriptfreezeduration).toInt() ); - bool bHasBlockchatmsgs = false; - int val_blockchatmsgs = -1; - if(parser.isSet(blockchatmsgs)) - { - val_blockchatmsgs = parser.value(blockchatmsgs).toInt(&bHasBlockchatmsgs); - } - w.NotifyFillChatSettings(val_blockchatmsgs); - w.NotifyFillLoadSettings(parser.value(loadsettings)); return a.exec(); diff --git a/CGAssistant/mainwindow.ui b/CGAssistant/mainwindow.ui index 76b6a8e..c1880e5 100644 --- a/CGAssistant/mainwindow.ui +++ b/CGAssistant/mainwindow.ui @@ -73,7 +73,7 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/logo.png" /></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;"><br /></p> -<p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;">当前版本:2023-09-28</span></p> +<p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;">当前版本:2024-02-25</span></p> <p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;">下载最新版本:群号 300303705</span></p> <p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; color:#40485b; background-color:#ffffff;">或 </span><a href="https://github.com/hzqst/CGAssistant/"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; text-decoration: underline; color:#005980; background-color:transparent;">https://github.com/hzqst/CGAssistantJS/</span></a></p> <p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:160%; background-color:#ffffff;"><a href="https://github.com/hzqst/CGAssistantJS/issues"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; text-decoration: underline; color:#005980; background-color:transparent;">或 </span></a><a href="https://github.com/hzqst/CGAssistant/"><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Liberation Sans,PingFang SC,Microsoft YaHei,Hiragino Sans GB,Wenquanyi Micro Hei,WenQuanYi Zen Hei,ST Heiti,SimHei,SimSun,WenQuanYi Zen Hei Sharp,sans-serif'; font-size:16px; text-decoration: underline; color:#005980; background-color:transparent;">https://gitee.com/hzqst/CGAssistantJS/</span></a></p></body></html> diff --git a/CGAssistant/player.h b/CGAssistant/player.h index e74e96a..fb4f93d 100644 --- a/CGAssistant/player.h +++ b/CGAssistant/player.h @@ -283,7 +283,6 @@ public slots: void OnSetNoSwitchAnim(int state); void OnSetGameTextUI(int state); void OnSetAntiAFKKick(int state); - void OnSetBlockAllChatMsgs(int state); void OnDownloadMap(int xsize, int ysize); void OnTabChanged(int tabindex); void OnSetUseFoodAt(QString str); diff --git a/CGAssistant/scriptform.cpp b/CGAssistant/scriptform.cpp index 62ae38c..06ef1a5 100644 --- a/CGAssistant/scriptform.cpp +++ b/CGAssistant/scriptform.cpp @@ -46,7 +46,7 @@ ScriptForm::ScriptForm(QWidget *parent) : connect(ui->horizontalSlider_freezeDuration, SIGNAL(valueChanged(int)), this, SLOT(OnSetFreezeDuration(int))); QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(OnAutoRestart())); + connect(timer, SIGNAL(timeout()), this, SLOT(OnTimer())); timer->start(1000); ui->label_freezeDuration->setText(tr("Freeze Duration: %1 s").arg( ui->horizontalSlider_freezeDuration->value() )); @@ -233,85 +233,94 @@ void ScriptForm::OnCloseWindow() } } -void ScriptForm::OnAutoRestart() +void ScriptForm::OnTimer() { if(g_CGAInterface->IsConnected()) { int ingame = 0; if(g_CGAInterface->IsInGame(ingame) && ingame) { - CGA::cga_player_info_t playerinfo; - if(g_CGAInterface->GetPlayerInfo(playerinfo)) + int worldStatus = 0, gameStatus = 0; + + if(g_CGAInterface->GetWorldStatus(worldStatus) && g_CGAInterface->GetGameStatus(gameStatus) && gameStatus == 3) { - if(playerinfo.health != 0 && ui->checkBox_injuryProt->isChecked()) + bool bIsInBattleState = (worldStatus == 10) ? true : false; + bool bIsInNormalState = (worldStatus == 9) ? true : false; + + CGA::cga_player_info_t playerinfo; + if(g_CGAInterface->GetPlayerInfo(playerinfo)) { - if(m_node->state() == QProcess::Running) + if(playerinfo.health != 0 && ui->checkBox_injuryProt->isChecked()) { - on_pushButton_term_clicked(); - return; + if(m_node->state() == QProcess::Running) + { + on_pushButton_term_clicked(); + return; + } + else + { + return; + } } - else + + if(playerinfo.souls != 0 && ui->checkBox_soulProt->isChecked()) { - return; + if(m_node->state() == QProcess::Running) + { + on_pushButton_term_clicked(); + return; + } + else + { + return; + } } } - if(playerinfo.souls != 0 && ui->checkBox_soulProt->isChecked()) + if(m_node->state() == QProcess::Running && + ( + (ui->checkBox_freezestop->checkState() == Qt::CheckState::PartiallyChecked && !bIsInBattleState) || + ui->checkBox_freezestop->checkState() == Qt::CheckState::Checked + ) + ) { - if(m_node->state() == QProcess::Running) - { - on_pushButton_term_clicked(); - return; - } - else + int x = 0, y = 0, index1 = 0, index2 = 0, index3 = 0; + if(g_CGAInterface->GetMapXY(x, y) && g_CGAInterface->GetMapIndex(index1, index2, index3)) { - return; + if(x != m_LastMapX || y != m_LastMapY || index3 != m_LastMapIndex) + { + m_LastMapChange = QTime::currentTime(); + m_LastMapX = x; + m_LastMapY = y; + m_LastMapIndex = index3; + } + else + { + int freezeDuration = ui->horizontalSlider_freezeDuration->value(); + if(m_LastMapChange.elapsed() > freezeDuration * 1000) + { + on_pushButton_term_clicked(); + g_CGAInterface->LogBack(); + return; + } + } } } - } - if(ui->checkBox_freezestop->isChecked() && m_node->state() == QProcess::Running) - { - int x, y, index1, index2, index3; - if(g_CGAInterface->GetMapXY(x, y) && g_CGAInterface->GetMapIndex(index1, index2, index3)) + if(m_node->state() != QProcess::Running && !m_scriptPath.isEmpty()) { - if(x != m_LastMapX || y != m_LastMapY || index3 != m_LastMapIndex) + if(ui->checkBox_autorestart->checkState() == Qt::CheckState::PartiallyChecked && bIsInNormalState) { - m_LastMapChange = QTime::currentTime(); - m_LastMapX = x; - m_LastMapY = y; + on_pushButton_run_clicked(); + return; } - else + if(ui->checkBox_autorestart->checkState() == Qt::CheckState::Checked && (bIsInNormalState || bIsInBattleState)) { - int freezeDuration = ui->horizontalSlider_freezeDuration->value(); - if(m_LastMapChange.elapsed() > freezeDuration * 1000) - { - on_pushButton_term_clicked(); - - g_CGAInterface->LogBack(); - return; - } + on_pushButton_run_clicked(); + return; } } - } - if(ui->checkBox_autorestart->checkState() == Qt::CheckState::PartiallyChecked && m_node->state() != QProcess::Running && !m_scriptPath.isEmpty()) - { - int worldStatus = 0, gameStatus = 0; - if(g_CGAInterface->GetWorldStatus(worldStatus) && g_CGAInterface->GetGameStatus(gameStatus) && worldStatus == 9 && gameStatus == 3) - { - on_pushButton_run_clicked(); - return; - } - } - else if(ui->checkBox_autorestart->checkState() == Qt::CheckState::Checked && m_node->state() != QProcess::Running && !m_scriptPath.isEmpty()) - { - int worldStatus = 0, gameStatus = 0; - if(g_CGAInterface->GetWorldStatus(worldStatus) && g_CGAInterface->GetGameStatus(gameStatus) && (worldStatus == 9 && gameStatus == 3) || (worldStatus == 10 && gameStatus == 3)) - { - on_pushButton_run_clicked(); - return; - } } } else diff --git a/CGAssistant/scriptform.h b/CGAssistant/scriptform.h index 50c0f31..d293ae8 100644 --- a/CGAssistant/scriptform.h +++ b/CGAssistant/scriptform.h @@ -41,7 +41,7 @@ private slots: void OnNodeReadyRead(); void OnNodeFinish(int exitCode, QProcess::ExitStatus exitStatus); void OnCloseWindow(); - void OnAutoRestart(); + void OnTimer(); void on_pushButton_suspend_clicked(); void OnSetFreezeDuration(int value); diff --git a/CGAssistant/scriptform.ui b/CGAssistant/scriptform.ui index 0fbdd11..131da51 100644 --- a/CGAssistant/scriptform.ui +++ b/CGAssistant/scriptform.ui @@ -6,7 +6,7 @@ 0 0 - 673 + 1142 414 @@ -253,7 +253,7 @@ - <html><head/><body><p>Full-Checked: auto restart script no matter what.</p><p>Semi-Checked: auto restart script only when not in battle status.</p></body></html> + <html><head/><body><p>Full-Checked: Restart script no matter what.</p><p>Partially-Checked: Restart script only when current player is not in battle status.</p></body></html> Auto Restart @@ -272,11 +272,14 @@ - Stop script when player freeze. + <html><head/><body><p>Full-Checked: Stop script when current player's position stays unchanged for &lt;Freeze Duration&gt; seconds no matter what.</p><p>Partially-Checked: Stop script when current player's position stays unchanged for &lt;Freeze Duration&gt; seconds only if current player is not in battle state.</p></body></html> Freeze Stop + + true + diff --git a/build-CGAssistant.bat b/build-CGAssistant.bat index f2fd2d3..bda5b22 100644 --- a/build-CGAssistant.bat +++ b/build-CGAssistant.bat @@ -8,7 +8,7 @@ if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" ( cd CGAssistant - qmake CGAssistant.pro -spec win32-msvc "CONFIG+=qtquickcompiler" + qmake CGAssistant.pro -spec win32-msvc "CONFIG+=qtquickcompiler release" jom -f MakeFile qmake_all diff --git a/cgahook/gameservice.cpp b/cgahook/gameservice.cpp index 389a3b3..2412c0e 100644 --- a/cgahook/gameservice.cpp +++ b/cgahook/gameservice.cpp @@ -1618,10 +1618,38 @@ void CGAService::NewNET_ParseChatMsg(int a1, int unitid, const char *buf, int co NET_ParseChatMsg(a1, unitid, buf, color, size); } +bool CGAService::IsPlayerInTeam(int unitId) +{ + if (!*g_is_in_team) + return false; + + for (int i = 0; i < 5; ++i) + { + if (g_team_player_base[i].valid) + { + if (g_team_player_base[i].unit_id == unitId) + { + return true; + } + } + } + + return false; +} + void __cdecl NewNET_ParseChatMsg(int a1, int unitid, const char *buf, int color, int size) { if (g_CGAService.m_ui_block_chatmsgs > 0 && buf[0] == 'P' && buf[1] == '|' && unitid != -1) - return; + { + if(g_CGAService.m_ui_block_chatmsgs >= 2) + return; + + if (g_CGAService.m_ui_block_chatmsgs == 1) + { + if(!g_CGAService.IsPlayerInTeam(unitid)) + return; + } + } g_CGAService.NewNET_ParseChatMsg(a1, unitid, buf, color, size); } diff --git a/cgahook/gameservice.h b/cgahook/gameservice.h index 037be38..d64197a 100644 --- a/cgahook/gameservice.h +++ b/cgahook/gameservice.h @@ -1160,6 +1160,7 @@ namespace CGA void AddAllTradeItems(void); void SetBlockChatMsgs(int state); + bool IsPlayerInTeam(int unitId); bool WM_BattleNormalAttack(int target); bool WM_BattleSkillAttack(int skillpos, int skilllv, int target); bool WM_BattleGuard();