feat(Util/Notify): Added busy spinner

This commit is contained in:
Yimura 2022-01-18 02:05:38 +01:00
parent c09df14671
commit 90bce8256d
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682

View File

@ -1,5 +1,6 @@
#pragma once
#include "natives.hpp"
#include "script.hpp"
namespace big::notify
{
@ -24,6 +25,19 @@ namespace big::notify
above_map(msg);
}
// 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)
{
HUD::BEGIN_TEXT_COMMAND_BUSYSPINNER_ON("STRING");
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(text);
HUD::END_TEXT_COMMAND_BUSYSPINNER_ON(3);
for (size_t i = 0; *address != value && i < (size_t)timeout * 100; i++)
script::get_current()->yield(10ms);
HUD::BUSYSPINNER_OFF();
}
inline void display_help_text(const char* text)
{
HUD::BEGIN_TEXT_COMMAND_DISPLAY_HELP("STRING");