Skip to content

Commit

Permalink
Merge pull request #505 from MAFINS/patch-searchFavourites
Browse files Browse the repository at this point in the history
  • Loading branch information
MAFINS authored Feb 1, 2023
2 parents 1bddc8d + 6e1b3fc commit e9bbf92
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 23 deletions.
44 changes: 35 additions & 9 deletions Solution/source/Submenus/PedAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ namespace sub

namespace AnimationSub_catind
{
std::string _searchStr = std::string();
void ClearSearchStr() { _searchStr.clear(); }

//struct NamedAnimation { std::string caption; std::string animDict, animName; };
const std::vector<AnimationSub_catind::NamedAnimation> vPresetPedAnims
{
Expand Down Expand Up @@ -174,13 +177,13 @@ namespace sub

AddOption(_searchStr.empty() ? "SEARCH" : boost::to_upper_copy(_searchStr), searchobj, nullFunc, -1, true); if (searchobj)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", _searchStr);
boost::to_lower(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToLower, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
}

AddOption("Stop Animation", null, AnimationSub_StopAnimationCallback);
AddTickol("Stop Animation", true, AnimationSub_StopAnimationCallback, AnimationSub_StopAnimationCallback, TICKOL::CROSS);

for (auto& current : vAllPedAnims)
{
Expand All @@ -193,9 +196,14 @@ namespace sub
notFoundInDict = true;
for (auto& current2 : current.second)
{
if (current2.find(_searchStr) != std::string::npos) { notFoundInDict = false; break; }
if (current2.find(_searchStr) != std::string::npos)
{
notFoundInDict = false;
break;
}
}
if (notFoundInDict) { continue; }
if (notFoundInDict)
continue;
}
}

Expand Down Expand Up @@ -437,7 +445,7 @@ namespace sub
SET_PED_IS_IGNORED_BY_AUTO_OPEN_DOORS(Static_241, TRUE);

AddTitle("Animations");
AddOption("Stop Animation", null, AnimationSub_StopAnimationCallback);
AddTickol("Stop Animation", true, AnimationSub_StopAnimationCallback, AnimationSub_StopAnimationCallback, TICKOL::CROSS);
AddanimOption_("Pole Dance", "mini@strip_club@pole_dance@pole_dance3", "pd_dance_03");
AddanimOption_("Hood Dance", "missfbi3_sniping", "dance_m_default");
AddanimOption_("Burning", "ragdoll@human", "on_fire");
Expand Down Expand Up @@ -561,16 +569,34 @@ namespace sub
Menu::SetSub_previous();
return;
}

auto nodeAnims = doc.child("PedAnims");

Menu::OnSubBack = AnimationSub_catind::ClearSearchStr;
auto& _searchStr = AnimationSub_catind::_searchStr;

AddTitle("Favourites");

bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : boost::to_upper_copy(_searchStr), bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", _searchStr);
boost::to_lower(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
}

for (auto nodeAnim = nodeAnims.first_child(); nodeAnim; nodeAnim = nodeAnim.next_sibling())
{
std::string dict = nodeAnim.attribute("dict").as_string();
std::string name = nodeAnim.attribute("name").as_string();

if (!_searchStr.empty())
{
if (dict.find(_searchStr) == std::string::npos &&
name.find(_searchStr) == std::string::npos)
continue;
}

AddanimOption_(dict + ", " + name, dict, name);
}
}
Expand Down Expand Up @@ -1156,7 +1182,7 @@ namespace sub
AddOption("ALL SCENARIOS", clearSearchStr, nullFunc, SUB::ANIMATIONSUB_TASKSCENARIOS2); if (clearSearchStr)
_searchStr.clear();

AddOption("End Scenarios", null, stopScenarioPls);
AddTickol("End Scenarios", true, stopScenarioPls, stopScenarioPls, TICKOL::CROSS);

