2022-06-22 11:36:06 -04:00
|
|
|
#include <STDInclude.hpp>
|
|
|
|
#include "ImenuDef_t.hpp"
|
2017-02-25 14:55:04 -05:00
|
|
|
|
|
|
|
namespace Assets
|
|
|
|
{
|
2019-01-16 23:52:42 -05:00
|
|
|
|
2022-06-22 11:36:06 -04:00
|
|
|
std::unordered_map<std::string, Game::menuDef_t*> ImenuDef_t::LoadedMenus;
|
2019-01-16 23:52:42 -05:00
|
|
|
|
2022-06-22 11:36:06 -04:00
|
|
|
void ImenuDef_t::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
|
|
|
|
{
|
|
|
|
// load from disk
|
2022-12-11 12:54:24 -05:00
|
|
|
auto menus = Components::Menus::LoadMenu(std::format("ui_mp/{}.menu", name));
|
2019-01-17 18:39:01 -05:00
|
|
|
|
2022-11-28 13:06:42 -05:00
|
|
|
if (menus.empty()) return;
|
2022-06-22 11:36:06 -04:00
|
|
|
if (menus.size() > 1) Components::Logger::Print("Menu '{}' on disk has more than one menudef in it. Only saving the first one\n", name);
|
2019-01-17 18:39:01 -05:00
|
|
|
|
2022-06-22 11:36:06 -04:00
|
|
|
header->menu = menus[0].second;
|
|
|
|
}
|
2019-01-16 23:52:42 -05:00
|
|
|
|
|
|
|
|
2017-02-25 15:11:17 -05:00
|
|
|
void ImenuDef_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
|
|
|
{
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* asset = header.menu;
|
2017-02-25 15:11:17 -05:00
|
|
|
|
|
|
|
if (asset->window.background)
|
|
|
|
{
|
|
|
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->window.background);
|
|
|
|
}
|
2017-06-14 06:06:04 -04:00
|
|
|
|
2017-02-25 15:11:17 -05:00
|
|
|
// mark items
|
2017-04-24 16:33:13 -04:00
|
|
|
for (int i = 0; i < asset->itemCount; ++i)
|
2017-02-25 15:11:17 -05:00
|
|
|
{
|
|
|
|
if (asset->items[i]->window.background)
|
|
|
|
{
|
|
|
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->items[i]->window.background);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (asset->items[i]->focusSound)
|
|
|
|
{
|
|
|
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_SOUND, asset->items[i]->focusSound);
|
|
|
|
}
|
2017-02-26 07:10:48 -05:00
|
|
|
|
|
|
|
if (asset->items[i]->type == 6 && asset->items[i]->typeData.listBox &&
|
|
|
|
asset->items[i]->typeData.listBox->selectIcon)
|
|
|
|
{
|
|
|
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->items[i]->typeData.listBox->selectIcon);
|
|
|
|
}
|
2017-02-25 15:11:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-26 08:54:19 -05:00
|
|
|
void ImenuDef_t::save_ExpressionSupportingData(Game::ExpressionSupportingData* asset, Components::ZoneBuilder::Zone* builder)
|
2017-02-25 16:02:58 -05:00
|
|
|
{
|
|
|
|
AssertSize(Game::ExpressionSupportingData, 24);
|
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
|
|
|
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("ExpressionSupportingData");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
|
|
|
|
2017-02-25 16:02:58 -05:00
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* dest = buffer->dest<Game::ExpressionSupportingData>();
|
2017-02-25 16:02:58 -05:00
|
|
|
buffer->save(asset);
|
|
|
|
|
|
|
|
if (asset->uifunctions.functions)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
|
2022-11-28 12:30:17 -05:00
|
|
|
auto** destStatement = buffer->dest<Game::Statement_s*>();
|
2017-02-25 16:02:58 -05:00
|
|
|
buffer->saveArray(asset->uifunctions.functions, asset->uifunctions.totalFunctions);
|
|
|
|
|
2017-04-24 16:33:13 -04:00
|
|
|
for (int i = 0; i < asset->uifunctions.totalFunctions; ++i)
|
2017-02-25 16:02:58 -05:00
|
|
|
{
|
|
|
|
if (asset->uifunctions.functions[i])
|
|
|
|
{
|
|
|
|
Utils::Stream::ClearPointer(&destStatement[i]);
|
|
|
|
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_Statement_s(asset->uifunctions.functions[i], builder);
|
2017-02-25 16:02:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Utils::Stream::ClearPointer(&dest->uifunctions.functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (asset->staticDvarList.staticDvars)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
|
2022-11-28 12:30:17 -05:00
|
|
|
auto** destStaticDvars = buffer->dest<Game::StaticDvar*>();
|
2017-02-25 16:02:58 -05:00
|
|
|
buffer->saveArray(asset->staticDvarList.staticDvars, asset->staticDvarList.numStaticDvars);
|
|
|
|
|
2022-11-28 12:30:17 -05:00
|
|
|
for (auto i = 0; i < asset->staticDvarList.numStaticDvars; ++i)
|
2017-02-25 16:02:58 -05:00
|
|
|
{
|
|
|
|
if (asset->staticDvarList.staticDvars[i])
|
|
|
|
{
|
|
|
|
Utils::Stream::ClearPointer(&destStaticDvars[i]);
|
|
|
|
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* destStaticDvar = buffer->dest<Game::StaticDvar>();
|
2017-02-25 16:02:58 -05:00
|
|
|
buffer->save(asset->staticDvarList.staticDvars[i]);
|
|
|
|
|
|
|
|
if (asset->staticDvarList.staticDvars[i]->dvarName)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->staticDvarList.staticDvars[i]->dvarName);
|
|
|
|
Utils::Stream::ClearPointer(&destStaticDvar->dvarName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Utils::Stream::ClearPointer(&dest->staticDvarList.staticDvars);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (asset->uiStrings.strings)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
|
2022-11-28 12:30:17 -05:00
|
|
|
const auto** destUIStrings = buffer->dest<const char*>();
|
2017-02-25 16:02:58 -05:00
|
|
|
buffer->saveArray(asset->uiStrings.strings, asset->uiStrings.totalStrings);
|
|
|
|
|
2017-04-24 16:33:13 -04:00
|
|
|
for (int i = 0; i < asset->uiStrings.totalStrings; ++i)
|
2017-02-25 16:02:58 -05:00
|
|
|
{
|
|
|
|
if (asset->uiStrings.strings[i])
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->uiStrings.strings[i]);
|
2022-11-28 12:30:17 -05:00
|
|
|
Utils::Stream::ClearPointer(&destUIStrings[i]);
|
2017-02-25 16:02:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 16:02:58 -05:00
|
|
|
}
|
|
|
|
|
2017-02-26 08:54:19 -05:00
|
|
|
void ImenuDef_t::save_Statement_s(Game::Statement_s* asset, Components::ZoneBuilder::Zone* builder)
|
2017-02-25 14:55:04 -05:00
|
|
|
{
|
|
|
|
AssertSize(Game::Statement_s, 24);
|
2022-06-22 11:36:06 -04:00
|
|
|
AssertSize(Game::expressionEntry, 12);
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
|
|
|
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("Statement_s");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
// Write header data
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* dest = buffer->dest<Game::Statement_s>();
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->save(asset);
|
|
|
|
|
|
|
|
// Write statement entries
|
|
|
|
if (asset->entries)
|
|
|
|
{
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("statement entries");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
|
|
|
|
// Write entries
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* destEntries = buffer->dest<Game::expressionEntry>();
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->save(asset->entries, sizeof(Game::expressionEntry), asset->numEntries);
|
|
|
|
|
|
|
|
// Loop through entries
|
2017-04-24 16:33:13 -04:00
|
|
|
for (int i = 0; i < asset->numEntries; ++i)
|
2017-02-25 14:55:04 -05:00
|
|
|
{
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("entry");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
if (asset->entries[i].type)
|
|
|
|
{
|
|
|
|
switch (asset->entries[i].data.operand.dataType)
|
|
|
|
{
|
|
|
|
// Those types do not require additional data
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Expression string
|
|
|
|
case 2:
|
|
|
|
if (asset->entries[i].data.operand.internals.stringVal.string)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->entries[i].data.operand.internals.stringVal.string);
|
|
|
|
Utils::Stream::ClearPointer(&destEntries[i].data.operand.internals.stringVal.string);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Function
|
|
|
|
case 3:
|
|
|
|
if (asset->entries[i].data.operand.internals.function)
|
|
|
|
{
|
2017-03-01 18:20:20 -05:00
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_Statement_s(asset->entries[i].data.operand.internals.function, builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream::ClearPointer(&destEntries[i].data.operand.internals.function);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
if (asset->supportingData)
|
|
|
|
{
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_ExpressionSupportingData(asset->supportingData, builder);
|
2017-02-25 16:02:58 -05:00
|
|
|
Utils::Stream::ClearPointer(&dest->supportingData);
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
|
|
|
|
2017-02-26 08:54:19 -05:00
|
|
|
void ImenuDef_t::save_MenuEventHandlerSet(Game::MenuEventHandlerSet* asset, Components::ZoneBuilder::Zone* builder)
|
2017-02-25 14:55:04 -05:00
|
|
|
{
|
|
|
|
AssertSize(Game::MenuEventHandlerSet, 8);
|
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
|
|
|
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("MenuEventHandlerSet");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
// Write header data
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* destset = buffer->dest<Game::MenuEventHandlerSet>();
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->save(asset);
|
|
|
|
|
|
|
|
// Event handlers
|
|
|
|
if (asset->eventHandlers)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
|
|
|
|
// Write pointers to zone
|
|
|
|
buffer->save(asset->eventHandlers, sizeof(Game::MenuEventHandler*), asset->eventHandlerCount);
|
|
|
|
|
|
|
|
// Loop through eventHandlers
|
2022-11-28 12:30:17 -05:00
|
|
|
for (auto i = 0; i < asset->eventHandlerCount; ++i)
|
2017-02-25 14:55:04 -05:00
|
|
|
{
|
|
|
|
if (asset->eventHandlers[i])
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("MenuEventHandler");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
|
|
|
|
// Write menu event handler
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* dest = buffer->dest<Game::MenuEventHandler>();
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->save(asset->eventHandlers[i]);
|
|
|
|
|
|
|
|
// Write additional data based on type
|
|
|
|
switch (asset->eventHandlers[i]->eventType)
|
|
|
|
{
|
|
|
|
// unconditional scripts
|
|
|
|
case 0:
|
|
|
|
if (asset->eventHandlers[i]->eventData.unconditionalScript)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->eventHandlers[i]->eventData.unconditionalScript);
|
|
|
|
Utils::Stream::ClearPointer(&dest->eventData.unconditionalScript);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// ConditionalScript
|
|
|
|
case 1:
|
|
|
|
if (asset->eventHandlers[i]->eventData.conditionalScript)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* destConditionalScript = buffer->dest<Game::ConditionalScript>();
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->save(asset->eventHandlers[i]->eventData.conditionalScript);
|
|
|
|
|
|
|
|
// eventExpression
|
|
|
|
if (asset->eventHandlers[i]->eventData.conditionalScript->eventExpression)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_Statement_s(asset->eventHandlers[i]->eventData.conditionalScript->eventExpression, builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream::ClearPointer(&destConditionalScript->eventExpression);
|
|
|
|
}
|
|
|
|
|
|
|
|
// eventHandlerSet
|
|
|
|
if (asset->eventHandlers[i]->eventData.conditionalScript->eventHandlerSet)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_MenuEventHandlerSet(asset->eventHandlers[i]->eventData.conditionalScript->eventHandlerSet, builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream::ClearPointer(&destConditionalScript->eventHandlerSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
Utils::Stream::ClearPointer(&dest->eventData.conditionalScript);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// elseScript
|
|
|
|
case 2:
|
|
|
|
if (asset->eventHandlers[i]->eventData.elseScript)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_MenuEventHandlerSet(asset->eventHandlers[i]->eventData.elseScript, builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream::ClearPointer(&dest->eventData.elseScript);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// localVarData expressions
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
if (asset->eventHandlers[i]->eventData.setLocalVarData)
|
|
|
|
{
|
2017-03-01 18:20:20 -05:00
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
// header data
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* destLocalVarData = buffer->dest<Game::SetLocalVarData>();
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->save(asset->eventHandlers[i]->eventData.setLocalVarData);
|
|
|
|
|
|
|
|
// localVarName
|
|
|
|
if (asset->eventHandlers[i]->eventData.setLocalVarData->localVarName)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->eventHandlers[i]->eventData.setLocalVarData->localVarName);
|
|
|
|
Utils::Stream::ClearPointer(&destLocalVarData->localVarName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// statement
|
|
|
|
if (asset->eventHandlers[i]->eventData.setLocalVarData->expression)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_Statement_s(asset->eventHandlers[i]->eventData.setLocalVarData->expression, builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream::ClearPointer(&destLocalVarData->expression);
|
|
|
|
}
|
|
|
|
|
|
|
|
Utils::Stream::ClearPointer(&dest->eventData.setLocalVarData);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Utils::Stream::ClearPointer(&destset->eventHandlers);
|
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
|
|
|
|
2017-02-26 08:54:19 -05:00
|
|
|
void ImenuDef_t::save_ItemKeyHandler(Game::ItemKeyHandler* asset, Components::ZoneBuilder::Zone* builder)
|
2017-02-25 14:55:04 -05:00
|
|
|
{
|
|
|
|
AssertSize(Game::ItemKeyHandler, 12);
|
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
|
|
|
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("ItemKeyHandler");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
while (asset)
|
|
|
|
{
|
|
|
|
// Write header
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* dest = buffer->dest<Game::ItemKeyHandler>();
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->save(asset);
|
|
|
|
|
|
|
|
// MenuEventHandlerSet
|
|
|
|
if (asset->action)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_MenuEventHandlerSet(asset->action, builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream::ClearPointer(&dest->action);
|
|
|
|
}
|
|
|
|
|
2017-03-01 18:20:20 -05:00
|
|
|
if (asset->next)
|
|
|
|
{
|
2022-11-28 12:30:17 -05:00
|
|
|
// align every index, besides the first one?
|
2017-03-01 18:20:20 -05:00
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
}
|
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
// Next key handler
|
|
|
|
asset = asset->next;
|
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
|
|
|
|
2022-11-28 12:30:17 -05:00
|
|
|
#define EVENTHANDLERSET(__index) \
|
|
|
|
if (asset->__index) \
|
2017-02-25 14:55:04 -05:00
|
|
|
{ \
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4); \
|
2022-11-28 12:30:17 -05:00
|
|
|
this->save_MenuEventHandlerSet(asset->__index, builder); \
|
|
|
|
Utils::Stream::ClearPointer(&dest->__index); \
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
|
|
|
|
2022-11-28 12:30:17 -05:00
|
|
|
#define STATEMENT(__index) \
|
|
|
|
if (asset->__index) \
|
2017-02-25 14:55:04 -05:00
|
|
|
{ \
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4); \
|
2022-11-28 12:30:17 -05:00
|
|
|
this->save_Statement_s(asset->__index, builder); \
|
|
|
|
Utils::Stream::ClearPointer(&dest->__index); \
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
|
|
|
|
2018-05-09 08:33:52 -04:00
|
|
|
void ImenuDef_t::save_itemDefData_t(Game::itemDefData_t* asset, int type, Game::itemDef_s* dest, Components::ZoneBuilder::Zone* builder)
|
2017-02-25 17:47:24 -05:00
|
|
|
{
|
2017-02-26 05:36:58 -05:00
|
|
|
AssertSize(Game::newsTickerDef_s, 28);
|
|
|
|
AssertSize(Game::listBoxDef_s, 324);
|
|
|
|
AssertSize(Game::editFieldDef_s, 32);
|
2017-02-26 05:45:53 -05:00
|
|
|
AssertSize(Game::multiDef_s, 392);
|
2017-02-26 05:36:58 -05:00
|
|
|
|
2017-02-25 17:47:24 -05:00
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
|
|
|
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("itemDefData_t");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
|
|
|
|
2017-02-25 17:47:24 -05:00
|
|
|
// feeder
|
|
|
|
if (type == 6)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* destlb = buffer->dest<Game::listBoxDef_s>();
|
2017-02-25 17:47:24 -05:00
|
|
|
buffer->save(asset->listBox);
|
|
|
|
|
2018-05-09 08:33:52 -04:00
|
|
|
if (asset->listBox->onDoubleClick)
|
2017-02-25 17:47:24 -05:00
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2018-05-09 08:33:52 -04:00
|
|
|
this->save_MenuEventHandlerSet(asset->listBox->onDoubleClick, builder);
|
2017-02-25 17:47:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (asset->listBox->selectIcon)
|
|
|
|
{
|
|
|
|
destlb->selectIcon = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->listBox->selectIcon).material;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// HexRays spaghetti
|
2022-11-28 12:30:17 -05:00
|
|
|
else if (type != 4 && type != 9 && type != 16 && type != 18 && type != 11 && type != 14 && type != 10 && type != 17 && type != 22 && type != 23 && type != 0)
|
2017-02-25 17:47:24 -05:00
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
// enum dvar
|
|
|
|
case 13:
|
|
|
|
buffer->saveString(asset->enumDvarName);
|
|
|
|
break;
|
|
|
|
// newsticker
|
|
|
|
case 20:
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
buffer->save(asset->ticker);
|
|
|
|
break;
|
|
|
|
// textScrollDef
|
|
|
|
case 21:
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
buffer->save(asset->scroll);
|
|
|
|
break;
|
|
|
|
case 12:
|
2017-02-26 05:45:53 -05:00
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* destdef = buffer->dest<Game::multiDef_s>();
|
2018-05-09 08:33:52 -04:00
|
|
|
buffer->save(asset->multi);
|
2017-02-26 05:45:53 -05:00
|
|
|
|
2017-04-24 16:33:13 -04:00
|
|
|
for (int i = 0; i < 32; ++i)
|
2017-02-26 05:45:53 -05:00
|
|
|
{
|
2018-05-09 08:33:52 -04:00
|
|
|
if (asset->multi->dvarList[i])
|
2017-02-26 05:45:53 -05:00
|
|
|
{
|
2018-05-09 08:33:52 -04:00
|
|
|
buffer->saveString(asset->multi->dvarList[i]);
|
2017-02-26 05:45:53 -05:00
|
|
|
Utils::Stream::ClearPointer(&destdef->dvarList[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-24 16:33:13 -04:00
|
|
|
for (int i = 0; i < 32; ++i)
|
2017-02-26 05:45:53 -05:00
|
|
|
{
|
2018-05-09 08:33:52 -04:00
|
|
|
if (asset->multi->dvarStr[i])
|
2017-02-26 05:45:53 -05:00
|
|
|
{
|
2018-05-09 08:33:52 -04:00
|
|
|
buffer->saveString(asset->multi->dvarStr[i]);
|
2017-02-26 05:45:53 -05:00
|
|
|
Utils::Stream::ClearPointer(&destdef->dvarStr[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-25 17:47:24 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// editFieldDef
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 05:36:58 -05:00
|
|
|
buffer->save(asset->editField);
|
2017-02-25 17:47:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Utils::Stream::ClearPointer(&dest->typeData.data);
|
2019-01-19 11:28:36 -05:00
|
|
|
|
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 17:47:24 -05:00
|
|
|
}
|
|
|
|
|
2018-05-09 08:33:52 -04:00
|
|
|
void ImenuDef_t::save_itemDef_s(Game::itemDef_s *asset, Components::ZoneBuilder::Zone* builder)
|
2017-02-25 14:55:04 -05:00
|
|
|
{
|
2022-12-02 14:18:04 -05:00
|
|
|
AssertSize(Game::itemDef_s, 0x17C);
|
2017-02-25 14:55:04 -05:00
|
|
|
|
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* dest = buffer->dest<Game::itemDef_s>();
|
2017-02-25 14:55:04 -05:00
|
|
|
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
if (asset->window.name)
|
|
|
|
buffer->enterStruct(Utils::String::VA("itemDef_s: name = '%s'", asset->window.name));
|
|
|
|
else if (asset->window.background)
|
|
|
|
buffer->enterStruct(Utils::String::VA("itemDef_s: bg = '%s'", asset->window.background->info.name));
|
|
|
|
else
|
|
|
|
buffer->enterStruct("itemDef_s");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->save(asset);
|
|
|
|
|
|
|
|
// window data
|
2018-05-09 08:33:52 -04:00
|
|
|
save_windowDef_t<Game::itemDef_s>(&asset->window, dest, builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
|
|
|
|
// text
|
|
|
|
if (asset->text)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->text);
|
|
|
|
Utils::Stream::ClearPointer(&dest->text);
|
|
|
|
}
|
|
|
|
|
|
|
|
// MenuEventHandlerSets
|
|
|
|
EVENTHANDLERSET(mouseEnterText);
|
|
|
|
EVENTHANDLERSET(mouseExitText);
|
|
|
|
EVENTHANDLERSET(mouseEnter);
|
|
|
|
EVENTHANDLERSET(mouseExit);
|
|
|
|
EVENTHANDLERSET(action);
|
|
|
|
EVENTHANDLERSET(accept);
|
|
|
|
EVENTHANDLERSET(onFocus);
|
|
|
|
EVENTHANDLERSET(leaveFocus);
|
|
|
|
|
|
|
|
// Dvar strings
|
|
|
|
if (asset->dvar)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->dvar);
|
|
|
|
Utils::Stream::ClearPointer(&dest->dvar);
|
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
if (asset->dvarTest)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->dvarTest);
|
|
|
|
Utils::Stream::ClearPointer(&dest->dvarTest);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ItemKeyHandler
|
|
|
|
if (asset->onKey)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_ItemKeyHandler(asset->onKey, builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream::ClearPointer(&dest->onKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dvar strings
|
|
|
|
if (asset->enableDvar)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->enableDvar);
|
|
|
|
Utils::Stream::ClearPointer(&dest->enableDvar);
|
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
if (asset->localVar)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->localVar);
|
|
|
|
Utils::Stream::ClearPointer(&dest->localVar);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Focus sound
|
|
|
|
if (asset->focusSound)
|
|
|
|
{
|
|
|
|
dest->focusSound = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_SOUND, asset->focusSound).sound;
|
|
|
|
}
|
|
|
|
|
2017-02-25 17:47:24 -05:00
|
|
|
// itemDefData
|
|
|
|
if (asset->typeData.data)
|
|
|
|
{
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_itemDefData_t(&asset->typeData, asset->type, dest, builder);
|
2017-02-25 17:47:24 -05:00
|
|
|
}
|
2017-02-25 14:55:04 -05:00
|
|
|
|
2017-02-26 05:25:22 -05:00
|
|
|
// floatExpressions
|
|
|
|
if (asset->floatExpressions)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("floatExpressions");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-26 05:25:22 -05:00
|
|
|
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* destExp = buffer->dest<Game::ItemFloatExpression>();
|
2017-02-26 05:25:22 -05:00
|
|
|
buffer->saveArray(asset->floatExpressions, asset->floatExpressionCount);
|
|
|
|
|
2017-04-24 16:33:13 -04:00
|
|
|
for (int i = 0; i < asset->floatExpressionCount; ++i)
|
2017-02-26 05:25:22 -05:00
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_Statement_s(asset->floatExpressions[i].expression, builder);
|
2019-01-19 11:28:36 -05:00
|
|
|
Utils::Stream::ClearPointer(&destExp[i].expression);
|
2017-02-26 05:25:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Utils::Stream::ClearPointer(&dest->floatExpressions);
|
2019-01-19 11:28:36 -05:00
|
|
|
|
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-26 05:25:22 -05:00
|
|
|
}
|
2017-02-25 14:55:04 -05:00
|
|
|
|
|
|
|
// Statements
|
|
|
|
STATEMENT(visibleExp);
|
|
|
|
STATEMENT(disabledExp);
|
|
|
|
STATEMENT(textExp);
|
|
|
|
STATEMENT(materialExp);
|
2019-01-19 11:28:36 -05:00
|
|
|
|
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
|
|
|
|
2017-02-25 15:07:27 -05:00
|
|
|
void ImenuDef_t::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
2017-02-25 14:55:04 -05:00
|
|
|
{
|
|
|
|
AssertSize(Game::menuDef_t, 400);
|
2022-12-02 14:18:04 -05:00
|
|
|
AssertSize(Game::windowDef_t, 0xA4);
|
2017-02-25 14:55:04 -05:00
|
|
|
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->enterStruct("ImenuDef_t");
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
|
|
|
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
2022-11-28 12:30:17 -05:00
|
|
|
auto* asset = header.menu;
|
|
|
|
auto* dest = buffer->dest<Game::menuDef_t>();
|
2017-02-25 14:55:04 -05:00
|
|
|
buffer->save(asset);
|
|
|
|
|
|
|
|
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
|
|
|
|
2017-02-25 16:02:58 -05:00
|
|
|
// ExpressionSupportingData
|
|
|
|
if (asset->expressionData)
|
|
|
|
{
|
2017-02-25 17:47:24 -05:00
|
|
|
// dest->expressionData = nullptr;
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_ExpressionSupportingData(asset->expressionData, builder);
|
2017-02-25 16:02:58 -05:00
|
|
|
Utils::Stream::ClearPointer(&dest->expressionData);
|
|
|
|
}
|
2017-02-25 14:55:04 -05:00
|
|
|
|
|
|
|
// Window data
|
|
|
|
save_windowDef_t<Game::menuDef_t>(&asset->window, dest, builder);
|
|
|
|
|
|
|
|
// Font
|
|
|
|
if (asset->font)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->font);
|
|
|
|
Utils::Stream::ClearPointer(&dest->font);
|
|
|
|
}
|
|
|
|
|
|
|
|
// MenuEventHandlerSets
|
|
|
|
EVENTHANDLERSET(onOpen);
|
2018-05-09 08:33:52 -04:00
|
|
|
EVENTHANDLERSET(onCloseRequest);
|
2017-02-25 14:55:04 -05:00
|
|
|
EVENTHANDLERSET(onClose);
|
2018-05-09 08:33:52 -04:00
|
|
|
EVENTHANDLERSET(onESC);
|
2017-02-25 14:55:04 -05:00
|
|
|
|
|
|
|
// ItemKeyHandler
|
|
|
|
if (asset->onKey)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2017-02-26 08:54:19 -05:00
|
|
|
this->save_ItemKeyHandler(asset->onKey, builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
Utils::Stream::ClearPointer(&dest->onKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Statement
|
|
|
|
STATEMENT(visibleExp);
|
|
|
|
|
|
|
|
// Strings
|
|
|
|
if (asset->allowedBinding)
|
|
|
|
{
|
|
|
|
buffer->saveString(asset->allowedBinding);
|
|
|
|
Utils::Stream::ClearPointer(&dest->allowedBinding);
|
|
|
|
}
|
2018-05-09 08:33:52 -04:00
|
|
|
if (asset->soundName)
|
2017-02-25 14:55:04 -05:00
|
|
|
{
|
2018-05-09 08:33:52 -04:00
|
|
|
buffer->saveString(asset->soundName);
|
|
|
|
Utils::Stream::ClearPointer(&dest->soundName);
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Statements
|
|
|
|
STATEMENT(rectXExp);
|
|
|
|
STATEMENT(rectYExp);
|
|
|
|
STATEMENT(rectHExp);
|
|
|
|
STATEMENT(rectWExp);
|
|
|
|
STATEMENT(openSoundExp);
|
|
|
|
STATEMENT(closeSoundExp);
|
|
|
|
|
|
|
|
// Items
|
|
|
|
if (asset->items)
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
|
|
|
buffer->saveArray(asset->items, asset->itemCount);
|
|
|
|
|
2017-04-24 16:33:13 -04:00
|
|
|
for (int i = 0; i < asset->itemCount; ++i)
|
2017-02-25 14:55:04 -05:00
|
|
|
{
|
|
|
|
if (asset->items[i])
|
|
|
|
{
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2018-05-09 08:33:52 -04:00
|
|
|
this->save_itemDef_s(asset->items[i], builder);
|
2017-02-25 14:55:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-19 11:28:36 -05:00
|
|
|
#ifdef WRITE_LOGS
|
2022-06-22 11:36:06 -04:00
|
|
|
buffer->leaveStruct();
|
2019-01-19 11:28:36 -05:00
|
|
|
#endif
|
2017-02-25 14:55:04 -05:00
|
|
|
|
|
|
|
buffer->popBlock();
|
|
|
|
}
|
|
|
|
}
|