Small fix
This commit is contained in:
parent
b3943b7a77
commit
1057a5cffc
@ -38,7 +38,7 @@ namespace asset_list
|
|||||||
const auto name = game::g_assetNames[i];
|
const auto name = game::g_assetNames[i];
|
||||||
const auto type = static_cast<game::XAssetType>(i);
|
const auto type = static_cast<game::XAssetType>(i);
|
||||||
|
|
||||||
if (utils::string::find_lower(name, asset_type_filter))
|
if (utils::string::strstr_lower(name, asset_type_filter.data()))
|
||||||
{
|
{
|
||||||
ImGui::Checkbox(name, &shown_assets[type]);
|
ImGui::Checkbox(name, &shown_assets[type]);
|
||||||
}
|
}
|
||||||
@ -63,14 +63,12 @@ namespace asset_list
|
|||||||
ImGui::InputText("asset name", &assets_name_filter[type]);
|
ImGui::InputText("asset name", &assets_name_filter[type]);
|
||||||
ImGui::BeginChild("assets list");
|
ImGui::BeginChild("assets list");
|
||||||
|
|
||||||
const auto lowercase_filter = utils::string::to_lower(assets_name_filter[type]);
|
fastfiles::enum_assets(type, [type](const game::XAssetHeader header)
|
||||||
|
|
||||||
fastfiles::enum_assets(type, [&lowercase_filter, type](const game::XAssetHeader header)
|
|
||||||
{
|
{
|
||||||
const auto asset = game::XAsset{type, header};
|
const auto asset = game::XAsset{type, header};
|
||||||
const auto* const asset_name = game::DB_GetXAssetName(&asset);
|
const auto* const asset_name = game::DB_GetXAssetName(&asset);
|
||||||
|
|
||||||
if (strstr(asset_name, lowercase_filter.data()) && ImGui::Button(asset_name))
|
if (utils::string::strstr_lower(asset_name, assets_name_filter[type].data()) && ImGui::Button(asset_name))
|
||||||
{
|
{
|
||||||
gui::copy_to_clipboard(asset_name);
|
gui::copy_to_clipboard(asset_name);
|
||||||
}
|
}
|
||||||
|
@ -204,4 +204,24 @@ namespace utils::string
|
|||||||
? text
|
? text
|
||||||
: text.substr(0, length - end.size()) + end;
|
: text.substr(0, length - end.size()) + end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool strstr_lower(const char* a, const char* b)
|
||||||
|
{
|
||||||
|
size_t index{};
|
||||||
|
while (*a != '\0' && b[index] != '\0')
|
||||||
|
{
|
||||||
|
if (std::tolower(*a) == std::tolower(b[index]))
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
else if (index != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
a++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return b[index] == '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,4 +102,6 @@ namespace utils::string
|
|||||||
bool find_lower(const std::string& a, const std::string& b);
|
bool find_lower(const std::string& a, const std::string& b);
|
||||||
|
|
||||||
std::string truncate(const std::string& text, const size_t length, const std::string& end);
|
std::string truncate(const std::string& text, const size_t length, const std::string& end);
|
||||||
|
|
||||||
|
bool strstr_lower(const char* a, const char* b);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user