mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
blocks and items 'caption' property
This commit is contained in:
parent
c9da6b9a0c
commit
5c3b61265a
10 changed files with 44 additions and 1 deletions
|
|
@ -335,6 +335,26 @@ std::wstring util::pascal_case(const std::wstring& str) {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string util::id_to_caption(const std::string& id) {
|
||||
std::string result = id;
|
||||
|
||||
size_t index = result.find(':');
|
||||
if (index < result.length()-1) {
|
||||
result = result.substr(index+1);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
size_t offset = 0;
|
||||
for (; offset < result.length() && result[offset] == '_'; offset++) {}
|
||||
|
||||
for (; offset < result.length(); offset++) {
|
||||
if (result[offset] == '_') {
|
||||
result[offset] = ' ';
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// @brief Split string by delimiter
|
||||
/// @param str source string
|
||||
/// @param delimiter split delimiter size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue