More console progress
This commit is contained in:
parent
bc52202b01
commit
5da497b61b
@ -498,9 +498,15 @@ namespace game_console
|
||||
|
||||
void add(const std::string& cmd, bool print_)
|
||||
{
|
||||
print(cmd, print_);
|
||||
execute(cmd.data());
|
||||
|
||||
history.push_front(cmd);
|
||||
game::Cbuf_AddText(0, utils::string::va("%s \n", cmd.data()));
|
||||
if (history.size() > 10)
|
||||
{
|
||||
history.erase(history.begin() + 10);
|
||||
}
|
||||
|
||||
print(cmd, print_);
|
||||
}
|
||||
|
||||
bool console_key_event(const int localClientNum, const int key, const int down)
|
||||
|
@ -113,8 +113,6 @@ namespace gui
|
||||
}
|
||||
});
|
||||
|
||||
ImGui::ShowDemoWindow();
|
||||
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("Windows"))
|
||||
@ -242,6 +240,12 @@ namespace gui
|
||||
});
|
||||
}
|
||||
|
||||
void copy_to_clipboard(const std::string& text)
|
||||
{
|
||||
utils::string::set_clipboard_data(text);
|
||||
gui::notification("Text copied to clipboard", utils::string::va("\"%s\"", text.data()));
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
|
@ -19,4 +19,5 @@ namespace gui
|
||||
void on_frame(const std::function<void()>& callback);
|
||||
bool is_menu_open(const std::string& name);
|
||||
void notification(const std::string& title, const std::string& text, const std::chrono::milliseconds duration = 3s);
|
||||
void copy_to_clipboard(const std::string& text);
|
||||
}
|
@ -43,7 +43,7 @@ namespace asset_list
|
||||
const auto name = game::g_assetNames[i];
|
||||
const auto type = static_cast<game::XAssetType>(i);
|
||||
|
||||
if (strstr(name, filter_buffer.data()))
|
||||
if (utils::string::find_lower(name, filter_buffer))
|
||||
{
|
||||
ImGui::Checkbox(name, &shown_assets[type]);
|
||||
}
|
||||
@ -73,15 +73,14 @@ namespace asset_list
|
||||
const auto asset = game::XAsset{type, header};
|
||||
const auto* const asset_name = game::DB_GetXAssetName(&asset);
|
||||
|
||||
if (!strstr(asset_name, filter))
|
||||
if (!utils::string::find_lower(asset_name, filter))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ImGui::Button(asset_name))
|
||||
{
|
||||
utils::string::set_clipboard_data(asset_name);
|
||||
gui::notification("Text copied to clipboard!", utils::string::va("\"%s\"", asset_name));
|
||||
gui::copy_to_clipboard(asset_name);
|
||||
}
|
||||
}, true);
|
||||
|
||||
|
@ -99,7 +99,7 @@ namespace gui_console
|
||||
const auto history = game_console::get_output();
|
||||
for (const auto& line : history)
|
||||
{
|
||||
if (strstr(line.data(), filter.data()))
|
||||
if (utils::string::find_lower(line, filter))
|
||||
{
|
||||
text.append(line.data());
|
||||
text.append("\n");
|
||||
@ -144,6 +144,7 @@ namespace gui_console
|
||||
if (ImGui::Button("Copy"))
|
||||
{
|
||||
utils::string::set_clipboard_data(filtered_text);
|
||||
gui::notification("Console", "Text copied to clipboard");
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
@ -170,7 +171,20 @@ namespace gui_console
|
||||
|
||||
if (ImGui::InputText("Input", &input, input_text_flags, input_text_edit))
|
||||
{
|
||||
auto history = game_console::get_history();
|
||||
|
||||
if (history_index != -1)
|
||||
{
|
||||
const auto itr = history.begin() + history_index;
|
||||
|
||||
if (*itr == input)
|
||||
{
|
||||
history.erase(history.begin() + history_index);
|
||||
}
|
||||
}
|
||||
|
||||
game_console::add(input.data());
|
||||
|
||||
input.clear();
|
||||
ImGui::SetKeyboardFocusHere(-1);
|
||||
}
|
||||
|
@ -348,7 +348,8 @@ namespace entity_list
|
||||
|
||||
const auto classname = classname_value.as<std::string>();
|
||||
const auto team_ = team_value.as<std::string>();
|
||||
if (strstr(classname.data(), "actor_") && (team == entity_team::team_any || team_ == team_names[team]))
|
||||
if (utils::string::find_lower(classname, "actor_") &&
|
||||
(team == entity_team::team_any || team_ == team_names[team]))
|
||||
{
|
||||
result.push(entity);
|
||||
}
|
||||
@ -457,8 +458,8 @@ namespace entity_list
|
||||
for (const auto& filter : data.filters.fields)
|
||||
{
|
||||
if (field_value.is<std::string>() &&
|
||||
strstr(field.first.data(), utils::string::to_lower(filter.first).data()) &&
|
||||
strstr(value_string.data(), filter.second.data()))
|
||||
utils::string::find_lower(field.first, filter.first) &&
|
||||
utils::string::find_lower(value_string, filter.second))
|
||||
{
|
||||
match_count++;
|
||||
}
|
||||
@ -789,16 +790,14 @@ namespace entity_list
|
||||
|
||||
if (ImGui::Button(field.first.data()))
|
||||
{
|
||||
utils::string::set_clipboard_data(field.first);
|
||||
gui::notification("Text copied to clipboard!", utils::string::va("\"%s\"", field.first.data()));
|
||||
gui::copy_to_clipboard(field.first);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(field.second.data()))
|
||||
{
|
||||
utils::string::set_clipboard_data(field.second);
|
||||
gui::notification("Text copied to clipboard!", utils::string::va("\"%s\"", field.second.data()));
|
||||
gui::copy_to_clipboard(field.second);
|
||||
}
|
||||
}
|
||||
|
||||
@ -815,7 +814,8 @@ namespace entity_list
|
||||
ImGui::InputText("field name", field_filter, IM_ARRAYSIZE(field_filter));
|
||||
for (auto& field : data.selected_fields)
|
||||
{
|
||||
if (strstr(field.first.data(), field_filter) && ImGui::Checkbox(field.first.data(), &field.second))
|
||||
if (utils::string::find_lower(field.first, field_filter) &&
|
||||
ImGui::Checkbox(field.first.data(), &field.second))
|
||||
{
|
||||
data.force_update = true;
|
||||
}
|
||||
|
@ -192,4 +192,9 @@ namespace utils::string
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bool find_lower(const std::string& a, const std::string& b)
|
||||
{
|
||||
return to_lower(a).find(to_lower(b)) != std::string::npos;
|
||||
}
|
||||
}
|
||||
|
@ -98,4 +98,6 @@ namespace utils::string
|
||||
std::wstring convert(const std::string& str);
|
||||
|
||||
std::string replace(std::string str, const std::string& from, const std::string& to);
|
||||
|
||||
bool find_lower(const std::string& a, const std::string& b);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user