generated from YimMenu/YimMenuV2
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improvements * vast improvement to ped spawner * update * updates * update * Necessary changes Renamed util file. Separated pedmodels library to secluded directory. Added new submenu called World. Added input completion callback. Adjusted InputTextWithHint item. Fixed SpawnPed logic. Removed duplicate clang variable. --------- Co-authored-by: DayibBaba <[email protected]>
- Loading branch information
Showing
12 changed files
with
199 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#include "World.hpp" | ||
|
||
#include "game/frontend/items/Items.hpp" | ||
#include "util/Ped.hpp" | ||
#include "util/libraries/PedModels.hpp" | ||
#include "game/backend/FiberPool.hpp" | ||
|
||
namespace YimMenu::Submenus | ||
{ | ||
bool is_ped_model_in_ped_model_list(std::string model) | ||
{ | ||
for (const auto& pedModel : pedModels) | ||
{ | ||
if (pedModel.model == model) | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
int PedSpawnerInputCallback(ImGuiInputTextCallbackData* data) | ||
{ | ||
if (data->EventFlag == ImGuiInputTextFlags_CallbackCompletion) | ||
{ | ||
std::string newText{}; | ||
std::string inputLower = data->Buf; | ||
std::transform(inputLower.begin(), inputLower.end(), inputLower.begin(), ::tolower); | ||
for (const auto& pedModel : pedModels) | ||
{ | ||
std::string modelLower = pedModel.model; | ||
std::transform(modelLower.begin(), modelLower.end(), modelLower.begin(), ::tolower); | ||
if (modelLower.find(inputLower) != std::string::npos) | ||
{ | ||
newText = pedModel.model; | ||
} | ||
} | ||
|
||
if (!newText.empty()) | ||
{ | ||
data->DeleteChars(0, data->BufTextLen); | ||
data->InsertChars(0, newText.c_str()); | ||
} | ||
} | ||
} | ||
|
||
void PedSpawnerGroup() | ||
{ | ||
static std::string pedModelBuffer; | ||
static float scale = 1; | ||
static bool dead, invis, godmode, freeze; | ||
InputTextWithHint("##pedmodel", "Ped Model", &pedModelBuffer, ImGuiInputTextFlags_CallbackCompletion, nullptr, PedSpawnerInputCallback).Draw(); | ||
if (ImGui::IsItemHovered()) | ||
ImGui::SetTooltip("Press Tab to auto fill"); | ||
if (!pedModelBuffer.empty() && !is_ped_model_in_ped_model_list(pedModelBuffer)) | ||
{ | ||
ImGui::BeginListBox("##pedmodels", ImVec2(250, 100)); | ||
|
||
std::string bufferLower = pedModelBuffer; | ||
std::transform(bufferLower.begin(), bufferLower.end(), bufferLower.begin(), ::tolower); | ||
for (const auto& pedModel : pedModels) | ||
{ | ||
std::string pedModelLower = pedModel.model; | ||
std::transform(pedModelLower.begin(), pedModelLower.end(), pedModelLower.begin(), ::tolower); | ||
if (pedModelLower.find(bufferLower) != std::string::npos && ImGui::Selectable(pedModel.model.data())) | ||
{ | ||
pedModelBuffer = pedModel.model; | ||
} | ||
} | ||
|
||
ImGui::EndListBox(); | ||
} | ||
|
||
ImGui::Checkbox("Spawn Dead", &dead); | ||
ImGui::Checkbox("Invisible", &invis); | ||
ImGui::Checkbox("GodMode", &godmode); | ||
ImGui::Checkbox("Frozen", &freeze); | ||
ImGui::SliderFloat("Scale", &scale, 0.1, 10); | ||
if (ImGui::Button("Spawn")) | ||
{ | ||
FiberPool::Push([] { | ||
Peds::SpawnPed(pedModelBuffer, ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(Self::PlayerPed, 0, 3, 0), 0, freeze, dead, godmode, invis, scale); | ||
}); | ||
} | ||
} | ||
|
||
World::World() : | ||
Submenu::Submenu("World") | ||
{ | ||
auto spawners = std::make_shared<Category>("Spawners"); | ||
auto pedSpawnerGroup = std::make_shared<Group>("Ped Spawner", GetListBoxDimensions()); | ||
|
||
pedSpawnerGroup->AddItem(std::make_shared<ImGuiItem>([] { | ||
PedSpawnerGroup(); | ||
})); | ||
|
||
spawners->AddItem(pedSpawnerGroup); | ||
|
||
AddCategory(std::move(spawners)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
#include "core/frontend/manager/UIManager.hpp" | ||
|
||
namespace YimMenu::Submenus | ||
{ | ||
class World : public Submenu | ||
{ | ||
public: | ||
World(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "Ped.hpp" | ||
#include "Joaat.hpp" | ||
|
||
namespace YimMenu::Peds | ||
{ | ||
// Returns 0 if it fails | ||
int SpawnPed(std::string model_name, Vector3 coords, float heading, bool blockNewPedMovement, bool spawnDead, bool invincible, bool invisible, int scale) | ||
{ | ||
Hash model = Joaat(model_name.c_str()); | ||
|
||
if (!STREAMING::IS_MODEL_IN_CDIMAGE(model) || !STREAMING::IS_MODEL_VALID(model)) | ||
{ | ||
Notifications::Show("Spawner", "Invalid ped model", NotificationType::Error); | ||
return 0; | ||
} | ||
|
||
for (int i = 0; i < 30 && !STREAMING::HAS_MODEL_LOADED(model); i++) | ||
{ | ||
STREAMING::REQUEST_MODEL(model, false); | ||
ScriptMgr::Yield(); | ||
} | ||
|
||
auto ped = PED::CREATE_PED(model, coords.x, coords.y, coords.z, heading, 1, 0, 0, 0); | ||
|
||
PED::_SET_RANDOM_OUTFIT_VARIATION(ped, true); | ||
ENTITY::PLACE_ENTITY_ON_GROUND_PROPERLY(ped, true); | ||
|
||
ENTITY::FREEZE_ENTITY_POSITION(ped, blockNewPedMovement); | ||
ENTITY::SET_ENTITY_INVINCIBLE(ped, invincible); | ||
ENTITY::SET_ENTITY_VISIBLE(ped, !invisible); | ||
PED::_SET_PED_SCALE(ped, (float)scale); | ||
|
||
if (spawnDead) | ||
PED::APPLY_DAMAGE_TO_PED(ped, std::numeric_limits<int>::max(), 1, 0, YimMenu::Self::PlayerPed); | ||
|
||
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(model); | ||
return ped; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
#include "core/frontend/Notifications.hpp" | ||
#include "game/backend/ScriptMgr.hpp" | ||
#include "game/features/Features.hpp" | ||
#include "game/rdr/Natives.hpp" | ||
|
||
|
||
namespace YimMenu::Peds | ||
{ | ||
extern int SpawnPed(std::string model_name, Vector3 coords, float heading = 0.0f, bool blockNewPedMovement = false, bool spawnDead = false, bool invincible = false, bool invisible = false, int scale = 1); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.