Game console fixes
This commit is contained in:
parent
7823fa9a93
commit
c69f59fa5b
@ -239,7 +239,15 @@ namespace game_console
|
||||
else if (matches.size() == 1)
|
||||
{
|
||||
auto* const dvar = game::Dvar_FindVar(matches[0].name.data());
|
||||
const auto line_count = dvar ? 3 : 1;
|
||||
auto line_count = dvar ? 3 : 1;
|
||||
|
||||
for (const auto& c : matches[0].description)
|
||||
{
|
||||
if (c == '\n')
|
||||
{
|
||||
++line_count;
|
||||
}
|
||||
}
|
||||
|
||||
const auto height = draw_hint_box(line_count, dvars::con_inputHintBoxColor->current.vector);
|
||||
draw_hint_text(0, matches[0].name.data(), dvar
|
||||
@ -290,11 +298,12 @@ namespace game_console
|
||||
{
|
||||
const auto value = game::Dvar_ValueToString(dvar, nullptr, &dvar->current);
|
||||
const auto truncated = utils::string::truncate(value, 34, "...");
|
||||
const auto truncated_desc = utils::string::truncate(matches[i].description, 160, "...");
|
||||
|
||||
draw_hint_text(static_cast<int>(i), truncated.data(),
|
||||
dvars::con_inputDvarValueColor->current.vector, offset);
|
||||
|
||||
draw_hint_text(static_cast<int>(i), matches[i].description.data(),
|
||||
draw_hint_text(static_cast<int>(i), truncated_desc.data(),
|
||||
dvars::con_inputDvarValueColor->current.vector, offset * 1.5f);
|
||||
}
|
||||
}
|
||||
|
@ -216,9 +216,29 @@ namespace utils::string
|
||||
|
||||
std::string truncate(const std::string& text, const size_t length, const std::string& end)
|
||||
{
|
||||
return text.size() <= length
|
||||
? text
|
||||
: text.substr(0, length - end.size()) + end;
|
||||
const auto new_line = text.find_first_of('\n');
|
||||
if (text.size() <= length)
|
||||
{
|
||||
if (new_line == std::string::npos)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
else
|
||||
{
|
||||
return text.substr(0, new_line + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (new_line == std::string::npos)
|
||||
{
|
||||
return text.substr(0, length - end.size()) + end;
|
||||
}
|
||||
else
|
||||
{
|
||||
return text.substr(0, std::min(new_line + 1, length) - end.size()) + end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool strstr_lower(const char* a, const char* b)
|
||||
|
Loading…
Reference in New Issue
Block a user