diff --git a/EliteSpeedrunTool/AcknowledgementDialog.h b/EliteSpeedrunTool/AcknowledgementDialog.h index 4499dd5..2a74caf 100644 --- a/EliteSpeedrunTool/AcknowledgementDialog.h +++ b/EliteSpeedrunTool/AcknowledgementDialog.h @@ -67,5 +67,6 @@ class AcknowledgementDialog : public QDialog { "____-669-____", "巨大糖丸🐷", "GodfatherCDW", + "9527_SSR", }; }; diff --git a/EliteSpeedrunTool/App.rc b/EliteSpeedrunTool/App.rc index 93fce64..5827ddb 100644 --- a/EliteSpeedrunTool/App.rc +++ b/EliteSpeedrunTool/App.rc @@ -8,8 +8,8 @@ 2 ICON "icon.ico" VS_VERSION_INFO VERSIONINFO - FILEVERSION 10,9,1,69 - PRODUCTVERSION 10,9,1,69 + FILEVERSION 10,10,1,69 + PRODUCTVERSION 10,10,1,69 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS VS_FF_DEBUG @@ -26,8 +26,8 @@ VS_VERSION_INFO VERSIONINFO BEGIN VALUE "CompanyName", "SkyD666\0" VALUE "FileDescription", "Elite Speedrun Tool\0" - VALUE "FileVersion", "10.9.1.69\0" - VALUE "ProductVersion", "10.9.1.69\0" + VALUE "FileVersion", "10.10.1.69\0" + VALUE "ProductVersion", "10.10.1.69\0" VALUE "ProductName", "Elite Speedrun Tool\0" END END diff --git a/EliteSpeedrunTool/CMakeLists.txt b/EliteSpeedrunTool/CMakeLists.txt index 66561c5..69b36a3 100644 --- a/EliteSpeedrunTool/CMakeLists.txt +++ b/EliteSpeedrunTool/CMakeLists.txt @@ -41,6 +41,7 @@ set(PROJECT_SOURCES NumberUtil.h NumberUtil.cpp RpRecognizeUtil.h RpRecognizeUtil.cpp RtssUtil.h RtssUtil.cpp + NetworkAdapterUtil.h NetworkAdapterUtil.cpp resource.qrc ) @@ -102,17 +103,13 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../QHotkey ${CMAKE_CURRENT_BINARY_D include_directories(../QHotkey) target_link_libraries(EliteSpeedrunTool PRIVATE QHotkey) -if (WIN32) - target_link_libraries(EliteSpeedrunTool PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/lib/WinMM.Lib - ) -endif() +target_link_libraries(EliteSpeedrunTool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lib/WinMM.Lib) +target_link_libraries(EliteSpeedrunTool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lib/setupapi.lib) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../DiscordGameSDK ${CMAKE_CURRENT_BINARY_DIR}/DiscordGameSDK) include_directories(../DiscordGameSDK) target_link_libraries(EliteSpeedrunTool PRIVATE DiscordGameSDK) -set(RTSS_INDLUDE_PATH "C:/Program Files (x86)/RivaTuner Statistics Server/SDK/Include") target_include_directories(EliteSpeedrunTool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../RTSS) # set(OpenCV_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../OpenCV) diff --git a/EliteSpeedrunTool/GlobalData.cpp b/EliteSpeedrunTool/GlobalData.cpp index a2db811..c53dd42 100644 --- a/EliteSpeedrunTool/GlobalData.cpp +++ b/EliteSpeedrunTool/GlobalData.cpp @@ -176,6 +176,14 @@ void GlobalData::readSettings() setFirewallDirection(settings.value("FirewallDirection", mFirewallDirection).toInt()); settings.endGroup(); + settings.beginGroup("NetworkAdapter"); + setSelectedNetworkAdapters(settings.value("SelectedNetworkAdapters", mSelectedNetworkAdapters).value>()); + setNetworkAdaptersDisableHotkey(settings.value("NetworkAdaptersDisableHotkey", mNetworkAdaptersDisableHotkey).toString()); + setNetworkAdaptersEnableHotkey(settings.value("NetworkAdaptersEnableHotkey", mNetworkAdaptersEnableHotkey).toString()); + setNetworkAdaptersDisableSound(settings.value("NetworkAdaptersDisableSound", mNetworkAdaptersDisableSound).toString()); + setNetworkAdaptersEnableSound(settings.value("NetworkAdaptersEnableSound", mNetworkAdaptersEnableSound).toString()); + settings.endGroup(); + settings.beginGroup("MissionData"); setMissionDataUpdateInterval(settings.value("MissionDataUpdateInterval", mMissionDataUpdateInterval).toInt()); setMissionDataName(MissionDataNameUtil::fromString( @@ -259,6 +267,14 @@ void GlobalData::writeSettings() settings.setValue("FirewallDirection", mFirewallDirection); settings.endGroup(); + settings.beginGroup("NetworkAdapter"); + settings.setValue("SelectedNetworkAdapters", mSelectedNetworkAdapters); + settings.setValue("NetworkAdaptersDisableHotkey", mNetworkAdaptersDisableHotkey); + settings.setValue("NetworkAdaptersEnableHotkey", mNetworkAdaptersEnableHotkey); + settings.setValue("NetworkAdaptersDisableSound", mNetworkAdaptersDisableSound); + settings.setValue("NetworkAdaptersEnableSound", mNetworkAdaptersEnableSound); + settings.endGroup(); + settings.beginGroup("MissionData"); settings.setValue("MissionDataInterval", mMissionDataUpdateInterval); settings.setValue("MissionDataName", MissionDataNameUtil::toString(mMissionDataName)); @@ -925,3 +941,68 @@ void GlobalData::setRtssOverlay(bool newRtssOverlay) mRtssOverlay = newRtssOverlay; emit rtssOverlayChanged(); } + +QList GlobalData::selectedNetworkAdapters() const +{ + return mSelectedNetworkAdapters; +} + +void GlobalData::setSelectedNetworkAdapters(const QList& newSelectedNetworkAdapters) +{ + if (mSelectedNetworkAdapters == newSelectedNetworkAdapters) + return; + mSelectedNetworkAdapters = newSelectedNetworkAdapters; + emit selectedNetworkAdaptersChanged(); +} + +QString GlobalData::networkAdaptersEnableHotkey() const +{ + return mNetworkAdaptersEnableHotkey; +} + +void GlobalData::setNetworkAdaptersEnableHotkey(const QString& newNetworkAdaptersEnableHotkey) +{ + if (mNetworkAdaptersEnableHotkey == newNetworkAdaptersEnableHotkey) + return; + mNetworkAdaptersEnableHotkey = newNetworkAdaptersEnableHotkey; + emit networkAdaptersEnableHotkeyChanged(); +} + +QString GlobalData::networkAdaptersDisableHotkey() const +{ + return mNetworkAdaptersDisableHotkey; +} + +void GlobalData::setNetworkAdaptersDisableHotkey(const QString& newNetworkAdaptersDisableHotkey) +{ + if (mNetworkAdaptersDisableHotkey == newNetworkAdaptersDisableHotkey) + return; + mNetworkAdaptersDisableHotkey = newNetworkAdaptersDisableHotkey; + emit networkAdaptersDisableHotkeyChanged(); +} + +QString GlobalData::networkAdaptersEnableSound() const +{ + return mNetworkAdaptersEnableSound; +} + +void GlobalData::setNetworkAdaptersEnableSound(const QString& newNetworkAdaptersEnableSound) +{ + if (mNetworkAdaptersEnableSound == newNetworkAdaptersEnableSound) + return; + mNetworkAdaptersEnableSound = newNetworkAdaptersEnableSound; + emit networkAdaptersEnableSoundChanged(); +} + +QString GlobalData::networkAdaptersDisableSound() const +{ + return mNetworkAdaptersDisableSound; +} + +void GlobalData::setNetworkAdaptersDisableSound(const QString& newNetworkAdaptersDisableSound) +{ + if (mNetworkAdaptersDisableSound == newNetworkAdaptersDisableSound) + return; + mNetworkAdaptersDisableSound = newNetworkAdaptersDisableSound; + emit networkAdaptersDisableSoundChanged(); +} diff --git a/EliteSpeedrunTool/GlobalData.h b/EliteSpeedrunTool/GlobalData.h index 1310675..96ba5a6 100644 --- a/EliteSpeedrunTool/GlobalData.h +++ b/EliteSpeedrunTool/GlobalData.h @@ -195,6 +195,27 @@ class GlobalData : public QObject { bool rtssOverlay() const; void setRtssOverlay(bool newRtssOverlay); + QList selectedNetworkAdapters() const; + void setSelectedNetworkAdapters(const QList& newSelectedNetworkAdapters); + + QString networkAdaptersEnable() const; + void setNetworkAdaptersEnable(const QString& newNetworkAdaptersEnable); + + QString networkAdaptersDisable() const; + void setNetworkAdaptersDisable(const QString& newNetworkAdaptersDisable); + + QString networkAdaptersEnableHotkey() const; + void setNetworkAdaptersEnableHotkey(const QString& newNetworkAdaptersEnableHotkey); + + QString networkAdaptersDisableHotkey() const; + void setNetworkAdaptersDisableHotkey(const QString& newNetworkAdaptersDisableHotkey); + + QString networkAdaptersEnableSound() const; + void setNetworkAdaptersEnableSound(const QString& newNetworkAdaptersEnableSound); + + QString networkAdaptersDisableSound() const; + void setNetworkAdaptersDisableSound(const QString& newNetworkAdaptersDisableSound); + signals: void minimizeToTrayChanged(); void styleNameChanged(); @@ -255,6 +276,16 @@ class GlobalData : public QObject { void rtssOverlayChanged(); + void selectedNetworkAdaptersChanged(); + + void networkAdaptersEnableHotkeyChanged(); + + void networkAdaptersDisableHotkeyChanged(); + + void networkAdaptersEnableSoundChanged(); + + void networkAdaptersDisableSoundChanged(); + private: bool mMinimizeToTray = false; QString mStyleName = "windowsvista"; @@ -291,6 +322,13 @@ class GlobalData : public QObject { QString mFirewallAppPath = ""; int mFirewallDirection = NET_FW_RULE_DIR_OUT; + // 网络适配器 + QList mSelectedNetworkAdapters = {}; + QString mNetworkAdaptersEnableHotkey = "Alt+Q"; + QString mNetworkAdaptersDisableHotkey = "Alt+Q"; + QString mNetworkAdaptersEnableSound = "./sound/uradaron.wav"; + QString mNetworkAdaptersDisableSound = "./sound/uradarof.wav"; + // 任务数据 int mMissionDataUpdateInterval = 50; QList mMissionDataNames = { @@ -388,4 +426,9 @@ class GlobalData : public QObject { Q_PROPERTY(QString act3HeadshotStartSound READ act3HeadshotStartSound WRITE setAct3HeadshotStartSound NOTIFY act3HeadshotStartSoundChanged FINAL) Q_PROPERTY(QString act3HeadshotStopSound READ act3HeadshotStopSound WRITE setAct3HeadshotStopSound NOTIFY act3HeadshotStopSoundChanged FINAL) Q_PROPERTY(bool rtssOverlay READ rtssOverlay WRITE setRtssOverlay NOTIFY rtssOverlayChanged FINAL) + Q_PROPERTY(QList selectedNetworkAdapters READ selectedNetworkAdapters WRITE setSelectedNetworkAdapters NOTIFY selectedNetworkAdaptersChanged FINAL) + Q_PROPERTY(QString networkAdaptersEnableHotkey READ networkAdaptersEnableHotkey WRITE setNetworkAdaptersEnableHotkey NOTIFY networkAdaptersEnableHotkeyChanged FINAL) + Q_PROPERTY(QString networkAdaptersDisableHotkey READ networkAdaptersDisableHotkey WRITE setNetworkAdaptersDisableHotkey NOTIFY networkAdaptersDisableHotkeyChanged FINAL) + Q_PROPERTY(QString networkAdaptersEnableSound READ networkAdaptersEnableSound WRITE setNetworkAdaptersEnableSound NOTIFY networkAdaptersEnableSoundChanged FINAL) + Q_PROPERTY(QString networkAdaptersDisableSound READ networkAdaptersDisableSound WRITE setNetworkAdaptersDisableSound NOTIFY networkAdaptersDisableSoundChanged FINAL) }; diff --git a/EliteSpeedrunTool/MainWindow.cpp b/EliteSpeedrunTool/MainWindow.cpp index 05c3ea2..b6fdbaf 100644 --- a/EliteSpeedrunTool/MainWindow.cpp +++ b/EliteSpeedrunTool/MainWindow.cpp @@ -6,6 +6,7 @@ #include "GlobalData.h" #include "HttpServerUtil.h" #include "LogUtil.h" +#include "NetworkAdapterUtil.h" #include "RegionSelectorDialog.h" #include "RpRecognizeUtil.h" #include "RtssUtil.h" @@ -27,12 +28,10 @@ #include #include -const QString MainWindow::hotkeyStatePattern = "🧱: %1, %2 ⏱️: %3, %4, %5 👤: %6 ❌: %7"; +const QString MainWindow::hotkeyStatePattern = "🧱%1, %2 📶%3, %4 ⏱️%5, %6, %7 👤%8 ❌%9"; MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) - , labCurrentHotkey(new QLabel(this)) - , labState(new QLabel(this)) { ui.setupUi(this); @@ -54,16 +53,12 @@ MainWindow::MainWindow(QWidget* parent) checkUpdate(); - ui.statusbar->addPermanentWidget(labCurrentHotkey); - - labState->setAutoFillBackground(true); - labState->setMinimumWidth(16); - QPalette palette = labState->palette(); - palette.setColor(QPalette::Window, Qt::red); - labState->setPalette(palette); - ui.statusbar->addPermanentWidget(labState); + ui.statusbar->addPermanentWidget(&labCurrentHotkey); + ui.statusbar->addPermanentWidget(&labFirewallState); + ui.statusbar->addPermanentWidget(&labNetworkAdaptersState); initFirewall(); + initNetworkAdapters(); initTimerStateMachine(); @@ -141,10 +136,58 @@ void MainWindow::checkUpdate() [](int, QString) {}); } +void MainWindow::registerHotkey( + const QString& hotkeyString, + QHotkey*& hotkey, + std::function onActivated, + std::function registerFailed) +{ + if (!hotkeyString.isEmpty()) { + hotkey = new QHotkey(QKeySequence(hotkeyString), true, qApp); + if (hotkey->isRegistered()) { + connect(hotkey, &QHotkey::activated, qApp, [onActivated]() { onActivated(); }); + } else { + registerFailed(); + } + } +} + +void MainWindow::registerHotkeyPair( + const QString& firstString, const QString& secondString, + QHotkey*& firstHotkey, QHotkey*& secondHotkey, + std::function toggle, std::function check, + std::function registerFailed, + bool canBeSame) +{ + if (canBeSame) { + if (!firstString.isEmpty() && !secondString.isEmpty()) { + bool sameHotkey = firstString == secondString; + firstHotkey = new QHotkey(QKeySequence(firstString), true, qApp); + if (firstHotkey->isRegistered()) { + connect(firstHotkey, &QHotkey::activated, qApp, [sameHotkey, toggle, check]() { + sameHotkey ? toggle() : check(true); + }); + } else { + registerFailed(true); + } + if (!sameHotkey) { + secondHotkey = new QHotkey(QKeySequence(secondString), true, qApp); + if (secondHotkey->isRegistered()) { + connect(secondHotkey, &QHotkey::activated, qApp, [check]() { check(false); }); + } else { + registerFailed(false); + } + } + } + } +} + void MainWindow::removeAllHotkeys() { removeHotkey(startFirewallHotkey); removeHotkey(stopFirewallHotkey); + removeHotkey(disableNetworkAdapterHotkey); + removeHotkey(enableNetworkAdapterHotkey); removeHotkey(startTimerHotkey); removeHotkey(pauseTimerHotkey); removeHotkey(stopTimerHotkey); @@ -166,9 +209,11 @@ void MainWindow::removeHotkey(QHotkey*& h) void MainWindow::setHotkey() { - labCurrentHotkey->setText(hotkeyStatePattern.arg( + labCurrentHotkey.setText(hotkeyStatePattern.arg( globalData->firewallStartHotkey(), globalData->firewallStopHotkey(), + globalData->networkAdaptersDisableHotkey(), + globalData->networkAdaptersEnableHotkey(), globalData->timerStartHotkey(), globalData->timerPauseHotkey(), globalData->timerStopHotkey(), @@ -176,139 +221,110 @@ void MainWindow::setHotkey() globalData->closeGameImmediatelyHotkey())); // 防火墙 - if (!globalData->firewallStartHotkey().isEmpty() && !globalData->firewallStopHotkey().isEmpty()) { - bool sameFirewallHotkey = globalData->firewallStartHotkey() == globalData->firewallStopHotkey(); - startFirewallHotkey = new QHotkey(QKeySequence(globalData->firewallStartHotkey()), true, qApp); - if (startFirewallHotkey->isRegistered()) { - connect(startFirewallHotkey, &QHotkey::activated, qApp, [this, sameFirewallHotkey]() { - if (sameFirewallHotkey) { - ui.btnStartFirewall->toggle(); - } else { - ui.btnStartFirewall->setChecked(true); - } - }); - } else { - QMessageBox::critical(this, QString(), tr("注册启用防火墙热键失败!")); - } - if (!sameFirewallHotkey) { - stopFirewallHotkey = new QHotkey(QKeySequence(globalData->firewallStopHotkey()), true, qApp); - if (stopFirewallHotkey->isRegistered()) { - connect(stopFirewallHotkey, &QHotkey::activated, qApp, [this]() { - ui.btnStartFirewall->setChecked(false); - }); - } else { - QMessageBox::critical(this, QString(), tr("注册关闭防火墙热键失败!")); - } - } - } + registerHotkeyPair( + globalData->firewallStartHotkey(), globalData->firewallStopHotkey(), + startFirewallHotkey, stopFirewallHotkey, + [this]() { ui.btnStartFirewall->toggle(); }, + [this](bool check) { ui.btnStartFirewall->setChecked(check); }, + [this](bool registerFirst) { + QMessageBox::critical(this, QString(), registerFirst ? tr("注册启用防火墙快捷键失败!") : tr("注册关闭防火墙快捷键失败!")); + }, + true); + + // 网络适配器 + registerHotkeyPair( + globalData->networkAdaptersDisableHotkey(), globalData->networkAdaptersEnableHotkey(), + disableNetworkAdapterHotkey, enableNetworkAdapterHotkey, + [this]() { + if (ui.pbDisableNetworkAdapters->isEnabled()) { + ui.pbDisableNetworkAdapters->toggle(); + }; + }, + [this](bool check) { + if (ui.pbDisableNetworkAdapters->isEnabled()) { + ui.pbDisableNetworkAdapters->setChecked(check); + }; + }, + [this](bool registerFirst) { + QMessageBox::critical(this, QString(), + registerFirst ? tr("注册禁用网络适配器快捷键失败!") : tr("注册启用网络适配器快捷键失败!")); + }, + true); // 计时器 - if (!globalData->timerStartHotkey().isEmpty() && !globalData->timerStopHotkey().isEmpty()) { - bool sameTimerHotkey = globalData->timerStartHotkey() == globalData->timerStopHotkey(); - startTimerHotkey = new QHotkey(QKeySequence(globalData->timerStartHotkey()), true, qApp); - if (startTimerHotkey->isRegistered()) { - connect(startTimerHotkey, &QHotkey::activated, qApp, [this, sameTimerHotkey]() { - if (sameTimerHotkey) { - ui.btnStartTimer->click(); + registerHotkeyPair( + globalData->timerStartHotkey(), globalData->timerStopHotkey(), + startTimerHotkey, stopTimerHotkey, + [this]() { ui.btnStartTimer->click(); }, + [this](bool check) { + if (check) { + if (globalData->timerStopStrategy() == TimerStopStrategy::StopSecondZero) { + // 在 stoppedState 时,按下开始快捷键要求不能开始,因此try尝试 + // 只有 stoppedAndZeroState 接受 tryToTimerRunningState 信号 + // 因此 TimerStopStrategy::StopSecondZero 且在 stoppedState 时按下开始快捷键也没有接收者 + emit tryToTimerRunningState(); } else { - if (globalData->timerStopStrategy() == TimerStopStrategy::StopSecondZero) { - // 在 stoppedState 时,按下开始热键要求不能开始,因此try尝试 - // 只有 stoppedAndZeroState 接受 tryToTimerRunningState 信号 - // 因此 TimerStopStrategy::StopSecondZero 且在 stoppedState 时按下开始热键也没有接收者 - emit tryToTimerRunningState(); - } else { - emit toTimerRunningState(); - } + emit toTimerRunningState(); } - }); - } else { - QMessageBox::critical(nullptr, QString(), tr("注册启动计时器热键失败!")); - } - if (!sameTimerHotkey) { - stopTimerHotkey = new QHotkey(QKeySequence(globalData->timerStopHotkey()), true, qApp); - if (stopTimerHotkey->isRegistered()) { - connect(stopTimerHotkey, &QHotkey::activated, qApp, [=]() { - if (globalData->timerStopStrategy() == TimerStopStrategy::OnlyStop - || globalData->timerStopStrategy() == TimerStopStrategy::StopAndZero) { - // 在 stoppedState 时,按下停止热键要求不能(再次)归零,因此try尝试 - // 只有 runningState 接受 tryToTimerStoppedOrStoppedAndZeroState 信号 - // 因此 (TimerStopStrategy::OnlyStop 或 TimerStopStrategy::StopAndZero) 且在 stoppedState 时按下停止热键也没有接收者 - emit tryToTimerStoppedOrStoppedAndZeroState(); - } else { - emit toTimerStoppedOrStoppedAndZeroState(); - } - }); } else { - QMessageBox::critical(this, QString(), tr("注册停止计时器热键失败!")); + if (globalData->timerStopStrategy() == TimerStopStrategy::OnlyStop + || globalData->timerStopStrategy() == TimerStopStrategy::StopAndZero) { + // 在 stoppedState 时,按下停止快捷键要求不能(再次)归零,因此try尝试 + // 只有 runningState 接受 tryToTimerStoppedOrStoppedAndZeroState 信号 + // 因此 (TimerStopStrategy::OnlyStop 或 TimerStopStrategy::StopAndZero) 且在 stoppedState 时按下停止快捷键也没有接收者 + emit tryToTimerStoppedOrStoppedAndZeroState(); + } else { + emit toTimerStoppedOrStoppedAndZeroState(); + } } - } + }, + [this](bool registerFirst) { + QMessageBox::critical(this, QString(), + registerFirst ? tr("注册启动计时器快捷键失败!") : tr("注册停止计时器快捷键失败!")); + }, + true); + if (!globalData->timerStartHotkey().isEmpty() && !globalData->timerStopHotkey().isEmpty()) { if (globalData->timerPauseHotkey() == globalData->timerStartHotkey() || globalData->timerPauseHotkey() == globalData->timerStopHotkey()) { - QMessageBox::critical(this, QString(), tr("暂停计时器热键与启动/停止计时器热键相同,暂停计时器热键将会无效!")); + QMessageBox::critical(this, QString(), tr("暂停计时器快捷键与启动/停止计时器快捷键相同,暂停计时器快捷键将会无效!")); } else { - pauseTimerHotkey = new QHotkey(QKeySequence(globalData->timerPauseHotkey()), true, qApp); - if (pauseTimerHotkey->isRegistered()) { - connect(pauseTimerHotkey, &QHotkey::activated, qApp, [this]() { + registerHotkey( + globalData->timerPauseHotkey(), + pauseTimerHotkey, + [this]() { if (ui.btnPauseTimer->isEnabled()) { ui.btnPauseTimer->click(); - } - }); - } else { - QMessageBox::critical(this, QString(), tr("注册暂停计时器热键失败!")); - } + }; + }, + [this]() { QMessageBox::critical(this, QString(), tr("注册暂停计时器快捷键失败!")); }); } } // 卡单 - if (!globalData->suspendAndResumeHotkey().isEmpty()) { - suspendAndResumeHotkey = new QHotkey(QKeySequence(globalData->suspendAndResumeHotkey()), true, qApp); - if (suspendAndResumeHotkey->isRegistered()) { - connect(suspendAndResumeHotkey, &QHotkey::activated, qApp, [this]() { - ui.btnSuspendProcess->click(); - }); - } else { - QMessageBox::critical(this, QString(), tr("注册卡单热键失败!")); - } - } + registerHotkey( + globalData->suspendAndResumeHotkey(), + suspendAndResumeHotkey, + [this]() { ui.btnSuspendProcess->click(); }, + [this]() { QMessageBox::critical(this, QString(), tr("注册卡单快捷键失败!")); }); // 快速结束游戏 - if (!globalData->closeGameImmediatelyHotkey().isEmpty()) { - closeGameImmediatelyHotkey = new QHotkey(QKeySequence(globalData->closeGameImmediatelyHotkey()), true, qApp); - if (closeGameImmediatelyHotkey->isRegistered()) { - connect(closeGameImmediatelyHotkey, &QHotkey::activated, qApp, [this]() { - closeGameImmediately(); - }); - } else { - QMessageBox::critical(this, QString(), tr("注册快速结束游戏热键失败!")); - } - } + registerHotkey( + globalData->closeGameImmediatelyHotkey(), + closeGameImmediatelyHotkey, + [this]() { closeGameImmediately(); }, + [this]() { QMessageBox::critical(this, QString(), tr("注册快速结束游戏快捷键失败!")); }); // 末日将至爆头识别 - if (!globalData->act3HeadshotStartHotkey().isEmpty() && !globalData->act3HeadshotStopHotkey().isEmpty()) { - bool sameHotkey = globalData->act3HeadshotStartHotkey() == globalData->act3HeadshotStopHotkey(); - act3HeadshotStartHotkey = new QHotkey(QKeySequence(globalData->act3HeadshotStartHotkey()), true, qApp); - if (act3HeadshotStartHotkey->isRegistered()) { - connect(act3HeadshotStartHotkey, &QHotkey::activated, qApp, [this, sameHotkey]() { - if (sameHotkey) { - ui.btnRpOcr->toggle(); - } else { - ui.btnRpOcr->setChecked(true); - } - }); - } else { - QMessageBox::critical(this, QString(), tr("注册末日将至爆头识别启动热键失败!")); - } - if (!sameHotkey) { - act3HeadshotStopHotkey = new QHotkey(QKeySequence(globalData->act3HeadshotStopHotkey()), true, qApp); - if (act3HeadshotStopHotkey->isRegistered()) { - connect(act3HeadshotStopHotkey, &QHotkey::activated, qApp, [this]() { - ui.btnRpOcr->setChecked(false); - }); - } else { - QMessageBox::critical(this, QString(), tr("注册末日将至爆头识别关闭热键失败!")); - } - } - } + registerHotkeyPair( + globalData->act3HeadshotStartHotkey(), globalData->act3HeadshotStopHotkey(), + act3HeadshotStartHotkey, act3HeadshotStopHotkey, + [this]() { ui.btnRpOcr->toggle(); }, + [this](bool check) { ui.btnRpOcr->setChecked(check); }, + [this](bool registerFirst) { + QMessageBox::critical(this, QString(), + registerFirst ? tr("注册末日将至爆头识别启动快捷键失败!") : tr("注册末日将至爆头识别关闭快捷键失败!")); + }, + true); } void MainWindow::initMenu() @@ -403,8 +419,8 @@ void MainWindow::initMenu() }); connect(ui.actionSetting, &QAction::triggered, this, [this]() { - auto dialog = new SettingDialog(this); removeAllHotkeys(); + auto dialog = new SettingDialog(this); dialog->exec(); setHotkey(); }); @@ -494,6 +510,11 @@ void MainWindow::initFirewall() }); ui.btnStartFirewall->setText(tr("已关闭")); + labFirewallState.setAutoFillBackground(true); + labFirewallState.setMinimumWidth(16); + QPalette palette = labFirewallState.palette(); + palette.setColor(QPalette::Window, Qt::red); + labFirewallState.setPalette(palette); connect(ui.btnStartFirewall, &QAbstractButton::toggled, this, [this](bool checked) { if (checked == FirewallUtil::getIsEnabled()) { return; @@ -502,18 +523,18 @@ void MainWindow::initFirewall() if (succeed) { if (checked) { ui.btnStartFirewall->setText(tr("已开启")); - QPalette palette = labState->palette(); + QPalette palette = labFirewallState.palette(); palette.setColor(QPalette::Window, Qt::green); - labState->setPalette(palette); + labFirewallState.setPalette(palette); if (globalData->firewallPlaySound()) { PlaySound(globalData->firewallStartSound().toStdWString().c_str(), nullptr, SND_FILENAME | SND_ASYNC); } } else { ui.btnStartFirewall->setText(tr("已关闭")); - QPalette palette = labState->palette(); + QPalette palette = labFirewallState.palette(); palette.setColor(QPalette::Window, Qt::red); - labState->setPalette(palette); + labFirewallState.setPalette(palette); if (globalData->firewallPlaySound()) { PlaySound(globalData->firewallStopSound().toStdWString().c_str(), nullptr, SND_FILENAME | SND_ASYNC); @@ -531,6 +552,38 @@ void MainWindow::initFirewall() ui.btnStartFirewall->setFocus(); } +void MainWindow::initNetworkAdapters() +{ + auto onSetLabelText = [this]() { + if (globalData->selectedNetworkAdapters().empty()) { + ui.labSelectedNetworkAdapters->setText(tr("请先在设置页面选择网络适配器!")); + } else { + ui.labSelectedNetworkAdapters->setText( + networkAdapterUtil->adapterNames(globalData->selectedNetworkAdapters()).join('\n')); + } + }; + auto onSetButtonEnabled = [this]() { + ui.pbDisableNetworkAdapters->setEnabled(!globalData->selectedNetworkAdapters().empty()); + }; + + onSetLabelText(); + onSetButtonEnabled(); + ui.pbDisableNetworkAdapters->setText(tr("未禁用")); + labNetworkAdaptersState.setText("🔗"); + + connect(globalData, &GlobalData::selectedNetworkAdaptersChanged, this, [onSetLabelText, onSetButtonEnabled]() { + onSetLabelText(); + onSetButtonEnabled(); + }); + connect(ui.pbDisableNetworkAdapters, &QAbstractButton::toggled, this, [this](bool checked) { + networkAdapterUtil->setNetworkAdaptersEnabled(globalData->selectedNetworkAdapters(), !checked); + ui.pbDisableNetworkAdapters->setText(checked ? tr("已禁用") : tr("未禁用")); + labNetworkAdaptersState.setText(checked ? "⛓️‍💥" : "🔗"); + auto sound = checked ? globalData->networkAdaptersDisableSound() : globalData->networkAdaptersEnableSound(); + PlaySound(sound.toStdWString().c_str(), nullptr, SND_FILENAME | SND_ASYNC); + }); +} + void MainWindow::initAct3Headshot() { connect(ui.btnSelectRegion, &QAbstractButton::clicked, this, [this]() { diff --git a/EliteSpeedrunTool/MainWindow.h b/EliteSpeedrunTool/MainWindow.h index bac9389..f9ac69f 100644 --- a/EliteSpeedrunTool/MainWindow.h +++ b/EliteSpeedrunTool/MainWindow.h @@ -28,6 +28,19 @@ class MainWindow : public QMainWindow { void checkUpdate(); + void registerHotkey( + const QString& hotkeyString, + QHotkey*& hotkey, + std::function onActivated, + std::function registerFailed); + + void registerHotkeyPair( + const QString& firstString, const QString& secondString, + QHotkey*& firstHotkey, QHotkey*& secondHotkey, + std::function toggle, std::function check, + std::function registerFailed, + bool canBeSame); + void removeAllHotkeys(); void removeHotkey(QHotkey*& h); @@ -37,6 +50,7 @@ class MainWindow : public QMainWindow { void initMenu(); void initFirewall(); + void initNetworkAdapters(); void initAct3Headshot(); @@ -92,6 +106,9 @@ class MainWindow : public QMainWindow { QHotkey* startFirewallHotkey = nullptr; QHotkey* stopFirewallHotkey = nullptr; + QHotkey* disableNetworkAdapterHotkey = nullptr; + QHotkey* enableNetworkAdapterHotkey = nullptr; + QHotkey* startTimerHotkey = nullptr; QHotkey* pauseTimerHotkey = nullptr; QHotkey* stopTimerHotkey = nullptr; @@ -103,9 +120,9 @@ class MainWindow : public QMainWindow { QHotkey* closeGameImmediatelyHotkey = nullptr; - QLabel* labCurrentHotkey; - - QLabel* labState; + QLabel labCurrentHotkey = QLabel(this); + QLabel labFirewallState = QLabel(this); + QLabel labNetworkAdaptersState = QLabel(this); QTimer* topMostTimer = nullptr; diff --git a/EliteSpeedrunTool/MainWindow.ui b/EliteSpeedrunTool/MainWindow.ui index 069f7f4..213b814 100644 --- a/EliteSpeedrunTool/MainWindow.ui +++ b/EliteSpeedrunTool/MainWindow.ui @@ -9,8 +9,8 @@ 0 0 - 428 - 328 + 457 + 361 @@ -44,215 +44,326 @@ 0 - - - QFrame::NoFrame + + + QTabWidget::West - + + 0 + + true - - - - 0 - 0 - 396 - 298 - - - + + + 防火墙 + + + + 0 + - - - - 0 - 0 - + + + QFrame::NoFrame + + true + + + + + 0 + 0 + 389 + 272 + + + + + 0 + + + 0 + + + 9 + + + 0 + + + + + + + 代言人 + + + + + + + 10 + + + + 代言人:AdstarGod +星神断网,好用没烦恼 +😋 + + + Qt::AlignCenter + + + + + + + + + + + 0 + 0 + + + + 防火墙状态 + + + + + + + + + + + + + + 0 + 0 + + + + + + + + 专用 + + + + + + + + 0 + 0 + + + + + + + + 公用 + + + + + + + + 0 + 0 + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + + true + + + + 注意:公用网络防火墙未开启,请先测试断网是否有效 + + + true + + + + + + + 播放提示音 + + + + + + + + 0 + 0 + + + + 警告 + + + + + + + true + + + + Windows 防火墙未启用,无法使用断网功能! + + + Qt::AlignCenter + + + true + + + + + + + QLayout::SetMinimumSize + + + + + 打开系统设置... + + + + + + + 刷新 + + + + + + + + + + + + + 0 + 0 + + + + true + + + true + + + true + + + + + + + + + + + + 网络适配器 + + + + - 警告 + 选择的网络适配器 - + - - - - true - + + + + 0 + 0 + - Windows 防火墙未启用,无法使用断网功能! - - - Qt::AlignCenter - - - true + - - - - QLayout::SetMinimumSize - - - - - 打开系统设置... - - - - - - - 刷新 - - - - - - - - - - 代言人 - - - - - - - 10 - - - - 代言人:AdstarGod -星神断网,好用没烦恼 -😋 - - - Qt::AlignCenter - - - - - - - - - - - 0 - 0 - - - - 防火墙状态 - - - - - - - - - - - - - - 0 - 0 - - - - - - - - 专用 - - - - - - - - 0 - 0 - - - - - - - - 公用 - - - - - - - - 0 - 0 - - - - - - - - - - - + 0 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - true - 注意:公用网络防火墙未开启,请先测试断网是否有效 + 注意:禁用网卡存在延迟,请勿用于时间敏感的操作! true @@ -260,27 +371,17 @@ - - - 播放提示音 - - - - - + 0 0 - - true - - - true + + - + true @@ -712,8 +813,8 @@ 0 0 - 428 - 21 + 457 + 20 diff --git a/EliteSpeedrunTool/NetworkAdapterUtil.cpp b/EliteSpeedrunTool/NetworkAdapterUtil.cpp new file mode 100644 index 0000000..ad9f821 --- /dev/null +++ b/EliteSpeedrunTool/NetworkAdapterUtil.cpp @@ -0,0 +1,205 @@ +#include "NetworkAdapterUtil.h" +#include +#include +#include +#include +#include + +Q_GLOBAL_STATIC(NetworkAdapterUtil, networkAdapterUtilInstance) + +NetworkAdapterUtil::NetworkAdapterUtil(QObject* parent) + : QObject { parent } +{ + initNetworkAdapterGuid(); +} + +NetworkAdapterUtil* NetworkAdapterUtil::instance() +{ + return networkAdapterUtilInstance; +} + +QList NetworkAdapterUtil::networkAdapters() +{ + QList adapters; + + // 获取网络适配器的设备信息集合 + HDEVINFO deviceInfoSet = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, nullptr, nullptr, DIGCF_PRESENT | DIGCF_PROFILE); + if (deviceInfoSet == INVALID_HANDLE_VALUE) { + qCritical() << "Failed to get device information set."; + return adapters; + } + + SP_DEVINFO_DATA deviceInfoData; + deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + DWORD deviceIndex = 0; + + // 遍历网络适配器 + while (SetupDiEnumDeviceInfo(deviceInfoSet, deviceIndex, &deviceInfoData)) { + deviceIndex++; + + // 获取设备名称 + WCHAR deviceName[256]; + if (SetupDiGetDeviceRegistryProperty(deviceInfoSet, &deviceInfoData, SPDRP_FRIENDLYNAME, nullptr, + (PBYTE)deviceName, sizeof(deviceName), nullptr)) { + qInfo() << "Device Name: " << QString::fromWCharArray(deviceName); + } else { + qCritical() << "Device Name: Unknown"; + } + + // 获取设备的实例 ID + WCHAR deviceInstanceId[256]; + if (SetupDiGetDeviceInstanceId(deviceInfoSet, &deviceInfoData, deviceInstanceId, + sizeof(deviceInstanceId) / sizeof(WCHAR), nullptr)) { + qInfo() << "Device Instance ID: " << QString::fromWCharArray(deviceInstanceId); + } else { + qCritical() << "Failed to get device instance ID for device index " << deviceIndex - 1; + } + + adapters << NetworkAdapter(QString::fromWCharArray(deviceName), QString::fromWCharArray(deviceInstanceId)); + } + + // 清理设备信息集合 + SetupDiDestroyDeviceInfoList(deviceInfoSet); + + return adapters; +} + +QList NetworkAdapterUtil::adapterNames(QList deviceIds) +{ + QList result; + // 获取设备信息集合句柄 + HDEVINFO deviceInfoSet = SetupDiGetClassDevs( + &networkAdapterGuid, nullptr, nullptr, DIGCF_PRESENT | DIGCF_PROFILE); + + if (deviceInfoSet == INVALID_HANDLE_VALUE) { + qCritical() << "Failed to get device information set."; + return result; + } + + SP_DEVINFO_DATA deviceInfoData; + deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + DWORD deviceIndex = 0; + + for (const auto& id : deviceIds) { + if (!SetupDiOpenDeviceInfoA(deviceInfoSet, id.toStdString().c_str(), nullptr, 0, &deviceInfoData)) { + qCritical() << "adapterName: Failed to open device with instance ID: " << id; + SetupDiDestroyDeviceInfoList(deviceInfoSet); + continue; + } + // 获取设备名称 + WCHAR deviceName[256]; + if (SetupDiGetDeviceRegistryProperty(deviceInfoSet, &deviceInfoData, SPDRP_FRIENDLYNAME, nullptr, + (PBYTE)deviceName, sizeof(deviceName), nullptr)) { + result << QString::fromWCharArray(deviceName); + } else { + qCritical() << "Device Name: Unknown"; + } + } + qInfo() << "Device Names: " << result; + + return result; +} + +bool NetworkAdapterUtil::setNetworkAdaptersEnabled(QList deviceIds, bool enabled) +{ + // 获取设备信息集合句柄 + HDEVINFO deviceInfoSet = SetupDiGetClassDevs( + &networkAdapterGuid, nullptr, nullptr, DIGCF_PRESENT | DIGCF_PROFILE); + + if (deviceInfoSet == INVALID_HANDLE_VALUE) { + qCritical() << "Failed to get device information set."; + return false; + } + + SP_DEVINFO_DATA deviceInfoData; + deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + DWORD deviceIndex = 0; + bool success = true; + + for (const auto& id : deviceIds) { + if (!SetupDiOpenDeviceInfoA(deviceInfoSet, id.toStdString().c_str(), nullptr, 0, &deviceInfoData)) { + qCritical() << "Failed to open device with instance ID: " << id; + SetupDiDestroyDeviceInfoList(deviceInfoSet); + success = false; + break; + } + + // 准备禁用设备的属性 + SP_PROPCHANGE_PARAMS propChangeParams; + propChangeParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); + propChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; + propChangeParams.StateChange = enabled ? DICS_ENABLE : DICS_DISABLE; + propChangeParams.Scope = DICS_FLAG_GLOBAL; + propChangeParams.HwProfile = 0; + + // 设置禁用参数 + if (!SetupDiSetClassInstallParams(deviceInfoSet, &deviceInfoData, + (SP_CLASSINSTALL_HEADER*)&propChangeParams, sizeof(propChangeParams))) { + qCritical() << "Failed to set class install parameters."; + SetupDiDestroyDeviceInfoList(deviceInfoSet); + success = false; + break; + } + + // 调用类安装程序执行禁用操作 + if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, deviceInfoSet, &deviceInfoData)) { + qCritical() << "Failed to disable device with instance ID: " << id; + SetupDiDestroyDeviceInfoList(deviceInfoSet); + success = false; + break; + } + } + + // 清理设备信息集合 + SetupDiDestroyDeviceInfoList(deviceInfoSet); + return success; +} + +void NetworkAdapterUtil::initNetworkAdapterGuid() +{ + // 获取所有网络适配器的设备信息 + HDEVINFO hDevInfo = SetupDiGetClassDevs( + &GUID_DEVCLASS_NET, nullptr, nullptr, DIGCF_PRESENT | DIGCF_PROFILE); + + if (hDevInfo == INVALID_HANDLE_VALUE) { + qCritical() << "Failed to get device information."; + return; + } + + // 枚举设备信息 + SP_DEVINFO_DATA devInfoData; + devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + DWORD i = 0; + + while (SetupDiEnumDeviceInfo(hDevInfo, i, &devInfoData)) { + i++; + + // 获取设备实例 ID + WCHAR instanceId[MAX_DEVICE_ID_LEN]; + if (SetupDiGetDeviceInstanceId(hDevInfo, &devInfoData, instanceId, MAX_DEVICE_ID_LEN, nullptr)) { + qInfo() << "Network Adapter Device Instance ID: " << QString::fromWCharArray(instanceId); + } + + // 获取设备的友好名称 + WCHAR friendlyName[256]; + if (SetupDiGetDeviceRegistryProperty(hDevInfo, &devInfoData, SPDRP_FRIENDLYNAME, nullptr, + (PBYTE)friendlyName, sizeof(friendlyName), nullptr)) { + qInfo() << "Network Adapter Friendly Name: " << QString::fromWCharArray(friendlyName); + } + + // 获取网络适配器的 GUID + WCHAR classGuid[39] = { 0 }; + if (SetupDiGetDeviceRegistryProperty(hDevInfo, &devInfoData, SPDRP_CLASSGUID, nullptr, + (PBYTE)&classGuid, sizeof(classGuid), nullptr)) { + HRESULT hr = CLSIDFromString(classGuid, (LPCLSID)&networkAdapterGuid); + if (FAILED(hr)) { + qCritical() << "CLSIDFromString failed."; + } + qInfo() << "Network Adapter GUID: " << QString::fromWCharArray(classGuid); + break; // 只需要获取一次即可 + } + } + + // 清理资源 + SetupDiDestroyDeviceInfoList(hDevInfo); +} diff --git a/EliteSpeedrunTool/NetworkAdapterUtil.h b/EliteSpeedrunTool/NetworkAdapterUtil.h new file mode 100644 index 0000000..1dd1022 --- /dev/null +++ b/EliteSpeedrunTool/NetworkAdapterUtil.h @@ -0,0 +1,39 @@ +#ifndef NETWORKADAPTERUTIL_H +#define NETWORKADAPTERUTIL_H + +#include +#include + +#define networkAdapterUtil (NetworkAdapterUtil::instance()) + +struct NetworkAdapter { + QString name; + QString deviceId; + NetworkAdapter(QString name, QString deviceId) + { + this->name = name; + this->deviceId = deviceId; + } +}; + +class NetworkAdapterUtil : public QObject { + Q_OBJECT +public: + explicit NetworkAdapterUtil(QObject* parent = nullptr); + + static NetworkAdapterUtil* instance(); + + QList networkAdapters(); + + QList adapterNames(QList deviceIds); + + bool setNetworkAdaptersEnabled(QList deviceIds, bool enabled); + +private: + void initNetworkAdapterGuid(); + GUID networkAdapterGuid; + +signals: +}; + +#endif // NETWORKADAPTERUTIL_H diff --git a/EliteSpeedrunTool/SettingDialog.cpp b/EliteSpeedrunTool/SettingDialog.cpp index 166d6e9..d706738 100644 --- a/EliteSpeedrunTool/SettingDialog.cpp +++ b/EliteSpeedrunTool/SettingDialog.cpp @@ -1,6 +1,7 @@ #include "SettingDialog.h" #include "GlobalData.h" #include "LanguageUtil.h" +#include "NetworkAdapterUtil.h" #include #include #include @@ -31,6 +32,7 @@ SettingDialog::SettingDialog(QWidget* parent) initGeneralSettings(); initFirewallSettings(); + initNetworkAdaptersSettings(); initTimerSettings(); initAct3Headshot(); initSuspendProcess(); @@ -73,97 +75,91 @@ void SettingDialog::initGeneralSettings() }); } -QString SettingDialog::getSoundFile(QString dir) +void SettingDialog::initSoundWidgets( + const QString& soundPath, + QLineEdit* soundPathEdit, + QAbstractButton* playButton, + QAbstractButton* selectFileButton, + std::function onUpdateSoundPath) { - return QFileDialog::getOpenFileName(this, tr("选择文件"), dir, tr("WAV 文件 (*.wav)")); -} - -// 防火墙 -void SettingDialog::initFirewallSettings() -{ - // 热键 - ui.keySeqStartFirewall->setKeySequence(QKeySequence(globalData->firewallStartHotkey())); - connect(ui.keySeqStartFirewall, &QKeySequenceEdit::editingFinished, this, [=]() { - if (ui.keySeqStartFirewall->keySequence().count() > 1) { - QKeyCombination value = ui.keySeqStartFirewall->keySequence()[0]; - QKeySequence shortcut(value); - ui.keySeqStartFirewall->setKeySequence(shortcut); - globalData->setFirewallStartHotkey(shortcut.toString()); - } else { - globalData->setFirewallStartHotkey(ui.keySeqStartFirewall->keySequence().toString()); + soundPathEdit->setText(soundPath); + connect(selectFileButton, &QAbstractButton::clicked, this, [=]() { + QString fileName = getSoundFile(soundPath); + if (!fileName.isEmpty()) { + soundPathEdit->setText(fileName); + onUpdateSoundPath(fileName); } }); - - connect(ui.tbClearStartFirewallHotkeyEdit, &QAbstractButton::clicked, this, [=]() { - ui.keySeqStartFirewall->clear(); - globalData->setFirewallStartHotkey(""); + connect(soundPathEdit, &QLineEdit::textChanged, this, [onUpdateSoundPath](const QString& text) { + onUpdateSoundPath(text); }); + connect(playButton, &QAbstractButton::clicked, this, [soundPathEdit]() { + PlaySound(soundPathEdit->text().toStdWString().c_str(), nullptr, SND_FILENAME | SND_ASYNC); + }); +} - ui.keySeqStopFirewall->setKeySequence(QKeySequence(globalData->firewallStopHotkey())); - connect(ui.keySeqStopFirewall, &QKeySequenceEdit::editingFinished, this, [=]() { - if (ui.keySeqStopFirewall->keySequence().count() > 1) { - QKeyCombination value = ui.keySeqStopFirewall->keySequence()[0]; +void SettingDialog::initHotkeyWidgets( + const QString& hotkey, + QKeySequenceEdit* keySequenceEdit, + QAbstractButton* clearButton, + std::function onUpdateHotkey) +{ + keySequenceEdit->setKeySequence(QKeySequence(hotkey)); + connect(keySequenceEdit, &QKeySequenceEdit::editingFinished, this, [=]() { + if (keySequenceEdit->keySequence().count() > 1) { + QKeyCombination value = keySequenceEdit->keySequence()[0]; QKeySequence shortcut(value); - ui.keySeqStopFirewall->setKeySequence(shortcut); - globalData->setFirewallStopHotkey(shortcut.toString()); + keySequenceEdit->setKeySequence(shortcut); + onUpdateHotkey(shortcut.toString()); } else { - globalData->setFirewallStopHotkey(ui.keySeqStopFirewall->keySequence().toString()); + onUpdateHotkey(keySequenceEdit->keySequence().toString()); } }); - - connect(ui.tbClearStopFirewallHotkeyEdit, &QAbstractButton::clicked, this, [=]() { - ui.keySeqStopFirewall->clear(); - globalData->setFirewallStopHotkey(""); + connect(clearButton, &QAbstractButton::clicked, this, [=]() { + keySequenceEdit->clear(); + onUpdateHotkey(""); }); +} - // 音效 - ui.leFirewallStartSoundPath->setText(globalData->firewallStartSound()); - connect(ui.tbFirewallSelectStartSound, &QAbstractButton::clicked, this, [=]() { - QString fileName = getSoundFile(globalData->firewallStartSound()); - if (!fileName.isEmpty()) { - ui.leFirewallStartSoundPath->setText(fileName); - globalData->setFirewallStartSound(fileName); - } - }); - connect(ui.leFirewallStartSoundPath, &QLineEdit::textChanged, this, [=](const QString& text) { - globalData->setFirewallStartSound(text); - }); - connect(ui.tbFirewallPlayStartSound, &QAbstractButton::clicked, this, [=]() { - PlaySound(globalData->firewallStartSound().toStdWString().c_str(), - nullptr, SND_FILENAME | SND_ASYNC); - }); +QString SettingDialog::getSoundFile(QString dir) +{ + return QFileDialog::getOpenFileName(this, tr("选择音频文件"), dir, tr("WAV 文件 (*.wav)")); +} - ui.leFirewallStopSoundPath->setText(globalData->firewallStopSound()); - connect(ui.tbFirewallSelectStopSound, &QAbstractButton::clicked, this, [=]() { - QString fileName = getSoundFile(globalData->firewallStopSound()); - if (!fileName.isEmpty()) { - ui.leFirewallStopSoundPath->setText(fileName); - globalData->setFirewallStopSound(fileName); - } - }); - connect(ui.leFirewallStopSoundPath, &QLineEdit::textChanged, this, [=](const QString& text) { - globalData->setFirewallStopSound(text); - }); - connect(ui.tbFirewallPlayStopSound, &QAbstractButton::clicked, this, [=]() { - PlaySound(globalData->firewallStopSound().toStdWString().c_str(), - nullptr, SND_FILENAME | SND_ASYNC); - }); +// 防火墙 +void SettingDialog::initFirewallSettings() +{ + // 快捷键 + initHotkeyWidgets( + globalData->firewallStartHotkey(), + ui.keySeqStartFirewall, + ui.tbClearStartFirewallHotkeyEdit, + [](const QString& hotkey) { globalData->setFirewallStartHotkey(hotkey); }); + initHotkeyWidgets( + globalData->firewallStopHotkey(), + ui.keySeqStopFirewall, + ui.tbClearStopFirewallHotkeyEdit, + [](const QString& hotkey) { globalData->setFirewallStopHotkey(hotkey); }); - ui.leFirewallErrorSoundPath->setText(globalData->firewallErrorSound()); - connect(ui.tbFirewallSelectErrorSound, &QAbstractButton::clicked, this, [=]() { - QString fileName = getSoundFile(globalData->firewallErrorSound()); - if (!fileName.isEmpty()) { - ui.leFirewallErrorSoundPath->setText(fileName); - globalData->setFirewallErrorSound(fileName); - } - }); - connect(ui.leFirewallErrorSoundPath, &QLineEdit::textChanged, this, [=](const QString& text) { - globalData->setFirewallErrorSound(text); - }); - connect(ui.tbFirewallPlayErrorSound, &QAbstractButton::clicked, this, [=]() { - PlaySound(globalData->firewallErrorSound().toStdWString().c_str(), - nullptr, SND_FILENAME | SND_ASYNC); - }); + // 音效 + initSoundWidgets( + globalData->firewallStartSound(), + ui.leFirewallStartSoundPath, + ui.tbFirewallPlayStartSound, + ui.tbFirewallSelectStartSound, + [](const QString& fileName) { globalData->setFirewallStartSound(fileName); }); + initSoundWidgets( + globalData->firewallStopSound(), + ui.leFirewallStopSoundPath, + ui.tbFirewallPlayStopSound, + ui.tbFirewallSelectStopSound, + [](const QString& fileName) { globalData->setFirewallStopSound(fileName); }); + initSoundWidgets( + globalData->firewallErrorSound(), + ui.leFirewallErrorSoundPath, + ui.tbFirewallPlayErrorSound, + ui.tbFirewallSelectErrorSound, + [](const QString& fileName) { globalData->setFirewallErrorSound(fileName); }); // 防火墙针对的exe程序 ui.leFirewallAppPath->setText(globalData->firewallAppPath()); @@ -202,59 +198,78 @@ void SettingDialog::initFirewallSettings() } } -// 计时器设置 -void SettingDialog::initTimerSettings() +void SettingDialog::initNetworkAdaptersSettings() { - ui.keySeqStartTimer->setKeySequence(QKeySequence(globalData->timerStartHotkey())); - connect(ui.keySeqStartTimer, &QKeySequenceEdit::editingFinished, this, [=]() { - if (ui.keySeqStartTimer->keySequence().count() > 1) { - QKeyCombination value = ui.keySeqStartTimer->keySequence()[0]; - QKeySequence shortcut(value); - ui.keySeqStartTimer->setKeySequence(shortcut); - globalData->setTimerStartHotkey(shortcut.toString()); - } else { - globalData->setTimerStartHotkey(ui.keySeqStartTimer->keySequence().toString()); - } - }); - - connect(ui.tbClearStartTimerHotkeyEdit, &QAbstractButton::clicked, this, [=]() { - ui.keySeqStartTimer->clear(); - globalData->setTimerStartHotkey(""); - }); - - ui.keySeqPauseTimer->setKeySequence(QKeySequence(globalData->timerPauseHotkey())); - connect(ui.keySeqPauseTimer, &QKeySequenceEdit::editingFinished, this, [=]() { - if (ui.keySeqPauseTimer->keySequence().count() > 1) { - QKeyCombination value = ui.keySeqPauseTimer->keySequence()[0]; - QKeySequence shortcut(value); - ui.keySeqPauseTimer->setKeySequence(shortcut); - globalData->setTimerPauseHotkey(shortcut.toString()); + // 选择网络适配器 + auto adapters = networkAdapterUtil->networkAdapters(); + for (const auto& adapter : adapters) { + auto item = new QListWidgetItem(adapter.name); + item->setData(Qt::UserRole, adapter.deviceId); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(globalData->selectedNetworkAdapters().contains(adapter.deviceId) ? Qt::Checked : Qt::Unchecked); + ui.lwNetworkAdapters->addItem(item); + } + connect(ui.lwNetworkAdapters, &QListWidget::itemChanged, this, [=](QListWidgetItem* item) { + QList adapters; + adapters.append(globalData->selectedNetworkAdapters()); + auto adapterName = item->data(Qt::UserRole).toString(); + if (item->checkState() == Qt::Checked) { + if (!adapters.contains(adapterName)) { + adapters.append(adapterName); + } } else { - globalData->setTimerPauseHotkey(ui.keySeqPauseTimer->keySequence().toString()); + if (adapters.contains(adapterName)) { + adapters.removeAll(adapterName); + } } + globalData->setSelectedNetworkAdapters(adapters); }); - connect(ui.tbClearPauseTimerHotkeyEdit, &QAbstractButton::clicked, this, [=]() { - ui.keySeqPauseTimer->clear(); - globalData->setTimerPauseHotkey(""); - }); + // 快捷键 + initHotkeyWidgets( + globalData->networkAdaptersDisableHotkey(), + ui.keySeqDisableNetworkAdapter, + ui.tbClearDisableNetworkAdapterHotkeyEdit, + [](const QString& hotkey) { globalData->setNetworkAdaptersDisableHotkey(hotkey); }); + initHotkeyWidgets( + globalData->networkAdaptersEnableHotkey(), + ui.keySeqEnableNetworkAdapter, + ui.tbClearEnableNetworkAdapteHotkeyEdit, + [](const QString& hotkey) { globalData->setNetworkAdaptersEnableHotkey(hotkey); }); - ui.keySeqStopTimer->setKeySequence(QKeySequence(globalData->timerStopHotkey())); - connect(ui.keySeqStopTimer, &QKeySequenceEdit::editingFinished, this, [=]() { - if (ui.keySeqStopTimer->keySequence().count() > 1) { - QKeyCombination value = ui.keySeqStopTimer->keySequence()[0]; - QKeySequence shortcut(value); - ui.keySeqStopTimer->setKeySequence(shortcut); - globalData->setTimerStopHotkey(shortcut.toString()); - } else { - globalData->setTimerStopHotkey(ui.keySeqStopTimer->keySequence().toString()); - } - }); + // 音效 + initSoundWidgets( + globalData->networkAdaptersDisableSound(), + ui.leDisableNetworkAdapterSoundPath, + ui.tbPlayDisableNetworkAdapterSound, + ui.tbSelectDisableNetworkAdapterSound, + [](const QString& fileName) { globalData->setNetworkAdaptersDisableSound(fileName); }); + initSoundWidgets( + globalData->networkAdaptersEnableSound(), + ui.leEnableNetworkAdapterSoundPath, + ui.tbPlayEnableNetworkAdapterSound, + ui.tbSelectEnableNetworkAdapterSound, + [](const QString& fileName) { globalData->setNetworkAdaptersEnableSound(fileName); }); +} - connect(ui.tbClearStopTimerHotkeyEdit, &QAbstractButton::clicked, this, [=]() { - ui.keySeqStopTimer->clear(); - globalData->setTimerStopHotkey(""); - }); +// 计时器设置 +void SettingDialog::initTimerSettings() +{ + initHotkeyWidgets( + globalData->timerStartHotkey(), + ui.keySeqStartTimer, + ui.tbClearStartTimerHotkeyEdit, + [](const QString& hotkey) { globalData->setTimerStartHotkey(hotkey); }); + initHotkeyWidgets( + globalData->timerPauseHotkey(), + ui.keySeqPauseTimer, + ui.tbClearPauseTimerHotkeyEdit, + [](const QString& hotkey) { globalData->setTimerPauseHotkey(hotkey); }); + initHotkeyWidgets( + globalData->timerStopHotkey(), + ui.keySeqStopTimer, + ui.tbClearStopTimerHotkeyEdit, + [](const QString& hotkey) { globalData->setTimerStopHotkey(hotkey); }); // 手动计时刷新间隔 ui.sbTimerUpdateInterval->setValue(globalData->timerUpdateInterval()); @@ -494,92 +509,39 @@ void SettingDialog::initRtssSettings() void SettingDialog::initAct3Headshot() { - ui.keySeqAct3HeadshotStart->setKeySequence(QKeySequence(globalData->act3HeadshotStartHotkey())); - connect(ui.keySeqAct3HeadshotStart, &QKeySequenceEdit::editingFinished, this, [=]() { - if (ui.keySeqAct3HeadshotStart->keySequence().count() > 1) { - QKeyCombination value = ui.keySeqAct3HeadshotStart->keySequence()[0]; - QKeySequence shortcut(value); - ui.keySeqAct3HeadshotStart->setKeySequence(shortcut); - globalData->setAct3HeadshotStartHotkey(shortcut.toString()); - } else { - globalData->setAct3HeadshotStartHotkey(ui.keySeqAct3HeadshotStart->keySequence().toString()); - } - }); - - connect(ui.tbClearAct3HeadshotStart, &QAbstractButton::clicked, this, [=]() { - ui.keySeqAct3HeadshotStart->clear(); - globalData->setAct3HeadshotStartHotkey(""); - }); - - ui.keySeqAct3HeadshotStop->setKeySequence(QKeySequence(globalData->act3HeadshotStopHotkey())); - connect(ui.keySeqAct3HeadshotStop, &QKeySequenceEdit::editingFinished, this, [=]() { - if (ui.keySeqAct3HeadshotStop->keySequence().count() > 1) { - QKeyCombination value = ui.keySeqAct3HeadshotStop->keySequence()[0]; - QKeySequence shortcut(value); - ui.keySeqAct3HeadshotStop->setKeySequence(shortcut); - globalData->setAct3HeadshotStopHotkey(shortcut.toString()); - } else { - globalData->setAct3HeadshotStopHotkey(ui.keySeqAct3HeadshotStop->keySequence().toString()); - } - }); - - connect(ui.tbClearAct3HeadshotStop, &QAbstractButton::clicked, this, [=]() { - ui.keySeqAct3HeadshotStop->clear(); - globalData->setAct3HeadshotStopHotkey(""); - }); + initHotkeyWidgets( + globalData->act3HeadshotStartHotkey(), + ui.keySeqAct3HeadshotStart, + ui.tbClearAct3HeadshotStart, + [](const QString& hotkey) { globalData->setAct3HeadshotStartHotkey(hotkey); }); + initHotkeyWidgets( + globalData->act3HeadshotStopHotkey(), + ui.keySeqAct3HeadshotStop, + ui.tbClearAct3HeadshotStop, + [](const QString& hotkey) { globalData->setAct3HeadshotStopHotkey(hotkey); }); // 音效 - ui.leAct3HeadshotStartSoundPath->setText(globalData->act3HeadshotStartSound()); - connect(ui.tbAct3HeadshotStartSound, &QAbstractButton::clicked, this, [=]() { - QString fileName = getSoundFile(globalData->act3HeadshotStartSound()); - if (!fileName.isEmpty()) { - ui.leAct3HeadshotStartSoundPath->setText(fileName); - globalData->setAct3HeadshotStartSound(fileName); - } - }); - connect(ui.leAct3HeadshotStartSoundPath, &QLineEdit::textChanged, this, [=](const QString& text) { - globalData->setAct3HeadshotStartSound(text); - }); - connect(ui.tbAct3HeadshotPlayStartSound, &QAbstractButton::clicked, this, [=]() { - PlaySound(globalData->act3HeadshotStartSound().toStdWString().c_str(), - nullptr, SND_FILENAME | SND_ASYNC); - }); - - ui.leAct3HeadshotStopSoundPath->setText(globalData->act3HeadshotStopSound()); - connect(ui.tbAct3HeadshotStopSound, &QAbstractButton::clicked, this, [=]() { - QString fileName = getSoundFile(globalData->act3HeadshotStopSound()); - if (!fileName.isEmpty()) { - ui.leAct3HeadshotStopSoundPath->setText(fileName); - globalData->setAct3HeadshotStopSound(fileName); - } - }); - connect(ui.leAct3HeadshotStopSoundPath, &QLineEdit::textChanged, this, [=](const QString& text) { - globalData->setAct3HeadshotStopSound(text); - }); - connect(ui.tbAct3HeadshotPlayStopSound, &QAbstractButton::clicked, this, [=]() { - PlaySound(globalData->act3HeadshotStopSound().toStdWString().c_str(), - nullptr, SND_FILENAME | SND_ASYNC); - }); + initSoundWidgets( + globalData->act3HeadshotStartSound(), + ui.leAct3HeadshotStartSoundPath, + ui.tbAct3HeadshotPlayStartSound, + ui.tbAct3HeadshotStartSound, + [](const QString& fileName) { globalData->setAct3HeadshotStartSound(fileName); }); + initSoundWidgets( + globalData->act3HeadshotStopSound(), + ui.leAct3HeadshotStopSoundPath, + ui.tbAct3HeadshotPlayStopSound, + ui.tbAct3HeadshotStopSound, + [](const QString& fileName) { globalData->setAct3HeadshotStopSound(fileName); }); } void SettingDialog::initSuspendProcess() { - ui.keySeqSuspendProcess->setKeySequence(QKeySequence(globalData->suspendAndResumeHotkey())); - connect(ui.keySeqSuspendProcess, &QKeySequenceEdit::editingFinished, this, [=]() { - if (ui.keySeqSuspendProcess->keySequence().count() > 1) { - QKeyCombination value = ui.keySeqSuspendProcess->keySequence()[0]; - QKeySequence shortcut(value); - ui.keySeqSuspendProcess->setKeySequence(shortcut); - globalData->setSuspendAndResumeHotkey(shortcut.toString()); - } else { - globalData->setSuspendAndResumeHotkey(ui.keySeqSuspendProcess->keySequence().toString()); - } - }); - - connect(ui.tbClearSuspendProcessEdit, &QAbstractButton::clicked, this, [=]() { - ui.keySeqSuspendProcess->clear(); - globalData->setSuspendAndResumeHotkey(""); - }); + initHotkeyWidgets( + globalData->suspendAndResumeHotkey(), + ui.keySeqSuspendProcess, + ui.tbClearSuspendProcessEdit, + [](const QString& hotkey) { globalData->setSuspendAndResumeHotkey(hotkey); }); ui.sbSuspendProcessDuration->setValue(globalData->suspendAndResumeDuration()); connect(ui.sbSuspendProcessDuration, &QSpinBox::valueChanged, this, [=](int value) { @@ -589,22 +551,11 @@ void SettingDialog::initSuspendProcess() void SettingDialog::initCloseGameImmediatelySettings() { - ui.keySeqCloseGameImmediately->setKeySequence(QKeySequence(globalData->closeGameImmediatelyHotkey())); - connect(ui.keySeqCloseGameImmediately, &QKeySequenceEdit::editingFinished, this, [=]() { - if (ui.keySeqCloseGameImmediately->keySequence().count() > 1) { - QKeyCombination value = ui.keySeqCloseGameImmediately->keySequence()[0]; - QKeySequence shortcut(value); - ui.keySeqCloseGameImmediately->setKeySequence(shortcut); - globalData->setCloseGameImmediatelyHotkey(shortcut.toString()); - } else { - globalData->setCloseGameImmediatelyHotkey(ui.keySeqCloseGameImmediately->keySequence().toString()); - } - }); - - connect(ui.tbClearCloseGameImmediatelyHotkeyEdit, &QAbstractButton::clicked, this, [=]() { - ui.keySeqCloseGameImmediately->clear(); - globalData->setCloseGameImmediatelyHotkey(""); - }); + initHotkeyWidgets( + globalData->closeGameImmediatelyHotkey(), + ui.keySeqCloseGameImmediately, + ui.tbClearCloseGameImmediatelyHotkeyEdit, + [](const QString& hotkey) { globalData->setCloseGameImmediatelyHotkey(hotkey); }); } void SettingDialog::initSocialSettings() diff --git a/EliteSpeedrunTool/SettingDialog.h b/EliteSpeedrunTool/SettingDialog.h index 41ce51d..d89ed17 100644 --- a/EliteSpeedrunTool/SettingDialog.h +++ b/EliteSpeedrunTool/SettingDialog.h @@ -41,6 +41,19 @@ class SettingDialog : public QDialog { protected: void initGeneralSettings(); + void initSoundWidgets( + const QString& soundPath, + QLineEdit* soundPathEdit, + QAbstractButton* playButton, + QAbstractButton* selectFileButton, + std::function onUpdateSoundPath); + + void initHotkeyWidgets( + const QString& hotkey, + QKeySequenceEdit* keySequenceEdit, + QAbstractButton* clearButton, + std::function onUpdateHotkey); + QString getSoundFile(QString dir = QString()); int currentSubFunctionIndex = 0; @@ -50,6 +63,7 @@ class SettingDialog : public QDialog { DisplayInfoSubFunction currentRtssSubFunction = DisplayInfoSubFunction::Timer; void initFirewallSettings(); + void initNetworkAdaptersSettings(); void initTimerSettings(); diff --git a/EliteSpeedrunTool/SettingDialog.ui b/EliteSpeedrunTool/SettingDialog.ui index 393eccf..cc4db45 100644 --- a/EliteSpeedrunTool/SettingDialog.ui +++ b/EliteSpeedrunTool/SettingDialog.ui @@ -46,7 +46,7 @@ QFrame::Sunken - 2 + 3 @@ -72,8 +72,8 @@ 0 0 - 151 - 217 + 497 + 492 @@ -178,8 +178,8 @@ 0 0 - 270 - 485 + 479 + 478 @@ -519,8 +519,8 @@ 0 0 - 251 - 262 + 493 + 463 @@ -848,219 +848,184 @@ 0 - - - true + + + 0 - - - - 0 - 0 - 203 - 742 - - - - - - - 断网热键 - - - - - - - - - - - - 启动 - - - - - - - - :/image/ic_cancel.ico:/image/ic_cancel.ico - - - - - - - 停止 - - - - - - - - :/image/ic_cancel.ico:/image/ic_cancel.ico - - - - - - - - - - 音效 - - - - - - - :/image/ic_sound.ico:/image/ic_sound.ico - - - - - - - - - - - - - - :/image/ic_sound.ico:/image/ic_sound.ico - - - - - - - 启动音效 - - - - - - - ... - - - - - - - - :/image/ic_sound.ico:/image/ic_sound.ico - - - - - - - ... - - - - - - - 停止音效 - - - - - - - 操作失败音效 - - - - - - - - - - ... - - - - - - - - - - 防火墙规则方向 - - - - - - - - - 默认值为出站,设置将在下次启动防火墙时生效。 - - - true - - - - - - + + + 防火墙规则 + + + + 0 + + + 0 + + + 0 + + + 0 + - - - 断网范围 + + + true - - - - - - - 若您不了解断网原理,请留空! - - - - - - - ... - - - - - - - - - 0 - - - - 说明 - - - - + + + + 0 + 0 + 479 + 588 + + + + + + + 快捷键 + + + + + + + + + + - 若您想断整个系统的网络,则留空(建议);若您只想断 GTA 的网络,请选择 GTA5.exe 文件;若您想断加速器的网络,请选择加速器的应用程序文件。 + 启动 - - true + + + + + + + :/image/ic_cancel.ico:/image/ic_cancel.ico + + + + + + + 停止 + + + + + + + + :/image/ic_cancel.ico:/image/ic_cancel.ico + + + + + + + + + + 音效 + + + + + + + :/image/ic_sound.ico:/image/ic_sound.ico + + + + + + + + + + + + + + :/image/ic_sound.ico:/image/ic_sound.ico + + + + + + + 启动 + + + + ... + + + + + + + + :/image/ic_sound.ico:/image/ic_sound.ico + + + + + + + ... + + + + + + + 停止 + + + + + + + 操作失败 + + + + + + + + + + ... + + + + + + + + + + 防火墙规则方向 + + - + + + + - 填写要断网程序的路径,留空表示断全部。设置将在下次启动防火墙时生效。 + 默认值为出站,设置将在下次启动防火墙时生效。 true @@ -1069,46 +1034,268 @@ - - - 加速器 (UU 用户必看) - - + + + + + 断网范围 + + - - - 使用 UU 加速器的用户请填写 GTA5.exe 的完整路径,然后在 UU 内使用“路由模式”进行加速。 + + + + + 若您不了解断网原理,请留空! + + + + + + + ... + + + + + + + + + 0 + + + + 说明 + + + + + + 若您想断整个系统的网络,则留空(建议);若您只想断 GTA 的网络,请选择 GTA5.exe 文件;若您想断加速器的网络,请选择加速器的应用程序文件。 + + + true + + + + + + + 填写要断网程序的路径,留空表示断全部。设置将在下次启动防火墙时生效。 + + + true + + + + + + + + 加速器 (UU 用户必看) + + + + + + 使用 UU 加速器的用户请填写 GTA5.exe 的完整路径,然后在 UU 内使用“路由模式”进行加速。 GTA5.exe 的完整路径例如: F:\Epic Games\GTAV\GTA5.exe 其他加速器用户可直接填写加速器可执行 EXE 文件的路径。 加速器可执行 EXE 文件的路径例如: C:\Program Files (x86)\nn\nn.exe - - - true - + + + true + + + + + - - - + + + + + Qt::Vertical + + + + 20 + 1 + + + + + + + + + + + 禁用网络适配器 + + + + 0 + + + 0 + + + 0 + + + 0 + - - - Qt::Vertical - - - - 20 - 1 - + + + true - + + + + 0 + 0 + 493 + 463 + + + + + + + 勾选要禁用的网络适配器,下次禁用时生效 + + + true + + + + + + + + 10 + + + + + + + + 快捷键 + + + + + + + + + 启用 + + + + + + + 禁用 + + + + + + + + + + + :/image/ic_cancel.ico:/image/ic_cancel.ico + + + + + + + + :/image/ic_cancel.ico:/image/ic_cancel.ico + + + + + + + + + + 音效 + + + + + + + :/image/ic_sound.ico:/image/ic_sound.ico + + + + + + + + + + 禁用 + + + + + + + + :/image/ic_sound.ico:/image/ic_sound.ico + + + + + + + 启用 + + + + + + + + + + ... + + + + + + + ... + + + + + + + + + @@ -1140,8 +1327,8 @@ C:\Program Files (x86)\nn\nn.exe 0 0 - 177 - 530 + 497 + 492 @@ -1154,7 +1341,7 @@ C:\Program Files (x86)\nn\nn.exe - 计时器热键 + 快捷键 @@ -1338,15 +1525,15 @@ C:\Program Files (x86)\nn\nn.exe 0 0 - 130 - 218 + 497 + 492 - 卡单热键 + 快捷键 @@ -1459,15 +1646,15 @@ C:\Program Files (x86)\nn\nn.exe 0 0 - 179 - 218 + 497 + 492 - 末日降至爆头识别热键 + 快捷键 @@ -1525,7 +1712,7 @@ C:\Program Files (x86)\nn\nn.exe - 启动音效 + 进隧道前 @@ -1561,7 +1748,7 @@ C:\Program Files (x86)\nn\nn.exe - 停止音效 + 出炮后 (重置) @@ -1611,15 +1798,15 @@ C:\Program Files (x86)\nn\nn.exe 0 0 - 124 - 89 + 497 + 492 - 结束游戏热键 + 快捷键 @@ -1686,8 +1873,8 @@ C:\Program Files (x86)\nn\nn.exe 0 0 - 207 - 146 + 497 + 492 @@ -1775,8 +1962,8 @@ C:\Program Files (x86)\nn\nn.exe 0 0 - 98 - 87 + 497 + 492 @@ -1836,8 +2023,8 @@ C:\Program Files (x86)\nn\nn.exe 0 0 - 98 - 46 + 497 + 492 diff --git a/EliteSpeedrunTool/en.ts b/EliteSpeedrunTool/en.ts index 8b316af..f4ef89a 100644 --- a/EliteSpeedrunTool/en.ts +++ b/EliteSpeedrunTool/en.ts @@ -226,13 +226,13 @@ Answer: Yes, you can. You can develop your own WebSocket client to receive real- MainWindow - + 断网 - Firewall + Net - - + + 播放提示音 Play sound @@ -250,16 +250,16 @@ AdstarGod Firewall, easy to use 😋 - - + + Windows 防火墙未启用,无法使用断网功能! Windows Firewall is not enabled, and the network disconnection feature cannot be used! - - + + - + 点击启动 Start counting @@ -310,7 +310,7 @@ AdstarGod Firewall, easy to use - + 爱发电... Ai Fa Dian... @@ -327,8 +327,8 @@ AdstarGod Firewall, easy to use Alipay... - - + + 代言人 Spokesperson @@ -364,8 +364,8 @@ AdstarGod Firewall, easy to use Note: The public type firewall is not turned on, please test whether the disconnection is effective - - + + 计时 Manual timing @@ -402,7 +402,7 @@ AdstarGod Firewall, easy to use - + 检查更新... Check for update... @@ -427,8 +427,14 @@ AdstarGod Firewall, easy to use About Qt... - - + + + 防火墙 + Firewall + + + + 警告 Warning @@ -446,8 +452,26 @@ AdstarGod Firewall, easy to use Refresh - - + + + 网络适配器 + Net adapter + + + + + 选择的网络适配器 + Selected net adapters + + + + + 注意:禁用网卡存在延迟,请勿用于时间敏感的操作! + Note: Disabling net adapters may have a delay, don't use it for time-sensitive operations! + + + + 卡单 Suspend @@ -484,7 +508,7 @@ AdstarGod Firewall, easy to use - + 关于本软件... About... @@ -520,7 +544,7 @@ AdstarGod Firewall, easy to use - + 复制地址 Copy link @@ -570,7 +594,7 @@ AdstarGod Firewall, easy to use - + 已关闭 Stopped @@ -580,99 +604,119 @@ AdstarGod Firewall, easy to use Running - + 服务器未运行 Server is not running - - - 获取服务器地址失败! - Failed to get the server address! + + 注册启用防火墙快捷键失败! + Failed to register the enable firewall hotkey! - - 已复制服务器地址! - Server address has been copied! + + 注册关闭防火墙快捷键失败! + Failed to register the disable firewall hotkey! - - 点击归零 - Click to Zero + + 注册启动计时器快捷键失败! + Failed to register the start timer hotkey! - - 点击停止 - Click to stop + + 注册停止计时器快捷键失败! + Failed to register the stop timer hotkey! - - 点击恢复 - Click to continue + + 暂停计时器快捷键与启动/停止计时器快捷键相同,暂停计时器快捷键将会无效! + The pause timer hotkey is the same as the start/stop timer hotkey, so the pause timer hotkey will be invalid! - - 注册启用防火墙热键失败! - 注册防火墙启动热键失败! - Failed to register enable firewall hotkeys! + + 注册暂停计时器快捷键失败! + Failed to register the pause timer hotkey! - 注册关闭防火墙热键失败! - 注册防火墙停止热键失败! - Failed to register disable firewall hotkey! + 注册卡单快捷键失败! + Failed to register the suspend game hotkey! - - 注册启动计时器热键失败! - 注册计时器启动热键失败! - Failed to register start timer hotkey! + + 注册快速结束游戏快捷键失败! + Failed to register the termnate game hotkey! - - 注册停止计时器热键失败! - 注册计时器停止热键失败! - Failed to register stop timer hotkey! + + 注册末日将至爆头识别启动快捷键失败! + Failed to register the start ACT3 Hs OCR hotkey! - - 暂停计时器热键与启动/停止计时器热键相同,暂停计时器热键将会无效! - 暂停热键与启动/停止热键相同,暂停热键设置无效! - The pause timer hotkey is the same as the start/stop timer hotkey; the pause timer hotkey is not valid! + + 注册末日将至爆头识别关闭快捷键失败! + Failed to register the stop ACT3 Hs OCR hotkey! + - 注册暂停计时器热键失败! - 注册计时器暂停热键失败! - Failed to register the pause timer hotkey! + 获取服务器地址失败! + Failed to get the server address! - - 注册卡单热键失败! - Failed to register the suspend game hotkey! + + 已复制服务器地址! + Server address has been copied! + + + + 请先在设置页面选择网络适配器! + Please select net adapters on the settings page first! - 注册快速结束游戏热键失败! - Failed to register the termination game hotkey! + + 未禁用 + Enabled - - 注册末日将至爆头识别启动热键失败! - Failed to register the ACT3 hs start hotkey! + + 已禁用 + Disabled - - 注册末日将至爆头识别关闭热键失败! - Failed to register the ACT3 hs stop hotkey! + + 点击归零 + Click to Zero + + + + 点击停止 + Click to stop + + + + 点击恢复 + Click to continue + + + + 注册禁用网络适配器快捷键失败! + Failed to register the disable net adapters hotkey! - + + 注册启用网络适配器快捷键失败! + Failed to register the enable net adapters hotkey! + + + 支付宝收款二维码 谢谢喵! Alipay payment QR code. Thank you! - + 加入 Telegram 群组一起划水~ Join Telegram group~ @@ -783,7 +827,7 @@ AdstarGod Firewall, easy to use SettingDialog - + 设置 Settings @@ -794,32 +838,38 @@ AdstarGod Firewall, easy to use windowsvista style does not support dark mode, while other styles support dark mode following the system - - + + + - + + 启动 Enable - - - - + + + + + + 停止 Disable - - - - + + + + + + 音效 Sound - - + + 默认值为出站,设置将在下次启动防火墙时生效。 The default value is outbound. The settings will take effect the next time the firewall is started. @@ -855,14 +905,25 @@ AdstarGod Firewall, easy to use Firewall rule direction - - - 计时器热键 - Timer hotkeys + + + + + + + + + + + + + 快捷键 + 计时器快捷键 + Hotkeys - - + + 暂停/恢复 Pause/resume @@ -873,8 +934,8 @@ AdstarGod Firewall, easy to use Refresh data interval - - + + 窗口 Window @@ -1026,14 +1087,14 @@ AdstarGod Firewall, easy to use OSD text format - - - 断网热键 - Firewall hotkey + + + 防火墙规则 + Firewall rules - - + + 模糊半径 Blur radius @@ -1075,25 +1136,10 @@ AdstarGod Firewall, easy to use Reset OSD text format - - - - - 启动音效 - Start - - - - - - - 停止音效 - Stop - - - - - 操作失败音效 + + + 操作失败 + 操作失败音效 Operation failed @@ -1134,8 +1180,38 @@ The path to the game network agent executable EXE file is for example: C:\Program Files (x86)\nn\nn.exe - - + + + 禁用网络适配器 + 禁用网卡 + Disable net adapters + + + + + 勾选要禁用的网络适配器,下次禁用时生效 + 勾选要禁用的网络适配器 + Select the net adapters to disable, it will take effect next time + + + + + + + 禁用 + Disable + + + + + + + 启用 + Enable + + + + 建议设置为 10-50 之间,配置低的用户请适当增大数值 建议设置为30-70之间,配置低的用户请适当增大数值 Suggested setting is between 10 to 50. Users with lower computer performance should consider increasing the value accordingly @@ -1166,28 +1242,16 @@ C:\Program Files (x86)\nn\nn.exe Note: The timer will be reset to zero after going from "Pause" to "Stop" no matter which strategy is selected - - - 结束游戏热键 - Terminate game hotkey - - - + - + 执行 Execute - - - 卡单热键 - Suspend game hotkey - - - - + + 间隔 Interval @@ -1199,27 +1263,25 @@ C:\Program Files (x86)\nn\nn.exe Suggested setting is between 6000 to 13000 - - - 末日降至爆头识别热键 - ACT3 hs OCR hotkey - - - - + + + + 进隧道前 Before tunnel cutscene - - + + + + 出炮后 (重置) 进炮前 (重置) After orbital cannon (Reset) - - + + Discord Discord @@ -1259,17 +1321,17 @@ C:\Program Files (x86)\nn\nn.exe Language - - 选择文件 - Choice a sound + + WAV 文件 (*.wav) + WAV file (*.wav) - WAV 文件 (*.wav) - WAV file (*.wav) + 选择音频文件 + Select a sound - + 选择程序 Select a exe file @@ -1296,7 +1358,7 @@ C:\Program Files (x86)\nn\nn.exe 断网 - Firewall + Net @@ -1335,7 +1397,7 @@ C:\Program Files (x86)\nn\nn.exe Developer options - + 左对齐 Left alignment diff --git a/EliteSpeedrunTool/main.cpp b/EliteSpeedrunTool/main.cpp index 3067f2d..9fa3297 100644 --- a/EliteSpeedrunTool/main.cpp +++ b/EliteSpeedrunTool/main.cpp @@ -25,8 +25,8 @@ int main(int argc, char* argv[]) QApplication::setWindowIcon(QIcon("://image/ic_icon.png")); QApplication::setOrganizationName("SkyD666"); QApplication::setApplicationName(QObject::tr("精英速通工具")); - QApplication::setApplicationVersion("10.9.1.69"); - qputenv("ApplicationVersionCode", "20241106"); + QApplication::setApplicationVersion("10.10.1.69"); + qputenv("ApplicationVersionCode", "20241108"); qApp->setStyle(globalData->styleName());