mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-09-22 22:07:08 +00:00
feat: xmodel preview in ModMan (#835)
* chore: upgrade webwindowed for dynamic assets * chore: make enums in ModMan lowercase * chore: add missing platform wiiu in ModMan * fix: register asset handler on all windows * chore: properly localize game and platform * chore: render example cube as xmodel preview * chore: allow origin * in debug * feat: show preview of xmodels with ModMan * feat: show images in xmodel preview * feat: auto load search paths in ModMan * chore: load objcontainer of loaded zones in ModMan * chore: add iw4x specific recognized zone dirs * chore: show when models are loading * fix: make sure webwindowed handles window and app destruction in correct order * chore: track and properly free threejs resources * chore: add skybox for 3d preview * chore: add small border radius to preview * fix: linting * fix: linux compilation * chore: update package lock
This commit is contained in:
@@ -1,19 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "SearchPath/SearchPaths.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include <expected>
|
||||
#include <memory>
|
||||
#include <shared_mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class ContextSearchPath
|
||||
{
|
||||
public:
|
||||
explicit ContextSearchPath(std::unique_ptr<ISearchPath> searchPath);
|
||||
|
||||
std::unique_ptr<ISearchPath> m_search_path;
|
||||
unsigned m_ref_count;
|
||||
};
|
||||
|
||||
class LoadedZone
|
||||
{
|
||||
public:
|
||||
LoadedZone(std::unique_ptr<Zone> zone, std::string filePath, std::vector<std::string> searchPaths);
|
||||
|
||||
[[nodiscard]] Zone& GetZone();
|
||||
[[nodiscard]] const Zone& GetZone() const;
|
||||
|
||||
[[nodiscard]] const std::string& GetFilePath() const;
|
||||
[[nodiscard]] const std::vector<std::string>& GetSearchPaths() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Zone> m_zone;
|
||||
std::string m_file_path;
|
||||
std::vector<std::string> m_search_paths;
|
||||
};
|
||||
|
||||
LoadedZone(std::unique_ptr<Zone> zone, std::string filePath);
|
||||
template<class T> class ReadAccess
|
||||
{
|
||||
public:
|
||||
ReadAccess(std::shared_lock<std::shared_mutex> lock, T& data)
|
||||
: m_read_lock(std::move(lock)),
|
||||
m_data(data)
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] T& Data() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_lock<std::shared_mutex> m_read_lock;
|
||||
T& m_data;
|
||||
};
|
||||
|
||||
class FastFileContext
|
||||
@@ -24,6 +63,14 @@ public:
|
||||
std::expected<LoadedZone*, std::string> LoadFastFile(const std::string& path);
|
||||
std::expected<void, std::string> UnloadZone(const std::string& zoneName);
|
||||
|
||||
ReadAccess<const std::vector<std::unique_ptr<LoadedZone>>> GetLoadedZones();
|
||||
ReadAccess<ISearchPath> GetSearchPaths();
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<LoadedZone>> m_loaded_zones;
|
||||
std::shared_mutex m_zone_lock;
|
||||
|
||||
SearchPaths m_search_paths;
|
||||
std::unordered_map<std::string, std::unique_ptr<ContextSearchPath>> m_context_search_paths;
|
||||
std::shared_mutex m_search_path_lock;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user