feat(Notify): Simplified code, using std::string_view
This commit is contained in:
parent
95f646aaad
commit
80ac68bce2
@ -15,13 +15,12 @@ namespace big
|
||||
{
|
||||
int amount_fixed = mobile::mors_mutual::fix_all();
|
||||
|
||||
QUEUE_JOB_BEGIN_CLAUSE(amount_fixed)
|
||||
g_fiber_pool->queue_job([amount_fixed]
|
||||
{
|
||||
char vehicles_fixed[42];
|
||||
sprintf(vehicles_fixed, "<C>%d</C> vehicle%s been fixed.", amount_fixed, amount_fixed == 1 ? " has" : "s have");
|
||||
|
||||
notify::above_map(vehicles_fixed);
|
||||
}QUEUE_JOB_END_CLAUSE
|
||||
notify::above_map(
|
||||
fmt::format("<C>{}</C> vehicle{} been fixed.", amount_fixed, amount_fixed == 1 ? " has" : "s have")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
@ -35,9 +35,10 @@ namespace big
|
||||
if (source_player->m_player_id < 32)
|
||||
{
|
||||
g_pointers->m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset);
|
||||
|
||||
std::string msg = fmt::format("<C>{}</C> possible attempt at freezing entity.", source_player->get_name());
|
||||
notify::above_map(msg);
|
||||
|
||||
notify::above_map(
|
||||
fmt::format("<C>{}</C> possible attempt at freezing entity.", source_player->get_name())
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -56,8 +57,9 @@ namespace big
|
||||
|
||||
if (money >= 2000)
|
||||
{
|
||||
std::string msg = fmt::format("<C>{}</C> is spawning cash.", source_player->get_name());
|
||||
notify::above_map(msg);
|
||||
notify::above_map(
|
||||
fmt::format("<C>{}</C> is spawning cash.", source_player->get_name())
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -66,17 +68,19 @@ namespace big
|
||||
case RockstarEvent::NETWORK_CHECK_CODE_CRCS_EVENT:
|
||||
case RockstarEvent::REPORT_MYSELF_EVENT:
|
||||
{
|
||||
std::string msg = fmt::format("Detected <C>{}</C> as cheating.", source_player->get_name());
|
||||
notify::above_map(msg);
|
||||
notify::above_map(
|
||||
fmt::format("Detected <C>{}</C> as cheating.", source_player->get_name())
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case RockstarEvent::REQUEST_CONTROL_EVENT:
|
||||
{
|
||||
g_pointers->m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset);
|
||||
|
||||
std::string msg = fmt::format("Denied player control request from <C>{}</C>", source_player->get_name());
|
||||
notify::above_map(msg);
|
||||
|
||||
notify::above_map(
|
||||
fmt::format("Denied player control request from <C>{}</C>", source_player->get_name())
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -114,8 +114,9 @@ namespace big
|
||||
|
||||
if (strlen(type) != 0)
|
||||
{
|
||||
std::string msg = fmt::format("~g~BLOCKED SCRIPT EVENT~s~\nFrom: <C>{}</C>\nEvent Type: ~b~{}", player->get_name(), type);
|
||||
notify::above_map(msg);
|
||||
notify::above_map(
|
||||
fmt::format("~g~BLOCKED SCRIPT EVENT~s~\nFrom: <C>{}</C>\nEvent Type: ~b~{}", player->get_name(), type)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -5,14 +5,13 @@
|
||||
|
||||
namespace big::notify
|
||||
{
|
||||
inline void above_map(const char* text)
|
||||
inline void above_map(std::string_view text)
|
||||
{
|
||||
HUD::SET_TEXT_OUTLINE();
|
||||
HUD::BEGIN_TEXT_COMMAND_THEFEED_POST("STRING");
|
||||
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(text);
|
||||
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(text.data());
|
||||
HUD::END_TEXT_COMMAND_THEFEED_POST_TICKER(false, false);
|
||||
}
|
||||
inline void above_map(std::string text) { above_map(text.c_str()); }
|
||||
|
||||
// deprecated/unused
|
||||
inline void blocked_event(const char* name, Player player)
|
||||
@ -29,10 +28,10 @@ namespace big::notify
|
||||
}
|
||||
|
||||
// Shows a busy spinner till the value at the address equals the value passed or if timeout is hit
|
||||
inline void busy_spinner(const char* text, int* address, int value, int timeout = 15)
|
||||
inline void busy_spinner(std::string_view text, int* address, int value, int timeout = 15)
|
||||
{
|
||||
HUD::BEGIN_TEXT_COMMAND_BUSYSPINNER_ON("STRING");
|
||||
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(text);
|
||||
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(text.data());
|
||||
HUD::END_TEXT_COMMAND_BUSYSPINNER_ON(3);
|
||||
|
||||
for (size_t i = 0; *address != value && i < (size_t)timeout * 100; i++)
|
||||
@ -41,10 +40,10 @@ namespace big::notify
|
||||
HUD::BUSYSPINNER_OFF();
|
||||
}
|
||||
|
||||
inline void display_help_text(const char* text)
|
||||
inline void display_help_text(std::string_view text)
|
||||
{
|
||||
HUD::BEGIN_TEXT_COMMAND_DISPLAY_HELP("STRING");
|
||||
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(text);
|
||||
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(text.data());
|
||||
HUD::END_TEXT_COMMAND_DISPLAY_HELP(0, 0, 1, -1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user