-
Notifications
You must be signed in to change notification settings - Fork 318
Label text #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: enhanced
Are you sure you want to change the base?
Label text #696
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #include "CustomLabelText.hpp" | ||
|
|
||
| namespace YimMenu | ||
| { | ||
| void CustomLabelText::InitImpl() | ||
| { | ||
| AddLabelImpl(0x1B2EA75B, "YimMenu Story"); // Title Story Mode | ||
| AddLabelImpl(0xABB00DEB, "YimMenu"); // Title Pause Menu | ||
| AddLabelImpl(Joaat("PM_ENTER_MP"), "Play GTA Online with YimMenu"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use "HUD_BE_RESTART_EF_DISABLED_WITH_BE": "GTA Online requires BattlEye to be disabled. Please restart Grand Theft Auto V to disable BattlEye.",
"HUD_BE_RESTART_EF_ENABLED_NO_BE": "BattlEye is required to play GTA Online. Please restart Grand Theft Auto V to enable BattlEye.",
"HUD_BE_RESTART_SERVICE_NOT_RUNNING": "BattlEye is required to play GTA Online. Please restart Grand Theft Auto V to enable BattlEye.", |
||
| AddLabelImpl(Joaat("PM_EXIT_GAME"), "Quit GTA V with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_GO"), "Play with YimMenu"); | ||
| AddLabelImpl(Joaat("HUD_MPREENTER"), "Joining a new session with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_FRIEND_FM"), "Closed Friend Session with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_INF_EXIT"), "Quit to desktop with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_CREWS"), "Join a Crew Only Session with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_INF_PGOT"), "Online with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_INVO_FM"), "Join an Invite Only Session with YimMenu"); | ||
| AddLabelImpl(Joaat("LOADING_SPLAYER_L"), "Loading Story Mode with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_NCREW_FM"), "Join a Crew Session with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_CREW_FM"), "Join a Closed Crew Session with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_SOLO_FM"), "Join a Solo Session with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_FRESES"), "Join a Friends Only Session with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_CHOOSE_CHAR"), "Choose your personnage with YimMenu"); | ||
| AddLabelImpl(Joaat("PM_INF_PGOT"), "Online with YimMenu"); | ||
| } | ||
|
|
||
| bool CustomLabelText::AddLabelImpl(joaat_t hash, const std::string_view text) | ||
| { | ||
| const auto size = text.size() + 1; | ||
| auto buffer = std::make_unique<char[]>(size); | ||
| memcpy(buffer.get(), text.data(), size); | ||
| return m_LabelOverwrites.insert({hash, std::move(buffer)}).second; | ||
| } | ||
|
|
||
| bool CustomLabelText::AddLabelImpl(joaat_t hash, CustomLabelText_t&& cb) | ||
| { | ||
| return m_Labels.insert({hash, std::move(cb)}).second; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #pragma once | ||
| #include "core/util/Joaat.hpp" | ||
|
|
||
| namespace YimMenu | ||
| { | ||
| using CustomLabelText_t = std::function<const char*(const char*)>; | ||
| class CustomLabelText | ||
| { | ||
| static CustomLabelText& GetInstance() | ||
| { | ||
| static CustomLabelText instance; | ||
| return instance; | ||
| } | ||
| public: | ||
| static uint64_t ComputeHash(const char* str) | ||
| { | ||
| return Joaat(str); | ||
| } | ||
| static uint64_t ComputeHash(uint64_t value) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove these two. |
||
| { | ||
| return value; | ||
| } | ||
|
|
||
| static void Init() | ||
| { | ||
| return GetInstance().InitImpl(); | ||
| } | ||
|
|
||
| static bool AddLabel(joaat_t hash, const std::string_view text) | ||
| { | ||
| return GetInstance().AddLabelImpl(hash, text); | ||
| } | ||
|
|
||
| static bool AddLabel(joaat_t hash, CustomLabelText_t&& cb) | ||
| { | ||
| return GetInstance().AddLabelImpl(hash, std::move(cb)); | ||
| } | ||
|
|
||
| template<typename T> | ||
| static const char* GetText(const T& label) | ||
| { | ||
| return GetInstance().GetTextImpl(label); | ||
| } | ||
| private: | ||
| bool AddLabelImpl(joaat_t hash, const std::string_view text); | ||
| bool AddLabelImpl(joaat_t hash, CustomLabelText_t&& cb); | ||
|
|
||
| void InitImpl(); | ||
|
|
||
| template<typename T> | ||
| const char* GetTextImpl(const T& label) const | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only accept |
||
| { | ||
| uint64_t hash; | ||
|
|
||
| if constexpr (std::is_same_v<T, const char*>) | ||
| hash = ComputeHash(label); | ||
| else if constexpr (std::is_same_v<T, uint32_t>) | ||
| hash = ComputeHash(label); | ||
| else | ||
| static_assert(sizeof(T) == 0, "Label type Unsupported"); | ||
|
|
||
| if (const auto& it = m_Labels.find(hash); it != m_Labels.end()) | ||
| { | ||
| if constexpr (std::is_same_v<T, const char*>) | ||
| return it->second(label); | ||
| else | ||
| return it->second(nullptr); | ||
| } | ||
|
|
||
| if (const auto& it = m_LabelOverwrites.find(hash); it != m_LabelOverwrites.end()) | ||
| return it->second.get(); | ||
|
|
||
| return nullptr; | ||
| } | ||
|
|
||
| std::unordered_map<uint64_t, std::function<const char*(const char*)>> m_Labels; | ||
| std::unordered_map<joaat_t, std::unique_ptr<char[]>> m_LabelOverwrites; | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,5 +101,7 @@ namespace YimMenu::Hooks | |
| namespace Misc | ||
| { | ||
| extern bool AssistedAimShouldReleaseEntity(__int64 a1); | ||
| extern const char* GetLabelText(void* unk, const char* label); | ||
| extern const char* GetLabelTextInternal(void* this_, uint32_t label_hash); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #include "core/hooking/DetourHook.hpp" | ||
| #include "game/hooks/Hooks.hpp" | ||
| #include "game/backend/CustomLabelText.hpp" | ||
|
|
||
| namespace YimMenu::Hooks | ||
| { | ||
| const char* Misc::GetLabelText(void* unk, const char* label) | ||
| { | ||
| if (const auto text = CustomLabelText::GetText<const char*>(label); text) | ||
| return text; | ||
|
|
||
| return BaseHook::Get<Misc::GetLabelText, DetourHook<decltype(&Misc::GetLabelText)>>()->Original()(unk, label); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #include "core/hooking/DetourHook.hpp" | ||
| #include "game/hooks/Hooks.hpp" | ||
| #include "game/backend/CustomLabelText.hpp" | ||
|
|
||
| namespace YimMenu::Hooks | ||
| { | ||
| const char* Misc::GetLabelTextInternal(void* this_, uint32_t label_hash) | ||
| { | ||
| if (const auto text = CustomLabelText::GetText<uint32_t>(label_hash); text) | ||
| return text; | ||
|
|
||
| return BaseHook::Get<Misc::GetLabelTextInternal, DetourHook<decltype(&Misc::GetLabelTextInternal)>>()->Original()(this_, label_hash); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert the changes to this file.