Add dependencies locally

This commit is contained in:
Ahrimdon
2024-03-07 05:13:50 -05:00
parent e4a5cd056e
commit 9a56906be7
9538 changed files with 3064916 additions and 107 deletions

44
deps/iw4-open-formats/include/api.hpp vendored Normal file
View File

@ -0,0 +1,44 @@
#pragma once
#include "params.hpp"
#include "iw4_native_asset.hpp"
#include <functional>
#include <filesystem>
namespace iw4of
{
class api final
{
public:
bool write(int iw4_int_type, void* header) const
{
return write_internal(iw4_int_type, header);
}
template <typename T>
T* read(int iw4_int_type, const std::string& name) const
{
return reinterpret_cast<T*>(read_internal(iw4_int_type, name));
}
void clear_writes() const;
void set_work_path(const std::filesystem::path& path);
bool is_type_supported(int iw4_type) const;
std::unordered_set<iw4_native_asset, iw4_native_asset::hash> get_children(int type, void* asset) const;
api(const params_t& params);
~api();
private:
class assets* _assets;
bool write_internal(int t, void* asset) const;
void* read_internal(int t, const std::string& name) const;
};
} // namespace iw4of

View File

@ -0,0 +1,20 @@
#pragma once
namespace iw4of
{
struct iw4_native_asset
{
int type;
void* data;
bool operator==(const iw4_native_asset& other) const{
return data == other.data;
};
struct hash {
size_t operator()(const iw4_native_asset& k) const {
return static_cast<size_t>(k.type) ^ reinterpret_cast<size_t>(k.data);
}
};
};
}

View File

@ -0,0 +1,33 @@
#pragma once
#include <functional>
#include <filesystem>
namespace iw4of
{
struct params_t
{
enum print_type
{
P_WARN,
P_ERR
};
std::filesystem::path work_directory{};
std::function<void*(int type, const std::string& name)> find_other_asset{};
std::function<void(int type, void* data)> request_mark_asset{};
std::function<void(print_type level, const std::string& message)> print{};
std::function<std::string(const std::string& filename)> fs_read_file{};
std::function<unsigned int(const std::string& text)> store_in_string_table{};
std::function<std::string(const unsigned int index)> get_from_string_table{};
bool write_only_once = false;
params_t(const std::filesystem::path& work_directory)
{
this->work_directory = work_directory;
}
params_t(){};
};
} // namespace iw4of