mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 12:07:46 +08:00
Add Description for Weapons (#3649)
This commit is contained in:
parent
706e6f7fc0
commit
d2b1b505ed
@ -81,5 +81,6 @@ namespace big
|
||||
inline script_function vehicle_cannot_accept_clan_logo("CVACL", "main_persistent"_J, "2D 01 03 00 00 2C 01 00 A1 06 ? 04");
|
||||
inline script_function get_component_name_string("GCNS", "mp_weapons"_J, "2D 02 43 00 00 38 01");
|
||||
inline script_function get_component_desc_string("GCDS", "mp_weapons"_J, "2D 02 43 00 00 38 00");
|
||||
inline script_function get_weapon_desc_string("GWDS", "mp_weapons"_J, "2D 02 A0 00 00");
|
||||
}
|
||||
}
|
@ -289,6 +289,23 @@ namespace big
|
||||
return std::find(arr.begin(), arr.end(), val) != arr.end();
|
||||
};
|
||||
|
||||
constexpr Hash script_hash = "MP_Weapons"_J;
|
||||
if (!SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(script_hash))
|
||||
{
|
||||
while (!SCRIPT::HAS_SCRIPT_WITH_NAME_HASH_LOADED(script_hash))
|
||||
{
|
||||
SCRIPT::REQUEST_SCRIPT_WITH_NAME_HASH(script_hash);
|
||||
script::get_current()->yield(10ms);
|
||||
}
|
||||
mp_weapons_thread_id = SYSTEM::START_NEW_SCRIPT_WITH_NAME_HASH(script_hash, 1424);
|
||||
auto thread = gta_util::find_script_thread_by_id(mp_weapons_thread_id);
|
||||
if (thread)
|
||||
thread->m_context.m_state = rage::eThreadState::paused;
|
||||
else
|
||||
LOG(FATAL) << "Failed to find MP_Weapons script!";
|
||||
SCRIPT::SET_SCRIPT_WITH_NAME_HASH_AS_NO_LONGER_NEEDED(script_hash);
|
||||
}
|
||||
|
||||
LOG(INFO) << "Rebuilding cache started...";
|
||||
yim_fipackfile::add_wrapper_call_back([&](yim_fipackfile& rpf_wrapper, std::filesystem::path path) -> void {
|
||||
if (path.filename() == "vehicles.meta")
|
||||
@ -358,23 +375,6 @@ namespace big
|
||||
|
||||
if (LocName.ends_with("INVALID"))
|
||||
{
|
||||
constexpr Hash script_hash = "MP_Weapons"_J;
|
||||
if (!SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(script_hash))
|
||||
{
|
||||
while (!SCRIPT::HAS_SCRIPT_WITH_NAME_HASH_LOADED(script_hash))
|
||||
{
|
||||
SCRIPT::REQUEST_SCRIPT_WITH_NAME_HASH(script_hash);
|
||||
script::get_current()->yield(10ms);
|
||||
}
|
||||
mp_weapons_thread_id = SYSTEM::START_NEW_SCRIPT_WITH_NAME_HASH(script_hash, 1424);
|
||||
auto thread = gta_util::find_script_thread_by_id(mp_weapons_thread_id);
|
||||
if (thread)
|
||||
thread->m_context.m_state = rage::eThreadState::paused;
|
||||
else
|
||||
LOG(FATAL) << "Failed to find MP_Weapons script!";
|
||||
SCRIPT::SET_SCRIPT_WITH_NAME_HASH_AS_NO_LONGER_NEEDED(script_hash);
|
||||
}
|
||||
|
||||
Hash weapon_hash = 0;
|
||||
if (name.starts_with("COMPONENT_KNIFE"))
|
||||
weapon_hash = "WEAPON_KNIFE"_J;
|
||||
@ -432,10 +432,15 @@ namespace big
|
||||
if (std::strcmp(human_name_hash, "WT_INVALID") == 0 || std::strcmp(human_name_hash, "WT_VEHMINE") == 0)
|
||||
continue;
|
||||
|
||||
std::string desc = scr_functions::get_weapon_desc_string.call<const char*>(hash, false);
|
||||
if (desc.ends_with("INVALID"))
|
||||
desc.clear();
|
||||
|
||||
auto weapon = weapon_item_parsed{};
|
||||
|
||||
weapon.m_name = name;
|
||||
weapon.m_name = name;
|
||||
weapon.m_display_name = human_name_hash;
|
||||
weapon.m_display_desc = desc;
|
||||
weapon.rpf_file_type = determine_file_type(file_str, rpf_wrapper.get_name());
|
||||
|
||||
auto weapon_flags = std::string(item.child("WeaponFlags").text().as_string());
|
||||
@ -568,6 +573,9 @@ namespace big
|
||||
for (auto& item : weapons)
|
||||
{
|
||||
item.second.m_display_name = HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(item.second.m_display_name.c_str());
|
||||
item.second.m_display_desc = HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(item.second.m_display_desc.c_str());
|
||||
if (item.second.m_display_desc == "NULL")
|
||||
item.second.m_display_desc.clear();
|
||||
}
|
||||
for (auto& item : weapon_components)
|
||||
{
|
||||
|
@ -16,6 +16,7 @@ namespace big
|
||||
public:
|
||||
std::string m_name;
|
||||
std::string m_display_name;
|
||||
std::string m_display_desc;
|
||||
std::string m_weapon_type;
|
||||
uint32_t m_hash;
|
||||
uint32_t m_reward_hash;
|
||||
@ -23,7 +24,7 @@ namespace big
|
||||
std::vector<std::string> m_attachments;
|
||||
bool m_throwable;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(weapon_item, m_name, m_display_name, m_weapon_type, m_hash, m_reward_hash, m_reward_ammo_hash, m_attachments, m_throwable)
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(weapon_item, m_name, m_display_name, m_display_desc, m_weapon_type, m_hash, m_reward_hash, m_reward_ammo_hash, m_attachments, m_throwable)
|
||||
};
|
||||
|
||||
class weapon_item_parsed : public weapon_item
|
||||
|
@ -106,6 +106,14 @@ namespace big
|
||||
selected_attachment_hash = 0;
|
||||
selected_tint = 0;
|
||||
}
|
||||
if (ImGui::IsItemHovered() && !weapon.second.m_display_desc.empty())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35);
|
||||
ImGui::TextUnformatted(weapon.second.m_display_desc.c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found_match)
|
||||
@ -141,7 +149,7 @@ namespace big
|
||||
selected_attachment = attachment_name;
|
||||
selected_attachment_hash = attachment_hash;
|
||||
}
|
||||
if (ImGui::IsItemHovered() && attachment_component.m_display_desc != "NULL")
|
||||
if (ImGui::IsItemHovered() && !attachment_component.m_display_desc.empty())
|
||||
{
|
||||
ImGui::SetTooltip(attachment_component.m_display_desc.c_str());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user