mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-23 04:27:25 +08:00
Refactor format money to use manual methods of comma addition. (#3020)
This commit is contained in:
parent
e97c057ae4
commit
2c55564d1a
@ -2,14 +2,14 @@
|
||||
|
||||
namespace big
|
||||
{
|
||||
static inline std::string format_money(int64_t amount)
|
||||
/*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 hooks::format_int(int64_t integer_to_format, char* format_string, size_t size_always_64, bool use_commas)
|
||||
{
|
||||
@ -17,12 +17,8 @@ namespace big
|
||||
auto return_bytes = static_cast<unsigned char*>(return_address);
|
||||
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::strncpy(format_string, money_format.c_str(), size_always_64);
|
||||
use_commas = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_hooking->get_original<format_int>()(integer_to_format, format_string, size_always_64, use_commas);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,13 +6,14 @@ namespace big
|
||||
{
|
||||
namespace shop_controller
|
||||
{
|
||||
static inline std::string format_money(int64_t amount)
|
||||
inline std::string format_chips(int value)
|
||||
{
|
||||
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);
|
||||
std::string formatted = std::to_string(value);
|
||||
for (int i = formatted.size() - 3; i > 0; i -= 3)
|
||||
{
|
||||
formatted.insert(i, ",");
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
||||
void SET_WARNING_MESSAGE_WITH_HEADER(rage::scrNativeCallContext* src)
|
||||
@ -43,7 +44,7 @@ namespace big
|
||||
STATS::STAT_GET_INT(casino_chips, &player_chips, -1);
|
||||
if (arg0 == player_chips && player_chips >= 1000)
|
||||
{
|
||||
auto chips_format = format_money(player_chips);
|
||||
auto chips_format = format_chips(player_chips);
|
||||
return GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(chips_format.c_str());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user