Skip to content

Commit

Permalink
[feature] Support crosshair by RTSS
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Dec 14, 2024
1 parent dea600c commit 2942729
Show file tree
Hide file tree
Showing 14 changed files with 972 additions and 202 deletions.
1 change: 1 addition & 0 deletions EliteSpeedrunTool/AcknowledgementDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@ class AcknowledgementDialog : public QDialog {
"GodfatherCDW",
"9527_SSR",
"Capucino_ovo",
"laosepi1996",
};
};
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 11,0,1,70
PRODUCTVERSION 11,0,1,70
FILEVERSION 11,1,1,70
PRODUCTVERSION 11,1,1,70
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", "11.0.1.70\0"
VALUE "ProductVersion", "11.0.1.70\0"
VALUE "FileVersion", "11.1.1.70\0"
VALUE "ProductVersion", "11.1.1.70\0"
VALUE "ProductName", "Elite Speedrun Tool\0"
END
END
Expand Down
105 changes: 105 additions & 0 deletions EliteSpeedrunTool/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void GlobalData::readSettings()
setVersion(settings.value("Version", mVersion).toString());
setIgnoredNewVersion(settings.value("IgnoredNewVersion", mIgnoredNewVersion).toString());
setMinimizeToTray(settings.value("MinimizeToTray", mMinimizeToTray).toBool());
setTopMostWindowHotkey(settings.value("TopMostWindowHotkey", mTopMostWindowHotkey).toString());
settings.endGroup();

settings.beginGroup("DisplayInfo");
Expand All @@ -163,6 +164,12 @@ void GlobalData::readSettings()

settings.beginGroup("Rtss");
setRtssOverlay(settings.value("RtssOverlay", mRtssOverlay).toBool());
setRtssCrosshair(settings.value("RtssCrosshair", mRtssCrosshair).toBool());
setRtssCrosshairText(settings.value("RtssCrosshairText", mRtssCrosshairText).toString());
setRtssCrosshairX(settings.value("RtssCrosshairX", mRtssCrosshairX).toInt());
setRtssCrosshairY(settings.value("RtssCrosshairY", mRtssCrosshairY).toInt());
setRtssCrosshairSize(settings.value("RtssCrosshairSize", mRtssCrosshairSize).toInt());
setRtssCrosshairColor(settings.value("RtssCrosshairColor", mRtssCrosshairColor).value<QColor>());
settings.endGroup();

settings.beginGroup("Firewall");
Expand Down Expand Up @@ -237,6 +244,7 @@ void GlobalData::writeSettings()
settings.setValue("Version", QApplication::applicationVersion());
settings.setValue("IgnoredNewVersion", mIgnoredNewVersion);
settings.setValue("MinimizeToTray", mMinimizeToTray);
settings.setValue("TopMostWindowHotkey", mTopMostWindowHotkey);
settings.endGroup();

settings.beginGroup("DisplayInfo");
Expand All @@ -254,6 +262,12 @@ void GlobalData::writeSettings()

settings.beginGroup("Rtss");
settings.setValue("RtssOverlay", mRtssOverlay);
settings.setValue("RtssCrosshair", mRtssCrosshair);
settings.setValue("RtssCrosshairText", mRtssCrosshairText);
settings.setValue("RtssCrosshairX", mRtssCrosshairX);
settings.setValue("RtssCrosshairY", mRtssCrosshairY);
settings.setValue("RtssCrosshairSize", mRtssCrosshairSize);
settings.setValue("RtssCrosshairColor", mRtssCrosshairColor);
settings.endGroup();

settings.beginGroup("Firewall");
Expand Down Expand Up @@ -1006,3 +1020,94 @@ void GlobalData::setNetworkAdaptersDisableSound(const QString& newNetworkAdapter
mNetworkAdaptersDisableSound = newNetworkAdaptersDisableSound;
emit networkAdaptersDisableSoundChanged();
}

bool GlobalData::rtssCrosshair() const
{
return mRtssCrosshair;
}

void GlobalData::setRtssCrosshair(bool newRtssCrosshair)
{
if (mRtssCrosshair == newRtssCrosshair)
return;
mRtssCrosshair = newRtssCrosshair;
emit rtssCrosshairChanged();
}

QString GlobalData::rtssCrosshairText() const
{
return mRtssCrosshairText;
}

void GlobalData::setRtssCrosshairText(const QString& newRtssCrosshairText)
{
if (mRtssCrosshairText == newRtssCrosshairText)
return;
mRtssCrosshairText = newRtssCrosshairText;
emit rtssCrosshairTextChanged();
}

int GlobalData::rtssCrosshairX() const
{
return mRtssCrosshairX;
}

