Skip to content

Commit

Permalink
feat: util_pad is now imported as module
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverlan committed Oct 12, 2024
1 parent 289a47b commit c95888f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build_scripts/scripts/external_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
get_submodule("util_bsp","https://github.com/Silverlan/util_bsp.git","26ca23e32ebedf1797985567455d125f2e94e2df")
get_submodule("util_formatted_text","https://github.com/Silverlan/util_formatted_text.git","c473a2bdc1ad84ef52d391226d6983ef3076958e")
get_submodule("util_image","https://github.com/Silverlan/util_image.git","bc1af9d7a0e4e4e51550a4730d65e072ae97d592")
get_submodule("util_pad","https://github.com/Silverlan/util_pad.git","1bca1e01058cc4a17a16d79ffe2a4397f9e667e5")
get_submodule("util_pad","https://github.com/Silverlan/util_pad.git","d3e649427bc8109814920e9b38ecf413f0e6075c")
get_submodule("util_pragma_doc","https://github.com/Silverlan/util_pragma_doc.git","88e85503b120f820143f6f4566e194b539297ffa")
get_submodule("util_smdmodel","https://github.com/Silverlan/util_smdmodel.git","10fb2d10eb62188c8b9639a62da646152277a748")
get_submodule("util_sound","https://github.com/Silverlan/util_sound.git","729915ed7eaa7c9669a57c4e0d3dc4bf02a62cea")
Expand Down
8 changes: 4 additions & 4 deletions core/client/src/addonsystem/addon_install_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include "pragma/util/curl_query_handler.hpp"
#include <pragma/addonsystem/addonsystem.h>
#include <sharedutils/util_file.h>
#include <util_pad.hpp>
#include <pragma/entities/entity_component_system_t.hpp>

import pragma.uva;
import pragma.pad;

extern DLLCLIENT CEngine *c_engine;

