Move stuff
This commit is contained in:
parent
b4232ef4c1
commit
66b2a82ab3
@ -4,6 +4,7 @@
|
|||||||
#include "command.hpp"
|
#include "command.hpp"
|
||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
#include "game_console.hpp"
|
#include "game_console.hpp"
|
||||||
|
#include "fastfiles.hpp"
|
||||||
|
|
||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
#include "game/dvars.hpp"
|
#include "game/dvars.hpp"
|
||||||
@ -277,15 +278,6 @@ namespace command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enum_assets(const game::XAssetType type, const std::function<void(game::XAssetHeader)>& callback, const bool includeOverride)
|
|
||||||
{
|
|
||||||
game::DB_EnumXAssets_Internal(type, static_cast<void(*)(game::XAssetHeader, void*)>([](game::XAssetHeader header, void* data)
|
|
||||||
{
|
|
||||||
const auto& cb = *static_cast<const std::function<void(game::XAssetHeader)>*>(data);
|
|
||||||
cb(header);
|
|
||||||
}), &callback, includeOverride);
|
|
||||||
}
|
|
||||||
|
|
||||||
class component final : public component_interface
|
class component final : public component_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -372,14 +364,14 @@ namespace command
|
|||||||
console::info("Listing assets in pool %s\n", game::g_assetNames[type]);
|
console::info("Listing assets in pool %s\n", game::g_assetNames[type]);
|
||||||
|
|
||||||
const std::string filter = params.get(2);
|
const std::string filter = params.get(2);
|
||||||
enum_assets(type, [type, filter](const game::XAssetHeader header)
|
fastfiles::enum_assets(type, [type, filter](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);
|
||||||
//const auto entry = game::DB_FindXAssetEntry(type, asset_name);
|
//const auto entry = game::DB_FindXAssetEntry(type, asset_name);
|
||||||
//TODO: display which zone the asset is from
|
//TODO: display which zone the asset is from
|
||||||
|
|
||||||
if (!filter.empty() && !game_console::match_compare(filter, asset_name, false))
|
if (!filter.empty() && !utils::string::match_compare(filter, asset_name, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,16 @@ namespace fastfiles
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enum_assets(const game::XAssetType type,
|
||||||
|
const std::function<void(game::XAssetHeader)>& callback, const bool includeOverride)
|
||||||
|
{
|
||||||
|
game::DB_EnumXAssets_Internal(type, static_cast<void(*)(game::XAssetHeader, void*)>([](game::XAssetHeader header, void* data)
|
||||||
|
{
|
||||||
|
const auto& cb = *static_cast<const std::function<void(game::XAssetHeader)>*>(data);
|
||||||
|
cb(header);
|
||||||
|
}), &callback, includeOverride);
|
||||||
|
}
|
||||||
|
|
||||||
class component final : public component_interface
|
class component final : public component_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -5,4 +5,7 @@
|
|||||||
namespace fastfiles
|
namespace fastfiles
|
||||||
{
|
{
|
||||||
std::string get_current_fastfile();
|
std::string get_current_fastfile();
|
||||||
|
|
||||||
|
void enum_assets(const game::XAssetType type,
|
||||||
|
const std::function<void(game::XAssetHeader)>& callback, const bool includeOverride);
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,51 @@ namespace game_console
|
|||||||
game::R_AddCmdDrawText(text, 0x7FFFFFFF, console_font, con.globals.x + offset_x, _y, 1.0f, 1.0f, 0.0f, color, 0);
|
game::R_AddCmdDrawText(text, 0x7FFFFFFF, console_font, con.globals.x + offset_x, _y, 1.0f, 1.0f, 0.0f, color, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void find_matches(std::string input, std::vector<dvars::dvar_info>& suggestions, const bool exact)
|
||||||
|
{
|
||||||
|
input = utils::string::to_lower(input);
|
||||||
|
|
||||||
|
for (const auto& dvar : dvars::dvar_list)
|
||||||
|
{
|
||||||
|
auto name = utils::string::to_lower(dvar.name);
|
||||||
|
if (game::Dvar_FindVar(name.data()) && utils::string::match_compare(input, name, exact))
|
||||||
|
{
|
||||||
|
suggestions.push_back(dvar);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exact && suggestions.size() > 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (suggestions.size() == 0 && game::Dvar_FindVar(input.data()))
|
||||||
|
{
|
||||||
|
suggestions.push_back({input, ""});
|
||||||
|
}
|
||||||
|
|
||||||
|
game::cmd_function_s* cmd = (*game::cmd_functions);
|
||||||
|
while (cmd)
|
||||||
|
{
|
||||||
|
if (cmd->name)
|
||||||
|
{
|
||||||
|
std::string name = utils::string::to_lower(cmd->name);
|
||||||
|
|
||||||
|
if (utils::string::match_compare(input, name, exact))
|
||||||
|
{
|
||||||
|
suggestions.push_back({cmd->name, ""});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exact && suggestions.size() > 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = cmd->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void draw_input()
|
void draw_input()
|
||||||
{
|
{
|
||||||
con.globals.font_height = static_cast<float>(console_font->pixelHeight);
|
con.globals.font_height = static_cast<float>(console_font->pixelHeight);
|
||||||
@ -666,58 +711,6 @@ namespace game_console
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match_compare(const std::string& input, const std::string& text, const bool exact)
|
|
||||||
{
|
|
||||||
if (exact && text == input) return true;
|
|
||||||
if (!exact && text.find(input) != std::string::npos) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void find_matches(std::string input, std::vector<dvars::dvar_info>& suggestions, const bool exact)
|
|
||||||
{
|
|
||||||
input = utils::string::to_lower(input);
|
|
||||||
|
|
||||||
for (const auto& dvar : dvars::dvar_list)
|
|
||||||
{
|
|
||||||
auto name = utils::string::to_lower(dvar.name);
|
|
||||||
if (game::Dvar_FindVar(name.data()) && match_compare(input, name, exact))
|
|
||||||
{
|
|
||||||
suggestions.push_back(dvar);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exact && suggestions.size() > 1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (suggestions.size() == 0 && game::Dvar_FindVar(input.data()))
|
|
||||||
{
|
|
||||||
suggestions.push_back({ input.data(), "" });
|
|
||||||
}
|
|
||||||
|
|
||||||
game::cmd_function_s* cmd = (*game::cmd_functions);
|
|
||||||
while (cmd)
|
|
||||||
{
|
|
||||||
if (cmd->name)
|
|
||||||
{
|
|
||||||
std::string name = utils::string::to_lower(cmd->name);
|
|
||||||
|
|
||||||
if (match_compare(input, name, exact))
|
|
||||||
{
|
|
||||||
suggestions.push_back({ cmd->name, "" });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exact && suggestions.size() > 1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd = cmd->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class component final : public component_interface
|
class component final : public component_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "game/dvars.hpp"
|
|
||||||
|
|
||||||
namespace game_console
|
namespace game_console
|
||||||
{
|
{
|
||||||
bool console_char_event(int local_client_num, int key);
|
bool console_char_event(int local_client_num, int key);
|
||||||
bool console_key_event(int local_client_num, int key, int down);
|
bool console_key_event(int local_client_num, int key, int down);
|
||||||
|
|
||||||
bool match_compare(const std::string& input, const std::string& text, const bool exact);
|
|
||||||
void find_matches(std::string input, std::vector<dvars::dvar_info>& suggestions, const bool exact);
|
|
||||||
}
|
}
|
@ -176,4 +176,11 @@ namespace utils::string
|
|||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool match_compare(const std::string& input, const std::string& text, const bool exact)
|
||||||
|
{
|
||||||
|
if (exact && text == input) return true;
|
||||||
|
if (!exact && text.find(input) != std::string::npos) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,4 +97,6 @@ namespace utils::string
|
|||||||
std::wstring convert(const std::string& str);
|
std::wstring convert(const std::string& str);
|
||||||
|
|
||||||
std::string replace(std::string str, const std::string& from, const std::string& to);
|
std::string replace(std::string str, const std::string& from, const std::string& to);
|
||||||
|
|
||||||
|
bool match_compare(const std::string& input, const std::string& text, const bool exact);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user