mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-16 22:37:22 +08:00

Added additional commands to showcase suggestion system. Added a new util file to operate on strings in a unified manner. Changed input_text_with_hint component to allow for more flags than one. Added more player seeking features to player_service such as get_by_name() * Fixed out of bounds suggestion navigation * Added suggestions to spawn_vehicle command * Created command play_animation * Added suggestion support for multi commands using a semicolon allows for more commands to fire at once, and is now supported with appropriate suggestions * Added rotation to teleport_to_location command * Fixed stupid error & added multiple raw command auto fills * Added sanity checks to avoid nullpointers * Added context identifiers to player commands * Added temporary self inclusion to player commands Needs translation on the translations repo * Applied rudamentary reviews * Experimental proxy globalization * Fixed argument sensitivity on spawn vehicle * Scrapped 2 ideas (maybe for future) * Added true and false suggestions to bool commands --------- Co-authored-by: Andreas Maerten <24669514+Yimura@users.noreply.github.com> Co-authored-by: gir489 <100792176+gir489returns@users.noreply.github.com>
95 lines
2.4 KiB
C++
95 lines
2.4 KiB
C++
#include "backend/bool_command.hpp"
|
|
#include "backend/command.hpp"
|
|
#include "natives.hpp"
|
|
#include "pointers.hpp"
|
|
#include "services/mobile/mobile_service.hpp"
|
|
#include "services/ped_animations/ped_animations_service.hpp"
|
|
#include "util/mobile.hpp"
|
|
#include "util/string_operations.hpp"
|
|
#include "util/vehicle.hpp"
|
|
#include "util/ped.hpp"
|
|
|
|
namespace big
|
|
{
|
|
class play_animation : command
|
|
{
|
|
using command::command;
|
|
|
|
virtual std::optional<std::vector<std::string>> get_argument_suggestions(int arg) override
|
|
{
|
|
if (arg == 1)
|
|
{
|
|
std::vector<std::string> suggestions;
|
|
for (auto& item : g_ped_animation_service.all_saved_animations | std::views::values | std::views::join)
|
|
{
|
|
std::string anim_name = item.name;
|
|
string::operations::remove_whitespace(anim_name);
|
|
string::operations::to_lower(anim_name);
|
|
suggestions.push_back(anim_name);
|
|
}
|
|
return suggestions;
|
|
}
|
|
|
|
return std::nullopt;
|
|
}
|
|
|
|
virtual std::optional<command_arguments> parse_args(const std::vector<std::string>& args, const std::shared_ptr<command_context> ctx) override
|
|
{
|
|
command_arguments result(1);
|
|
const std::string anim_name = args[0];
|
|
|
|
if (anim_name == "stop")
|
|
{
|
|
result.push<int>(-1);
|
|
return result;
|
|
}
|
|
|
|
|
|
int anim_index = 0;
|
|
for (auto& item : g_ped_animation_service.all_saved_animations | std::views::values | std::views::join)
|
|
{
|
|
std::string display_name = item.name;
|
|
display_name = string::operations::remove_whitespace(display_name);
|
|
display_name = string::operations::to_lower(display_name);
|
|
|
|
if (display_name.find(anim_name) != std::string::npos)
|
|
{
|
|
result.push<int>(anim_index);
|
|
break;
|
|
}
|
|
anim_index++;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
virtual CommandAccessLevel get_access_level() override
|
|
{
|
|
return CommandAccessLevel::ADMIN;
|
|
}
|
|
|
|
virtual void execute(const command_arguments& args, const std::shared_ptr<command_context> ctx) override
|
|
{
|
|
const auto anim_index = args.get<int>(0);
|
|
|
|
if (anim_index == -1)
|
|
{
|
|
TASK::CLEAR_PED_TASKS(self::ped);
|
|
return;
|
|
}
|
|
|
|
int count = 0;
|
|
for (auto& item : g_ped_animation_service.all_saved_animations | std::views::values | std::views::join)
|
|
{
|
|
if (count == anim_index)
|
|
g_ped_animation_service.play_saved_ped_animation(item, self::ped);
|
|
|
|
count++;
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
play_animation g_play_animation("anim", "PLAY_ANIMATION", "PLAY_ANIMATION_DESC", 1);
|
|
}
|