diff --git a/src/client/component/gui/asset_list.cpp b/src/client/component/gui/asset_list.cpp index ae53b45d..d69e4fa4 100644 --- a/src/client/component/gui/asset_list.cpp +++ b/src/client/component/gui/asset_list.cpp @@ -24,6 +24,7 @@ namespace gui::asset_list std::string zone_name_filter[game::XAssetType::ASSET_TYPE_COUNT]; std::unordered_map> asset_view_callbacks; + std::unordered_map> asset_name_override_callbacks; bool default_only[game::ASSET_TYPE_COUNT] = {}; int asset_count[game::ASSET_TYPE_COUNT] = {}; @@ -98,9 +99,21 @@ namespace gui::asset_list ImGui::TableSetColumnIndex(col_index++); - if (ImGui::Button(asset_name)) + std::string asset_name_view; + + const auto& name_override_cb = asset_name_override_callbacks.find(type); + if (name_override_cb != asset_name_override_callbacks.end()) + { + asset_name_view = name_override_cb->second.operator()(asset_name); + } + else { - gui::copy_to_clipboard(asset_name); + asset_name_view = asset_name; + } + + if (ImGui::Button(asset_name_view.data())) + { + gui::copy_to_clipboard(asset_name_view); } if (type == game::ASSET_TYPE_LOCALIZE_ENTRY) @@ -265,6 +278,11 @@ namespace gui::asset_list asset_view_callbacks.insert(std::make_pair(type, callback)); } + void add_asset_name_override_callback(game::XAssetType type, const std::function& callback) + { + asset_name_override_callbacks.insert(std::make_pair(type, callback)); + } + class component final : public component_interface { public: diff --git a/src/client/component/gui/asset_list.hpp b/src/client/component/gui/asset_list.hpp index 24b021fa..c2de6bd8 100644 --- a/src/client/component/gui/asset_list.hpp +++ b/src/client/component/gui/asset_list.hpp @@ -6,6 +6,8 @@ namespace gui::asset_list { void add_asset_view_callback(game::XAssetType, const std::function& callback); + void add_asset_name_override_callback(game::XAssetType type, const std::function& callback); + void add_view_button(int id, game::XAssetType type, const char* name); template diff --git a/src/client/component/gui/assets/scriptfile.cpp b/src/client/component/gui/assets/scriptfile.cpp new file mode 100644 index 00000000..5e01fd07 --- /dev/null +++ b/src/client/component/gui/assets/scriptfile.cpp @@ -0,0 +1,48 @@ +#include +#include "loader/component_loader.hpp" + +#include "game/game.hpp" +#include "game/dvars.hpp" + +#include "component/scheduler.hpp" +#include "component/command.hpp" +#include "component/fastfiles.hpp" +#include "component/gsc/script_loading.hpp" +#include "../gui.hpp" +#include "../asset_list.hpp" + +#include "utils/mapents.hpp" + +#include +#include +#include +#include + +namespace gui::asset_list::scriptfile +{ + namespace + { + std::string get_asset_display_name(const std::string& name) + { + const auto id = static_cast(std::atoi(name.data())); + + if (id == 0) + { + return name; + } + + return gsc::gsc_ctx->token_name(id); + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + gui::asset_list::add_asset_name_override_callback(game::ASSET_TYPE_SCRIPTFILE, get_asset_display_name); + } + }; +} + +REGISTER_COMPONENT(gui::asset_list::scriptfile::component)