Changed from Button to Hotkey(Animation Changer)
This commit is contained in:
parent
a13bde4367
commit
905fb68f5f
@ -219,11 +219,13 @@ namespace cheat::feature
|
|||||||
"Blocking_Hit",
|
"Blocking_Hit",
|
||||||
"Blocking_AS"
|
"Blocking_AS"
|
||||||
};
|
};
|
||||||
static std::string currentAnimation{};
|
|
||||||
AnimationChanger::AnimationChanger() : Feature(),
|
AnimationChanger::AnimationChanger() : Feature(),
|
||||||
NF(f_Enabled, "Animation Changer", "Visuals::AnimationChanger", false),
|
NF(f_Enabled, "Animation Changer", "Visuals::AnimationChanger", false),
|
||||||
NF(f_ApplyAnimation, "Apply Animation", "Visuals::AnimationChanger", false),
|
NF(f_Animation, "Animation", "Visuals::AnimationChanger", "ExtraAttack"),
|
||||||
NF(f_ResetAnimation, "Reset Animation", "Visuals::AnimationChanger", false)
|
NF(f_ApplyKey, "Apply Animation", "Visuals::AnimationChanger", Hotkey('Y')),
|
||||||
|
NF(f_ResetKey, "Reset Animation", "Visuals::AnimationChanger", Hotkey('R')),
|
||||||
|
toBeUpdate(), nextUpdate(0)
|
||||||
{
|
{
|
||||||
events::GameUpdateEvent += MY_METHOD_HANDLER(AnimationChanger::OnGameUpdate);
|
events::GameUpdateEvent += MY_METHOD_HANDLER(AnimationChanger::OnGameUpdate);
|
||||||
}
|
}
|
||||||
@ -236,30 +238,30 @@ namespace cheat::feature
|
|||||||
|
|
||||||
void AnimationChanger::DrawMain()
|
void AnimationChanger::DrawMain()
|
||||||
{
|
{
|
||||||
ConfigWidget(f_Enabled, "Changes active character's animation.\nNot all animations work for every character except Main Character.");
|
ImGui::BeginGroupPanel("Animation Changer");
|
||||||
if (f_Enabled)
|
|
||||||
{
|
{
|
||||||
if (ImGui::BeginCombo("Animations", currentAnimation.c_str()))
|
ConfigWidget(f_Enabled, "Changes active character's animation.\nNot all animations work for every character except Main Character.");
|
||||||
|
if (f_Enabled)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < IM_ARRAYSIZE(animations); n++)
|
if (ImGui::BeginCombo("Animations", f_Animation.value().c_str()))
|
||||||
{
|
{
|
||||||
bool is_selected = (currentAnimation.c_str() == animations[n]);
|
for (int n = 0; n < IM_ARRAYSIZE(animations); n++)
|
||||||
if (ImGui::Selectable(animations[n].c_str(), is_selected))
|
{
|
||||||
currentAnimation = animations[n];
|
bool is_selected = (f_Animation.value().c_str() == animations[n]);
|
||||||
|
if (ImGui::Selectable(animations[n].c_str(), is_selected))
|
||||||
|
f_Animation.value() = animations[n];
|
||||||
|
|
||||||
if (is_selected)
|
if (is_selected)
|
||||||
ImGui::SetItemDefaultFocus();
|
ImGui::SetItemDefaultFocus();
|
||||||
|
}
|
||||||
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
|
||||||
|
ConfigWidget("Apply Key", f_ApplyKey, true);
|
||||||
|
ConfigWidget("Reset Key", f_ResetKey, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Button("Apply"))
|
|
||||||
f_ApplyAnimation = true;
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Button("Reset"))
|
|
||||||
f_ResetAnimation = true;
|
|
||||||
}
|
}
|
||||||
|
ImGui::EndGroupPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnimationChanger::NeedStatusDraw() const
|
bool AnimationChanger::NeedStatusDraw() const
|
||||||
@ -283,21 +285,21 @@ namespace cheat::feature
|
|||||||
if (!f_Enabled)
|
if (!f_Enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto currentTime = util::GetCurrentTimeMillisec();
|
||||||
|
if (currentTime < nextUpdate)
|
||||||
|
return;
|
||||||
|
|
||||||
auto& manager = game::EntityManager::instance();
|
auto& manager = game::EntityManager::instance();
|
||||||
auto avatar = manager.avatar();
|
auto avatar = manager.avatar();
|
||||||
if (avatar->animator() == nullptr)
|
if (avatar->animator() == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (f_Enabled && f_ApplyAnimation)
|
if (f_ApplyKey.value().IsPressed())
|
||||||
{
|
app::Animator_Play(avatar->animator(), string_to_il2cppi(f_Animation.value().c_str()), 0, 0, nullptr);
|
||||||
app::Animator_Play(avatar->animator(), string_to_il2cppi(currentAnimation.c_str()), 0, 0, nullptr);
|
|
||||||
f_ApplyAnimation = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (f_Enabled && f_ResetAnimation)
|
if (f_ResetKey.value().IsPressed())
|
||||||
{
|
|
||||||
app::Animator_Rebind(avatar->animator(), nullptr);
|
app::Animator_Rebind(avatar->animator(), nullptr);
|
||||||
f_ResetAnimation = false;
|
|
||||||
}
|
nextUpdate = currentTime + (int)f_DelayUpdate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cheat-base/cheat/Feature.h>
|
#include <cheat-base/cheat/Feature.h>
|
||||||
#include <cheat-base/config/config.h>
|
#include <cheat-base/config/config.h>
|
||||||
|
#include <cheat-base/thread-safe.h>
|
||||||
|
|
||||||
namespace cheat::feature
|
namespace cheat::feature
|
||||||
{
|
{
|
||||||
@ -9,19 +10,21 @@ namespace cheat::feature
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
config::Field<config::Toggle<Hotkey>> f_Enabled;
|
config::Field<config::Toggle<Hotkey>> f_Enabled;
|
||||||
config::Field<config::Toggle<Hotkey>> f_ApplyAnimation;
|
config::Field<std::string> f_Animation;
|
||||||
config::Field<config::Toggle<Hotkey>> f_ResetAnimation;
|
config::Field<Hotkey> f_ApplyKey;
|
||||||
|
config::Field<Hotkey> f_ResetKey;
|
||||||
static AnimationChanger& GetInstance();
|
|
||||||
|
|
||||||
const FeatureGUIInfo& GetGUIInfo() const override;
|
const FeatureGUIInfo& GetGUIInfo() const override;
|
||||||
void DrawMain() override;
|
void DrawMain() override;
|
||||||
|
|
||||||
virtual bool NeedStatusDraw() const override;
|
virtual bool NeedStatusDraw() const override;
|
||||||
void DrawStatus() override;
|
void DrawStatus() override;
|
||||||
|
static AnimationChanger& GetInstance();
|
||||||
void OnGameUpdate();
|
void OnGameUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SafeQueue<uint32_t> toBeUpdate;
|
||||||
|
SafeValue<int64_t> nextUpdate;
|
||||||
|
int f_DelayUpdate = 500;
|
||||||
AnimationChanger();
|
AnimationChanger();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user