V-Gears 0
Free Final Fantasy VII engine.
FieldDataInstaller Class Reference

#include <FieldDataInstaller.h>

Collaboration diagram for FieldDataInstaller:

Public Member Functions

 FieldDataInstaller (const std::string input_dir, const std::string output_dir)
 Installer constructor. More...
 
 ~FieldDataInstaller ()
 Installer destructor. More...
 
int CollectSpawnAndScaleFactorsInit (Ogre::ResourceGroupManager *res_mgr)
 Initializer for {. More...
 
void CollectSpawnAndScaleFactors (int field_index)
 Reads spawn points and scale factors from flevel files. More...
 
void Convert (int field_index)
 Converts FFVII PC fields to V-Gears format. More...
 
int WriteInit ()
 Initializer for {. More...
 
void Write (int field_index)
 Saves the game maps to XML files. More...
 
void WriteEnd ()
 Cleans up after {. More...
 
std::vector< std::string > ConvertModelsInit ()
 Initializer for {. More...
 
void ConvertModels (std::string model_name)
 Converts the field models to V-Gears format. More...
 

Private Member Functions

void ExportMesh (const std::string outdir, const Ogre::MeshPtr &mesh)
 Exports a mesh to a file. More...
 
std::vector< int > ExtractMusicTrackIds (VGears::FLevelFilePtr &field)
 Reads the music track IDs from a specific field. More...
 
void PcFieldToVGearsField (VGears::FLevelFilePtr &field)
 Converts a FFVII PC field to a V-Gears field. More...
 
float GetFieldScaleFactor (size_t field_id)
 Retrieves a field scale factor. More...
 
void CreateDir (const std::string &dir)
 Creates a directory in the outputh path. More...
 

Static Private Member Functions

static std::string CreateGateWayScript (const std::string &gateway_entity_name, const std::string &target_map_name, const std::string &source_spawn_point_name)
 Creates a gateway script. More...
 
static size_t GetFieldId (const std::string &name, const std::vector< std::string > &field_id_to_name_lookup)
 Retrieves a field ID from a name. More...
 
static bool IsAFieldFile (const Ogre::String &resource_name)
 Checks if a file is a field file. More...
 
static bool WillCrash (const Ogre::String &resource_name)
 Checks if a map cause fatal crash bugs. More...
 
static bool IsTestField (const Ogre::String &resource_name)
 Checks if a map is a test field. More...
 
static void CollectFieldScaleFactors (VGears::FLevelFilePtr &field, FieldScaleFactorMap &scale_factors, const std::vector< std::string > &field_id_to_name_lookup)
 Collects the scale factor from a map. More...
 
static void CollectSpawnPoints (VGears::FLevelFilePtr &field, const std::vector< std::string > &field_id_to_name_lookup, FieldSpawnPointsMap &spawn_points)
 Collects the spawn point from a field. More...
 

Private Attributes

std::string input_dir_
 The path to the directory from which to read the PC game data. More...
 
std::string output_dir_
 The path to the directory where to save the V-Gears data. More...
 
size_t conversion_step_
 Helper variable to indicate internal progress of installation steps. More...
 
size_t progress_step_num_elements_
 Helper variable to indicate internal progress of installation steps. More...
 
size_t iterator_counter_
 Iterator counter. More...
 
std::unique_ptr< ScopedLgpfields_lgp_
 LGP archive with field data. More...
 
std::unique_ptr< ScopedLgptextures_lgp_
 LGP archive with texture data. More...
 
std::unique_ptr< ScopedLgpfield_models_lgp_
 LGP archive with field model data. More...
 
Ogre::StringVectorPtr flevel_file_list_
 List of flevel files. More...
 
std::vector< std::string > map_list_
 The list of maps. More...
 
FieldSpawnPointsMap spawn_points_
 Map of the collected spawn points. More...
 
FieldScaleFactorMap scale_factors_
 Map of th collected scale factors. More...
 
ModelsAndAnimationsDb used_models_and_anims_
 ModelsAndAnimationsUsedByConvertedFields. More...
 
MapList converted_map_list_
 List of converted maps. More...
 
MapList::iterator converted_map_list_iterator_
 Iterator for {. More...
 
VGears::FLevelFilePtr field_
 Field currently being processed. More...
 
Ogre::StringVectorPtr field_model_file_list_
 List of model files. More...
 
std::unique_ptr< TiXmlDocument > doc_
 An XML document. More...
 
std::unique_ptr< TiXmlElement > element_
 An XML element. More...
 
ModelAnimationMap::iterator model_animation_map_iterator_
 Iterator for {. More...
 
std::function< void(std::string)> write_output_line_
 Function used to print text to the log output, line by line. More...
 
std::function< void(std::string)> set_progress_label_
 Function used to print set the current installation progress text. More...
 
FieldTextWriter field_text_writer_
 Field text writer. More...
 
std::vector< std::string > materials_
 Written materials. More...
 

Static Private Attributes

static float LINE_SCALE_FACTOR
 The scale factor for line point coordinates. More...
 
static std::string FIELD_MODELS_DIR
 Path to the field models directory. More...
 
static std::string FIELD_MAPS_DIR
 Path to the field maps directory. More...
 
static int INACTIVE_GATEWAY_ID
 Gateways to this map ID are considered to be inactive. More...
 

Constructor & Destructor Documentation

◆ FieldDataInstaller()

FieldDataInstaller::FieldDataInstaller ( const std::string  input_dir,
const std::string  output_dir 
)

Installer constructor.

Parameters
[in]input_dirPath to the directory containing the original data to parse.
[in]output_dirPath to the directory to write generated data to.

◆ ~FieldDataInstaller()

FieldDataInstaller::~FieldDataInstaller ( )

Installer destructor.

Member Function Documentation

◆ CollectFieldScaleFactors()

void FieldDataInstaller::CollectFieldScaleFactors ( VGears::FLevelFilePtr field,
FieldScaleFactorMap scale_factors,
const std::vector< std::string > &  field_id_to_name_lookup 
)
staticprivate

Collects the scale factor from a map.

Parameters
[in]fieldThe field to collect from.
[out]scale_factorsThe scale factor for the map will be set here, in the appropiate map entry.
[in]field_id_to_name_lookupLookup table to relate field IDs and names.

◆ CollectSpawnAndScaleFactors()

void FieldDataInstaller::CollectSpawnAndScaleFactors ( int  field_index)

Reads spawn points and scale factors from flevel files.

Installation step 2.

Parameters
[in]field_indexIndex of the field to collect from. Must be less than the value returned by {
See also
CollectSpawnAndScaleFactorsInit}.

◆ CollectSpawnAndScaleFactorsInit()

int FieldDataInstaller::CollectSpawnAndScaleFactorsInit ( Ogre::ResourceGroupManager *  res_mgr)

Initializer for {.

See also
CollectionFieldSpawnAndScaleFactors}.

Installation step 1.

Parameters
[in]res_mgrThe application resource manager.
Returns
The total number of level files to process.

◆ CollectSpawnPoints()

void FieldDataInstaller::CollectSpawnPoints ( VGears::FLevelFilePtr field,
const std::vector< std::string > &  field_id_to_name_lookup,
FieldSpawnPointsMap spawn_points 
)
staticprivate

Collects the spawn point from a field.

If a spawn is new, a new record will be added to the spawn point database. If it was already there, update the record to add the origin.

Parameters
[in]fieldThe field to collect from.
[in]field_id_to_name_lookupLookup table to relate field IDs and names.
[out]spawn_pointsSpawn points will be added sequentially to the end of this map.

◆ Convert()

void FieldDataInstaller::Convert ( int  field_index)

Converts FFVII PC fields to V-Gears format.

Parameters
[in]field_indexIndex of the field to collect from. Must be less than the value returned by {
See also
CollectSpawnAndScaleFactorsInit}.

◆ ConvertModels()

void FieldDataInstaller::ConvertModels ( std::string  model_name)

Converts the field models to V-Gears format.

Installation step 7 and final.

Parameters
[in]model_nameName of the model to convert.

◆ ConvertModelsInit()

std::vector< std::string > FieldDataInstaller::ConvertModelsInit ( )

Initializer for {.

See also
ConvertFieldModelsIteration}.

Installation step 6.

Returns
List of names of models to convert.

◆ CreateDir()

void FieldDataInstaller::CreateDir ( const std::string &  dir)
private

Creates a directory in the outputh path.

Parameters
[in]dirPath of the directory to create, relative to the output path..
Exceptions
std::runtime_errorIf the directory can't be created.

◆ CreateGateWayScript()

std::string FieldDataInstaller::CreateGateWayScript ( const std::string &  gateway_entity_name,
const std::string &  target_map_name,
const std::string &  source_spawn_point_name 
)
staticprivate

Creates a gateway script.

Parameters
[in]gateway_entity_nameName of the gateway entity.
[in]target_map_nameName of the target map.
[in]source_spawn_point_nameThe spawn point name.
Returns
Gateway LUA script.

◆ ExportMesh()

void FieldDataInstaller::ExportMesh ( const std::string  outdir,
const Ogre::MeshPtr &  mesh 
)
private

Exports a mesh to a file.

The file will have the mesh name.

Parameters
[in]outdirPath to the directory where the file will be saved.
[in]meshThe mesh to export.

◆ ExtractMusicTrackIds()

std::vector< int > FieldDataInstaller::ExtractMusicTrackIds ( VGears::FLevelFilePtr field)
private

Reads the music track IDs from a specific field.

Parameters
[in]fieldThe field to extract tracks from.
Returns
The list of tracks. It can be empty.

◆ GetFieldId()

size_t FieldDataInstaller::GetFieldId ( const std::string &  name,
const std::vector< std::string > &  field_id_to_name_lookup 
)
staticprivate

Retrieves a field ID from a name.

Parameters
[in]nameThe name of the field.
[in]field_id_to_name_lookupLookup table to use.
Returns
The field ID for the specified name.
Exceptions
std::runtime_errorIf there is no ID for the field name.

◆ GetFieldScaleFactor()

float FieldDataInstaller::GetFieldScaleFactor ( size_t  field_id)
private

Retrieves a field scale factor.

Parameters
[in]field_idThe id (name) of the field.
Returns
The scale factor for the map.
Exceptions
std::runtime_errorIf there is no ID for the field name.

◆ IsAFieldFile()

bool FieldDataInstaller::IsAFieldFile ( const Ogre::String &  resource_name)
staticprivate

Checks if a file is a field file.

To verify it, it just checks that the extension is not '.tex', '.tut' or '.siz' and that the name is not 'maplist'.

Parameters
[in]resource_nameThe name of the file to test.
Returns
False if the file is surely not a field file, true otherwise.

◆ IsTestField()

bool FieldDataInstaller::IsTestField ( const Ogre::String &  resource_name)
staticprivate

Checks if a map is a test field.

It uses a hardcoded list of maps that are known to be test maps. Unused maps are considered to be test maps.

Parameters
[in]resource_nameThe name of the map file to test.
Returns
True if the map is a test map, false otherwise.

◆ PcFieldToVGearsField()

void FieldDataInstaller::PcFieldToVGearsField ( VGears::FLevelFilePtr field)
private

Converts a FFVII PC field to a V-Gears field.

Parameters
[in]fieldThe field map to convert.

◆ WillCrash()

bool FieldDataInstaller::WillCrash ( const Ogre::String &  resource_name)
staticprivate

Checks if a map cause fatal crash bugs.

It uses a hardcoded list of maps that are known to cause errors. This can be removed when whatever is causing the crash(s) is fixed.

NOTE: Even so, conversion of all models will fail with a bone index out of bounds.

Parameters
[in]resource_nameThe name of the map file to test.
Returns
True if the map will crash, false otherwise.

◆ Write()

void FieldDataInstaller::Write ( int  field_index)

Saves the game maps to XML files.

Installation step 4.

Parameters
[in]field_indexIndex of the field to collect from. Must be less than the value returned by {
See also
WriteInit}.

◆ WriteEnd()

void FieldDataInstaller::WriteEnd ( )

Cleans up after {.

See also
WriteMapsXmlIteration}.

Installation step 5.

◆ WriteInit()

int FieldDataInstaller::WriteInit ( )

Initializer for {.

See also
WriteMapsXmlIteration}.

Installation step 3.

Returns
The number of converted maps that need to be written.

Member Data Documentation

◆ conversion_step_

size_t FieldDataInstaller::conversion_step_
private

Helper variable to indicate internal progress of installation steps.

◆ converted_map_list_

MapList FieldDataInstaller::converted_map_list_
private

List of converted maps.

◆ converted_map_list_iterator_

MapList::iterator FieldDataInstaller::converted_map_list_iterator_
private

Iterator for {.

See also
converted_map_list}.

◆ doc_

std::unique_ptr<TiXmlDocument> FieldDataInstaller::doc_
private

An XML document.

Internally used during some installation steps.

◆ element_

std::unique_ptr<TiXmlElement> FieldDataInstaller::element_
private

An XML element.

Internally used during some installation steps.

◆ field_

VGears::FLevelFilePtr FieldDataInstaller::field_
private

Field currently being processed.

◆ FIELD_MAPS_DIR

std::string FieldDataInstaller::FIELD_MAPS_DIR
staticprivate

Path to the field maps directory.

◆ field_model_file_list_

Ogre::StringVectorPtr FieldDataInstaller::field_model_file_list_
private

List of model files.

◆ FIELD_MODELS_DIR

std::string FieldDataInstaller::FIELD_MODELS_DIR
staticprivate

Path to the field models directory.

◆ field_models_lgp_

std::unique_ptr<ScopedLgp> FieldDataInstaller::field_models_lgp_
private

LGP archive with field model data.

◆ field_text_writer_

FieldTextWriter FieldDataInstaller::field_text_writer_
private

Field text writer.

◆ fields_lgp_

std::unique_ptr<ScopedLgp> FieldDataInstaller::fields_lgp_
private

LGP archive with field data.

◆ flevel_file_list_

Ogre::StringVectorPtr FieldDataInstaller::flevel_file_list_
private

List of flevel files.

◆ INACTIVE_GATEWAY_ID

int FieldDataInstaller::INACTIVE_GATEWAY_ID
staticprivate

Gateways to this map ID are considered to be inactive.

◆ input_dir_

std::string FieldDataInstaller::input_dir_
private

The path to the directory from which to read the PC game data.

◆ iterator_counter_

size_t FieldDataInstaller::iterator_counter_
private

Iterator counter.

◆ LINE_SCALE_FACTOR

float FieldDataInstaller::LINE_SCALE_FACTOR
staticprivate

The scale factor for line point coordinates.

When a LINE opcode is found in the game scripts, the line points X and Y coordinates must be scaled down by this factor.

◆ map_list_

std::vector<std::string> FieldDataInstaller::map_list_
private

The list of maps.

◆ materials_

std::vector<std::string> FieldDataInstaller::materials_
private

Written materials.

◆ model_animation_map_iterator_

ModelAnimationMap::iterator FieldDataInstaller::model_animation_map_iterator_
private

Iterator for {.

See also
used_models_and_anims_}.

◆ output_dir_

std::string FieldDataInstaller::output_dir_
private

The path to the directory where to save the V-Gears data.

◆ progress_step_num_elements_

size_t FieldDataInstaller::progress_step_num_elements_
private

Helper variable to indicate internal progress of installation steps.

◆ scale_factors_

FieldScaleFactorMap FieldDataInstaller::scale_factors_
private

Map of th collected scale factors.

◆ set_progress_label_

std::function<void(std::string)> FieldDataInstaller::set_progress_label_
private

Function used to print set the current installation progress text.

◆ spawn_points_

FieldSpawnPointsMap FieldDataInstaller::spawn_points_
private

Map of the collected spawn points.

◆ textures_lgp_

std::unique_ptr<ScopedLgp> FieldDataInstaller::textures_lgp_
private

LGP archive with texture data.

◆ used_models_and_anims_

ModelsAndAnimationsDb FieldDataInstaller::used_models_and_anims_
private

ModelsAndAnimationsUsedByConvertedFields.

◆ write_output_line_

std::function<void(std::string)> FieldDataInstaller::write_output_line_
private

Function used to print text to the log output, line by line.


The documentation for this class was generated from the following files: