fix(TabSpawn): Input enter returns true & improved code

This commit is contained in:
Yimura 2021-01-13 15:35:46 +01:00
parent 79a59603b5
commit c4b6e7698d
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682

View File

@ -9,9 +9,10 @@ namespace big
{ {
if (ImGui::BeginTabItem("Spawn")) if (ImGui::BeginTabItem("Spawn"))
{ {
ImGui::InputText("Model Name", model, sizeof(model)); if (
ImGui::InputText("Model Name", model, sizeof(model), ImGuiInputTextFlags_EnterReturnsTrue) ||
if (ImGui::Button("Spawn")) ImGui::Button("Spawn")
)
{ {
QUEUE_JOB_BEGIN_CLAUSE(= ) QUEUE_JOB_BEGIN_CLAUSE(= )
{ {
@ -19,17 +20,13 @@ namespace big
if (hash) if (hash)
{ {
int tries = 0; for (uint8_t i = 0; !STREAMING::HAS_MODEL_LOADED(hash) && i < 100; i++)
const int max = 100;
while (!STREAMING::HAS_MODEL_LOADED(hash) && tries < max)
{ {
STREAMING::REQUEST_MODEL(hash); STREAMING::REQUEST_MODEL(hash);
tries++;
script::get_current()->yield(); script::get_current()->yield();
} }
if (tries >= max) if (!STREAMING::HAS_MODEL_LOADED(hash))
{ {
features::notify::above_map("~r~Failed to spawn model, did you give an incorrect model?"); features::notify::above_map("~r~Failed to spawn model, did you give an incorrect model?");