2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-10-16 11:39:04 +00:00

Merge pull request #541 from Laupetin/feature/modman-progressbar

feat: modman progressbar
This commit is contained in:
Jan
2025-10-15 23:55:12 +02:00
committed by GitHub
186 changed files with 1891 additions and 1215 deletions

View File

@@ -2,10 +2,11 @@
#include "GameLanguage.h"
#include <cstdint>
#include <type_traits>
#include <vector>
enum class GameId
enum class GameId : std::uint8_t
{
IW3,
IW4,
@@ -18,7 +19,7 @@ enum class GameId
// The full uppercase names are macros in the standard lib
// So unfortunately not usable as values in the enum
enum class GameEndianness
enum class GameEndianness : std::uint8_t
{
/* Little endian */
LE,
@@ -26,12 +27,19 @@ enum class GameEndianness
BE
};
enum class GameWordSize
enum class GameWordSize : std::uint8_t
{
ARCH_32,
ARCH_64
};
enum class GamePlatform : std::uint8_t
{
PC,
XBOX,
PS3
};
static constexpr const char* GameId_Names[]{
"IW3",
"IW4",

View File

@@ -0,0 +1,12 @@
#pragma once
#include <cstdlib>
class ProgressCallback
{
public:
ProgressCallback() = default;
virtual ~ProgressCallback() = default;
virtual void OnProgress(size_t current, size_t total) = 0;
};

View File

@@ -364,7 +364,7 @@ class LinkerImpl final : public Linker
zoneDirectory = fs::current_path();
auto absoluteZoneDirectory = absolute(zoneDirectory).string();
auto maybeZone = ZoneLoading::LoadZone(zonePath);
auto maybeZone = ZoneLoading::LoadZone(zonePath, std::nullopt);
if (!maybeZone)
{
con::error("Failed to load zone \"{}\": {}", zonePath, maybeZone.error());

View File

@@ -4,6 +4,40 @@
#include "Web/UiCommunication.h"
#include "ZoneLoading.h"
#include <filesystem>
namespace fs = std::filesystem;
namespace
{
constexpr double MIN_PROGRESS_TO_REPORT = 0.005;
class LoadingEventProgressReporter : public ProgressCallback
{
public:
explicit LoadingEventProgressReporter(std::string zoneName)
: m_zone_name(std::move(zoneName)),
m_last_progress(0)
{
}
void OnProgress(const size_t current, const size_t total) override
{
const double percentage = static_cast<double>(current) / static_cast<double>(total);
if (percentage - m_last_progress >= MIN_PROGRESS_TO_REPORT)
{
m_last_progress = percentage;
ui::NotifyZoneLoadProgress(m_zone_name, percentage);
}
}
private:
std::string m_zone_name;
double m_last_progress;
};
} // namespace
void FastFileContext::Destroy()
{
// Unload all zones
@@ -12,7 +46,7 @@ void FastFileContext::Destroy()
result::Expected<Zone*, std::string> FastFileContext::LoadFastFile(const std::string& path)
{
auto zone = ZoneLoading::LoadZone(path);
auto zone = ZoneLoading::LoadZone(path, std::make_unique<LoadingEventProgressReporter>(fs::path(path).filename().replace_extension().string()));
if (!zone)
return result::Unexpected(std::move(zone.error()));

View File

@@ -14,22 +14,41 @@ namespace fs = std::filesystem;
namespace
{
class ZoneLoadedDto
class ZoneUnlinkProgressDto
{
public:
std::string zoneName;
std::string filePath;
double percentage;
};
NLOHMANN_DEFINE_TYPE_EXTENSION(ZoneLoadedDto, zoneName, filePath);
NLOHMANN_DEFINE_TYPE_EXTENSION(ZoneUnlinkProgressDto, zoneName, percentage);
class ZoneUnloadedDto
constexpr double MIN_PROGRESS_TO_REPORT = 0.005;
class UnlinkingEventProgressReporter : public ProgressCallback
{
public:
std::string zoneName;
};
explicit UnlinkingEventProgressReporter(std::string zoneName)
: m_zone_name(std::move(zoneName)),
m_last_progress(0)
{
}
NLOHMANN_DEFINE_TYPE_EXTENSION(ZoneUnloadedDto, zoneName);
void OnProgress(const size_t current, const size_t total) override
{
const double percentage = static_cast<double>(current) / static_cast<double>(total);
if (percentage - m_last_progress >= MIN_PROGRESS_TO_REPORT)
{
m_last_progress = percentage;
ui::NotifyZoneUnlinkProgress(m_zone_name, percentage);
}
}
private:
std::string m_zone_name;
double m_last_progress;
};
result::Expected<NoResult, std::string> UnlinkZoneInDbThread(const std::string& zoneName)
{
@@ -52,7 +71,8 @@ namespace
OutputPathFilesystem outputFolderOutputPath(outputFolderPath);
SearchPaths searchPaths;
AssetDumpingContext dumpingContext(zone, outputFolderPathStr, outputFolderOutputPath, searchPaths);
AssetDumpingContext dumpingContext(
zone, outputFolderPathStr, outputFolderOutputPath, searchPaths, std::make_unique<UnlinkingEventProgressReporter>(zoneName));
objWriter->DumpZone(dumpingContext);
return NoResult();
@@ -81,6 +101,15 @@ namespace
namespace ui
{
void NotifyZoneUnlinkProgress(std::string zoneName, const double percentage)
{
const ZoneUnlinkProgressDto dto{
.zoneName = std::move(zoneName),
.percentage = percentage,
};
Notify(*ModManContext::Get().m_main_webview, "zoneUnlinkProgress", dto);
}
void RegisterUnlinkingBinds(webview::webview& wv)
{
BindAsync<std::string>(wv,

View File

@@ -4,5 +4,7 @@
namespace ui
{
void NotifyZoneUnlinkProgress(std::string zoneName, double percentage);
void RegisterUnlinkingBinds(webview::webview& wv);
} // namespace ui

View File

@@ -7,6 +7,15 @@
namespace
{
class ZoneLoadProgressDto
{
public:
std::string zoneName;
double percentage;
};
NLOHMANN_DEFINE_TYPE_EXTENSION(ZoneLoadProgressDto, zoneName, percentage);
class ZoneLoadedDto
{
public:
@@ -71,6 +80,15 @@ namespace
namespace ui
{
void NotifyZoneLoadProgress(std::string zoneName, const double percentage)
{
const ZoneLoadProgressDto dto{
.zoneName = std::move(zoneName),
.percentage = percentage,
};
Notify(*ModManContext::Get().m_main_webview, "zoneLoadProgress", dto);
}
void NotifyZoneLoaded(std::string zoneName, std::string fastFilePath)
{
const ZoneLoadedDto dto{

View File

@@ -4,6 +4,7 @@
namespace ui
{
void NotifyZoneLoadProgress(std::string zoneName, double percentage);
void NotifyZoneLoaded(std::string zoneName, std::string fastFilePath);
void NotifyZoneUnloaded(std::string zoneName);

View File

@@ -1,14 +1,16 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { webviewBinds } from "@/native";
import { webviewAddEventListener, webviewBinds } from "@/native";
import { useZoneStore } from "@/stores/ZoneStore";
import SpinningLoader from "@/components/SpinningLoader.vue";
const zoneStore = useZoneStore();
const loadingFastFile = ref(false);
const unlinkingFastFile = ref(false);
const lastPercentage = ref<number>(0);
const performingAction = computed<boolean>(() => loadingFastFile.value || unlinkingFastFile.value);
const progressBarWidth = computed<string>(() => `${lastPercentage.value * 100}%`);
async function openFastFileSelect() {
return await webviewBinds.openFileDialog({ filters: [{ name: "Fastfiles", filter: "*.ff" }] });
@@ -21,6 +23,7 @@ async function onOpenFastFileClick() {
if (!fastFilePath) return;
loadingFastFile.value = true;
lastPercentage.value = 0;
webviewBinds
.loadFastFile(fastFilePath)
@@ -29,6 +32,7 @@ async function onOpenFastFileClick() {
})
.finally(() => {
loadingFastFile.value = false;
lastPercentage.value = 1;
});
}
@@ -43,6 +47,7 @@ async function onUnlinkFastFileClick() {
let loadedZoneName: string;
try {
lastPercentage.value = 0;
loadedZoneName = (await webviewBinds.loadFastFile(fastFilePath)).zoneName;
} catch (e: unknown) {
console.error("Failed to load fastfile:", e as string);
@@ -50,6 +55,7 @@ async function onUnlinkFastFileClick() {
}
try {
lastPercentage.value = 0;
await webviewBinds.unlinkZone(loadedZoneName);
} catch (e: unknown) {
console.error("Failed to unlink fastfile:", e as string);
@@ -59,6 +65,7 @@ async function onUnlinkFastFileClick() {
}
} finally {
unlinkingFastFile.value = false;
lastPercentage.value = 1;
}
}
@@ -67,6 +74,14 @@ function onUnloadClicked(zoneName: string) {
console.error("Failed to unload zone:", e);
});
}
webviewAddEventListener("zoneLoadProgress", (dto) => {
lastPercentage.value = dto.percentage;
});
webviewAddEventListener("zoneUnlinkProgress", (dto) => {
lastPercentage.value = dto.percentage;
});
</script>
<template>
@@ -94,10 +109,18 @@ function onUnloadClicked(zoneName: string) {
</div>
</div>
</div>
<div class="progressbar-wrapper">
<div
class="progressbar"
:class="{ visible: performingAction }"
:style="{ width: progressBarWidth }"
></div>
</div>
</main>
</template>
<style scoped>
<style scoped lang="scss">
.actions {
display: flex;
justify-content: center;
@@ -117,4 +140,24 @@ function onUnloadClicked(zoneName: string) {
.zone > button {
margin-left: 0.5em;
}
.progressbar-wrapper {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 0.35rem 0.4rem;
}
.progressbar {
opacity: 0;
height: 0.4rem;
border-radius: 2.5rem;
background-color: #b9772c;
transition: opacity 0.2s ease-in-out;
&.visible {
opacity: 1;
}
}
</style>

View File

@@ -14,13 +14,24 @@
-webkit-text-size-adjust: 100%;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.container {
margin: 0;
padding-top: 10vh;
display: flex;
position: relative;
flex-direction: column;
justify-content: center;
justify-content: start;
text-align: center;
height: 100vh;
}
.logo {

View File

@@ -1,3 +1,12 @@
export interface ZoneUnlinkProgressDto {
zoneName: string;
percentage: number;
}
export interface UnlinkingBinds {
unlinkZone(zoneName: string): Promise<void>;
}
export interface UnlinkingEventMap {
zoneUnlinkProgress: ZoneUnlinkProgressDto;
}

View File

@@ -1,3 +1,8 @@
export interface ZoneLoadProgressDto {
zoneName: string;
percentage: number;
}
export interface ZoneLoadedDto {
zoneName: string;
filePath: string;
@@ -13,6 +18,7 @@ export interface ZoneBinds {
}
export interface ZoneEventMap {
zoneLoadProgress: ZoneLoadProgressDto;
zoneLoaded: ZoneLoadedDto;
zoneUnloaded: ZoneUnloadedDto;
}

View File

@@ -1,10 +1,10 @@
import type { DialogBinds } from "./DialogBinds";
import type { UnlinkingBinds } from "./UnlinkingBinds";
import type { UnlinkingBinds, UnlinkingEventMap } from "./UnlinkingBinds";
import type { ZoneBinds, ZoneEventMap } from "./ZoneBinds";
export type NativeMethods = DialogBinds & UnlinkingBinds & ZoneBinds;
type NativeEventMap = ZoneEventMap;
type NativeEventMap = UnlinkingEventMap & ZoneEventMap;
type WebViewExtensions = {
webviewBinds: NativeMethods;

View File

@@ -25,7 +25,8 @@ public:
[[nodiscard]] virtual std::optional<asset_type_t> GetHandlingAssetType() const = 0;
virtual AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) = 0;
virtual void FinalizeZone(AssetCreationContext& context) {};
virtual void FinalizeZone(AssetCreationContext& context) {}
};
template<typename AssetType> class AssetCreator : public IAssetCreator

View File

@@ -1,28 +1,69 @@
#pragma once
#include "Game/IAsset.h"
#include "IAssetDumper.h"
#include "Pool/AssetPool.h"
template<class T> class AbstractAssetDumper : public IAssetDumper<T>
template<class AssetType> class AbstractAssetDumper : public IAssetDumper
{
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
public:
using AssetType_t = AssetType;
[[nodiscard]] size_t GetProgressTotalCount() const override
{
return m_pool.m_asset_lookup.size();
}
void Dump(AssetDumpingContext& context) override
{
for (const auto* assetInfo : m_pool)
{
if (assetInfo->m_name[0] == ',' || !ShouldDump(*assetInfo))
{
context.IncrementProgress();
continue;
}
DumpAsset(context, *assetInfo);
context.IncrementProgress();
}
}
protected:
virtual bool ShouldDump(XAssetInfo<T>* asset)
explicit AbstractAssetDumper(const AssetPool<typename AssetType::Type>& pool)
: m_pool(pool)
{
}
virtual bool ShouldDump(const XAssetInfo<typename AssetType::Type>& asset)
{
return true;
}
virtual void DumpAsset(AssetDumpingContext& context, XAssetInfo<T>* asset) = 0;
virtual void DumpAsset(AssetDumpingContext& context, const XAssetInfo<typename AssetType::Type>& asset) = 0;
const AssetPool<typename AssetType::Type>& m_pool;
};
template<class AssetType> class AbstractSingleProgressAssetDumper : public IAssetDumper
{
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
public:
void DumpPool(AssetDumpingContext& context, AssetPool<T>* pool) override
{
for (auto assetInfo : *pool)
{
if (assetInfo->m_name[0] == ',' || !ShouldDump(assetInfo))
{
continue;
}
using AssetType_t = AssetType;
DumpAsset(context, assetInfo);
}
[[nodiscard]] size_t GetProgressTotalCount() const override
{
return m_pool.m_asset_lookup.empty() ? 0uz : 1uz;
}
protected:
explicit AbstractSingleProgressAssetDumper(const AssetPool<typename AssetType::Type>& pool)
: m_pool(pool)
{
}
const AssetPool<typename AssetType::Type>& m_pool;
};

View File

@@ -1,18 +1,43 @@
#include "AssetDumpingContext.h"
#include <filesystem>
#include <format>
#include <fstream>
AssetDumpingContext::AssetDumpingContext(const Zone& zone, const std::string& basePath, IOutputPath& outputPath, ISearchPath& objSearchPath)
AssetDumpingContext::AssetDumpingContext(const Zone& zone,
const std::string& basePath,
IOutputPath& outputPath,
ISearchPath& objSearchPath,
std::optional<std::unique_ptr<ProgressCallback>> progressCallback)
: m_zone(zone),
m_base_path(basePath),
m_output_path(outputPath),
m_obj_search_path(objSearchPath)
m_obj_search_path(objSearchPath),
m_current_progress(0uz),
m_total_progress(0uz)
{
if (progressCallback)
m_progress_callback = *std::move(progressCallback);
}
std::unique_ptr<std::ostream> AssetDumpingContext::OpenAssetFile(const std::string& fileName) const
{
return m_output_path.Open(fileName);
}
void AssetDumpingContext::IncrementProgress()
{
if (m_progress_callback)
{
m_current_progress++;
m_progress_callback->OnProgress(m_current_progress, m_total_progress);
}
}
void AssetDumpingContext::SetTotalProgress(const size_t value)
{
m_total_progress = value;
}
bool AssetDumpingContext::ShouldTrackProgress() const
{
return static_cast<bool>(m_progress_callback);
}

View File

@@ -4,6 +4,7 @@
#include "Obj/Gdt/GdtStream.h"
#include "SearchPath/IOutputPath.h"
#include "SearchPath/ISearchPath.h"
#include "Utils/ProgressCallback.h"
#include "Zone/Zone.h"
#include <memory>
@@ -14,10 +15,18 @@
class AssetDumpingContext
{
public:
AssetDumpingContext(const Zone& zone, const std::string& basePath, IOutputPath& outputPath, ISearchPath& objSearchPath);
AssetDumpingContext(const Zone& zone,
const std::string& basePath,
IOutputPath& outputPath,
ISearchPath& objSearchPath,
std::optional<std::unique_ptr<ProgressCallback>> progressCallback);
[[nodiscard]] std::unique_ptr<std::ostream> OpenAssetFile(const std::string& fileName) const;
void IncrementProgress();
void SetTotalProgress(size_t value);
[[nodiscard]] bool ShouldTrackProgress() const;
template<typename T> T* GetZoneAssetDumperState()
{
static_assert(std::is_base_of_v<IZoneAssetDumperState, T>, "T must inherit IZoneAssetDumperState");
@@ -42,4 +51,7 @@ public:
private:
std::unordered_map<std::type_index, std::unique_ptr<IZoneAssetDumperState>> m_zone_asset_dumper_states;
std::unique_ptr<ProgressCallback> m_progress_callback;
size_t m_current_progress;
size_t m_total_progress;
};

View File

@@ -1,9 +1,8 @@
#pragma once
#include "AssetDumpingContext.h"
#include "Pool/AssetPool.h"
template<class T> class IAssetDumper
class IAssetDumper
{
public:
IAssetDumper() = default;
@@ -13,5 +12,6 @@ public:
IAssetDumper& operator=(const IAssetDumper& other) = default;
IAssetDumper& operator=(IAssetDumper&& other) noexcept = default;
virtual void DumpPool(AssetDumpingContext& context, AssetPool<T>* pool) = 0;
[[nodiscard]] virtual size_t GetProgressTotalCount() const = 0;
virtual void Dump(AssetDumpingContext& context) = 0;
};

View File

@@ -62,7 +62,8 @@ namespace
namespace image
{
DumperIW3::DumperIW3()
DumperIW3::DumperIW3(const AssetPool<AssetImage::Type>& pool)
: AbstractAssetDumper(pool)
{
switch (ObjWriting::Configuration.ImageOutputFormat)
{
@@ -79,19 +80,14 @@ namespace image
}
}
bool DumperIW3::ShouldDump(XAssetInfo<GfxImage>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<GfxImage>& asset)
{
return true;
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset)
{
const auto* image = asset->Asset();
const auto* image = asset.Asset();
const auto texture = LoadImageData(context.m_obj_search_path, *image);
if (!texture)
return;
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension()));
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name, m_writer->GetFileExtension()));
if (!assetFile)
return;

View File

@@ -8,14 +8,13 @@
namespace image
{
class DumperIW3 final : public AbstractAssetDumper<IW3::GfxImage>
class DumperIW3 final : public AbstractAssetDumper<IW3::AssetImage>
{
public:
DumperIW3();
explicit DumperIW3(const AssetPool<IW3::AssetImage::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW3::GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::AssetImage::Type>& asset) override;
private:
std::unique_ptr<IImageWriter> m_writer;

View File

@@ -11,9 +11,19 @@ using namespace IW3;
namespace localize
{
void DumperIW3::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
DumperIW3::DumperIW3(const AssetPool<IW3::AssetLocalize::Type>& pool)
: AbstractSingleProgressAssetDumper(pool)
{
if (pool->m_asset_lookup.empty())
}
size_t DumperIW3::GetProgressTotalCount() const
{
return m_pool.m_asset_lookup.empty() ? 0uz : 1uz;
}
void DumperIW3::Dump(AssetDumpingContext& context)
{
if (m_pool.m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
@@ -30,7 +40,7 @@ namespace localize
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
for (const auto* localizeEntry : m_pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
@@ -41,5 +51,7 @@ namespace localize
{
con::error("Could not create string file for dumping localized strings of zone '{}'", context.m_zone.m_name);
}
context.IncrementProgress();
}
} // namespace localize

View File

@@ -2,12 +2,16 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
#include "Pool/AssetPool.h"
namespace localize
{
class DumperIW3 final : public IAssetDumper<IW3::LocalizeEntry>
class DumperIW3 final : public AbstractSingleProgressAssetDumper<IW3::AssetLocalize>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<IW3::LocalizeEntry>* pool) override;
explicit DumperIW3(const AssetPool<IW3::AssetLocalize::Type>& pool);
[[nodiscard]] size_t GetProgressTotalCount() const override;
void Dump(AssetDumpingContext& context) override;
};
} // namespace localize

View File

@@ -4,15 +4,15 @@ using namespace IW3;
namespace map_ents
{
bool DumperIW3::ShouldDump(XAssetInfo<MapEnts>* asset)
DumperIW3::DumperIW3(const AssetPool<IW3::AssetMapEnts::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<MapEnts>& asset)
{
const auto* mapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name + ".ents");
const auto* mapEnts = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name + ".ents");
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace map_ents
{
class DumperIW3 final : public AbstractAssetDumper<IW3::MapEnts>
class DumperIW3 final : public AbstractAssetDumper<IW3::AssetMapEnts>
{
public:
explicit DumperIW3(const AssetPool<IW3::AssetMapEnts::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW3::MapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::MapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::MapEnts>& asset) override;
};
} // namespace map_ents

View File

@@ -15,43 +15,55 @@ using namespace IW3;
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
{
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
#define REGISTER_DUMPER(dumperType, poolName) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \
{ \
dumperType dumper; \
dumper.DumpPool(context, assetPools->poolName.get()); \
dumpers.emplace_back(std::make_unique<dumperType>(*assetPools->poolName)); \
}
const auto* assetPools = dynamic_cast<GameAssetPoolIW3*>(context.m_zone.m_pools.get());
std::vector<std::unique_ptr<IAssetDumper>> dumpers;
// DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET)
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
DUMP_ASSET_POOL(xmodel::DumperIW3, m_xmodel, ASSET_TYPE_XMODEL)
DUMP_ASSET_POOL(material::JsonDumperIW3, m_material, ASSET_TYPE_MATERIAL)
// DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(image::DumperIW3, m_image, ASSET_TYPE_IMAGE)
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
// DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
DUMP_ASSET_POOL(sound::LoadedSoundDumperIW3, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS)
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
DUMP_ASSET_POOL(map_ents::DumperIW3, m_map_ents, ASSET_TYPE_MAP_ENTS)
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
// DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def, ASSET_TYPE_MENU)
DUMP_ASSET_POOL(localize::DumperIW3, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
// DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON)
// DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS)
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX)
DUMP_ASSET_POOL(raw_file::DumperIW3, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(string_table::DumperIW3, m_string_table, ASSET_TYPE_STRINGTABLE)
// REGISTER_DUMPER(AssetDumperPhysPreset, m_phys_preset)
// REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts)
REGISTER_DUMPER(xmodel::DumperIW3, m_xmodel)
REGISTER_DUMPER(material::JsonDumperIW3, m_material)
// REGISTER_DUMPER(AssetDumperMaterialTechniqueSet, m_technique_set)
REGISTER_DUMPER(image::DumperIW3, m_image)
// REGISTER_DUMPER(AssetDumpersnd_alias_list_t, m_sound)
// REGISTER_DUMPER(AssetDumperSndCurve, m_sound_curve)
REGISTER_DUMPER(sound::LoadedSoundDumperIW3, m_loaded_sound)
// REGISTER_DUMPER(AssetDumperClipMap, m_clip_map)
// REGISTER_DUMPER(AssetDumperComWorld, m_com_world)
// REGISTER_DUMPER(AssetDumperGameWorldSp, m_game_world_sp)
// REGISTER_DUMPER(AssetDumperGameWorldMp, m_game_world_mp)
REGISTER_DUMPER(map_ents::DumperIW3, m_map_ents)
// REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world)
// REGISTER_DUMPER(AssetDumperGfxLightDef, m_gfx_light_def)
// REGISTER_DUMPER(AssetDumperFont_s, m_font)
// REGISTER_DUMPER(AssetDumperMenuList, m_menu_list)
// REGISTER_DUMPER(AssetDumpermenuDef_t, m_menu_def)
REGISTER_DUMPER(localize::DumperIW3, m_localize)
// REGISTER_DUMPER(AssetDumperWeapon, m_weapon)
// REGISTER_DUMPER(AssetDumperSndDriverGlobals, m_snd_driver_globals)
// REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx)
// REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table)
REGISTER_DUMPER(raw_file::DumperIW3, m_raw_file)
REGISTER_DUMPER(string_table::DumperIW3, m_string_table)
if (context.ShouldTrackProgress())
{
size_t totalProgress = 0uz;
for (const auto& dumper : dumpers)
totalProgress += dumper->GetProgressTotalCount();
context.SetTotalProgress(totalProgress);
}
for (const auto& dumper : dumpers)
dumper->Dump(context);
return true;
#undef DUMP_ASSET_POOL
#undef REGISTER_DUMPER
}

View File

@@ -4,15 +4,15 @@ using namespace IW3;
namespace raw_file
{
bool DumperIW3::ShouldDump(XAssetInfo<RawFile>* asset)
DumperIW3::DumperIW3(const AssetPool<AssetRawFile::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<RawFile>& asset)
{
const auto* rawFile = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* rawFile = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace raw_file
{
class DumperIW3 final : public AbstractAssetDumper<IW3::RawFile>
class DumperIW3 final : public AbstractAssetDumper<IW3::AssetRawFile>
{
public:
explicit DumperIW3(const AssetPool<IW3::AssetRawFile::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW3::RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::RawFile>& asset) override;
};
} // namespace raw_file

View File

@@ -25,15 +25,15 @@ namespace
namespace sound
{
bool LoadedSoundDumperIW3::ShouldDump(XAssetInfo<LoadedSound>* asset)
LoadedSoundDumperIW3::LoadedSoundDumperIW3(const AssetPool<AssetLoadedSound::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void LoadedSoundDumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset)
void LoadedSoundDumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<LoadedSound>& asset)
{
const auto* loadedSound = asset->Asset();
const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name));
const auto* loadedSound = asset.Asset();
const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset.m_name));
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace sound
{
class LoadedSoundDumperIW3 final : public AbstractAssetDumper<IW3::LoadedSound>
class LoadedSoundDumperIW3 final : public AbstractAssetDumper<IW3::AssetLoadedSound>
{
public:
explicit LoadedSoundDumperIW3(const AssetPool<IW3::AssetLoadedSound::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW3::LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::AssetLoadedSound::Type>& asset) override;
};
} // namespace sound

View File

@@ -6,15 +6,15 @@ using namespace IW3;
namespace string_table
{
bool DumperIW3::ShouldDump(XAssetInfo<StringTable>* asset)
DumperIW3::DumperIW3(const AssetPool<AssetStringTable::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<StringTable>& asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* stringTable = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace string_table
{
class DumperIW3 final : public AbstractAssetDumper<IW3::StringTable>
class DumperIW3 final : public AbstractAssetDumper<IW3::AssetStringTable>
{
public:
explicit DumperIW3(const AssetPool<IW3::AssetStringTable::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW3::StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW3::StringTable>& asset) override;
};
} // namespace string_table

View File

@@ -59,7 +59,8 @@ namespace
namespace image
{
DumperIW4::DumperIW4()
DumperIW4::DumperIW4(const AssetPool<AssetImage::Type>& pool)
: AbstractAssetDumper(pool)
{
switch (ObjWriting::Configuration.ImageOutputFormat)
{
@@ -76,19 +77,14 @@ namespace image
}
}
bool DumperIW4::ShouldDump(XAssetInfo<GfxImage>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetImage::Type>& asset)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset)
{
const auto* image = asset->Asset();
const auto* image = asset.Asset();
const auto texture = LoadImageData(context.m_obj_search_path, *image);
if (!texture)
return;
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension()));
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name, m_writer->GetFileExtension()));
if (!assetFile)
return;

View File

@@ -8,14 +8,13 @@
namespace image
{
class DumperIW4 final : public AbstractAssetDumper<IW4::GfxImage>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetImage>
{
public:
DumperIW4();
explicit DumperIW4(const AssetPool<IW4::AssetImage::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetImage::Type>& asset) override;
private:
std::unique_ptr<IImageWriter> m_writer;

View File

@@ -77,19 +77,19 @@ namespace
namespace leaderboard
{
bool JsonDumperIW4::ShouldDump(XAssetInfo<LeaderboardDef>* asset)
JsonDumperIW4::JsonDumperIW4(const AssetPool<AssetLeaderboard::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void JsonDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset)
void JsonDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetLeaderboard::Type>& asset)
{
const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name));
const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset.m_name));
if (!assetFile)
return;
Dumper dumper(*assetFile);
dumper.Dump(*asset->Asset());
dumper.Dump(*asset.Asset());
}
} // namespace leaderboard

View File

@@ -5,10 +5,12 @@
namespace leaderboard
{
class JsonDumperIW4 final : public AbstractAssetDumper<IW4::LeaderboardDef>
class JsonDumperIW4 final : public AbstractAssetDumper<IW4::AssetLeaderboard>
{
public:
explicit JsonDumperIW4(const AssetPool<IW4::AssetLeaderboard::Type>& pool);
protected:
[[nodiscard]] bool ShouldDump(XAssetInfo<IW4::LeaderboardDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::LeaderboardDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetLeaderboard::Type>& asset) override;
};
} // namespace leaderboard

View File

@@ -2,21 +2,19 @@
#include "LightDef/LightDefCommon.h"
#include <sstream>
using namespace IW4;
namespace light_def
{
bool DumperIW4::ShouldDump(XAssetInfo<GfxLightDef>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetLightDef::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxLightDef>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetLightDef::Type>& asset)
{
const auto* lightDef = asset->Asset();
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name));
const auto* lightDef = asset.Asset();
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
return;

View File

@@ -5,10 +5,12 @@
namespace light_def
{
class DumperIW4 final : public AbstractAssetDumper<IW4::GfxLightDef>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetLightDef>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetLightDef::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::GfxLightDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::GfxLightDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetLightDef::Type>& asset) override;
};
} // namespace light_def

View File

@@ -5,15 +5,19 @@
#include "Utils/Logging/Log.h"
#include <format>
#include <sstream>
using namespace IW4;
namespace localize
{
void DumperIW4::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
DumperIW4::DumperIW4(const AssetPool<AssetLocalize::Type>& pool)
: AbstractSingleProgressAssetDumper(pool)
{
if (pool->m_asset_lookup.empty())
}
void DumperIW4::Dump(AssetDumpingContext& context)
{
if (m_pool.m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
@@ -30,7 +34,7 @@ namespace localize
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
for (const auto* localizeEntry : m_pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
@@ -41,5 +45,7 @@ namespace localize
{
con::error("Could not create string file for dumping localized strings of zone '{}'", context.m_zone.m_name);
}
context.IncrementProgress();
}
} // namespace localize

View File

@@ -5,9 +5,11 @@
namespace localize
{
class DumperIW4 final : public IAssetDumper<IW4::LocalizeEntry>
class DumperIW4 final : public AbstractSingleProgressAssetDumper<IW4::AssetLocalize>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<IW4::LocalizeEntry>* pool) override;
explicit DumperIW4(const AssetPool<IW4::AssetLocalize::Type>& pool);
void Dump(AssetDumpingContext& context) override;
};
} // namespace localize

View File

@@ -7,15 +7,15 @@ using namespace IW4;
namespace addon_map_ents
{
bool DumperIW4::ShouldDump(XAssetInfo<AddonMapEnts>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetAddonMapEnts::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetAddonMapEnts::Type>& asset)
{
const auto* addonMapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* addonMapEnts = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace addon_map_ents
{
class DumperIW4 final : public AbstractAssetDumper<IW4::AddonMapEnts>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetAddonMapEnts>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetAddonMapEnts::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::AddonMapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::AddonMapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetAddonMapEnts::Type>& asset) override;
};
} // namespace addon_map_ents

View File

@@ -1110,17 +1110,17 @@ namespace
namespace material
{
bool DecompilingGdtDumperIW4::ShouldDump(XAssetInfo<Material>* asset)
DecompilingGdtDumperIW4::DecompilingGdtDumperIW4(const AssetPool<AssetMaterial::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DecompilingGdtDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset)
void DecompilingGdtDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetMaterial::Type>& asset)
{
if (!context.m_gdt)
return;
MaterialGdtDumper dumper(*asset->Asset());
MaterialGdtDumper dumper(*asset.Asset());
context.m_gdt->WriteEntry(dumper.CreateGdtEntry());
}
} // namespace material

View File

@@ -5,10 +5,12 @@
namespace material
{
class DecompilingGdtDumperIW4 final : public AbstractAssetDumper<IW4::Material>
class DecompilingGdtDumperIW4 final : public AbstractAssetDumper<IW4::AssetMaterial>
{
public:
explicit DecompilingGdtDumperIW4(const AssetPool<IW4::AssetMaterial::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::Material>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::Material>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetMaterial::Type>& asset) override;
};
} // namespace material

View File

@@ -1,7 +1,6 @@
#include "MenuDumperIW4.h"
#include "Game/IW4/GameAssetPoolIW4.h"
#include "Game/IW4/Menu/MenuDumperIW4.h"
#include "MenuListDumperIW4.h"
#include "MenuWriterIW4.h"
#include "ObjWriting.h"
@@ -13,12 +12,12 @@ using namespace IW4;
namespace
{
std::string GetPathForMenu(menu::MenuDumpingZoneState* zoneState, XAssetInfo<menuDef_t>* asset)
std::string GetPathForMenu(menu::MenuDumpingZoneState* zoneState, const XAssetInfo<menuDef_t>& asset)
{
const auto menuDumpingState = zoneState->m_menu_dumping_state_map.find(asset->Asset());
const auto menuDumpingState = zoneState->m_menu_dumping_state_map.find(asset.Asset());
if (menuDumpingState == zoneState->m_menu_dumping_state_map.end())
return "ui_mp/" + std::string(asset->Asset()->window.name) + ".menu";
return "ui_mp/" + std::string(asset.Asset()->window.name) + ".menu";
return menuDumpingState->second.m_path;
}
@@ -26,20 +25,20 @@ namespace
namespace menu
{
bool MenuDumperIW4::ShouldDump(XAssetInfo<menuDef_t>* asset)
MenuDumperIW4::MenuDumperIW4(const AssetPool<AssetMenu::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void MenuDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<menuDef_t>* asset)
void MenuDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetMenu::Type>& asset)
{
const auto* menu = asset->Asset();
const auto* menu = asset.Asset();
auto* zoneState = context.GetZoneAssetDumperState<MenuDumpingZoneState>();
if (!ObjWriting::ShouldHandleAssetType(ASSET_TYPE_MENULIST))
{
// Make sure menu paths based on menu lists are created
const auto* gameAssetPool = dynamic_cast<GameAssetPoolIW4*>(asset->m_zone->m_pools.get());
const auto* gameAssetPool = dynamic_cast<GameAssetPoolIW4*>(asset.m_zone->m_pools.get());
for (auto* menuListAsset : *gameAssetPool->m_menu_list)
CreateDumpingStateForMenuListIW4(zoneState, menuListAsset->Asset());
}

View File

@@ -2,14 +2,15 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
#include "Menu/MenuDumpingZoneState.h"
namespace menu
{
class MenuDumperIW4 final : public AbstractAssetDumper<IW4::menuDef_t>
class MenuDumperIW4 final : public AbstractAssetDumper<IW4::AssetMenu>
{
public:
explicit MenuDumperIW4(const AssetPool<IW4::AssetMenu::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::menuDef_t>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::menuDef_t>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetMenu::Type>& asset) override;
};
} // namespace menu

View File

@@ -147,15 +147,15 @@ namespace menu
}
}
bool MenuListDumperIW4::ShouldDump(XAssetInfo<MenuList>* asset)
MenuListDumperIW4::MenuListDumperIW4(const AssetPool<AssetMenuList::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void MenuListDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<MenuList>* asset)
void MenuListDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetMenuList::Type>& asset)
{
const auto* menuList = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* menuList = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;
@@ -174,13 +174,13 @@ namespace menu
menuWriter->End();
}
void MenuListDumperIW4::DumpPool(AssetDumpingContext& context, AssetPool<MenuList>* pool)
void MenuListDumperIW4::Dump(AssetDumpingContext& context)
{
auto* zoneState = context.GetZoneAssetDumperState<MenuDumpingZoneState>();
for (auto* asset : *pool)
for (const auto* asset : m_pool)
CreateDumpingStateForMenuListIW4(zoneState, asset->Asset());
AbstractAssetDumper<MenuList>::DumpPool(context, pool);
AbstractAssetDumper::Dump(context);
}
} // namespace menu

View File

@@ -2,20 +2,20 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
#include "Game/IW4/Menu/MenuDumperIW4.h"
#include "Menu/MenuDumpingZoneState.h"
namespace menu
{
void CreateDumpingStateForMenuListIW4(MenuDumpingZoneState* zoneState, const IW4::MenuList* menuList);
class MenuListDumperIW4 final : public AbstractAssetDumper<IW4::MenuList>
class MenuListDumperIW4 final : public AbstractAssetDumper<IW4::AssetMenuList>
{
protected:
bool ShouldDump(XAssetInfo<IW4::MenuList>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::MenuList>* asset) override;
public:
void DumpPool(AssetDumpingContext& context, AssetPool<IW4::MenuList>* pool) override;
explicit MenuListDumperIW4(const AssetPool<IW4::AssetMenuList::Type>& pool);
void Dump(AssetDumpingContext& context) override;
protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetMenuList::Type>& asset) override;
};
} // namespace menu

View File

@@ -30,55 +30,67 @@ using namespace IW4;
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
{
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
#define REGISTER_DUMPER(dumperType, poolName) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \
{ \
dumperType dumper; \
dumper.DumpPool(context, assetPools->poolName.get()); \
dumpers.emplace_back(std::make_unique<dumperType>(*assetPools->poolName)); \
}
const auto* assetPools = dynamic_cast<GameAssetPoolIW4*>(context.m_zone.m_pools.get());
std::vector<std::unique_ptr<IAssetDumper>> dumpers;
DUMP_ASSET_POOL(phys_preset::InfoStringDumperIW4, m_phys_preset, ASSET_TYPE_PHYSPRESET)
DUMP_ASSET_POOL(phys_collmap::DumperIW4, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP)
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
DUMP_ASSET_POOL(xmodel::DumperIW4, m_xmodel, ASSET_TYPE_XMODEL)
DUMP_ASSET_POOL(material::JsonDumperIW4, m_material, ASSET_TYPE_MATERIAL)
REGISTER_DUMPER(phys_preset::InfoStringDumperIW4, m_phys_preset)
REGISTER_DUMPER(phys_collmap::DumperIW4, m_phys_collmap)
// REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts)
REGISTER_DUMPER(xmodel::DumperIW4, m_xmodel)
REGISTER_DUMPER(material::JsonDumperIW4, m_material)
#ifdef EXPERIMENTAL_MATERIAL_COMPILATION
DUMP_ASSET_POOL(material::DecompilingGdtDumperIW4, m_material, ASSET_TYPE_MATERIAL)
DUMP_ASSET_POOL(material::DecompilingGdtDumperIW4, m_material)
#endif
DUMP_ASSET_POOL(shader::PixelShaderDumperIW4, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER)
DUMP_ASSET_POOL(shader::VertexShaderDumperIW4, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
DUMP_ASSET_POOL(techset::DumperIW4, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(image::DumperIW4, m_image, ASSET_TYPE_IMAGE)
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
DUMP_ASSET_POOL(sound_curve::DumperIW4, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
DUMP_ASSET_POOL(sound::LoadedSoundDumperIW4, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_MP)
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
// DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
// DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world, ASSET_TYPE_FXWORLD)
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
DUMP_ASSET_POOL(light_def::DumperIW4, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)
DUMP_ASSET_POOL(menu::MenuListDumperIW4, m_menu_list, ASSET_TYPE_MENULIST)
DUMP_ASSET_POOL(menu::MenuDumperIW4, m_menu_def, ASSET_TYPE_MENU)
DUMP_ASSET_POOL(localize::DumperIW4, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(weapon::DumperIW4, m_weapon, ASSET_TYPE_WEAPON)
// DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS)
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX)
DUMP_ASSET_POOL(raw_file::DumperIW4, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(string_table::DumperIW4, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(leaderboard::JsonDumperIW4, m_leaderboard, ASSET_TYPE_LEADERBOARD)
DUMP_ASSET_POOL(structured_data_def::DumperIW4, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
DUMP_ASSET_POOL(tracer::DumperIW4, m_tracer, ASSET_TYPE_TRACER)
DUMP_ASSET_POOL(vehicle::DumperIW4, m_vehicle, ASSET_TYPE_VEHICLE)
DUMP_ASSET_POOL(addon_map_ents::DumperIW4, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS)
REGISTER_DUMPER(shader::PixelShaderDumperIW4, m_material_pixel_shader)
REGISTER_DUMPER(shader::VertexShaderDumperIW4, m_material_vertex_shader)
REGISTER_DUMPER(techset::DumperIW4, m_technique_set)
REGISTER_DUMPER(image::DumperIW4, m_image)
// REGISTER_DUMPER(AssetDumpersnd_alias_list_t, m_sound)
REGISTER_DUMPER(sound_curve::DumperIW4, m_sound_curve)
REGISTER_DUMPER(sound::LoadedSoundDumperIW4, m_loaded_sound)
// REGISTER_DUMPER(AssetDumperClipMap, m_clip_map)
// REGISTER_DUMPER(AssetDumperComWorld, m_com_world)
// REGISTER_DUMPER(AssetDumperGameWorldSp, m_game_world_sp)
// REGISTER_DUMPER(AssetDumperGameWorldMp, m_game_world_mp)
// REGISTER_DUMPER(AssetDumperMapEnts, m_map_ents)
// REGISTER_DUMPER(AssetDumperFxWorld, m_fx_world)
// REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world)
REGISTER_DUMPER(light_def::DumperIW4, m_gfx_light_def)
// REGISTER_DUMPER(AssetDumperFont_s, m_font)
REGISTER_DUMPER(menu::MenuListDumperIW4, m_menu_list)
REGISTER_DUMPER(menu::MenuDumperIW4, m_menu_def)
REGISTER_DUMPER(localize::DumperIW4, m_localize)
REGISTER_DUMPER(weapon::DumperIW4, m_weapon)
// REGISTER_DUMPER(AssetDumperSndDriverGlobals, m_snd_driver_globals)
// REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx)
// REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table)
REGISTER_DUMPER(raw_file::DumperIW4, m_raw_file)
REGISTER_DUMPER(string_table::DumperIW4, m_string_table)
REGISTER_DUMPER(leaderboard::JsonDumperIW4, m_leaderboard)
REGISTER_DUMPER(structured_data_def::DumperIW4, m_structed_data_def_set)
REGISTER_DUMPER(tracer::DumperIW4, m_tracer)
REGISTER_DUMPER(vehicle::DumperIW4, m_vehicle)
REGISTER_DUMPER(addon_map_ents::DumperIW4, m_addon_map_ents)
if (context.ShouldTrackProgress())
{
size_t totalProgress = 0uz;
for (const auto& dumper : dumpers)
totalProgress += dumper->GetProgressTotalCount();
context.SetTotalProgress(totalProgress);
}
for (const auto& dumper : dumpers)
dumper->Dump(context);
return true;
#undef DUMP_ASSET_POOL
#undef REGISTER_DUMPER
}

View File

@@ -10,15 +10,15 @@ using namespace IW4;
namespace phys_collmap
{
bool DumperIW4::ShouldDump(XAssetInfo<PhysCollmap>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetPhysCollMap::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<PhysCollmap>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetPhysCollMap::Type>& asset)
{
const auto* physCollmap = asset->Asset();
const auto assetFile = context.OpenAssetFile(phys_collmap::GetFileNameForAssetName(asset->m_name));
const auto* physCollmap = asset.Asset();
const auto assetFile = context.OpenAssetFile(phys_collmap::GetFileNameForAssetName(asset.m_name));
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace phys_collmap
{
class DumperIW4 final : public AbstractAssetDumper<IW4::PhysCollmap>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetPhysCollMap>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetPhysCollMap::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::PhysCollmap>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::PhysCollmap>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetPhysCollMap::Type>& asset) override;
};
} // namespace phys_collmap

View File

@@ -57,21 +57,21 @@ namespace
physPresetInfo->perSurfaceSndAlias = physPreset->perSurfaceSndAlias ? 1 : 0;
}
InfoString CreateInfoString(XAssetInfo<PhysPreset>* asset)
InfoString CreateInfoString(const XAssetInfo<PhysPreset>& asset)
{
auto* physPresetInfo = new PhysPresetInfo;
CopyToPhysPresetInfo(asset->Asset(), physPresetInfo);
CopyToPhysPresetInfo(asset.Asset(), physPresetInfo);
InfoStringFromPhysPresetConverter converter(physPresetInfo,
phys_preset_fields,
std::extent_v<decltype(phys_preset_fields)>,
[asset](const scr_string_t scrStr) -> std::string
{
assert(scrStr < asset->m_zone->m_script_strings.Count());
if (scrStr >= asset->m_zone->m_script_strings.Count())
assert(scrStr < asset.m_zone->m_script_strings.Count());
if (scrStr >= asset.m_zone->m_script_strings.Count())
return "";
return asset->m_zone->m_script_strings[scrStr];
return asset.m_zone->m_script_strings[scrStr];
});
return converter.Convert();
@@ -80,24 +80,24 @@ namespace
namespace phys_preset
{
bool InfoStringDumperIW4::ShouldDump(XAssetInfo<IW4::PhysPreset>* asset)
InfoStringDumperIW4::InfoStringDumperIW4(const AssetPool<AssetPhysPreset::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void InfoStringDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::PhysPreset>* asset)
void InfoStringDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetPhysPreset::Type>& asset)
{
// Only dump raw when no gdt available
if (context.m_gdt)
{
const auto infoString = CreateInfoString(asset);
GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_PHYS_PRESET);
GdtEntry gdtEntry(asset.m_name, ObjConstants::GDF_FILENAME_PHYS_PRESET);
infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, gdtEntry);
context.m_gdt->WriteEntry(gdtEntry);
}
else
{
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name));
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset.m_name));
if (!assetFile)
return;

View File

@@ -2,14 +2,15 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
#include "InfoString/InfoString.h"
namespace phys_preset
{
class InfoStringDumperIW4 final : public AbstractAssetDumper<IW4::PhysPreset>
class InfoStringDumperIW4 final : public AbstractAssetDumper<IW4::AssetPhysPreset>
{
public:
explicit InfoStringDumperIW4(const AssetPool<IW4::AssetPhysPreset::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::PhysPreset>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::PhysPreset>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetPhysPreset::Type>& asset) override;
};
} // namespace phys_preset

View File

@@ -10,15 +10,15 @@ using namespace IW4;
namespace raw_file
{
bool DumperIW4::ShouldDump(XAssetInfo<RawFile>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetRawFile::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetRawFile::Type>& asset)
{
const auto* rawFile = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* rawFile = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace raw_file
{
class DumperIW4 final : public AbstractAssetDumper<IW4::RawFile>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetRawFile>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetRawFile::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetRawFile::Type>& asset) override;
};
} // namespace raw_file

View File

@@ -6,15 +6,15 @@ using namespace IW4;
namespace shader
{
bool PixelShaderDumperIW4::ShouldDump(XAssetInfo<IW4::MaterialPixelShader>* asset)
PixelShaderDumperIW4::PixelShaderDumperIW4(const AssetPool<AssetPixelShader::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void PixelShaderDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::MaterialPixelShader>* asset)
void PixelShaderDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetPixelShader::Type>& asset)
{
const auto* pixelShader = asset->Asset();
const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForPixelShaderAssetName(asset->m_name));
const auto* pixelShader = asset.Asset();
const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForPixelShaderAssetName(asset.m_name));
if (!shaderFile)
return;

View File

@@ -5,10 +5,12 @@
namespace shader
{
class PixelShaderDumperIW4 final : public AbstractAssetDumper<IW4::MaterialPixelShader>
class PixelShaderDumperIW4 final : public AbstractAssetDumper<IW4::AssetPixelShader>
{
public:
explicit PixelShaderDumperIW4(const AssetPool<IW4::AssetPixelShader::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::MaterialPixelShader>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::MaterialPixelShader>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetPixelShader::Type>& asset) override;
};
} // namespace shader

View File

@@ -6,15 +6,15 @@ using namespace IW4;
namespace shader
{
bool VertexShaderDumperIW4::ShouldDump(XAssetInfo<IW4::MaterialVertexShader>* asset)
VertexShaderDumperIW4::VertexShaderDumperIW4(const AssetPool<AssetVertexShader::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void VertexShaderDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::MaterialVertexShader>* asset)
void VertexShaderDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetVertexShader::Type>& asset)
{
const auto* vertexShader = asset->Asset();
const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForVertexShaderAssetName(asset->m_name));
const auto* vertexShader = asset.Asset();
const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForVertexShaderAssetName(asset.m_name));
if (!shaderFile)
return;

View File

@@ -5,10 +5,12 @@
namespace shader
{
class VertexShaderDumperIW4 final : public AbstractAssetDumper<IW4::MaterialVertexShader>
class VertexShaderDumperIW4 final : public AbstractAssetDumper<IW4::AssetVertexShader>
{
public:
explicit VertexShaderDumperIW4(const AssetPool<IW4::AssetVertexShader::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::MaterialVertexShader>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::MaterialVertexShader>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetVertexShader::Type>& asset) override;
};
} // namespace shader

View File

@@ -25,15 +25,15 @@ namespace
namespace sound
{
bool LoadedSoundDumperIW4::ShouldDump(XAssetInfo<LoadedSound>* asset)
LoadedSoundDumperIW4::LoadedSoundDumperIW4(const AssetPool<AssetLoadedSound::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void LoadedSoundDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset)
void LoadedSoundDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetLoadedSound::Type>& asset)
{
const auto* loadedSound = asset->Asset();
const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name));
const auto* loadedSound = asset.Asset();
const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset.m_name));
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace sound
{
class LoadedSoundDumperIW4 final : public AbstractAssetDumper<IW4::LoadedSound>
class LoadedSoundDumperIW4 final : public AbstractAssetDumper<IW4::AssetLoadedSound>
{
public:
explicit LoadedSoundDumperIW4(const AssetPool<IW4::AssetLoadedSound::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetLoadedSound::Type>& asset) override;
};
} // namespace sound

View File

@@ -3,20 +3,18 @@
#include "Sound/SndCurveDumper.h"
#include "Sound/SoundCurveCommon.h"
#include <sstream>
using namespace IW4;
namespace sound_curve
{
bool DumperIW4::ShouldDump(XAssetInfo<SndCurve>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetSoundCurve::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<SndCurve>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetSoundCurve::Type>& asset)
{
const auto* sndCurve = asset->Asset();
const auto* sndCurve = asset.Asset();
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(sndCurve->filename));

View File

@@ -5,10 +5,12 @@
namespace sound_curve
{
class DumperIW4 final : public AbstractAssetDumper<IW4::SndCurve>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetSoundCurve>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetSoundCurve::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::SndCurve>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::SndCurve>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetSoundCurve::Type>& asset) override;
};
} // namespace sound_curve

View File

@@ -6,15 +6,15 @@ using namespace IW4;
namespace string_table
{
bool DumperIW4::ShouldDump(XAssetInfo<StringTable>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetStringTable::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetStringTable::Type>& asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* stringTable = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace string_table
{
class DumperIW4 final : public AbstractAssetDumper<IW4::StringTable>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetStringTable>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetStringTable::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetStringTable::Type>& asset) override;
};
} // namespace string_table

View File

@@ -1,9 +1,11 @@
#include "StructuredDataDefDumperIW4.h"
#include "StructuredDataDef/CommonStructuredDataDef.h"
#include "StructuredDataDef/StructuredDataDefDumper.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <sstream>
using namespace IW4;
@@ -185,15 +187,15 @@ namespace
namespace structured_data_def
{
bool DumperIW4::ShouldDump(XAssetInfo<StructuredDataDefSet>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetStructuredDataDef::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<StructuredDataDefSet>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetStructuredDataDef::Type>& asset)
{
const auto* set = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* set = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile || set->defs == nullptr)
return;

View File

@@ -2,16 +2,15 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
#include "StructuredDataDef/CommonStructuredDataDef.h"
#include <cstddef>
namespace structured_data_def
{
class DumperIW4 final : public AbstractAssetDumper<IW4::StructuredDataDefSet>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetStructuredDataDef>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetStructuredDataDef::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::StructuredDataDefSet>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::StructuredDataDefSet>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetStructuredDataDef::Type>& asset) override;
};
} // namespace structured_data_def

View File

@@ -536,14 +536,14 @@ namespace IW4
namespace techset
{
bool DumperIW4::ShouldDump(XAssetInfo<MaterialTechniqueSet>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetTechniqueSet::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialTechniqueSet>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetTechniqueSet::Type>& asset)
{
const auto* techset = asset->Asset();
const auto* techset = asset.Asset();
const auto techsetFile = context.OpenAssetFile(GetFileNameForTechsetName(techset->name));

View File

@@ -5,10 +5,12 @@
namespace techset
{
class DumperIW4 final : public AbstractAssetDumper<IW4::MaterialTechniqueSet>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetTechniqueSet>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetTechniqueSet::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::MaterialTechniqueSet>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::MaterialTechniqueSet>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetTechniqueSet::Type>& asset) override;
};
} // namespace techset

View File

@@ -32,18 +32,18 @@ namespace
}
};
InfoString CreateInfoString(XAssetInfo<TracerDef>* asset)
InfoString CreateInfoString(const XAssetInfo<TracerDef>& asset)
{
InfoStringFromTracerConverter converter(asset->Asset(),
InfoStringFromTracerConverter converter(asset.Asset(),
tracer_fields,
std::extent_v<decltype(tracer_fields)>,
[asset](const scr_string_t scrStr) -> std::string
{
assert(scrStr < asset->m_zone->m_script_strings.Count());
if (scrStr >= asset->m_zone->m_script_strings.Count())
assert(scrStr < asset.m_zone->m_script_strings.Count());
if (scrStr >= asset.m_zone->m_script_strings.Count())
return "";
return asset->m_zone->m_script_strings[scrStr];
return asset.m_zone->m_script_strings[scrStr];
});
return converter.Convert();
@@ -52,24 +52,24 @@ namespace
namespace tracer
{
bool DumperIW4::ShouldDump(XAssetInfo<TracerDef>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetTracer::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<TracerDef>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetTracer::Type>& asset)
{
// Only dump raw when no gdt available
if (context.m_gdt)
{
const auto infoString = CreateInfoString(asset);
GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_TRACER);
GdtEntry gdtEntry(asset.m_name, ObjConstants::GDF_FILENAME_TRACER);
infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_TRACER, gdtEntry);
context.m_gdt->WriteEntry(gdtEntry);
}
else
{
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name));
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset.m_name));
if (!assetFile)
return;

View File

@@ -2,14 +2,15 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
#include "InfoString/InfoString.h"
namespace tracer
{
class DumperIW4 final : public AbstractAssetDumper<IW4::TracerDef>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetTracer>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetTracer::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::TracerDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::TracerDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetTracer::Type>& asset) override;
};
} // namespace tracer

