Skip to content

Commit

Permalink
[feature] Support disabling network adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Nov 8, 2024
1 parent d0cc18d commit d96b75e
Show file tree
Hide file tree
Showing 15 changed files with 1,729 additions and 978 deletions.
1 change: 1 addition & 0 deletions EliteSpeedrunTool/AcknowledgementDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ class AcknowledgementDialog : public QDialog {
"____-669-____",
"巨大糖丸🐷",
"GodfatherCDW",
"9527_SSR",
};
};
8 changes: 4 additions & 4 deletions EliteSpeedrunTool/App.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 3 additions & 6 deletions EliteSpeedrunTool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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)
Expand Down
81 changes: 81 additions & 0 deletions EliteSpeedrunTool/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ void GlobalData::readSettings()
setFirewallDirection(settings.value("FirewallDirection", mFirewallDirection).toInt());
settings.endGroup();

settings.beginGroup("NetworkAdapter");
setSelectedNetworkAdapters(settings.value("SelectedNetworkAdapters", mSelectedNetworkAdapters).value<QList<QString>>());
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(
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -925,3 +941,68 @@ void GlobalData::setRtssOverlay(bool newRtssOverlay)
mRtssOverlay = newRtssOverlay;
emit rtssOverlayChanged();
}

QList<QString> GlobalData::selectedNetworkAdapters() const
{
return mSelectedNetworkAdapters;
}

void GlobalData::setSelectedNetworkAdapters(const QList<QString>& 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();
}
43 changes: 43 additions & 0 deletions EliteSpeedrunTool/GlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,27 @@ class GlobalData : public QObject {
bool rtssOverlay() const;
void setRtssOverlay(bool newRtssOverlay);

QList<QString> selectedNetworkAdapters() const;
void setSelectedNetworkAdapters(const QList<QString>& 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();
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -291,6 +322,13 @@ class GlobalData : public QObject {
QString mFirewallAppPath = "";
int mFirewallDirection = NET_FW_RULE_DIR_OUT;

// 网络适配器
QList<QString> mSelectedNetworkAdapters = {};
QString mNetworkAdaptersEnableHotkey = "Alt+Q";
QString mNetworkAdaptersDisableHotkey = "Alt+Q";
QString mNetworkAdaptersEnableSound = "./sound/uradaron.wav";
QString mNetworkAdaptersDisableSound = "./sound/uradarof.wav";

// 任务数据
int mMissionDataUpdateInterval = 50;
QList<MissionDataNameUtil::MissionDataName> mMissionDataNames = {
Expand Down Expand Up @@ -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<QString> 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)
};
Loading

0 comments on commit d96b75e

Please sign in to comment.