void GlobalData::setRtssCrosshairX(int newRtssCrosshairX)
{
if (mRtssCrosshairX == newRtssCrosshairX)
return;
mRtssCrosshairX = newRtssCrosshairX;
emit rtssCrosshairXChanged();
}

int GlobalData::rtssCrosshairY() const
{
return mRtssCrosshairY;
}

void GlobalData::setRtssCrosshairY(int newRtssCrosshairY)
{
if (mRtssCrosshairY == newRtssCrosshairY)
return;
mRtssCrosshairY = newRtssCrosshairY;
emit rtssCrosshairYChanged();
}

int GlobalData::rtssCrosshairSize() const
{
return mRtssCrosshairSize;
}

void GlobalData::setRtssCrosshairSize(int newRtssCrosshairSize)
{
if (mRtssCrosshairSize == newRtssCrosshairSize)
return;
mRtssCrosshairSize = newRtssCrosshairSize;
emit rtssCrosshairSizeChanged();
}

QColor GlobalData::rtssCrosshairColor() const
{
return mRtssCrosshairColor;
}

void GlobalData::setRtssCrosshairColor(QColor newRtssCrosshairColor)
{
if (mRtssCrosshairColor == newRtssCrosshairColor)
return;
mRtssCrosshairColor = newRtssCrosshairColor;
emit rtssCrosshairColorChanged();
}

QString GlobalData::topMostWindowHotkey() const
{
return mTopMostWindowHotkey;
}