View File

@@ -73,18 +73,18 @@ namespace
}
};
InfoString CreateInfoString(XAssetInfo<VehicleDef>* asset)
InfoString CreateInfoString(const XAssetInfo<VehicleDef>& asset)
{
InfoStringFromVehicleConverter converter(asset->Asset(),
InfoStringFromVehicleConverter converter(asset.Asset(),
vehicle_fields,
std::extent_v<decltype(vehicle_fields)>,
[asset](const scr_string_t scrStr) -> std::string
{
assert(scrStr < asset->m_zone->m_script_strings.Count());
if (scrStr >= asset->m_zone->m_script_strings.Count())
assert(scrStr < asset.m_zone->m_script_strings.Count());
if (scrStr >= asset.m_zone->m_script_strings.Count())
return "";
return asset->m_zone->m_script_strings[scrStr];
return asset.m_zone->m_script_strings[scrStr];
});
return converter.Convert();
@@ -93,24 +93,24 @@ namespace
namespace vehicle
{
bool DumperIW4::ShouldDump(XAssetInfo<VehicleDef>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetVehicle::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetVehicle::Type>& asset)
{
// Only dump raw when no gdt available
if (context.m_gdt)
{
const auto infoString = CreateInfoString(asset);
GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_VEHICLE);
GdtEntry gdtEntry(asset.m_name, ObjConstants::GDF_FILENAME_VEHICLE);
infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_VEHICLE, gdtEntry);
context.m_gdt->WriteEntry(gdtEntry);
}
else
{
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name));
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset.m_name));
if (!assetFile)
return;

