mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-05-09 22:14:56 +00:00
Move IW4 MaterialDumper code to IW4 MaterialDecompiler
This commit is contained in:
parent
d48e0519ac
commit
2088118b4a
@ -52,6 +52,7 @@ function ObjLoading:project()
|
|||||||
self:include(includes)
|
self:include(includes)
|
||||||
Crypto:include(includes)
|
Crypto:include(includes)
|
||||||
Utils:include(includes)
|
Utils:include(includes)
|
||||||
|
json:include(includes)
|
||||||
minilzo:include(includes)
|
minilzo:include(includes)
|
||||||
minizip:include(includes)
|
minizip:include(includes)
|
||||||
zlib:include(includes)
|
zlib:include(includes)
|
||||||
|
42
src/ObjLoading/Decompiling/DecompilingContext.h
Normal file
42
src/ObjLoading/Decompiling/DecompilingContext.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <ostream>
|
||||||
|
#include <memory>
|
||||||
|
#include <typeindex>
|
||||||
|
|
||||||
|
#include "IZoneDecompilingState.h"
|
||||||
|
#include "Utils/ClassUtils.h"
|
||||||
|
#include "Obj/Gdt/GdtStream.h"
|
||||||
|
#include "Zone/Zone.h"
|
||||||
|
|
||||||
|
class DecompilingContext
|
||||||
|
{
|
||||||
|
std::unordered_map<std::type_index, std::unique_ptr<IZoneDecompilingState>> m_zone_decompiling_states;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Zone* m_zone;
|
||||||
|
std::string m_base_path;
|
||||||
|
std::unique_ptr<GdtOutputStream> m_gdt;
|
||||||
|
|
||||||
|
DecompilingContext();
|
||||||
|
|
||||||
|
_NODISCARD std::unique_ptr<std::ostream> OpenAssetFile(const std::string& fileName) const;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T* GetZoneDecompilingState()
|
||||||
|
{
|
||||||
|
static_assert(std::is_base_of_v<IZoneDecompilingState, T>, "T must inherit IZoneDecompilingState");
|
||||||
|
// T must also have a public default constructor
|
||||||
|
|
||||||
|
const auto foundEntry = m_zone_decompiling_states.find(typeid(T));
|
||||||
|
if (foundEntry != m_zone_decompiling_states.end())
|
||||||
|
return dynamic_cast<T*>(foundEntry->second.get());
|
||||||
|
|
||||||
|
auto newState = std::make_unique<T>();
|
||||||
|
newState->SetZone(m_zone);
|
||||||
|
auto* newStatePtr = newState.get();
|
||||||
|
m_zone_decompiling_states.emplace(std::make_pair<std::type_index, std::unique_ptr<IZoneDecompilingState>>(typeid(T), std::move(newState)));
|
||||||
|
return newStatePtr;
|
||||||
|
}
|
||||||
|
};
|
20
src/ObjLoading/Decompiling/IZoneDecompilingState.h
Normal file
20
src/ObjLoading/Decompiling/IZoneDecompilingState.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Zone/Zone.h"
|
||||||
|
|
||||||
|
class IZoneDecompilingState
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
IZoneDecompilingState() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~IZoneDecompilingState() = default;
|
||||||
|
IZoneDecompilingState(const IZoneDecompilingState& other) = default;
|
||||||
|
IZoneDecompilingState(IZoneDecompilingState&& other) noexcept = default;
|
||||||
|
IZoneDecompilingState& operator=(const IZoneDecompilingState& other) = default;
|
||||||
|
IZoneDecompilingState& operator=(IZoneDecompilingState&& other) noexcept = default;
|
||||||
|
|
||||||
|
virtual void SetZone(Zone* zone)
|
||||||
|
{
|
||||||
|
// Do nothing by default
|
||||||
|
}
|
||||||
|
};
|
1498
src/ObjLoading/Game/IW4/Decompilers/DecompilerMaterial.cpp
Normal file
1498
src/ObjLoading/Game/IW4/Decompilers/DecompilerMaterial.cpp
Normal file
File diff suppressed because it is too large
Load Diff
13
src/ObjLoading/Game/IW4/Decompilers/DecompilerMaterial.h
Normal file
13
src/ObjLoading/Game/IW4/Decompilers/DecompilerMaterial.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Decompiling/DecompilingContext.h"
|
||||||
|
#include "Game/IW4/IW4.h"
|
||||||
|
|
||||||
|
namespace IW4
|
||||||
|
{
|
||||||
|
class DecompilerMaterial
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void DumpAsset(DecompilingContext& context, XAssetInfo<Material>* asset);
|
||||||
|
};
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user