
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>
78 lines
1.8 KiB
C++
78 lines
1.8 KiB
C++
#pragma once
|
|
|
|
namespace big::string::operations
|
|
{
|
|
inline std::string to_lower(std::string& str)
|
|
{
|
|
std::string result = str;
|
|
std::transform(result.begin(), result.end(), result.begin(), ::tolower);
|
|
str = result;
|
|
return result;
|
|
}
|
|
|
|
inline std::string to_upper(std::string& str)
|
|
{
|
|
std::string result = str;
|
|
std::transform(result.begin(), result.end(), result.begin(), ::toupper);
|
|
str = result;
|
|
return result;
|
|
}
|
|
|
|
inline std::string trim(std::string& str)
|
|
{
|
|
std::string result = str;
|
|
result.erase(result.begin(), std::find_if(result.begin(), result.end(), [](unsigned char ch) {
|
|
return !std::isspace(ch);
|
|
}));
|
|
result.erase(std::find_if(result.rbegin(),
|
|
result.rend(),
|
|
[](unsigned char ch) {
|
|
return !std::isspace(ch);
|
|
})
|
|
.base(),
|
|
result.end());
|
|
str = result;
|
|
return result;
|
|
}
|
|
|
|
inline std::string remove_whitespace(std::string& str)
|
|
{
|
|
std::string result = str;
|
|
result.erase(std::remove_if(result.begin(), result.end(), isspace), result.end());
|
|
str = result;
|
|
return result;
|
|
}
|
|
|
|
static std::vector<std::string> split(const std::string text, char delimiter)
|
|
{
|
|
std::vector<std::string> tokens;
|
|
std::size_t start = 0, end = 0;
|
|
while ((end = text.find(delimiter, start)) != std::string::npos)
|
|
{
|
|
if (end != start)
|
|
{
|
|
tokens.push_back(text.substr(start, end - start));
|
|
}
|
|
start = end + 1;
|
|
}
|
|
if (end != start)
|
|
{
|
|
tokens.push_back(text.substr(start));
|
|
}
|
|
return tokens;
|
|
}
|
|
|
|
static std::string join(const std::vector<std::string>& tokens, char delimiter)
|
|
{
|
|
std::string result;
|
|
for (size_t i = 0; i < tokens.size(); i++)
|
|
{
|
|
result += tokens[i];
|
|
if (i != tokens.size() - 1)
|
|
{
|
|
result += delimiter;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
} |