View File

@@ -2,14 +2,15 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
#include "InfoString/InfoString.h"
namespace vehicle
{
class DumperIW4 final : public AbstractAssetDumper<IW4::VehicleDef>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetVehicle>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetVehicle::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::VehicleDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::VehicleDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetVehicle::Type>& asset) override;
};
} // namespace vehicle

View File

@@ -353,31 +353,31 @@ namespace
}
}
InfoString CreateInfoString(XAssetInfo<WeaponCompleteDef>* asset)
InfoString CreateInfoString(const XAssetInfo<WeaponCompleteDef>& asset)
{
const auto fullDef = std::make_unique<WeaponFullDef>();
memset(fullDef.get(), 0, sizeof(WeaponFullDef));
CopyToFullDef(asset->Asset(), fullDef.get());
CopyToFullDef(asset.Asset(), fullDef.get());
InfoStringFromWeaponConverter converter(fullDef.get(),
weapon_fields,
std::extent_v<decltype(weapon_fields)>,
[asset](const scr_string_t scrStr) -> std::string
{
assert(scrStr < asset->m_zone->m_script_strings.Count());
if (scrStr >= asset->m_zone->m_script_strings.Count())
assert(scrStr < asset.m_zone->m_script_strings.Count());
if (scrStr >= asset.m_zone->m_script_strings.Count())
return "";
return asset->m_zone->m_script_strings[scrStr];
return asset.m_zone->m_script_strings[scrStr];
});
return converter.Convert();
}
void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset)
void DumpAccuracyGraphs(AssetDumpingContext& context, const XAssetInfo<WeaponCompleteDef>& asset)
{
auto* accuracyGraphWriter = context.GetZoneAssetDumperState<AccuracyGraphWriter>();
const auto weapon = asset->Asset();
const auto weapon = asset.Asset();
const auto* weapDef = weapon->weapDef;
if (!weapDef)
@@ -405,24 +405,24 @@ namespace
namespace weapon
{
bool DumperIW4::ShouldDump(XAssetInfo<WeaponCompleteDef>* asset)
DumperIW4::DumperIW4(const AssetPool<AssetWeapon::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset)
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetWeapon::Type>& asset)
{
// Only dump raw when no gdt available
if (context.m_gdt)
{
const auto infoString = CreateInfoString(asset);
GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON);
GdtEntry gdtEntry(asset.m_name, ObjConstants::GDF_FILENAME_WEAPON);
infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON, gdtEntry);
context.m_gdt->WriteEntry(gdtEntry);
}
else
{
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name));
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset.m_name));
if (!assetFile)
return;

