Add ShootTimer to ServerConfig
All checks were successful
Linux arm64 / Build (push) Successful in 5m20s

This commit is contained in:
Morph01
2024-03-30 22:46:32 +01:00
parent ce964294f4
commit 08e3463c70
4 changed files with 27 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ typedef std::array<int, kaMax> Keybinds;
struct ServerConfig {
float Gravity;
float ShootTimer;
};
class BlitzConfig {
@@ -73,6 +74,14 @@ class BlitzConfig {
m_ServerConfig.Gravity = gravity;
}
float GetServerConfigShootTimer() const {
return m_ServerConfig.ShootTimer;
}
void SetServerConfigShootTimer(float shootTimer) {
m_ServerConfig.ShootTimer = shootTimer;
}
private:
void LoadConfig();
void LoadDefaultConfig();

View File

@@ -39,6 +39,7 @@ void BlitzConfig::LoadConfig() {
jsonInput.at("fps").get_to<bool>(m_DisplayFps);
jsonInput.at("sensitivity").get_to<float>(m_MouseSpeed);
jsonInput.at("gravity").get_to<float>(m_ServerConfig.Gravity);
jsonInput.at("shoottimer").get_to<float>(m_ServerConfig.ShootTimer);
jsonInput.at("keys").get_to<Keybinds>(m_Keybinds);
utils::LOG("[BlitzConfig] Restored config !");
@@ -54,6 +55,7 @@ void BlitzConfig::LoadDefaultConfig() {
std::memcpy(m_Pseudo.data(), defaultPseudo, sizeof(defaultPseudo));
m_MouseSpeed = 0.0025f;
m_ServerConfig.Gravity = 20.0f;
m_ServerConfig.ShootTimer = 0.015f;
m_Keybinds = {ImGuiKey_Z, ImGuiKey_S, ImGuiKey_D, ImGuiKey_Q, ImGuiKey_P};
}
@@ -70,6 +72,7 @@ void BlitzConfig::SaveConfig() {
{"fps", IsFPSDisplayEnabled()},
{"sensitivity", GetMouseSpeed()},
{"gravity", GetServerConfigGravity()},
{"shoottimer", GetServerConfigShootTimer()},
{"keys", GetKeys()},
};

View File

@@ -3,7 +3,6 @@
#include "blitz/game/Player.h"
#include "blitz/maths/Maths.h"
#include "blitz/misc/Log.h"
#include "blitz/maths/Maths.h"
#include "client/Client.h"
#include "client/config/BlitzConfig.h"
#include "client/display/InputManager.h"
@@ -67,7 +66,7 @@ void PlayerController::Update(float delta) {
NotifyListeners(&game::PlayerInputListener::OnLocalPlayerJump);
}
bool canShoot = m_ShootTimer.Update(delta);
bool canShoot = m_ShootTimer.Update(m_Client->GetConfig()->GetServerConfigShootTimer());
if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && canShoot) {
NotifyListeners(
&game::PlayerInputListener::OnLocalPlayerShoot, m_Player->GetPosition(), m_Player->GetYaw(), m_Player->GetPitch());

View File

@@ -24,7 +24,7 @@ void ServerGui::Render() {
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar;
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
static float servergui_width = 640.0f;
static float servergui_height = 450.0f;
static float servergui_height = 640.0f;
const static ImVec2 buttonSize = {300, 60};
@@ -66,6 +66,19 @@ void ServerGui::Render() {
}
ImGui::EndListBox();
}
ImGui::NewLine();
int shoottimer = static_cast<int>(m_Client->GetConfig()->GetServerConfigShootTimer() * ((2.0f / 3.0f) * 100.0f));
ImGui::SetNextItemWidth(300.0f);
if (ImGui::DragInt("##CADENCE TIR", &shoottimer, 1, 1, 100)) {
if (shoottimer < 0)
shoottimer = 1;
if (shoottimer > 100)
shoottimer = 100;
m_Client->GetConfig()->SetServerConfigShootTimer(shoottimer / ((2.0f / 3.0f) * 100.0f));
}
ImGui::Text("Cadence x%i", shoottimer);
ImGui::SetCursorPosY(servergui_height - 2.0f * buttonSize.y);
if (ImGui::Button("Retour", buttonSize)) {
ImGui::CloseCurrentPopup();