generated from YimMenu/YimMenuV2
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
maybegreat48
committed
Jul 15, 2024
1 parent
46041d0
commit c8b462e
Showing
32 changed files
with
250 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "FloatCommand.hpp" | ||
#include "game/backend/FiberPool.hpp" // TODO: game import in core | ||
|
||
namespace YimMenu | ||
{ | ||
void FloatCommand::OnCall() | ||
{ | ||
} | ||
|
||
void FloatCommand::SaveState(nlohmann::json& value) | ||
{ | ||
value = m_State; | ||
} | ||
|
||
void FloatCommand::LoadState(nlohmann::json& value) | ||
{ | ||
m_State = value; | ||
} | ||
|
||
FloatCommand::FloatCommand(std::string name, std::string label, std::string description, std::optional<float> min, std::optional<float> max, float def_val) : | ||
Command(name, label, description, 0), | ||
m_Min(min), | ||
m_Max(max), | ||
m_State(def_val) | ||
{ | ||
} | ||
|
||
float FloatCommand::GetState() | ||
{ | ||
return m_State; | ||
} | ||
|
||
void FloatCommand::SetState(float state) | ||
{ | ||
FiberPool::Push([this] { | ||
OnChange(); | ||
}); | ||
m_State = state; | ||
MarkDirty(); | ||
} | ||
|
||
std::optional<float> FloatCommand::GetMinimum() | ||
{ | ||
return m_Min; | ||
} | ||
|
||
std::optional<float> FloatCommand::GetMaximum() | ||
{ | ||
return m_Max; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
#include "Command.hpp" | ||
|
||
namespace YimMenu | ||
{ | ||
class FloatCommand : public Command | ||
{ | ||
protected: | ||
virtual void OnChange(){}; | ||
virtual void OnCall() override; | ||
virtual void SaveState(nlohmann::json& value) override; | ||
virtual void LoadState(nlohmann::json& value) override; | ||
|
||
float m_State = 0; | ||
std::optional<float> m_Min; | ||
std::optional<float> m_Max; | ||
|
||
public: | ||
FloatCommand(std::string name, std::string label, std::string description, std::optional<float> min = std::nullopt, std::optional<float> max = std::nullopt, float def_val = 0.0f); | ||
float GetState(); | ||
void SetState(float state); | ||
std::optional<float> GetMinimum(); | ||
std::optional<float> GetMaximum(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
#include "game/frontend/submenus/Self.hpp" | ||
#include "core/commands/LoopedCommand.hpp" | ||
#include "core/commands/FloatCommand.hpp" | ||
#include "game/rdr/Natives.hpp" | ||
#include "game/features/Features.hpp" | ||
#include "game/backend/Self.hpp" | ||
|
||
namespace YimMenu::Features | ||
{ | ||
static FloatCommand _WhistlePitch{"whistlepitch", "Whistle Pitch", "The pitch of your whistle", 0.0f, 1.0f, 0.0f}; | ||
static FloatCommand _WhistleClarity{"whistleclarity", "Whistle Clarity", "The clarity of your whistle", 0.0f, 1.0f, 0.0f}; | ||
static FloatCommand _WhistleShape{"whistleshape", "Whistle Shape", "The shape of your whistle", 0.0f, 10.0f, 0.0f}; | ||
|
||
class WhistleOverride : public LoopedCommand | ||
{ | ||
using LoopedCommand::LoopedCommand; | ||
|
||
virtual void OnTick() override | ||
{ | ||
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(Self::PlayerPed, "Ped.WhistlePitch", SelfStorage::pitch); | ||
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(Self::PlayerPed, "Ped.WhistleClarity", SelfStorage::clarity); | ||
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(Self::PlayerPed, "Ped.WhistleShape", SelfStorage::shape); | ||
if (auto ped = Self::GetPed()) | ||
{ | ||
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(ped.GetHandle(), "Ped.WhistlePitch", _WhistlePitch.GetState()); | ||
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(ped.GetHandle(), "Ped.WhistleClarity", _WhistleClarity.GetState()); | ||
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(ped.GetHandle(), "Ped.WhistleShape", _WhistleShape.GetState()); | ||
} | ||
} | ||
}; | ||
|
||
static WhistleOverride _WhistleOverride{"overridewhistle", "Whistle Modifier", "Modify your whistle tone"}; | ||
static WhistleOverride _WhistleOverride{"overridewhistle", "Modify Whistles", "Modify your whistle tone"}; | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "Items.hpp" | ||
#include "core/commands/Command.hpp" | ||
#include "core/commands/Commands.hpp" | ||
#include "core/commands/FloatCommand.hpp" | ||
#include "core/frontend/widgets/toggle/imgui_toggle.hpp" | ||
|
||
namespace YimMenu | ||
{ | ||
FloatCommandItem::FloatCommandItem(joaat_t id, std::optional<std::string> label_override) : | ||
m_Command(Commands::GetCommand<FloatCommand>(id)), | ||
m_LabelOverride(label_override) | ||
{ | ||
} | ||
|
||
void FloatCommandItem::Draw() | ||
{ | ||
if (!m_Command) | ||
{ | ||
ImGui::Text("Unknown!"); | ||
return; | ||
} | ||
|
||
auto value = m_Command->GetState(); | ||
auto label = m_LabelOverride.has_value() ? m_LabelOverride.value().c_str() : m_Command->GetLabel().c_str(); | ||
if (!m_Command->GetMinimum().has_value() || !m_Command->GetMaximum().has_value()) | ||
{ | ||
ImGui::SetNextItemWidth(150); | ||
if (ImGui::InputFloat(label, &value)) | ||
{ | ||
m_Command->SetState(value); | ||
} | ||
} | ||
else | ||
{ | ||
ImGui::SetNextItemWidth(150); | ||
if (ImGui::SliderFloat(label, &value, m_Command->GetMinimum().value(), m_Command->GetMaximum().value())) | ||
{ | ||
m_Command->SetState(value); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.