View File

@@ -2,14 +2,15 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
#include "InfoString/InfoString.h"
namespace weapon
{
class DumperIW4 final : public AbstractAssetDumper<IW4::WeaponCompleteDef>
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetWeapon>
{
public:
explicit DumperIW4(const AssetPool<IW4::AssetWeapon::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW4::WeaponCompleteDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW4::WeaponCompleteDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetWeapon::Type>& asset) override;
};
} // namespace weapon

View File

@@ -60,7 +60,8 @@ namespace
namespace image
{
DumperIW5::DumperIW5()
DumperIW5::DumperIW5(const AssetPool<AssetImage::Type>& pool)
: AbstractAssetDumper(pool)
{
switch (ObjWriting::Configuration.ImageOutputFormat)
{
@@ -77,19 +78,14 @@ namespace image
}
}
bool DumperIW5::ShouldDump(XAssetInfo<GfxImage>* asset)
void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetImage::Type>& asset)
{
return true;
}
void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset)
{
const auto* image = asset->Asset();
const auto* image = asset.Asset();
const auto texture = LoadImageData(context.m_obj_search_path, *image);
if (!texture)
return;
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension()));
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name, m_writer->GetFileExtension()));
if (!assetFile)
return;

View File

@@ -8,14 +8,13 @@
namespace image
{
class DumperIW5 final : public AbstractAssetDumper<IW5::GfxImage>
class DumperIW5 final : public AbstractAssetDumper<IW5::AssetImage>
{
public:
DumperIW5();
explicit DumperIW5(const AssetPool<IW5::AssetImage::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetImage::Type>& asset) override;
private:
std::unique_ptr<IImageWriter> m_writer;

View File

@@ -94,19 +94,19 @@ namespace
namespace leaderboard
{
bool JsonDumperIW5::ShouldDump(XAssetInfo<LeaderboardDef>* asset)
JsonDumperIW5::JsonDumperIW5(const AssetPool<AssetLeaderboard::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void JsonDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset)
void JsonDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetLeaderboard::Type>& asset)
{
const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name));
const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset.m_name));
if (!assetFile)
return;
Dumper dumper(*assetFile);
dumper.Dump(*asset->Asset());
dumper.Dump(*asset.Asset());
}
} // namespace leaderboard