Expand Down Expand Up @@ -58,13 +58,13 @@ void pragma::AddonInstallManager::QueryFile(const std::shared_ptr<AddonUpdateQue
if(it != addon->fileIds.end()) {
addon->fileIds.erase(it);
if(addon->fileIds.empty() == true && updateFile->ReOpen("rb") == true) {
upad::PADPackage *pad = nullptr;
pragma::pad::PADPackage *pad = nullptr;
uva::ArchiveFile *archFile = nullptr;
std::unique_ptr<uva::ArchiveFile> ptrArchFile = nullptr;
if(addon->addonInfo->GetLocalPath().empty() == true) // New addon
{
std::shared_ptr<upad::PADPackage::Header> header = nullptr;
ptrArchFile = upad::open(addon->addonPath, header);
std::shared_ptr<pragma::pad::PADPackage::Header> header = nullptr;
ptrArchFile = pragma::pad::open(addon->addonPath, header);
archFile = ptrArchFile.get();

auto &uniqueId = addon->addonInfo->GetUniqueId();
Expand Down
5 changes: 3 additions & 2 deletions core/client/src/gui/mainmenu/wimainmenu_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
#include <sharedutils/util_file.h>
#include <sharedutils/util_clock.hpp>
#include <fsys/fsys_package.hpp>
#include <util_pad.hpp>
#include <prosper_window.hpp>

import pragma.pad;

extern DLLCLIENT CEngine *c_engine;
extern ClientState *client;

Expand Down Expand Up @@ -1233,7 +1234,7 @@ void WIMainMenuOptions::InitializeControlSettings()
pList->AddKeyBinding(Locale::GetText("key_toggle_vr_mirror_window"), "toggle cl_vr_mirror_window_enabled");

// Initialize custom control options from addons
auto *upadManager = dynamic_cast<upad::PackageManager *>(FileManager::GetPackageManager("upad"));
auto *upadManager = dynamic_cast<pragma::pad::PackageManager *>(FileManager::GetPackageManager("upad"));
auto &mountedAddons = AddonSystem::GetMountedAddons();
for(auto &info : mountedAddons) {
auto addonPath = info.GetAbsolutePath();
Expand Down
4 changes: 2 additions & 2 deletions core/shared/include/pragma/addonsystem/addonsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DLLNETWORK AddonInfo {
};

class DirectoryWatcherCallback;
namespace upad {
namespace pragma::pad {
class PADPackage;
};
class DLLNETWORK AddonSystem {
Expand All @@ -50,7 +50,7 @@ class DLLNETWORK AddonSystem {
static bool MountAddon(const std::string &addonPath, std::vector<AddonInfo> &outAddons, bool silent = true);
static std::vector<AddonInfo> m_addons;
static std::shared_ptr<DirectoryWatcherCallback> m_addonWatcher;
static upad::PADPackage *LoadPADPackage(const std::string &path);
static pragma::pad::PADPackage *LoadPADPackage(const std::string &path);
};
#pragma warning(pop)

Expand Down
6 changes: 3 additions & 3 deletions core/shared/include/pragma/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct Color;
namespace Con {
enum class MessageFlags : uint8_t;
};
namespace upad {
namespace pragma::pad {
class PackageManager;
};
namespace util {
Expand Down Expand Up @@ -162,7 +162,7 @@ class DLLNETWORK Engine : public CVarHandler, public CallbackHandler {
bool StartProfilingStage(const char *stage);
bool StopProfilingStage();

upad::PackageManager *GetPADPackageManager() const;
pragma::pad::PackageManager *GetPADPackageManager() const;

void SetVerbose(bool bVerbose);
bool IsVerbose() const;
Expand Down Expand Up @@ -345,7 +345,7 @@ class DLLNETWORK Engine : public CVarHandler, public CallbackHandler {
std::queue<std::function<void()>> m_tickEventQueue;
std::mutex m_tickEventQueueMutex;
StateFlags m_stateFlags;
mutable upad::PackageManager *m_padPackageManager = nullptr;
mutable pragma::pad::PackageManager *m_padPackageManager = nullptr;
std::unique_ptr<pragma::debug::ProfilingStageManager<pragma::debug::ProfilingStage>> m_profilingStageManager;

std::unordered_map<std::string, std::function<void(int, char *[])>> m_launchOptions;
Expand Down
6 changes: 3 additions & 3 deletions core/shared/src/addonsystem/addonsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
#include "pragma/addonsystem/addonsystem.h"
#include "pragma/logging.hpp"
#include <fsys/filesystem.h>
#include <util_pad.hpp>
#include <sharedutils/util_file.h>
#include <fsys/directory_watcher.h>
#ifdef _WIN32
#include <sharedutils/util_link.hpp>
#endif

import pragma.uva;
import pragma.pad;

extern DLLNETWORK Engine *engine;

decltype(AddonSystem::m_addons) AddonSystem::m_addons;
decltype(AddonSystem::m_addonWatcher) AddonSystem::m_addonWatcher = nullptr;

upad::PADPackage *AddonSystem::LoadPADPackage(const std::string &path)
pragma::pad::PADPackage *AddonSystem::LoadPADPackage(const std::string &path)
{
auto it = std::find_if(m_addons.begin(), m_addons.end(), [&path](const AddonInfo &addon) { return FileManager::ComparePath(addon.GetLocalPath(), path); });
if(it != m_addons.end())
return nullptr;
auto *package = dynamic_cast<upad::PADPackage *>(FileManager::LoadPackage(path.c_str(), static_cast<fsys::SearchFlags>(FSYS_SEARCH_ADDON)));
auto *package = dynamic_cast<pragma::pad::PADPackage *>(FileManager::LoadPackage(path.c_str(), static_cast<fsys::SearchFlags>(FSYS_SEARCH_ADDON)));
if(package != nullptr)
m_addons.push_back(AddonInfo(path, package->GetPackageVersion(), package->GetPackageId()));
return package;
Expand Down
6 changes: 3 additions & 3 deletions core/shared/src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <sharedutils/util_parallel_job.hpp>
#include <pragma/game/game_resources.hpp>
#include <pragma/util/resource_watcher.h>
#include <util_pad.hpp>
#include <material_manager2.hpp>
#include <pragma/networking/iserver.hpp>
#include <pragma/addonsystem/addonsystem.h>
Expand All @@ -48,6 +47,7 @@
#endif

import util_zip;
import pragma.pad;

const pragma::IServerState &Engine::GetServerStateInterface() const
{
Expand Down Expand Up @@ -131,7 +131,7 @@ Engine::Engine(int, char *[]) : CVarHandler(), m_logFile(nullptr), m_tickRate(En
#endif

// Link package system to file system
m_padPackageManager = upad::link_to_file_system();
m_padPackageManager = pragma::pad::link_to_file_system();
m_assetManager = std::make_unique<pragma::asset::AssetManager>();

RegisterCallback<void>("Think");
Expand Down Expand Up @@ -215,7 +215,7 @@ void Engine::SetProfilingEnabled(bool bEnabled)
}
}

upad::PackageManager *Engine::GetPADPackageManager() const { return m_padPackageManager; }
pragma::pad::PackageManager *Engine::GetPADPackageManager() const { return m_padPackageManager; }

void Engine::LockResourceWatchers()
{
Expand Down

0 comments on commit c95888f

Please sign in to comment.