mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
chore: make IZoneLoadingState return reference
This commit is contained in:
parent
fa6f9451d2
commit
9068e96dfa
@ -39,8 +39,8 @@ void AbstractImageIPakPostProcessor::FindNextObjContainer(AssetCreationContext&
|
|||||||
if (objContainer.m_type != ZoneDefinitionObjContainerType::IPAK)
|
if (objContainer.m_type != ZoneDefinitionObjContainerType::IPAK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto* ipakCreator = context.GetZoneAssetLoaderState<IPakCreator>();
|
auto& ipakCreator = context.GetZoneAssetLoaderState<IPakCreator>();
|
||||||
m_current_ipak = ipakCreator->GetOrAddIPak(objContainer.m_name);
|
m_current_ipak = ipakCreator.GetOrAddIPak(objContainer.m_name);
|
||||||
m_current_ipak_start_index = objContainer.m_asset_start;
|
m_current_ipak_start_index = objContainer.m_asset_start;
|
||||||
m_current_ipak_end_index = objContainer.m_asset_end;
|
m_current_ipak_end_index = objContainer.m_asset_end;
|
||||||
return;
|
return;
|
||||||
@ -70,5 +70,5 @@ void AbstractImageIPakPostProcessor::PostProcessAsset(XAssetInfoGeneric& assetIn
|
|||||||
|
|
||||||
void AbstractImageIPakPostProcessor::FinalizeZone(AssetCreationContext& context)
|
void AbstractImageIPakPostProcessor::FinalizeZone(AssetCreationContext& context)
|
||||||
{
|
{
|
||||||
context.GetZoneAssetLoaderState<IPakCreator>()->Finalize(m_search_path, m_out_dir);
|
context.GetZoneAssetLoaderState<IPakCreator>().Finalize(m_search_path, m_out_dir);
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ void AbstractImageIwdPostProcessor::FindNextObjContainer(AssetCreationContext& c
|
|||||||
if (objContainer.m_type != ZoneDefinitionObjContainerType::IWD)
|
if (objContainer.m_type != ZoneDefinitionObjContainerType::IWD)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto* iwdCreator = context.GetZoneAssetLoaderState<IwdCreator>();
|
auto& iwdCreator = context.GetZoneAssetLoaderState<IwdCreator>();
|
||||||
m_current_iwd = iwdCreator->GetOrAddIwd(objContainer.m_name);
|
m_current_iwd = iwdCreator.GetOrAddIwd(objContainer.m_name);
|
||||||
m_current_iwd_start_index = objContainer.m_asset_start;
|
m_current_iwd_start_index = objContainer.m_asset_start;
|
||||||
m_current_iwd_end_index = objContainer.m_asset_end;
|
m_current_iwd_end_index = objContainer.m_asset_end;
|
||||||
return;
|
return;
|
||||||
@ -71,5 +71,5 @@ void AbstractImageIwdPostProcessor::PostProcessAsset(XAssetInfoGeneric& assetInf
|
|||||||
|
|
||||||
void AbstractImageIwdPostProcessor::FinalizeZone(AssetCreationContext& context)
|
void AbstractImageIwdPostProcessor::FinalizeZone(AssetCreationContext& context)
|
||||||
{
|
{
|
||||||
context.GetZoneAssetLoaderState<IwdCreator>()->Finalize(m_search_path, m_out_dir);
|
context.GetZoneAssetLoaderState<IwdCreator>().Finalize(m_search_path, m_out_dir);
|
||||||
}
|
}
|
||||||
|
@ -32,20 +32,21 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> T* GetZoneAssetLoaderState()
|
template<typename T> T& GetZoneAssetLoaderState()
|
||||||
{
|
{
|
||||||
static_assert(std::is_base_of_v<IZoneAssetLoaderState, T>, "T must inherit IZoneAssetLoaderState");
|
static_assert(std::is_base_of_v<IZoneAssetLoaderState, T>, "T must inherit IZoneAssetLoaderState");
|
||||||
// T must also have a public default constructor
|
// T must also have a public default constructor
|
||||||
|
|
||||||
const auto foundEntry = m_zone_asset_loader_states.find(typeid(T));
|
const auto foundEntry = m_zone_asset_loader_states.find(typeid(T));
|
||||||
if (foundEntry != m_zone_asset_loader_states.end())
|
if (foundEntry != m_zone_asset_loader_states.end())
|
||||||
return dynamic_cast<T*>(foundEntry->second.get());
|
return *dynamic_cast<T*>(foundEntry->second.get());
|
||||||
|
|
||||||
auto newState = std::make_unique<T>();
|
auto newState = std::make_unique<T>();
|
||||||
newState->SetZone(&m_zone);
|
newState->SetZone(&m_zone);
|
||||||
auto* newStatePtr = newState.get();
|
auto* newStatePtr = newState.get();
|
||||||
m_zone_asset_loader_states.emplace(std::make_pair<std::type_index, std::unique_ptr<IZoneAssetLoaderState>>(typeid(T), std::move(newState)));
|
m_zone_asset_loader_states.emplace(std::make_pair<std::type_index, std::unique_ptr<IZoneAssetLoaderState>>(typeid(T), std::move(newState)));
|
||||||
return newStatePtr;
|
|
||||||
|
return *newStatePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -792,7 +792,7 @@ namespace
|
|||||||
m_registration.AddDependency(techset);
|
m_registration.AddDependency(techset);
|
||||||
m_material.techniqueSet = techset->Asset();
|
m_material.techniqueSet = techset->Asset();
|
||||||
|
|
||||||
auto* definitionCache = m_context.GetZoneAssetLoaderState<techset::TechsetDefinitionCache>();
|
auto& definitionCache = m_context.GetZoneAssetLoaderState<techset::TechsetDefinitionCache>();
|
||||||
|
|
||||||
bool failure = false;
|
bool failure = false;
|
||||||
const auto* techsetDefinition = m_techset_creator->LoadTechsetDefinition(techsetName, m_context, failure);
|
const auto* techsetDefinition = m_techset_creator->LoadTechsetDefinition(techsetName, m_context, failure);
|
||||||
@ -855,7 +855,7 @@ namespace
|
|||||||
|
|
||||||
_NODISCARD const state_map::StateMapDefinition* GetStateMapForTechnique(const std::string& techniqueName) const
|
_NODISCARD const state_map::StateMapDefinition* GetStateMapForTechnique(const std::string& techniqueName) const
|
||||||
{
|
{
|
||||||
const auto* preloadedStateMap = m_state_map_cache->GetStateMapForTechnique(techniqueName);
|
const auto* preloadedStateMap = m_state_map_cache.GetStateMapForTechnique(techniqueName);
|
||||||
if (preloadedStateMap)
|
if (preloadedStateMap)
|
||||||
return preloadedStateMap;
|
return preloadedStateMap;
|
||||||
|
|
||||||
@ -868,13 +868,13 @@ namespace
|
|||||||
const techset::TechniqueFileReader reader(*file.m_stream, techniqueFileName, &extractor);
|
const techset::TechniqueFileReader reader(*file.m_stream, techniqueFileName, &extractor);
|
||||||
if (!reader.ReadTechniqueDefinition())
|
if (!reader.ReadTechniqueDefinition())
|
||||||
{
|
{
|
||||||
m_state_map_cache->SetTechniqueUsesStateMap(techniqueName, nullptr);
|
m_state_map_cache.SetTechniqueUsesStateMap(techniqueName, nullptr);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto stateMapName = extractor.RetrieveStateMap();
|
const auto stateMapName = extractor.RetrieveStateMap();
|
||||||
const auto* loadedStateMap = m_techset_creator->LoadStateMapDefinition(stateMapName, m_context);
|
const auto* loadedStateMap = m_techset_creator->LoadStateMapDefinition(stateMapName, m_context);
|
||||||
m_state_map_cache->SetTechniqueUsesStateMap(techniqueName, loadedStateMap);
|
m_state_map_cache.SetTechniqueUsesStateMap(techniqueName, loadedStateMap);
|
||||||
|
|
||||||
return loadedStateMap;
|
return loadedStateMap;
|
||||||
}
|
}
|
||||||
@ -1306,7 +1306,7 @@ namespace
|
|||||||
AssetCreationContext& m_context;
|
AssetCreationContext& m_context;
|
||||||
AssetRegistration<AssetMaterial>& m_registration;
|
AssetRegistration<AssetMaterial>& m_registration;
|
||||||
|
|
||||||
techset::TechniqueStateMapCache* m_state_map_cache;
|
techset::TechniqueStateMapCache& m_state_map_cache;
|
||||||
std::unordered_map<const state_map::StateMapDefinition*, GfxStateBits> m_state_bits_per_state_map;
|
std::unordered_map<const state_map::StateMapDefinition*, GfxStateBits> m_state_bits_per_state_map;
|
||||||
|
|
||||||
GfxStateBits m_base_state_bits;
|
GfxStateBits m_base_state_bits;
|
||||||
|
@ -28,13 +28,13 @@ namespace
|
|||||||
std::vector<menuDef_t*> menus;
|
std::vector<menuDef_t*> menus;
|
||||||
AssetRegistration<AssetMenuList> registration(assetName);
|
AssetRegistration<AssetMenuList> registration(assetName);
|
||||||
|
|
||||||
auto* zoneState = context.GetZoneAssetLoaderState<menu::MenuAssetZoneState>();
|
auto& zoneState = context.GetZoneAssetLoaderState<menu::MenuAssetZoneState>();
|
||||||
auto* conversionState = context.GetZoneAssetLoaderState<MenuConversionZoneState>();
|
auto& conversionState = context.GetZoneAssetLoaderState<MenuConversionZoneState>();
|
||||||
|
|
||||||
std::deque<std::string> menuLoadQueue;
|
std::deque<std::string> menuLoadQueue;
|
||||||
const auto alreadyLoadedMenuListFileMenus = conversionState->m_menus_by_filename.find(assetName);
|
const auto alreadyLoadedMenuListFileMenus = conversionState.m_menus_by_filename.find(assetName);
|
||||||
|
|
||||||
if (alreadyLoadedMenuListFileMenus == conversionState->m_menus_by_filename.end())
|
if (alreadyLoadedMenuListFileMenus == conversionState.m_menus_by_filename.end())
|
||||||
{
|
{
|
||||||
const auto file = m_search_path.Open(assetName);
|
const auto file = m_search_path.Open(assetName);
|
||||||
if (!file.IsOpen())
|
if (!file.IsOpen())
|
||||||
@ -43,12 +43,12 @@ namespace
|
|||||||
const auto menuListResult = ParseMenuFile(*file.m_stream, assetName, zoneState);
|
const auto menuListResult = ParseMenuFile(*file.m_stream, assetName, zoneState);
|
||||||
if (menuListResult)
|
if (menuListResult)
|
||||||
{
|
{
|
||||||
ProcessParsedResults(assetName, context, menuListResult.get(), zoneState, conversionState, menus, registration);
|
ProcessParsedResults(assetName, context, *menuListResult, zoneState, conversionState, menus, registration);
|
||||||
|
|
||||||
for (const auto& menuToLoad : menuListResult->m_menus_to_load)
|
for (const auto& menuToLoad : menuListResult->m_menus_to_load)
|
||||||
menuLoadQueue.emplace_back(menuToLoad);
|
menuLoadQueue.emplace_back(menuToLoad);
|
||||||
|
|
||||||
zoneState->AddMenusToLoad(assetName, std::move(menuListResult->m_menus_to_load));
|
zoneState.AddMenusToLoad(assetName, std::move(menuListResult->m_menus_to_load));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return AssetCreationResult::Failure();
|
return AssetCreationResult::Failure();
|
||||||
@ -74,19 +74,19 @@ namespace
|
|||||||
|
|
||||||
void FinalizeZone(AssetCreationContext& context) override
|
void FinalizeZone(AssetCreationContext& context) override
|
||||||
{
|
{
|
||||||
context.GetZoneAssetLoaderState<MenuConversionZoneState>()->FinalizeSupportingData();
|
context.GetZoneAssetLoaderState<MenuConversionZoneState>().FinalizeSupportingData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool LoadMenuFileFromQueue(const std::string& menuFilePath,
|
bool LoadMenuFileFromQueue(const std::string& menuFilePath,
|
||||||
AssetCreationContext& context,
|
AssetCreationContext& context,
|
||||||
menu::MenuAssetZoneState* zoneState,
|
menu::MenuAssetZoneState& zoneState,
|
||||||
MenuConversionZoneState* conversionState,
|
MenuConversionZoneState& conversionState,
|
||||||
std::vector<menuDef_t*>& menus,
|
std::vector<menuDef_t*>& menus,
|
||||||
AssetRegistration<AssetMenuList>& registration)
|
AssetRegistration<AssetMenuList>& registration)
|
||||||
{
|
{
|
||||||
const auto alreadyLoadedMenuFile = conversionState->m_menus_by_filename.find(menuFilePath);
|
const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath);
|
||||||
if (alreadyLoadedMenuFile != conversionState->m_menus_by_filename.end())
|
if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end())
|
||||||
{
|
{
|
||||||
std::cout << std::format("Already loaded \"{}\", skipping\n", menuFilePath);
|
std::cout << std::format("Already loaded \"{}\", skipping\n", menuFilePath);
|
||||||
for (auto* menu : alreadyLoadedMenuFile->second)
|
for (auto* menu : alreadyLoadedMenuFile->second)
|
||||||
@ -107,7 +107,7 @@ namespace
|
|||||||
const auto menuFileResult = ParseMenuFile(*file.m_stream, menuFilePath, zoneState);
|
const auto menuFileResult = ParseMenuFile(*file.m_stream, menuFilePath, zoneState);
|
||||||
if (menuFileResult)
|
if (menuFileResult)
|
||||||
{
|
{
|
||||||
ProcessParsedResults(menuFilePath, context, menuFileResult.get(), zoneState, conversionState, menus, registration);
|
ProcessParsedResults(menuFilePath, context, *menuFileResult, zoneState, conversionState, menus, registration);
|
||||||
if (!menuFileResult->m_menus_to_load.empty())
|
if (!menuFileResult->m_menus_to_load.empty())
|
||||||
std::cout << std::format("WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"{}\"\n", menuFilePath);
|
std::cout << std::format("WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"{}\"\n", menuFilePath);
|
||||||
|
|
||||||
@ -121,17 +121,17 @@ namespace
|
|||||||
|
|
||||||
bool ProcessParsedResults(const std::string& fileName,
|
bool ProcessParsedResults(const std::string& fileName,
|
||||||
AssetCreationContext& context,
|
AssetCreationContext& context,
|
||||||
menu::ParsingResult* parsingResult,
|
menu::ParsingResult& parsingResult,
|
||||||
menu::MenuAssetZoneState* zoneState,
|
menu::MenuAssetZoneState& zoneState,
|
||||||
MenuConversionZoneState* conversionState,
|
MenuConversionZoneState& conversionState,
|
||||||
std::vector<menuDef_t*>& menus,
|
std::vector<menuDef_t*>& menus,
|
||||||
AssetRegistration<AssetMenuList>& registration)
|
AssetRegistration<AssetMenuList>& registration)
|
||||||
{
|
{
|
||||||
const auto menuCount = parsingResult->m_menus.size();
|
const auto menuCount = parsingResult.m_menus.size();
|
||||||
const auto functionCount = parsingResult->m_functions.size();
|
const auto functionCount = parsingResult.m_functions.size();
|
||||||
const auto menuLoadCount = parsingResult->m_menus_to_load.size();
|
const auto menuLoadCount = parsingResult.m_menus_to_load.size();
|
||||||
auto totalItemCount = 0u;
|
auto totalItemCount = 0u;
|
||||||
for (const auto& menu : parsingResult->m_menus)
|
for (const auto& menu : parsingResult.m_menus)
|
||||||
totalItemCount += menu->m_items.size();
|
totalItemCount += menu->m_items.size();
|
||||||
|
|
||||||
std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n",
|
std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n",
|
||||||
@ -142,15 +142,15 @@ namespace
|
|||||||
totalItemCount);
|
totalItemCount);
|
||||||
|
|
||||||
// Add all functions to the zone state to make them available for all menus to be converted
|
// Add all functions to the zone state to make them available for all menus to be converted
|
||||||
for (auto& function : parsingResult->m_functions)
|
for (auto& function : parsingResult.m_functions)
|
||||||
zoneState->AddFunction(std::move(function));
|
zoneState.AddFunction(std::move(function));
|
||||||
|
|
||||||
// Prepare a list of all menus of this file
|
// Prepare a list of all menus of this file
|
||||||
std::vector<XAssetInfo<menuDef_t>*> allMenusOfFile;
|
std::vector<XAssetInfo<menuDef_t>*> allMenusOfFile;
|
||||||
allMenusOfFile.reserve(parsingResult->m_menus.size());
|
allMenusOfFile.reserve(parsingResult.m_menus.size());
|
||||||
|
|
||||||
// Convert all menus and add them as assets
|
// Convert all menus and add them as assets
|
||||||
for (auto& commonMenu : parsingResult->m_menus)
|
for (auto& commonMenu : parsingResult.m_menus)
|
||||||
{
|
{
|
||||||
auto converter = IMenuConverter::Create(ObjLoading::Configuration.MenuNoOptimization, m_search_path, m_memory, context);
|
auto converter = IMenuConverter::Create(ObjLoading::Configuration.MenuNoOptimization, m_search_path, m_memory, context);
|
||||||
|
|
||||||
@ -173,11 +173,11 @@ namespace
|
|||||||
registration.AddDependency(menuAssetInfo);
|
registration.AddDependency(menuAssetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
zoneState->AddMenu(std::move(commonMenu));
|
zoneState.AddMenu(std::move(commonMenu));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register this file with all loaded menus
|
// Register this file with all loaded menus
|
||||||
conversionState->AddLoadedFile(fileName, std::move(allMenusOfFile));
|
conversionState.AddLoadedFile(fileName, std::move(allMenusOfFile));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ namespace
|
|||||||
menuList.menus = nullptr;
|
menuList.menus = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState* zoneState)
|
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState)
|
||||||
{
|
{
|
||||||
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW4, m_search_path);
|
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW4, m_search_path);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ namespace
|
|||||||
staticDvarIndexEntry.type = EET_OPERAND;
|
staticDvarIndexEntry.type = EET_OPERAND;
|
||||||
staticDvarIndexEntry.data.operand.dataType = VAL_INT;
|
staticDvarIndexEntry.data.operand.dataType = VAL_INT;
|
||||||
staticDvarIndexEntry.data.operand.internals.intVal =
|
staticDvarIndexEntry.data.operand.internals.intVal =
|
||||||
static_cast<int>(m_conversion_zone_state->AddStaticDvar(*staticDvarNameExpressionValue.m_string_value));
|
static_cast<int>(m_conversion_zone_state.AddStaticDvar(*staticDvarNameExpressionValue.m_string_value));
|
||||||
entries.emplace_back(staticDvarIndexEntry);
|
entries.emplace_back(staticDvarIndexEntry);
|
||||||
|
|
||||||
expressionEntry parenRight{};
|
expressionEntry parenRight{};
|
||||||
@ -133,7 +133,7 @@ namespace
|
|||||||
parenRight.data.op = OP_RIGHTPAREN;
|
parenRight.data.op = OP_RIGHTPAREN;
|
||||||
entries.emplace_back(parenRight);
|
entries.emplace_back(parenRight);
|
||||||
|
|
||||||
gameStatement->supportingData = m_conversion_zone_state->m_supporting_data;
|
gameStatement->supportingData = m_conversion_zone_state.m_supporting_data;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -206,18 +206,18 @@ namespace
|
|||||||
std::string lowerCaseFunctionName(functionCall->m_function_name);
|
std::string lowerCaseFunctionName(functionCall->m_function_name);
|
||||||
utils::MakeStringLowerCase(lowerCaseFunctionName);
|
utils::MakeStringLowerCase(lowerCaseFunctionName);
|
||||||
|
|
||||||
Statement_s* functionStatement = m_conversion_zone_state->FindFunction(lowerCaseFunctionName);
|
Statement_s* functionStatement = m_conversion_zone_state.FindFunction(lowerCaseFunctionName);
|
||||||
|
|
||||||
if (functionStatement == nullptr)
|
if (functionStatement == nullptr)
|
||||||
{
|
{
|
||||||
// Function was not converted yet: Convert it now
|
// Function was not converted yet: Convert it now
|
||||||
const auto foundCommonFunction = m_parsing_zone_state->m_functions_by_name.find(lowerCaseFunctionName);
|
const auto foundCommonFunction = m_parsing_zone_state.m_functions_by_name.find(lowerCaseFunctionName);
|
||||||
|
|
||||||
if (foundCommonFunction == m_parsing_zone_state->m_functions_by_name.end())
|
if (foundCommonFunction == m_parsing_zone_state.m_functions_by_name.end())
|
||||||
throw MenuConversionException("Failed to find definition for custom function \"" + functionCall->m_function_name + "\"", menu, item);
|
throw MenuConversionException("Failed to find definition for custom function \"" + functionCall->m_function_name + "\"", menu, item);
|
||||||
|
|
||||||
functionStatement = ConvertExpression(foundCommonFunction->second->m_value.get(), menu, item);
|
functionStatement = ConvertExpression(foundCommonFunction->second->m_value.get(), menu, item);
|
||||||
functionStatement = m_conversion_zone_state->AddFunction(foundCommonFunction->second->m_name, functionStatement);
|
functionStatement = m_conversion_zone_state.AddFunction(foundCommonFunction->second->m_name, functionStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
expressionEntry functionEntry{};
|
expressionEntry functionEntry{};
|
||||||
@ -227,7 +227,7 @@ namespace
|
|||||||
entries.emplace_back(functionEntry);
|
entries.emplace_back(functionEntry);
|
||||||
|
|
||||||
// Statement uses custom function so it needs supporting data
|
// Statement uses custom function so it needs supporting data
|
||||||
gameStatement->supportingData = m_conversion_zone_state->m_supporting_data;
|
gameStatement->supportingData = m_conversion_zone_state.m_supporting_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr static expressionOperatorType_e UNARY_OPERATION_MAPPING[static_cast<unsigned>(SimpleUnaryOperationId::COUNT)]{
|
constexpr static expressionOperatorType_e UNARY_OPERATION_MAPPING[static_cast<unsigned>(SimpleUnaryOperationId::COUNT)]{
|
||||||
@ -361,7 +361,7 @@ namespace
|
|||||||
else if (expressionValue->m_type == SimpleExpressionValue::Type::STRING)
|
else if (expressionValue->m_type == SimpleExpressionValue::Type::STRING)
|
||||||
{
|
{
|
||||||
entry.data.operand.dataType = VAL_STRING;
|
entry.data.operand.dataType = VAL_STRING;
|
||||||
entry.data.operand.internals.stringVal.string = m_conversion_zone_state->AddString(*expressionValue->m_string_value);
|
entry.data.operand.internals.stringVal.string = m_conversion_zone_state.AddString(*expressionValue->m_string_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.emplace_back(entry);
|
entries.emplace_back(entry);
|
||||||
@ -1115,8 +1115,6 @@ namespace
|
|||||||
m_conversion_zone_state(context.GetZoneAssetLoaderState<MenuConversionZoneState>()),
|
m_conversion_zone_state(context.GetZoneAssetLoaderState<MenuConversionZoneState>()),
|
||||||
m_parsing_zone_state(context.GetZoneAssetLoaderState<MenuAssetZoneState>())
|
m_parsing_zone_state(context.GetZoneAssetLoaderState<MenuAssetZoneState>())
|
||||||
{
|
{
|
||||||
assert(m_conversion_zone_state);
|
|
||||||
assert(m_parsing_zone_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration<AssetMenu>& registration) override
|
void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration<AssetMenu>& registration) override
|
||||||
@ -1165,7 +1163,7 @@ namespace
|
|||||||
menu.onESC = ConvertEventHandlerSet(commonMenu.m_on_esc.get(), &commonMenu);
|
menu.onESC = ConvertEventHandlerSet(commonMenu.m_on_esc.get(), &commonMenu);
|
||||||
menu.onKey = ConvertKeyHandler(commonMenu.m_key_handlers, &commonMenu);
|
menu.onKey = ConvertKeyHandler(commonMenu.m_key_handlers, &commonMenu);
|
||||||
menu.items = ConvertMenuItems(commonMenu, menu.itemCount);
|
menu.items = ConvertMenuItems(commonMenu, menu.itemCount);
|
||||||
menu.expressionData = m_conversion_zone_state->m_supporting_data;
|
menu.expressionData = m_conversion_zone_state.m_supporting_data;
|
||||||
}
|
}
|
||||||
catch (const MenuConversionException& e)
|
catch (const MenuConversionException& e)
|
||||||
{
|
{
|
||||||
@ -1173,8 +1171,8 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuConversionZoneState* m_conversion_zone_state;
|
MenuConversionZoneState& m_conversion_zone_state;
|
||||||
MenuAssetZoneState* m_parsing_zone_state;
|
MenuAssetZoneState& m_parsing_zone_state;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ namespace
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_state_map_cache->SetTechniqueUsesStateMap(m_technique_name, stateMap);
|
m_state_map_cache.SetTechniqueUsesStateMap(m_technique_name, stateMap);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ namespace
|
|||||||
|
|
||||||
if (pass.m_vertex_shader->Asset()->name && pass.m_vertex_shader->Asset()->name[0] == ',')
|
if (pass.m_vertex_shader->Asset()->name && pass.m_vertex_shader->Asset()->name[0] == ',')
|
||||||
{
|
{
|
||||||
pass.m_vertex_shader_info = m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, GetVertexShaderFileName(vertexShaderName));
|
pass.m_vertex_shader_info = m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, GetVertexShaderFileName(vertexShaderName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -498,7 +498,7 @@ namespace
|
|||||||
|
|
||||||
if (pass.m_pixel_shader->Asset()->name && pass.m_pixel_shader->Asset()->name[0] == ',')
|
if (pass.m_pixel_shader->Asset()->name && pass.m_pixel_shader->Asset()->name[0] == ',')
|
||||||
{
|
{
|
||||||
pass.m_pixel_shader_info = m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, GetPixelShaderFileName(pixelShaderName));
|
pass.m_pixel_shader_info = m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, GetPixelShaderFileName(pixelShaderName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -901,7 +901,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
argument.dest = static_cast<uint16_t>(shaderConstant.m_register_index + registerOffset);
|
argument.dest = static_cast<uint16_t>(shaderConstant.m_register_index + registerOffset);
|
||||||
argument.u.literalConst = m_zone_state->GetAllocatedLiteral(m_memory, source);
|
argument.u.literalConst = m_zone_state.GetAllocatedLiteral(m_memory, source);
|
||||||
pass.m_arguments.emplace_back(argument);
|
pass.m_arguments.emplace_back(argument);
|
||||||
|
|
||||||
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
||||||
@ -1021,9 +1021,9 @@ namespace
|
|||||||
ISearchPath& m_search_path;
|
ISearchPath& m_search_path;
|
||||||
MemoryManager& m_memory;
|
MemoryManager& m_memory;
|
||||||
AssetCreationContext& m_context;
|
AssetCreationContext& m_context;
|
||||||
TechniqueZoneLoadingState* m_zone_state;
|
TechniqueZoneLoadingState& m_zone_state;
|
||||||
techset::TechniqueStateMapCache* m_state_map_cache;
|
techset::TechniqueStateMapCache& m_state_map_cache;
|
||||||
ShaderInfoFromFileSystemCacheState* m_shader_info_cache;
|
ShaderInfoFromFileSystemCacheState& m_shader_info_cache;
|
||||||
ITechsetCreator* m_techset_creator;
|
ITechsetCreator* m_techset_creator;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1041,7 +1041,7 @@ namespace
|
|||||||
|
|
||||||
_NODISCARD const LoadedTechnique* LoadMaterialTechnique(const std::string& techniqueName) const
|
_NODISCARD const LoadedTechnique* LoadMaterialTechnique(const std::string& techniqueName) const
|
||||||
{
|
{
|
||||||
auto* technique = m_zone_state->FindLoadedTechnique(techniqueName);
|
auto* technique = m_zone_state.FindLoadedTechnique(techniqueName);
|
||||||
if (technique)
|
if (technique)
|
||||||
return technique;
|
return technique;
|
||||||
|
|
||||||
@ -1050,7 +1050,7 @@ namespace
|
|||||||
if (techniqueFromRaw == nullptr)
|
if (techniqueFromRaw == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return m_zone_state->AddLoadedTechnique(techniqueName, techniqueFromRaw, dependencies);
|
return m_zone_state.AddLoadedTechnique(techniqueName, techniqueFromRaw, dependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1257,7 +1257,7 @@ namespace
|
|||||||
ISearchPath& m_search_path;
|
ISearchPath& m_search_path;
|
||||||
MemoryManager& m_memory;
|
MemoryManager& m_memory;
|
||||||
AssetCreationContext& m_context;
|
AssetCreationContext& m_context;
|
||||||
TechniqueZoneLoadingState* m_zone_state;
|
TechniqueZoneLoadingState& m_zone_state;
|
||||||
ITechsetCreator* m_techset_creator;
|
ITechsetCreator* m_techset_creator;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1313,8 +1313,8 @@ namespace
|
|||||||
techset::TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) override
|
techset::TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) override
|
||||||
{
|
{
|
||||||
failure = false;
|
failure = false;
|
||||||
auto* definitionCache = context.GetZoneAssetLoaderState<techset::TechsetDefinitionCache>();
|
auto& definitionCache = context.GetZoneAssetLoaderState<techset::TechsetDefinitionCache>();
|
||||||
auto* cachedTechsetDefinition = definitionCache->GetCachedTechsetDefinition(assetName);
|
auto* cachedTechsetDefinition = definitionCache.GetCachedTechsetDefinition(assetName);
|
||||||
if (cachedTechsetDefinition)
|
if (cachedTechsetDefinition)
|
||||||
return cachedTechsetDefinition;
|
return cachedTechsetDefinition;
|
||||||
|
|
||||||
@ -1333,15 +1333,15 @@ namespace
|
|||||||
|
|
||||||
auto* techsetDefinitionPtr = techsetDefinition.get();
|
auto* techsetDefinitionPtr = techsetDefinition.get();
|
||||||
|
|
||||||
definitionCache->AddTechsetDefinitionToCache(assetName, std::move(techsetDefinition));
|
definitionCache.AddTechsetDefinitionToCache(assetName, std::move(techsetDefinition));
|
||||||
|
|
||||||
return techsetDefinitionPtr;
|
return techsetDefinitionPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, AssetCreationContext& context) override
|
const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, AssetCreationContext& context) override
|
||||||
{
|
{
|
||||||
auto* stateMapCache = context.GetZoneAssetLoaderState<techset::TechniqueStateMapCache>();
|
auto& stateMapCache = context.GetZoneAssetLoaderState<techset::TechniqueStateMapCache>();
|
||||||
auto* cachedStateMap = stateMapCache->GetCachedStateMap(stateMapName);
|
auto* cachedStateMap = stateMapCache.GetCachedStateMap(stateMapName);
|
||||||
if (cachedStateMap)
|
if (cachedStateMap)
|
||||||
return cachedStateMap;
|
return cachedStateMap;
|
||||||
|
|
||||||
@ -1357,7 +1357,7 @@ namespace
|
|||||||
|
|
||||||
const auto* stateMapDefinitionPtr = stateMapDefinition.get();
|
const auto* stateMapDefinitionPtr = stateMapDefinition.get();
|
||||||
|
|
||||||
stateMapCache->AddStateMapToCache(std::move(stateMapDefinition));
|
stateMapCache.AddStateMapToCache(std::move(stateMapDefinition));
|
||||||
|
|
||||||
return stateMapDefinitionPtr;
|
return stateMapDefinitionPtr;
|
||||||
}
|
}
|
||||||
|
@ -392,11 +392,11 @@ namespace
|
|||||||
|
|
||||||
bool LoadAccuracyGraphs(WeaponFullDef& weaponFullDef, MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context)
|
bool LoadAccuracyGraphs(WeaponFullDef& weaponFullDef, MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context)
|
||||||
{
|
{
|
||||||
auto* accuracyGraphLoader = context.GetZoneAssetLoaderState<AccuracyGraphLoader>();
|
auto& accuracyGraphLoader = context.GetZoneAssetLoaderState<AccuracyGraphLoader>();
|
||||||
|
|
||||||
if (weaponFullDef.weapDef.aiVsAiAccuracyGraphName && weaponFullDef.weapDef.aiVsAiAccuracyGraphName[0])
|
if (weaponFullDef.weapDef.aiVsAiAccuracyGraphName && weaponFullDef.weapDef.aiVsAiAccuracyGraphName[0])
|
||||||
{
|
{
|
||||||
const auto* graph = accuracyGraphLoader->LoadAiVsAiGraph(searchPath, weaponFullDef.weapDef.aiVsAiAccuracyGraphName);
|
const auto* graph = accuracyGraphLoader.LoadAiVsAiGraph(searchPath, weaponFullDef.weapDef.aiVsAiAccuracyGraphName);
|
||||||
if (!graph)
|
if (!graph)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ namespace
|
|||||||
|
|
||||||
if (weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName && weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName[0])
|
if (weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName && weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName[0])
|
||||||
{
|
{
|
||||||
const auto* graph = accuracyGraphLoader->LoadAiVsPlayerGraph(searchPath, weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName);
|
const auto* graph = accuracyGraphLoader.LoadAiVsPlayerGraph(searchPath, weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName);
|
||||||
if (!graph)
|
if (!graph)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -28,13 +28,13 @@ namespace
|
|||||||
std::vector<menuDef_t*> menus;
|
std::vector<menuDef_t*> menus;
|
||||||
AssetRegistration<AssetMenuList> registration(assetName);
|
AssetRegistration<AssetMenuList> registration(assetName);
|
||||||
|
|
||||||
auto* zoneState = context.GetZoneAssetLoaderState<menu::MenuAssetZoneState>();
|
auto& zoneState = context.GetZoneAssetLoaderState<menu::MenuAssetZoneState>();
|
||||||
auto* conversionState = context.GetZoneAssetLoaderState<MenuConversionZoneState>();
|
auto& conversionState = context.GetZoneAssetLoaderState<MenuConversionZoneState>();
|
||||||
|
|
||||||
std::deque<std::string> menuLoadQueue;
|
std::deque<std::string> menuLoadQueue;
|
||||||
const auto alreadyLoadedMenuListFileMenus = conversionState->m_menus_by_filename.find(assetName);
|
const auto alreadyLoadedMenuListFileMenus = conversionState.m_menus_by_filename.find(assetName);
|
||||||
|
|
||||||
if (alreadyLoadedMenuListFileMenus == conversionState->m_menus_by_filename.end())
|
if (alreadyLoadedMenuListFileMenus == conversionState.m_menus_by_filename.end())
|
||||||
{
|
{
|
||||||
const auto file = m_search_path.Open(assetName);
|
const auto file = m_search_path.Open(assetName);
|
||||||
if (!file.IsOpen())
|
if (!file.IsOpen())
|
||||||
@ -43,12 +43,12 @@ namespace
|
|||||||
const auto menuListResult = ParseMenuFile(*file.m_stream, assetName, zoneState);
|
const auto menuListResult = ParseMenuFile(*file.m_stream, assetName, zoneState);
|
||||||
if (menuListResult)
|
if (menuListResult)
|
||||||
{
|
{
|
||||||
ProcessParsedResults(assetName, context, menuListResult.get(), zoneState, conversionState, menus, registration);
|
ProcessParsedResults(assetName, context, *menuListResult, zoneState, conversionState, menus, registration);
|
||||||
|
|
||||||
for (const auto& menuToLoad : menuListResult->m_menus_to_load)
|
for (const auto& menuToLoad : menuListResult->m_menus_to_load)
|
||||||
menuLoadQueue.emplace_back(menuToLoad);
|
menuLoadQueue.emplace_back(menuToLoad);
|
||||||
|
|
||||||
zoneState->AddMenusToLoad(assetName, std::move(menuListResult->m_menus_to_load));
|
zoneState.AddMenusToLoad(assetName, std::move(menuListResult->m_menus_to_load));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return AssetCreationResult::Failure();
|
return AssetCreationResult::Failure();
|
||||||
@ -74,19 +74,19 @@ namespace
|
|||||||
|
|
||||||
void FinalizeZone(AssetCreationContext& context) override
|
void FinalizeZone(AssetCreationContext& context) override
|
||||||
{
|
{
|
||||||
context.GetZoneAssetLoaderState<MenuConversionZoneState>()->FinalizeSupportingData();
|
context.GetZoneAssetLoaderState<MenuConversionZoneState>().FinalizeSupportingData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool LoadMenuFileFromQueue(const std::string& menuFilePath,
|
bool LoadMenuFileFromQueue(const std::string& menuFilePath,
|
||||||
AssetCreationContext& context,
|
AssetCreationContext& context,
|
||||||
menu::MenuAssetZoneState* zoneState,
|
menu::MenuAssetZoneState& zoneState,
|
||||||
MenuConversionZoneState* conversionState,
|
MenuConversionZoneState& conversionState,
|
||||||
std::vector<menuDef_t*>& menus,
|
std::vector<menuDef_t*>& menus,
|
||||||
AssetRegistration<AssetMenuList>& registration)
|
AssetRegistration<AssetMenuList>& registration)
|
||||||
{
|
{
|
||||||
const auto alreadyLoadedMenuFile = conversionState->m_menus_by_filename.find(menuFilePath);
|
const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath);
|
||||||
if (alreadyLoadedMenuFile != conversionState->m_menus_by_filename.end())
|
if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end())
|
||||||
{
|
{
|
||||||
std::cout << std::format("Already loaded \"{}\", skipping\n", menuFilePath);
|
std::cout << std::format("Already loaded \"{}\", skipping\n", menuFilePath);
|
||||||
for (auto* menu : alreadyLoadedMenuFile->second)
|
for (auto* menu : alreadyLoadedMenuFile->second)
|
||||||
@ -107,7 +107,7 @@ namespace
|
|||||||
const auto menuFileResult = ParseMenuFile(*file.m_stream, menuFilePath, zoneState);
|
const auto menuFileResult = ParseMenuFile(*file.m_stream, menuFilePath, zoneState);
|
||||||
if (menuFileResult)
|
if (menuFileResult)
|
||||||
{
|
{
|
||||||
ProcessParsedResults(menuFilePath, context, menuFileResult.get(), zoneState, conversionState, menus, registration);
|
ProcessParsedResults(menuFilePath, context, *menuFileResult, zoneState, conversionState, menus, registration);
|
||||||
if (!menuFileResult->m_menus_to_load.empty())
|
if (!menuFileResult->m_menus_to_load.empty())
|
||||||
std::cout << std::format("WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"{}\"\n", menuFilePath);
|
std::cout << std::format("WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"{}\"\n", menuFilePath);
|
||||||
|
|
||||||
@ -121,17 +121,17 @@ namespace
|
|||||||
|
|
||||||
bool ProcessParsedResults(const std::string& fileName,
|
bool ProcessParsedResults(const std::string& fileName,
|
||||||
AssetCreationContext& context,
|
AssetCreationContext& context,
|
||||||
menu::ParsingResult* parsingResult,
|
menu::ParsingResult& parsingResult,
|
||||||
menu::MenuAssetZoneState* zoneState,
|
menu::MenuAssetZoneState& zoneState,
|
||||||
MenuConversionZoneState* conversionState,
|
MenuConversionZoneState& conversionState,
|
||||||
std::vector<menuDef_t*>& menus,
|
std::vector<menuDef_t*>& menus,
|
||||||
AssetRegistration<AssetMenuList>& registration)
|
AssetRegistration<AssetMenuList>& registration)
|
||||||
{
|
{
|
||||||
const auto menuCount = parsingResult->m_menus.size();
|
const auto menuCount = parsingResult.m_menus.size();
|
||||||
const auto functionCount = parsingResult->m_functions.size();
|
const auto functionCount = parsingResult.m_functions.size();
|
||||||
const auto menuLoadCount = parsingResult->m_menus_to_load.size();
|
const auto menuLoadCount = parsingResult.m_menus_to_load.size();
|
||||||
auto totalItemCount = 0u;
|
auto totalItemCount = 0u;
|
||||||
for (const auto& menu : parsingResult->m_menus)
|
for (const auto& menu : parsingResult.m_menus)
|
||||||
totalItemCount += menu->m_items.size();
|
totalItemCount += menu->m_items.size();
|
||||||
|
|
||||||
std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n",
|
std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n",
|
||||||
@ -142,15 +142,15 @@ namespace
|
|||||||
totalItemCount);
|
totalItemCount);
|
||||||
|
|
||||||
// Add all functions to the zone state to make them available for all menus to be converted
|
// Add all functions to the zone state to make them available for all menus to be converted
|
||||||
for (auto& function : parsingResult->m_functions)
|
for (auto& function : parsingResult.m_functions)
|
||||||
zoneState->AddFunction(std::move(function));
|
zoneState.AddFunction(std::move(function));
|
||||||
|
|
||||||
// Prepare a list of all menus of this file
|
// Prepare a list of all menus of this file
|
||||||
std::vector<XAssetInfo<menuDef_t>*> allMenusOfFile;
|
std::vector<XAssetInfo<menuDef_t>*> allMenusOfFile;
|
||||||
allMenusOfFile.reserve(parsingResult->m_menus.size());
|
allMenusOfFile.reserve(parsingResult.m_menus.size());
|
||||||
|
|
||||||
// Convert all menus and add them as assets
|
// Convert all menus and add them as assets
|
||||||
for (auto& commonMenu : parsingResult->m_menus)
|
for (auto& commonMenu : parsingResult.m_menus)
|
||||||
{
|
{
|
||||||
auto converter = IMenuConverter::Create(ObjLoading::Configuration.MenuNoOptimization, m_search_path, m_memory, context);
|
auto converter = IMenuConverter::Create(ObjLoading::Configuration.MenuNoOptimization, m_search_path, m_memory, context);
|
||||||
|
|
||||||
@ -173,11 +173,11 @@ namespace
|
|||||||
registration.AddDependency(menuAssetInfo);
|
registration.AddDependency(menuAssetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
zoneState->AddMenu(std::move(commonMenu));
|
zoneState.AddMenu(std::move(commonMenu));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register this file with all loaded menus
|
// Register this file with all loaded menus
|
||||||
conversionState->AddLoadedFile(fileName, std::move(allMenusOfFile));
|
conversionState.AddLoadedFile(fileName, std::move(allMenusOfFile));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ namespace
|
|||||||
menuList.menus = nullptr;
|
menuList.menus = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState* zoneState)
|
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState)
|
||||||
{
|
{
|
||||||
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW5, m_search_path);
|
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW5, m_search_path);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ namespace
|
|||||||
staticDvarIndexEntry.type = EET_OPERAND;
|
staticDvarIndexEntry.type = EET_OPERAND;
|
||||||
staticDvarIndexEntry.data.operand.dataType = VAL_INT;
|
staticDvarIndexEntry.data.operand.dataType = VAL_INT;
|
||||||
staticDvarIndexEntry.data.operand.internals.intVal =
|
staticDvarIndexEntry.data.operand.internals.intVal =
|
||||||
static_cast<int>(m_conversion_zone_state->AddStaticDvar(*staticDvarNameExpressionValue.m_string_value));
|
static_cast<int>(m_conversion_zone_state.AddStaticDvar(*staticDvarNameExpressionValue.m_string_value));
|
||||||
entries.emplace_back(staticDvarIndexEntry);
|
entries.emplace_back(staticDvarIndexEntry);
|
||||||
|
|
||||||
expressionEntry parenRight{};
|
expressionEntry parenRight{};
|
||||||
@ -133,7 +133,7 @@ namespace
|
|||||||
parenRight.data.op = OP_RIGHTPAREN;
|
parenRight.data.op = OP_RIGHTPAREN;
|
||||||
entries.emplace_back(parenRight);
|
entries.emplace_back(parenRight);
|
||||||
|
|
||||||
gameStatement->supportingData = m_conversion_zone_state->m_supporting_data;
|
gameStatement->supportingData = m_conversion_zone_state.m_supporting_data;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -206,18 +206,18 @@ namespace
|
|||||||
std::string lowerCaseFunctionName(functionCall->m_function_name);
|
std::string lowerCaseFunctionName(functionCall->m_function_name);
|
||||||
utils::MakeStringLowerCase(lowerCaseFunctionName);
|
utils::MakeStringLowerCase(lowerCaseFunctionName);
|
||||||
|
|
||||||
Statement_s* functionStatement = m_conversion_zone_state->FindFunction(lowerCaseFunctionName);
|
Statement_s* functionStatement = m_conversion_zone_state.FindFunction(lowerCaseFunctionName);
|
||||||
|
|
||||||
if (functionStatement == nullptr)
|
if (functionStatement == nullptr)
|
||||||
{
|
{
|
||||||
// Function was not converted yet: Convert it now
|
// Function was not converted yet: Convert it now
|
||||||
const auto foundCommonFunction = m_parsing_zone_state->m_functions_by_name.find(lowerCaseFunctionName);
|
const auto foundCommonFunction = m_parsing_zone_state.m_functions_by_name.find(lowerCaseFunctionName);
|
||||||
|
|
||||||
if (foundCommonFunction == m_parsing_zone_state->m_functions_by_name.end())
|
if (foundCommonFunction == m_parsing_zone_state.m_functions_by_name.end())
|
||||||
throw MenuConversionException("Failed to find definition for custom function \"" + functionCall->m_function_name + "\"", menu, item);
|
throw MenuConversionException("Failed to find definition for custom function \"" + functionCall->m_function_name + "\"", menu, item);
|
||||||
|
|
||||||
functionStatement = ConvertExpression(foundCommonFunction->second->m_value.get(), menu, item);
|
functionStatement = ConvertExpression(foundCommonFunction->second->m_value.get(), menu, item);
|
||||||
functionStatement = m_conversion_zone_state->AddFunction(lowerCaseFunctionName, functionStatement);
|
functionStatement = m_conversion_zone_state.AddFunction(lowerCaseFunctionName, functionStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
expressionEntry functionEntry{};
|
expressionEntry functionEntry{};
|
||||||
@ -227,7 +227,7 @@ namespace
|
|||||||
entries.emplace_back(functionEntry);
|
entries.emplace_back(functionEntry);
|
||||||
|
|
||||||
// Statement uses custom function so it needs supporting data
|
// Statement uses custom function so it needs supporting data
|
||||||
gameStatement->supportingData = m_conversion_zone_state->m_supporting_data;
|
gameStatement->supportingData = m_conversion_zone_state.m_supporting_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr static expressionOperatorType_e UNARY_OPERATION_MAPPING[static_cast<unsigned>(SimpleUnaryOperationId::COUNT)]{
|
constexpr static expressionOperatorType_e UNARY_OPERATION_MAPPING[static_cast<unsigned>(SimpleUnaryOperationId::COUNT)]{
|
||||||
@ -361,7 +361,7 @@ namespace
|
|||||||
else if (expressionValue->m_type == SimpleExpressionValue::Type::STRING)
|
else if (expressionValue->m_type == SimpleExpressionValue::Type::STRING)
|
||||||
{
|
{
|
||||||
entry.data.operand.dataType = VAL_STRING;
|
entry.data.operand.dataType = VAL_STRING;
|
||||||
entry.data.operand.internals.stringVal.string = m_conversion_zone_state->AddString(*expressionValue->m_string_value);
|
entry.data.operand.internals.stringVal.string = m_conversion_zone_state.AddString(*expressionValue->m_string_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.emplace_back(entry);
|
entries.emplace_back(entry);
|
||||||
@ -1123,8 +1123,6 @@ namespace
|
|||||||
m_conversion_zone_state(context.GetZoneAssetLoaderState<MenuConversionZoneState>()),
|
m_conversion_zone_state(context.GetZoneAssetLoaderState<MenuConversionZoneState>()),
|
||||||
m_parsing_zone_state(context.GetZoneAssetLoaderState<MenuAssetZoneState>())
|
m_parsing_zone_state(context.GetZoneAssetLoaderState<MenuAssetZoneState>())
|
||||||
{
|
{
|
||||||
assert(m_conversion_zone_state);
|
|
||||||
assert(m_parsing_zone_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration<AssetMenu>& registration) override
|
void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration<AssetMenu>& registration) override
|
||||||
@ -1177,7 +1175,7 @@ namespace
|
|||||||
menuData->onFocusDueToClose = ConvertEventHandlerSet(commonMenu.m_on_focus_due_to_close.get(), &commonMenu);
|
menuData->onFocusDueToClose = ConvertEventHandlerSet(commonMenu.m_on_focus_due_to_close.get(), &commonMenu);
|
||||||
menuData->onKey = ConvertKeyHandler(commonMenu.m_key_handlers, &commonMenu);
|
menuData->onKey = ConvertKeyHandler(commonMenu.m_key_handlers, &commonMenu);
|
||||||
menu.items = ConvertMenuItems(commonMenu, menu.itemCount);
|
menu.items = ConvertMenuItems(commonMenu, menu.itemCount);
|
||||||
menuData->expressionData = m_conversion_zone_state->m_supporting_data;
|
menuData->expressionData = m_conversion_zone_state.m_supporting_data;
|
||||||
}
|
}
|
||||||
catch (const MenuConversionException& e)
|
catch (const MenuConversionException& e)
|
||||||
{
|
{
|
||||||
@ -1185,8 +1183,8 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuConversionZoneState* m_conversion_zone_state;
|
MenuConversionZoneState& m_conversion_zone_state;
|
||||||
MenuAssetZoneState* m_parsing_zone_state;
|
MenuAssetZoneState& m_parsing_zone_state;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -822,11 +822,11 @@ namespace
|
|||||||
|
|
||||||
bool LoadAccuracyGraphs(WeaponFullDef& weaponFullDef, MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context)
|
bool LoadAccuracyGraphs(WeaponFullDef& weaponFullDef, MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context)
|
||||||
{
|
{
|
||||||
auto* accuracyGraphLoader = context.GetZoneAssetLoaderState<AccuracyGraphLoader>();
|
auto& accuracyGraphLoader = context.GetZoneAssetLoaderState<AccuracyGraphLoader>();
|
||||||
|
|
||||||
if (weaponFullDef.weapDef.aiVsAiAccuracyGraphName && weaponFullDef.weapDef.aiVsAiAccuracyGraphName[0])
|
if (weaponFullDef.weapDef.aiVsAiAccuracyGraphName && weaponFullDef.weapDef.aiVsAiAccuracyGraphName[0])
|
||||||
{
|
{
|
||||||
const auto* graph = accuracyGraphLoader->LoadAiVsAiGraph(searchPath, weaponFullDef.weapDef.aiVsAiAccuracyGraphName);
|
const auto* graph = accuracyGraphLoader.LoadAiVsAiGraph(searchPath, weaponFullDef.weapDef.aiVsAiAccuracyGraphName);
|
||||||
if (!graph)
|
if (!graph)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -840,7 +840,7 @@ namespace
|
|||||||
|
|
||||||
if (weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName && weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName[0])
|
if (weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName && weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName[0])
|
||||||
{
|
{
|
||||||
const auto* graph = accuracyGraphLoader->LoadAiVsPlayerGraph(searchPath, weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName);
|
const auto* graph = accuracyGraphLoader.LoadAiVsPlayerGraph(searchPath, weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName);
|
||||||
if (!graph)
|
if (!graph)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -409,11 +409,11 @@ namespace
|
|||||||
|
|
||||||
bool LoadAccuracyGraphs(WeaponFullDef& weaponFullDef, MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context)
|
bool LoadAccuracyGraphs(WeaponFullDef& weaponFullDef, MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context)
|
||||||
{
|
{
|
||||||
auto* accuracyGraphLoader = context.GetZoneAssetLoaderState<AccuracyGraphLoader>();
|
auto& accuracyGraphLoader = context.GetZoneAssetLoaderState<AccuracyGraphLoader>();
|
||||||
|
|
||||||
if (weaponFullDef.weapDef.aiVsAiAccuracyGraphName && weaponFullDef.weapDef.aiVsAiAccuracyGraphName[0])
|
if (weaponFullDef.weapDef.aiVsAiAccuracyGraphName && weaponFullDef.weapDef.aiVsAiAccuracyGraphName[0])
|
||||||
{
|
{
|
||||||
const auto* graph = accuracyGraphLoader->LoadAiVsAiGraph(searchPath, weaponFullDef.weapDef.aiVsAiAccuracyGraphName);
|
const auto* graph = accuracyGraphLoader.LoadAiVsAiGraph(searchPath, weaponFullDef.weapDef.aiVsAiAccuracyGraphName);
|
||||||
if (!graph)
|
if (!graph)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ namespace
|
|||||||
|
|
||||||
if (weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName && weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName[0])
|
if (weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName && weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName[0])
|
||||||
{
|
{
|
||||||
const auto* graph = accuracyGraphLoader->LoadAiVsPlayerGraph(searchPath, weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName);
|
const auto* graph = accuracyGraphLoader.LoadAiVsPlayerGraph(searchPath, weaponFullDef.weapDef.aiVsPlayerAccuracyGraphName);
|
||||||
if (!graph)
|
if (!graph)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ std::unique_ptr<ParsingResult> MenuFileReader::CreateParsingResult(MenuFileParse
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuFileReader::IncludeZoneState(const MenuAssetZoneState* zoneState)
|
void MenuFileReader::IncludeZoneState(const MenuAssetZoneState& zoneState)
|
||||||
{
|
{
|
||||||
m_zone_state = zoneState;
|
m_zone_state = &zoneState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuFileReader::SetPermissiveMode(const bool usePermissiveMode)
|
void MenuFileReader::SetPermissiveMode(const bool usePermissiveMode)
|
||||||
|
@ -19,7 +19,7 @@ namespace menu
|
|||||||
public:
|
public:
|
||||||
MenuFileReader(std::istream& stream, std::string fileName, FeatureLevel featureLevel, ISearchPath& searchPath);
|
MenuFileReader(std::istream& stream, std::string fileName, FeatureLevel featureLevel, ISearchPath& searchPath);
|
||||||
|
|
||||||
void IncludeZoneState(const MenuAssetZoneState* zoneState);
|
void IncludeZoneState(const MenuAssetZoneState& zoneState);
|
||||||
void SetPermissiveMode(bool usePermissiveMode);
|
void SetPermissiveMode(bool usePermissiveMode);
|
||||||
|
|
||||||
std::unique_ptr<ParsingResult> ReadMenuFile();
|
std::unique_ptr<ParsingResult> ReadMenuFile();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user