View File

@@ -5,10 +5,12 @@
namespace leaderboard
{
class JsonDumperIW5 final : public AbstractAssetDumper<IW5::LeaderboardDef>
class JsonDumperIW5 final : public AbstractAssetDumper<IW5::AssetLeaderboard>
{
public:
explicit JsonDumperIW5(const AssetPool<IW5::AssetLeaderboard::Type>& pool);
protected:
[[nodiscard]] bool ShouldDump(XAssetInfo<IW5::LeaderboardDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::LeaderboardDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetLeaderboard::Type>& asset) override;
};
} // namespace leaderboard

View File

@@ -11,9 +11,14 @@ using namespace IW5;
namespace localize
{
void DumperIW5::DumpPool(AssetDumpingContext& context, AssetPool<IW5::LocalizeEntry>* pool)
DumperIW5::DumperIW5(const AssetPool<AssetLocalize::Type>& pool)
: AbstractSingleProgressAssetDumper(pool)
{
if (pool->m_asset_lookup.empty())
}
void DumperIW5::Dump(AssetDumpingContext& context)
{
if (m_pool.m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
@@ -30,7 +35,7 @@ namespace localize
stringFileDumper.SetNotes("");
for (auto* localizeEntry : *pool)
for (const auto* localizeEntry : m_pool)
{
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
}
@@ -41,5 +46,7 @@ namespace localize
{
con::error("Could not create string file for dumping localized strings of zone '{}'", context.m_zone.m_name);
}
context.IncrementProgress();
}
} // namespace localize

View File

@@ -5,9 +5,11 @@
namespace localize
{
class DumperIW5 final : public IAssetDumper<IW5::LocalizeEntry>
class DumperIW5 final : public AbstractSingleProgressAssetDumper<IW5::AssetLocalize>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<IW5::LocalizeEntry>* pool) override;
explicit DumperIW5(const AssetPool<IW5::AssetLocalize::Type>& pool);
void Dump(AssetDumpingContext& context) override;
};
} // namespace localize

