Fixed format_money not working. (#2969)

This commit is contained in:
gir489 2024-04-24 15:14:41 -04:00 committed by GitHub
parent 1fa3ef8a45
commit 51ee53ee51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 53 additions and 7 deletions

View File

@ -33,6 +33,12 @@ if(Git_FOUND)
OUTPUT_VARIABLE GIT_BRANCH
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
# Check if GIT_BRANCH is empty
if(NOT GIT_BRANCH)
# If GIT_BRANCH is empty, use GITHUB_HEAD_REF
set(GIT_BRANCH "$ENV{GITHUB_HEAD_REF}")
endif()
# generate version.cpp
configure_file("${SRC_DIR}/version.cpp.in" "${SRC_DIR}/version.cpp" @ONLY)
endif()

View File

@ -947,7 +947,14 @@ namespace big
NLOHMANN_DEFINE_TYPE_INTRUSIVE(vehicle_control, operation_animation, render_distance_on_veh, show_info)
} vehicle_control{};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(window, background_color, demo, text_color, button_color, frame_color, gui_scale, switched_view, ingame_overlay, vehicle_control, ingame_overlay_indicators)
struct gui
{
bool format_money = true;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(gui, format_money)
} gui{};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(window, background_color, demo, text_color, button_color, frame_color, gui_scale, switched_view, ingame_overlay, vehicle_control, ingame_overlay_indicators, gui)
} window{};
struct context_menu

View File

@ -5,7 +5,7 @@ namespace big
static inline std::string format_money(int64_t amount)
{
std::stringstream ss;
ss.imbue(std::locale(""));
ss.imbue(std::locale("en_US.UTF-8"));
ss << "$" << std::put_money(static_cast<long double>(amount) * 100, false);
std::string money = ss.str();
return money.substr(0, money.size() - 3);
@ -15,12 +15,14 @@ namespace big
{
auto return_address = _ReturnAddress();
auto return_bytes = static_cast<unsigned char*>(return_address);
if (return_bytes[0] == 0x48 && return_bytes[1] == 0x8D && return_bytes[2] == 0x15) //lea rdx, aHcGreenlightFo ; "~HC_GREENLIGHT~ <font size='20'>"
if (g.window.gui.format_money && return_bytes[0] == 0x48 && return_bytes[1] == 0x8D && return_bytes[2] == 0x15) //lea rdx, aHcGreenlightFo ; "~HC_GREENLIGHT~ <font size='20'>"
{
auto money_format = format_money(integer_to_format);
std::strcpy(format_string, money_format.c_str());
return;
std::strncpy(format_string, money_format.c_str(), size_always_64);
}
else
{
g_hooking->get_original<format_int>()(integer_to_format, format_string, size_always_64, use_commas);
}
g_hooking->get_original<format_int>()(integer_to_format, format_string, size_always_64, use_commas);
}
}

View File

@ -103,6 +103,7 @@ namespace big
add_native_detour("shop_controller"_J, NativeIndex::IS_PED_SHOOTING, all_scripts::RETURN_FALSE); // prevent exploit reports
add_native_detour("shop_controller"_J, NativeIndex::SET_WARNING_MESSAGE_WITH_HEADER, shop_controller::SET_WARNING_MESSAGE_WITH_HEADER);
add_native_detour("shop_controller"_J, NativeIndex::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT, shop_controller::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT);
add_native_detour("carmod_shop"_J, NativeIndex::SET_ENTITY_COORDS, carmod_shop::SET_ENTITY_COORDS);
add_native_detour("carmod_shop"_J, NativeIndex::SET_ENTITY_HEADING, carmod_shop::SET_ENTITY_HEADING);

View File

@ -6,7 +6,16 @@ namespace big
{
namespace shop_controller
{
inline void SET_WARNING_MESSAGE_WITH_HEADER(rage::scrNativeCallContext* src)
static inline std::string format_money(int64_t amount)
{
std::stringstream ss;
ss.imbue(std::locale("en_US.UTF-8"));
ss << std::put_money(static_cast<long double>(amount) * 100, false);
std::string money = ss.str();
return money.substr(0, money.size() - 3);
}
void SET_WARNING_MESSAGE_WITH_HEADER(rage::scrNativeCallContext* src)
{
if (auto entry_line = src->get_arg<const char*>(1); !strcmp(entry_line, "CTALERT_F_2"))
{
@ -22,5 +31,24 @@ namespace big
HUD::SET_WARNING_MESSAGE_WITH_HEADER(src->get_arg<const char*>(0), src->get_arg<const char*>(1), src->get_arg<int>(2), src->get_arg<const char*>(3), src->get_arg<BOOL>(4), src->get_arg<Any>(5), src->get_arg<Any*>(6), src->get_arg<Any*>(7), src->get_arg<BOOL>(8), src->get_arg<Any>(9));
}
void SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(rage::scrNativeCallContext* src)
{
if (g.window.gui.format_money)
{
auto arg0 = src->get_arg<int>(0);
Hash casino_chips = self::char_index ? "MP1_CASINO_CHIPS"_J : "MP0_CASINO_CHIPS"_J;
int player_chips;
STATS::STAT_GET_INT(casino_chips, &player_chips, -1);
if (arg0 == player_chips && player_chips >= 1000)
{
auto chips_format = format_money(player_chips);
return GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(chips_format.c_str());
}
}
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(src->get_arg<int>(0));
}
}
}

View File

@ -59,6 +59,8 @@ namespace big
ImGui::EndGroup();
ImGui::Checkbox("VIEW_GUI_FORMAT_MONEY"_T.data(), &g.window.gui.format_money);
if (g.window.ingame_overlay.show_indicators)
{
if (ImGui::TreeNode("VIEW_GUI_SETTINGS_OVERLAY_INDICATORS"_T.data()))