From 162947dd92bb72792af25f100a8a7ce3dbf2131d Mon Sep 17 00:00:00 2001 From: Jesse <69196954+ThisAMJ@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:31:25 +1000 Subject: [PATCH] refactor: style --- docs/cvars.md | 2 ++ src/Features/Hud/VelocityGraph.cpp | 18 +++++++++--------- src/Features/Hud/VelocityGraph.hpp | 2 +- src/Utils/SDK.hpp | 10 +++++----- src/Utils/SDK/FixedQueue.hpp | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/cvars.md b/docs/cvars.md index aa25c013..dc9d9b09 100644 --- a/docs/cvars.md +++ b/docs/cvars.md @@ -640,6 +640,8 @@ |sar_velocitygraph_font_index|21|Font index of velocity graph.| |sar_velocitygraph_rainbow|0|Rainbow mode of velocity graph text.| |sar_velocitygraph_show_speed_on_graph|1|Show speed between jumps.| +|sar_velocitygraph_x|-250|Velocity graph x axis offset.| +|sar_velocitygraph_y|-175|Velocity graph y axis offset.| |sar_vphys_hud|0|Enables or disables the vphys HUD.| |sar_vphys_hud_font|1|Sets font of the vphys HUD.| |sar_vphys_hud_precision|3|Sets decimal precision of the vphys HUD.| diff --git a/src/Features/Hud/VelocityGraph.cpp b/src/Features/Hud/VelocityGraph.cpp index e01fe2d1..4101e5a7 100644 --- a/src/Features/Hud/VelocityGraph.cpp +++ b/src/Features/Hud/VelocityGraph.cpp @@ -1,16 +1,16 @@ #include "VelocityGraph.hpp" #include "Event.hpp" +#include "Features/Session.hpp" #include "Modules/Client.hpp" #include "Modules/Engine.hpp" #include "Modules/Scheme.hpp" #include "Modules/Surface.hpp" -#include "Features/Session.hpp" +#include "Utils/SDK/FixedQueue.hpp" #include "Variable.hpp" -#include "Utils/SDK/FixedQueue.hpp" -#include #include +#include Variable sar_velocitygraph("sar_velocitygraph", "0", "Shows velocity graph.\n"); Variable sar_velocitygraph_font_index("sar_velocitygraph_font_index", "21", 0, "Font index of velocity graph.\n"); // 21 looks pretty good @@ -33,7 +33,7 @@ struct VelocityData { } }; -std::vector> velocityStamps(2, FixedQueue(500, VelocityData())); +std::vector> velocityStamps(2, FixedQueue(500, VelocityData())); static int last_vel[2] = {0, 0}; static int tick_prev[2] = {0, 0}; @@ -57,7 +57,7 @@ void ClearData(int slot) { } void VelocityGraph::GatherData(int slot, bool on_ground) { - auto player = client->GetPlayer(slot + 1); //not sure how to get it properly with event + auto player = client->GetPlayer(slot + 1); if (!player) return; auto vel = client->GetLocalVelocity(player); @@ -75,10 +75,10 @@ void VelocityGraph::GatherData(int slot, bool on_ground) { void VelocityGraph::Paint(int slot) { int speed = velocityStamps[slot].Last().speed; - int screenSizeX, y; - engine->GetScreenSize(nullptr, screenSizeX, y); + int x, y; + engine->GetScreenSize(nullptr, x, y); - const Vector2 graphPos = Vector2(screenSizeX / 2, y) + + const Vector2 graphPos = Vector2(x / 2, y) + Vector2(sar_velocitygraph_x.GetInt(), sar_velocitygraph_y.GetInt()); if (sar_velocitygraph_background.GetBool()) @@ -142,4 +142,4 @@ ON_EVENT(PROCESS_MOVEMENT) { velocityGraph->GatherData(event.slot, event.grounded); } -VelocityGraph *velocityGraph = new VelocityGraph(); \ No newline at end of file +VelocityGraph *velocityGraph = new VelocityGraph(); diff --git a/src/Features/Hud/VelocityGraph.hpp b/src/Features/Hud/VelocityGraph.hpp index 5ab81227..2e9b1e5c 100644 --- a/src/Features/Hud/VelocityGraph.hpp +++ b/src/Features/Hud/VelocityGraph.hpp @@ -20,4 +20,4 @@ extern Variable sar_velocitygraph_x; extern Variable sar_velocitygraph_y; extern Variable sar_velocitygraph_background; extern Variable sar_velocitygraph_show_speed_on_graph; -extern Variable sar_velocitygraph_rainbow; \ No newline at end of file +extern Variable sar_velocitygraph_rainbow; diff --git a/src/Utils/SDK.hpp b/src/Utils/SDK.hpp index 26e6bcaa..eb82ab6c 100644 --- a/src/Utils/SDK.hpp +++ b/src/Utils/SDK.hpp @@ -2,16 +2,18 @@ #include "SDK/BaseEntity.hpp" #include "SDK/BitBuf.hpp" +#include "SDK/CViewSetup.hpp" #include "SDK/Class.hpp" #include "SDK/Color.hpp" #include "SDK/Convar.hpp" -#include "SDK/CViewSetup.hpp" #include "SDK/Datamap.hpp" #include "SDK/EntityEdict.hpp" +#include "SDK/EventQueue.hpp" +#include "SDK/FixedQueue.hpp" #include "SDK/GameEvents.hpp" +#include "SDK/GameMovement.hpp" #include "SDK/GlobalVars.hpp" #include "SDK/Handle.hpp" -#include "SDK/EventQueue.hpp" #include "SDK/HostState.hpp" #include "SDK/ICollideable.hpp" #include "SDK/ILoggingListener.hpp" @@ -20,13 +22,11 @@ #include "SDK/KeyValues.hpp" #include "SDK/Math.hpp" #include "SDK/MeshBuilder.hpp" -#include "SDK/GameMovement.hpp" #include "SDK/PlayerLocalData.hpp" #include "SDK/PortalPlacement.hpp" #include "SDK/ServerPlugin.hpp" +#include "SDK/Trace.hpp" #include "SDK/UserCmd.hpp" #include "SDK/UtlMemory.hpp" -#include "SDK/Trace.hpp" -#include "SDK/FixedQueue.hpp" #include "SDK/Other.hpp" diff --git a/src/Utils/SDK/FixedQueue.hpp b/src/Utils/SDK/FixedQueue.hpp index 2edb4c8b..0b4fea31 100644 --- a/src/Utils/SDK/FixedQueue.hpp +++ b/src/Utils/SDK/FixedQueue.hpp @@ -65,4 +65,4 @@ class FixedQueue { inline T &operator[](int index) { return queue[BoundIndex(index + begin, 1)]; } -}; \ No newline at end of file +};