View File

@@ -7,15 +7,15 @@ using namespace IW5;
namespace addon_map_ents
{
bool DumperIW5::ShouldDump(XAssetInfo<AddonMapEnts>* asset)
DumperIW5::DumperIW5(const AssetPool<AssetAddonMapEnts::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset)
void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetAddonMapEnts::Type>& asset)
{
const auto* addonMapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* addonMapEnts = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace addon_map_ents
{
class DumperIW5 final : public AbstractAssetDumper<IW5::AddonMapEnts>
class DumperIW5 final : public AbstractAssetDumper<IW5::AssetAddonMapEnts>
{
public:
explicit DumperIW5(const AssetPool<IW5::AssetAddonMapEnts::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::AddonMapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::AddonMapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetAddonMapEnts::Type>& asset) override;
};
} // namespace addon_map_ents

View File

@@ -15,10 +15,10 @@ using namespace IW5;
namespace
{
const MenuList* GetParentMenuList(XAssetInfo<menuDef_t>* asset)
const MenuList* GetParentMenuList(const XAssetInfo<menuDef_t>& asset)
{
const auto* menu = asset->Asset();
const auto* gameAssetPool = dynamic_cast<GameAssetPoolIW5*>(asset->m_zone->m_pools.get());
const auto* menu = asset.Asset();
const auto* gameAssetPool = dynamic_cast<GameAssetPoolIW5*>(asset.m_zone->m_pools.get());
for (const auto* menuList : *gameAssetPool->m_menu_list)
{
const auto* menuListAsset = menuList->Asset();
@@ -33,32 +33,32 @@ namespace
return nullptr;
}
std::string GetPathForMenu(XAssetInfo<menuDef_t>* asset)
std::string GetPathForMenu(const XAssetInfo<menuDef_t>& asset)
{
const auto* list = GetParentMenuList(asset);
if (!list)
return std::format("ui_mp/{}.menu", asset->Asset()->window.name);
return std::format("ui_mp/{}.menu", asset.Asset()->window.name);
const fs::path p(list->name);
std::string parentPath;
if (p.has_parent_path())
parentPath = p.parent_path().string() + "/";
return std::format("{}{}.menu", parentPath, asset->Asset()->window.name);
return std::format("{}{}.menu", parentPath, asset.Asset()->window.name);
}
} // namespace
namespace menu
{
bool MenuDumperIW5::ShouldDump(XAssetInfo<menuDef_t>* asset)
MenuDumperIW5::MenuDumperIW5(const AssetPool<AssetMenu::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void MenuDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<menuDef_t>* asset)
void MenuDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetMenu::Type>& asset)
{
const auto* menu = asset->Asset();
const auto* menu = asset.Asset();
const auto menuFilePath = GetPathForMenu(asset);
if (ObjWriting::ShouldHandleAssetType(ASSET_TYPE_MENULIST))

View File

@@ -2,14 +2,15 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW5/IW5.h"
#include "Game/IW5/Menu/MenuDumperIW5.h"
namespace menu
{
class MenuDumperIW5 final : public AbstractAssetDumper<IW5::menuDef_t>
class MenuDumperIW5 final : public AbstractAssetDumper<IW5::AssetMenu>
{
public:
explicit MenuDumperIW5(const AssetPool<IW5::AssetMenu::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::menuDef_t>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::menuDef_t>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetMenu::Type>& asset) override;
};
} // namespace menu

View File

@@ -106,15 +106,15 @@ namespace
namespace menu
{
bool MenuListDumperIW5::ShouldDump(XAssetInfo<MenuList>* asset)
MenuListDumperIW5::MenuListDumperIW5(const AssetPool<AssetMenuList::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void MenuListDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<MenuList>* asset)
void MenuListDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetMenuList::Type>& asset)
{
const auto* menuList = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* menuList = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace menu
{
class MenuListDumperIW5 final : public AbstractAssetDumper<IW5::MenuList>
class MenuListDumperIW5 final : public AbstractAssetDumper<IW5::AssetMenuList>
{
public:
explicit MenuListDumperIW5(const AssetPool<IW5::AssetMenuList::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::MenuList>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::MenuList>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetMenuList::Type>& asset) override;
};
} // namespace menu

View File

@@ -21,56 +21,69 @@ using namespace IW5;
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
{
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
#define REGISTER_DUMPER(dumperType, poolName) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \
{ \
dumperType dumper; \
dumper.DumpPool(context, assetPools->poolName.get()); \
dumpers.emplace_back(std::make_unique<dumperType>(*assetPools->poolName)); \
}
const auto* assetPools = dynamic_cast<GameAssetPoolIW5*>(context.m_zone.m_pools.get());
// DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET)
// DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP)
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
// DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs, ASSET_TYPE_XMODEL_SURFS)
DUMP_ASSET_POOL(xmodel::DumperIW5, m_xmodel, ASSET_TYPE_XMODEL)
DUMP_ASSET_POOL(material::JsonDumperIW5, m_material, ASSET_TYPE_MATERIAL)
// DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER)
// DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
// DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL)
// DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(image::DumperIW5, m_image, ASSET_TYPE_IMAGE)
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
// DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
DUMP_ASSET_POOL(sound::LoadedSoundDumperIW5, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
// DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP)
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
// DUMP_ASSET_POOL(AssetDumperGlassWorld, m_glass_world, ASSET_TYPE_GLASSWORLD)
// DUMP_ASSET_POOL(AssetDumperPathData, m_path_data, ASSET_TYPE_PATHDATA)
// DUMP_ASSET_POOL(AssetDumperVehicleTrack, m_vehicle_track, ASSET_TYPE_VEHICLE_TRACK)
// DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
// DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world, ASSET_TYPE_FXWORLD)
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)
DUMP_ASSET_POOL(menu::MenuListDumperIW5, m_menu_list, ASSET_TYPE_MENULIST)
DUMP_ASSET_POOL(menu::MenuDumperIW5, m_menu_def, ASSET_TYPE_MENU)
DUMP_ASSET_POOL(localize::DumperIW5, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(attachment::JsonDumperIW5, m_attachment, ASSET_TYPE_ATTACHMENT)
DUMP_ASSET_POOL(weapon::DumperIW5, m_weapon, ASSET_TYPE_WEAPON)
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX)
// DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX)
DUMP_ASSET_POOL(raw_file::DumperIW5, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(script::DumperIW5, m_script_file, ASSET_TYPE_SCRIPTFILE)
DUMP_ASSET_POOL(string_table::DumperIW5, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(leaderboard::JsonDumperIW5, m_leaderboard, ASSET_TYPE_LEADERBOARD)
// DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
// DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER)
// DUMP_ASSET_POOL(AssetDumperVehicleDef, m_vehicle, ASSET_TYPE_VEHICLE)
DUMP_ASSET_POOL(addon_map_ents::DumperIW5, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS)
std::vector<std::unique_ptr<IAssetDumper>> dumpers;
// REGISTER_DUMPER(AssetDumperPhysPreset, m_phys_preset)
// REGISTER_DUMPER(AssetDumperPhysCollmap, m_phys_collmap)
// REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts)
// REGISTER_DUMPER(AssetDumperXModelSurfs, m_xmodel_surfs)
REGISTER_DUMPER(xmodel::DumperIW5, m_xmodel)
REGISTER_DUMPER(material::JsonDumperIW5, m_material)
// REGISTER_DUMPER(AssetDumperMaterialPixelShader, m_material_pixel_shader)
// REGISTER_DUMPER(AssetDumperMaterialVertexShader, m_material_vertex_shader)
// REGISTER_DUMPER(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl)
// REGISTER_DUMPER(AssetDumperMaterialTechniqueSet, m_technique_set)
REGISTER_DUMPER(image::DumperIW5, m_image)
// REGISTER_DUMPER(AssetDumpersnd_alias_list_t, m_sound)
// REGISTER_DUMPER(AssetDumperSndCurve, m_sound_curve)
REGISTER_DUMPER(sound::LoadedSoundDumperIW5, m_loaded_sound)
// REGISTER_DUMPER(AssetDumperclipMap_t, m_clip_map)
// REGISTER_DUMPER(AssetDumperComWorld, m_com_world)
// REGISTER_DUMPER(AssetDumperGlassWorld, m_glass_world)
// REGISTER_DUMPER(AssetDumperPathData, m_path_data)
// REGISTER_DUMPER(AssetDumperVehicleTrack, m_vehicle_track)
// REGISTER_DUMPER(AssetDumperMapEnts, m_map_ents)
// REGISTER_DUMPER(AssetDumperFxWorld, m_fx_world)
// REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world)
// REGISTER_DUMPER(AssetDumperGfxLightDef, m_gfx_light_def)
// REGISTER_DUMPER(AssetDumperFont_s, m_font)
REGISTER_DUMPER(menu::MenuListDumperIW5, m_menu_list)
REGISTER_DUMPER(menu::MenuDumperIW5, m_menu_def)
REGISTER_DUMPER(localize::DumperIW5, m_localize)
REGISTER_DUMPER(attachment::JsonDumperIW5, m_attachment)
REGISTER_DUMPER(weapon::DumperIW5, m_weapon)
// REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx)
// REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table)
// REGISTER_DUMPER(AssetDumperSurfaceFxTable, m_surface_fx_table)
REGISTER_DUMPER(raw_file::DumperIW5, m_raw_file)
REGISTER_DUMPER(script::DumperIW5, m_script_file)
REGISTER_DUMPER(string_table::DumperIW5, m_string_table)
REGISTER_DUMPER(leaderboard::JsonDumperIW5, m_leaderboard)
// REGISTER_DUMPER(AssetDumperStructuredDataDefSet, m_structed_data_def_set)
// REGISTER_DUMPER(AssetDumperTracerDef, m_tracer)
// REGISTER_DUMPER(AssetDumperVehicleDef, m_vehicle)
REGISTER_DUMPER(addon_map_ents::DumperIW5, m_addon_map_ents)
if (context.ShouldTrackProgress())
{
size_t totalProgress = 0uz;
for (const auto& dumper : dumpers)
totalProgress += dumper->GetProgressTotalCount();
context.SetTotalProgress(totalProgress);
}
for (const auto& dumper : dumpers)
dumper->Dump(context);
return true;
#undef DUMP_ASSET_POOL
#undef REGISTER_DUMPER
}

View File

@@ -10,15 +10,15 @@ using namespace IW5;
namespace raw_file
{
bool DumperIW5::ShouldDump(XAssetInfo<RawFile>* asset)
DumperIW5::DumperIW5(const AssetPool<AssetRawFile::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetRawFile::Type>& asset)
{
const auto* rawFile = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* rawFile = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace raw_file
{
class DumperIW5 final : public AbstractAssetDumper<IW5::RawFile>
class DumperIW5 final : public AbstractAssetDumper<IW5::AssetRawFile>
{
public:
explicit DumperIW5(const AssetPool<IW5::AssetRawFile::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetRawFile::Type>& asset) override;
};
} // namespace raw_file

View File

@@ -4,16 +4,16 @@ using namespace IW5;
namespace script
{
bool DumperIW5::ShouldDump(XAssetInfo<IW5::ScriptFile>* asset)
DumperIW5::DumperIW5(const AssetPool<AssetScript::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
// See https://github.com/xensik/gsc-tool#file-format for an in-depth explanation about the .gscbin format
void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::ScriptFile>* asset)
void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetScript::Type>& asset)
{
auto* scriptFile = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name + ".gscbin");
auto* scriptFile = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name + ".gscbin");
if (!assetFile)
return;
@@ -21,10 +21,10 @@ namespace script
auto& stream = *assetFile;
// Dump the name and the numeric fields
stream.write(asset->m_name.c_str(), asset->m_name.size() + 1);
stream.write(reinterpret_cast<char*>(&scriptFile->compressedLen), sizeof(scriptFile->compressedLen));
stream.write(reinterpret_cast<char*>(&scriptFile->len), sizeof(scriptFile->len));
stream.write(reinterpret_cast<char*>(&scriptFile->bytecodeLen), sizeof(scriptFile->bytecodeLen));
stream.write(asset.m_name.c_str(), asset.m_name.size() + 1);
stream.write(reinterpret_cast<const char*>(&scriptFile->compressedLen), sizeof(scriptFile->compressedLen));
stream.write(reinterpret_cast<const char*>(&scriptFile->len), sizeof(scriptFile->len));
stream.write(reinterpret_cast<const char*>(&scriptFile->bytecodeLen), sizeof(scriptFile->bytecodeLen));
// Dump the buffers
stream.write(scriptFile->buffer, scriptFile->compressedLen);

View File

@@ -5,10 +5,12 @@
namespace script
{
class DumperIW5 final : public AbstractAssetDumper<IW5::ScriptFile>
class DumperIW5 final : public AbstractAssetDumper<IW5::AssetScript>
{
public:
explicit DumperIW5(const AssetPool<IW5::AssetScript::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::ScriptFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::ScriptFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetScript::Type>& asset) override;
};
} // namespace script

View File

@@ -25,15 +25,15 @@ namespace
namespace sound
{
bool LoadedSoundDumperIW5::ShouldDump(XAssetInfo<LoadedSound>* asset)
LoadedSoundDumperIW5::LoadedSoundDumperIW5(const AssetPool<AssetLoadedSound::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void LoadedSoundDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset)
void LoadedSoundDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetLoadedSound::Type>& asset)
{
const auto* loadedSound = asset->Asset();
const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name));
const auto* loadedSound = asset.Asset();
const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset.m_name));
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace sound
{
class LoadedSoundDumperIW5 final : public AbstractAssetDumper<IW5::LoadedSound>
class LoadedSoundDumperIW5 final : public AbstractAssetDumper<IW5::AssetLoadedSound>
{
public:
explicit LoadedSoundDumperIW5(const AssetPool<IW5::AssetLoadedSound::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetLoadedSound::Type>& asset) override;
};
} // namespace sound

View File

@@ -6,15 +6,15 @@ using namespace IW5;
namespace string_table
{
bool DumperIW5::ShouldDump(XAssetInfo<StringTable>* asset)
DumperIW5::DumperIW5(const AssetPool<AssetStringTable::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetStringTable::Type>& asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
const auto* stringTable = asset.Asset();
const auto assetFile = context.OpenAssetFile(asset.m_name);
if (!assetFile)
return;

View File

@@ -5,10 +5,12 @@
namespace string_table
{
class DumperIW5 final : public AbstractAssetDumper<IW5::StringTable>
class DumperIW5 final : public AbstractAssetDumper<IW5::AssetStringTable>
{
public:
explicit DumperIW5(const AssetPool<IW5::AssetStringTable::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetStringTable::Type>& asset) override;
};
} // namespace string_table

View File

@@ -395,19 +395,19 @@ namespace
namespace attachment
{
bool JsonDumperIW5::ShouldDump(XAssetInfo<WeaponAttachment>* asset)
JsonDumperIW5::JsonDumperIW5(const AssetPool<AssetAttachment::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void JsonDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponAttachment>* asset)
void JsonDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetAttachment::Type>& asset)
{
const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAssetName(asset->m_name));
const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAssetName(asset.m_name));
if (!assetFile)
return;
const JsonDumperImpl dumper(context, *assetFile);
dumper.Dump(asset->Asset());
dumper.Dump(asset.Asset());
}
} // namespace attachment

View File

@@ -5,10 +5,12 @@
namespace attachment
{
class JsonDumperIW5 final : public AbstractAssetDumper<IW5::WeaponAttachment>
class JsonDumperIW5 final : public AbstractAssetDumper<IW5::AssetAttachment>
{
public:
explicit JsonDumperIW5(const AssetPool<IW5::AssetAttachment::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::WeaponAttachment>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::WeaponAttachment>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetAttachment::Type>& asset) override;
};
} // namespace attachment

View File

@@ -681,31 +681,31 @@ namespace
}
}
InfoString CreateInfoString(XAssetInfo<WeaponCompleteDef>* asset)
InfoString CreateInfoString(const XAssetInfo<WeaponCompleteDef>& asset)
{
const auto fullDef = std::make_unique<WeaponFullDef>();
memset(fullDef.get(), 0, sizeof(WeaponFullDef));
CopyToFullDef(asset->Asset(), fullDef.get());
CopyToFullDef(asset.Asset(), fullDef.get());
InfoStringFromWeaponConverter converter(fullDef.get(),
weapon_fields,
std::extent_v<decltype(weapon_fields)>,
[asset](const scr_string_t scrStr) -> std::string
{
assert(scrStr < asset->m_zone->m_script_strings.Count());
if (scrStr >= asset->m_zone->m_script_strings.Count())
assert(scrStr < asset.m_zone->m_script_strings.Count());
if (scrStr >= asset.m_zone->m_script_strings.Count())
return "";
return asset->m_zone->m_script_strings[scrStr];
return asset.m_zone->m_script_strings[scrStr];
});
return converter.Convert();
}
void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset)
void DumpAccuracyGraphs(AssetDumpingContext& context, const XAssetInfo<WeaponCompleteDef>& asset)
{
auto* accuracyGraphWriter = context.GetZoneAssetDumperState<AccuracyGraphWriter>();
const auto weapon = asset->Asset();
const auto weapon = asset.Asset();
const auto* weapDef = weapon->weapDef;
if (!weapDef)
@@ -733,12 +733,12 @@ namespace
namespace weapon
{
bool DumperIW5::ShouldDump(XAssetInfo<WeaponCompleteDef>* asset)
DumperIW5::DumperIW5(const AssetPool<AssetWeapon::Type>& pool)
: AbstractAssetDumper(pool)
{
return true;
}
void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset)
void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetWeapon::Type>& asset)
{
// TODO: only dump infostring fields when non-default
@@ -746,13 +746,13 @@ namespace weapon
if (context.m_gdt)
{
const auto infoString = CreateInfoString(asset);
GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON);
GdtEntry gdtEntry(asset.m_name, ObjConstants::GDF_FILENAME_WEAPON);
infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON, gdtEntry);
context.m_gdt->WriteEntry(gdtEntry);
}
else
{
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name));
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset.m_name));
if (!assetFile)
return;