for (auto& scen : vNamedScenarios)
{
Expand All @@ -1171,13 +1197,13 @@ namespace sub

AddOption(_searchStr.empty() ? "SEARCH" : boost::to_upper_copy(_searchStr), searchobj, nullFunc, -1, true); if (searchobj)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", _searchStr);
boost::to_lower(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToLower, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
}

AddOption("End Scenarios", null, stopScenarioPls);
AddTickol("End Scenarios", true, stopScenarioPls, stopScenarioPls, TICKOL::CROSS);

for (auto& current : vValues_TaskScenarios)
{
Expand Down
2 changes: 1 addition & 1 deletion Solution/source/Submenus/PedComponentChanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down
17 changes: 17 additions & 0 deletions Solution/source/Submenus/PedModelChanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ namespace sub
namespace PedFavourites_catind
{
std::string xmlFavouritePeds = "FavouritePeds.xml";
std::string _searchStr = std::string();

void ClearSearchStr() { _searchStr.clear(); }

bool IsPedAFavourite(GTAmodel::Model model)
{
pugi::xml_document doc;
Expand Down Expand Up @@ -130,6 +134,8 @@ namespace sub

void Sub_PedFavourites()
{
Menu::OnSubBack = ClearSearchStr;

AddTitle("Favourites");

pugi::xml_document doc;
Expand Down Expand Up @@ -176,11 +182,22 @@ namespace sub
{
AddBreak("---Added Ped Models---");

bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
}

for (auto nodeLocToLoad = nodeRoot.first_child(); nodeLocToLoad; nodeLocToLoad = nodeLocToLoad.next_sibling())
{
const std::string& customName = nodeLocToLoad.attribute("customName").as_string();
Model model = nodeLocToLoad.attribute("hash").as_uint();

if (!_searchStr.empty()) { if (boost::to_upper_copy(customName).find(_searchStr) == std::string::npos) continue; }

AddmodelOption_(customName, model);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Solution/source/Submenus/PedSpeech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down Expand Up @@ -433,7 +433,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down
8 changes: 4 additions & 4 deletions Solution/source/Submenus/Spooner/Submenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down Expand Up @@ -400,7 +400,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down Expand Up @@ -2930,7 +2930,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : boost::to_upper_copy(_searchStr), bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", _searchStr);
boost::to_lower(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToLower, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down Expand Up @@ -3064,7 +3064,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : boost::to_upper_copy(_searchStr), bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", _searchStr);
boost::to_lower(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToLower, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down
6 changes: 3 additions & 3 deletions Solution/source/Submenus/Spooner/Submenus_TaskSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ namespace sub::Spooner
bool searchobj = false;
AddOption(_searchStr.empty() ? "SEARCH" : boost::to_upper_copy(_searchStr), searchobj, nullFunc, -1, true); if (searchobj)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", _searchStr);
boost::to_lower(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToLower, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down Expand Up @@ -688,7 +688,7 @@ namespace sub::Spooner

AddOption(_searchStr.empty() ? "SEARCH" : boost::to_upper_copy(_searchStr), searchobj, nullFunc, -1, true); if (searchobj)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", _searchStr);
boost::to_lower(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToLower, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down Expand Up @@ -857,7 +857,7 @@ namespace sub::Spooner
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down
4 changes: 2 additions & 2 deletions Solution/source/Submenus/VehicleSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down Expand Up @@ -2098,7 +2098,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down
4 changes: 2 additions & 2 deletions Solution/source/Submenus/WeaponOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ namespace sub
bool bSearchPressed = false;
AddOption(_searchStr.empty() ? "SEARCH" : _searchStr, bSearchPressed, nullFunc, -1, true); if (bSearchPressed)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", boost::to_lower_copy(_searchStr));
boost::to_upper(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToUpper, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down Expand Up @@ -1731,7 +1731,7 @@ namespace sub

AddOption(_searchStr.empty() ? "SEARCH" : boost::to_upper_copy(_searchStr), searchobj, nullFunc, -1, true); if (searchobj)
{
_searchStr = Game::InputBox(_searchStr, 126U, "", _searchStr);
_searchStr = Game::InputBox(_searchStr, 126U, "SEARCH", _searchStr);
boost::to_lower(_searchStr);
//OnscreenKeyboard::State::Set(OnscreenKeyboard::Purpose::SearchToLower, _searchStr, 126U, std::string(), _searchStr);
//OnscreenKeyboard::State::arg1._ptr = reinterpret_cast<void*>(&_searchStr);
Expand Down

0 comments on commit e9bbf92

Please sign in to comment.