void GlobalData::setTopMostWindowHotkey(const QString& newShowToolHotkey)
{
if (mTopMostWindowHotkey == newShowToolHotkey)
return;
mTopMostWindowHotkey = newShowToolHotkey;
emit topMostWindowHotkeyChanged();
}
49 changes: 49 additions & 0 deletions EliteSpeedrunTool/GlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,27 @@ class GlobalData : public QObject {
QString networkAdaptersDisableSound() const;
void setNetworkAdaptersDisableSound(const QString& newNetworkAdaptersDisableSound);

bool rtssCrosshair() const;
void setRtssCrosshair(bool newRtssCrosshair);

QString rtssCrosshairText() const;
void setRtssCrosshairText(const QString& newRtssCrosshairText);

int rtssCrosshairX() const;
void setRtssCrosshairX(int newRtssCrosshairX);

int rtssCrosshairY() const;
void setRtssCrosshairY(int newRtssCrosshairY);

int rtssCrosshairSize() const;
void setRtssCrosshairSize(int newRtssCrosshairSize);

QColor rtssCrosshairColor() const;
void setRtssCrosshairColor(QColor newRtssCrosshairColor);

QString topMostWindowHotkey() const;
void setTopMostWindowHotkey(const QString& newShowToolHotkey);

signals:
void minimizeToTrayChanged();
void styleNameChanged();
Expand Down Expand Up @@ -286,8 +307,23 @@ class GlobalData : public QObject {

void networkAdaptersDisableSoundChanged();

void rtssCrosshairChanged();

void rtssCrosshairTextChanged();

void rtssCrosshairXChanged();

void rtssCrosshairYChanged();

void rtssCrosshairSizeChanged();

void rtssCrosshairColorChanged();

void topMostWindowHotkeyChanged();

private:
bool mMinimizeToTray = false;
QString mTopMostWindowHotkey = "";
QString mStyleName = "windows11";
// 版本
bool mAutoCheckUpdate = true;
Expand All @@ -311,6 +347,12 @@ class GlobalData : public QObject {

// RTSS
bool mRtssOverlay = true;
bool mRtssCrosshair = false;
QString mRtssCrosshairText = "*";
int mRtssCrosshairX = 200;
int mRtssCrosshairY = 200;
int mRtssCrosshairSize = 80;
QColor mRtssCrosshairColor = Qt::yellow;

// 防火墙
QString mFirewallStartHotkey = "F9";
Expand Down Expand Up @@ -431,4 +473,11 @@ class GlobalData : public QObject {
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)
Q_PROPERTY(bool rtssCrosshair READ rtssCrosshair WRITE setRtssCrosshair NOTIFY rtssCrosshairChanged FINAL)
Q_PROPERTY(QString rtssCrosshairText READ rtssCrosshairText WRITE setRtssCrosshairText NOTIFY rtssCrosshairTextChanged FINAL)
Q_PROPERTY(int rtssCrosshairX READ rtssCrosshairX WRITE setRtssCrosshairX NOTIFY rtssCrosshairXChanged FINAL)
Q_PROPERTY(int rtssCrosshairY READ rtssCrosshairY WRITE setRtssCrosshairY NOTIFY rtssCrosshairYChanged FINAL)
Q_PROPERTY(int rtssCrosshairSize READ rtssCrosshairSize WRITE setRtssCrosshairSize NOTIFY rtssCrosshairSizeChanged FINAL)
Q_PROPERTY(QColor rtssCrosshairColor READ rtssCrosshairColor WRITE setRtssCrosshairColor NOTIFY rtssCrosshairColorChanged FINAL)
Q_PROPERTY(QString topMostWindowHotkey READ topMostWindowHotkey WRITE setTopMostWindowHotkey NOTIFY topMostWindowHotkeyChanged FINAL)
};
32 changes: 32 additions & 0 deletions EliteSpeedrunTool/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ void MainWindow::registerHotkeyPair(

void MainWindow::removeAllHotkeys()
{
removeHotkey(topMostWindowHotkey);
removeHotkey(startFirewallHotkey);
removeHotkey(stopFirewallHotkey);
removeHotkey(disableNetworkAdapterHotkey);
Expand Down Expand Up @@ -206,6 +207,12 @@ void MainWindow::setHotkey()
globalData->suspendAndResumeHotkey(),
globalData->closeGameImmediatelyHotkey()));

// 置顶工具
registerHotkey(
globalData->topMostWindowHotkey(),
topMostWindowHotkey,
[this]() { topMostWindow(!ui.actionTopMost->isChecked(), true); });

// 防火墙
registerHotkeyPair(
globalData->firewallStartHotkey(), globalData->firewallStopHotkey(),
Expand Down Expand Up @@ -350,6 +357,15 @@ void MainWindow::initMenu()
});
ui.actionDisplayInfoTouchable->setChecked(globalData->displayInfoTouchable());

// Refresh RTSS
connect(ui.actionRefreshRtss, &QAction::toggled, this, [this]() {
rtssUtil->refreshAll();
});
// Top most
connect(ui.actionTopMost, &QAction::toggled, this, [this](bool checked) {
topMostWindow(checked, false);
});

// 启动服务器
auto enableServerLambda = [=](bool checked) {
globalData->setDisplayInfoServer(checked);
Expand Down Expand Up @@ -850,6 +866,22 @@ void MainWindow::closeGameImmediately()
qInfo("Using taskkill command to terminate GTA5.exe");
}

void MainWindow::topMostWindow(bool isTop, bool fromHotkey)
{
ui.actionTopMost->setChecked(isTop);
HWND hwnd = reinterpret_cast<HWND>(winId());
if (isTop) {
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
show();
setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
} else {
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
if (fromHotkey) {
setWindowState(windowState() | Qt::WindowMinimized);
}
}
}

void MainWindow::initSystemTray()
{
if (!globalData->minimizeToTray() || systemTray) {
Expand Down
11 changes: 9 additions & 2 deletions EliteSpeedrunTool/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class MainWindow : public QMainWindow {

void closeGameImmediately();

void topMostWindow(bool isTop, bool fromHotkey);

signals:
void toTimerStoppedAndZeroState();
void toTimerStoppedOrStoppedAndZeroState();
Expand All @@ -101,6 +103,8 @@ class MainWindow : public QMainWindow {
std::atomic<bool> displayInfoDialogIsShowing = false;
DisplayInfoDialog* displayInfoDialog = nullptr;

QHotkey* topMostWindowHotkey = nullptr;

QHotkey* startFirewallHotkey = nullptr;
QHotkey* stopFirewallHotkey = nullptr;

Expand Down Expand Up @@ -135,9 +139,12 @@ class MainWindow : public QMainWindow {

QString license = "<h3>" + QApplication::applicationDisplayName()
+ " v" + QApplication::applicationVersion() + "</h3>"
+ tr("<p>一个 GTAOL 精英、速通工具,支持快速启动防火墙、计时、结束游戏等。</p>")
+ "<p>"
+ tr("程序开发:SkyD666") + "<br>"
+ tr("一个 GTAOL 精英、速通工具,支持断网、计时、卡单、结束游戏、屏幕准星等。")
+ "</p>"
+ "<p>"
+ tr("程序开发:SkyD666")
+ "<br>"
+ tr("游戏逆向:Zerkalo2147")
+ "</p>"
+ "<p>"
Expand Down
15 changes: 15 additions & 0 deletions EliteSpeedrunTool/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@
<addaction name="menuServer"/>
</widget>
<addaction name="menuDisplayInfo"/>
<addaction name="actionRefreshRtss"/>
<addaction name="actionTopMost"/>
</widget>
<widget class="QMenu" name="menuSponsor">
<property name="title">
Expand Down Expand Up @@ -1034,6 +1036,19 @@
<string>致谢...</string>
</property>
</action>
<action name="actionTopMost">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>置顶窗口</string>
</property>
</action>
<action name="actionRefreshRtss">
<property name="text">
<string>刷新 RTSS 显示</string>
</property>
</action>
</widget>
<resources>
<include location="resource.qrc"/>
Expand Down
Loading

0 comments on commit 2942729

Please sign in to comment.