View File

@@ -2,14 +2,15 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW5/IW5.h"
#include "InfoString/InfoString.h"
namespace weapon
{
class DumperIW5 final : public AbstractAssetDumper<IW5::WeaponCompleteDef>
class DumperIW5 final : public AbstractAssetDumper<IW5::AssetWeapon>
{
public:
explicit DumperIW5(const AssetPool<IW5::AssetWeapon::Type>& pool);
protected:
bool ShouldDump(XAssetInfo<IW5::WeaponCompleteDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW5::WeaponCompleteDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW5::AssetWeapon::Type>& asset) override;
};
} // namespace weapon

View File

@@ -59,7 +59,8 @@ namespace
namespace image
{
DumperT5::DumperT5()
DumperT5::DumperT5(const AssetPool<AssetImage::Type>& pool)
: AbstractAssetDumper(pool)
{
switch (ObjWriting::Configuration.ImageOutputFormat)
{
@@ -76,19 +77,14 @@ namespace image
}
}
bool DumperT5::ShouldDump(XAssetInfo<GfxImage>* asset)
void DumperT5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetImage::Type>& asset)
{
return true;
}
void DumperT5::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset)
{
const auto* image = asset->Asset();
const auto* image = asset.Asset();
const auto texture = LoadImageData(context.m_obj_search_path, *image);
if (!texture)
return;
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension()));
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name, m_writer->GetFileExtension()));
if (!assetFile)
return;

Some files were not shown because too many files have changed in this diff Show More