Skip to content

Commit

Permalink
convert: Data pre-processor.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Oct 23, 2019
1 parent 116a021 commit 6d93a4a
Show file tree
Hide file tree
Showing 30 changed files with 498 additions and 117 deletions.
1 change: 1 addition & 0 deletions openage/convert/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_pxds(
)

add_subdirectory(dataformat)
add_subdirectory(export)
add_subdirectory(gamedata)
add_subdirectory(hardcoded)
add_subdirectory(interface)
Expand Down
3 changes: 2 additions & 1 deletion openage/convert/dataformat/aoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ add_py_modules(
genie_civ.py
genie_connection.py
genie_effect.py
genie_graphic.py
genie_object_container.py
genie_sound.py
genie_sprite.py
genie_tech.py
genie_terrain.py
genie_unit.py
internal_nyan_names.py
)
7 changes: 4 additions & 3 deletions openage/convert/dataformat/aoc/genie_civ.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2019-2019 the openage authors. See copying.md for legal info.

from openage.convert.dataformat.converter_object import ConverterObject,\
from ...dataformat.converter_object import ConverterObject,\
ConverterObjectGroup


Expand All @@ -9,7 +9,7 @@ class GenieCivilizationObject(ConverterObject):
Civilization in AoE2.
"""

def __init__(self, civ_id, full_data_set):
def __init__(self, civ_id, full_data_set, members=None):
"""
Creates a new Genie civilization object.
Expand All @@ -18,9 +18,10 @@ def __init__(self, civ_id, full_data_set):
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(civ_id)
super().__init__(civ_id, members=members)

self.data = full_data_set
self.data.genie_civs.update({self.get_id(): self})
Expand Down
22 changes: 13 additions & 9 deletions openage/convert/dataformat/aoc/genie_connection.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
# Copyright 2019-2019 the openage authors. See copying.md for legal info.


from openage.convert.dataformat.converter_object import ConverterObject
from ...dataformat.converter_object import ConverterObject


class GenieAgeConnection(ConverterObject):
"""
A relation between an Age and buildings/techs/units in AoE.
"""

def __init__(self, age_id, full_data_set):
def __init__(self, age_id, full_data_set, members=None):
"""
Creates a new Genie age connection.
:param age_id: The index of the Age. (First Age = 0)
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(age_id)
super().__init__(age_id, members=members)

self.data = full_data_set
self.data.age_connections.update({self.get_id(): self})
Expand All @@ -30,17 +31,18 @@ class GenieBuildingConnection(ConverterObject):
A relation between a building and other buildings/techs/units in AoE.
"""

def __init__(self, building_id, full_data_set):
def __init__(self, building_id, full_data_set, members=None):
"""
Creates a new Genie building connection.
:param building_id: The id of the building from the .dat file.
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(building_id)
super().__init__(building_id, members=members)

self.data = full_data_set
self.data.building_connections.update({self.get_id(): self})
Expand All @@ -51,17 +53,18 @@ class GenieTechConnection(ConverterObject):
A relation between a tech and other buildings/techs/units in AoE.
"""

def __init__(self, tech_id, full_data_set):
def __init__(self, tech_id, full_data_set, members=None):
"""
Creates a new Genie tech connection.
:param tech_id: The id of the tech from the .dat file.
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(tech_id)
super().__init__(tech_id, members=members)

self.data = full_data_set
self.data.tech_connections.update({self.get_id(): self})
Expand All @@ -72,17 +75,18 @@ class GenieUnitConnection(ConverterObject):
A relation between a unit and other buildings/techs/units in AoE.
"""

def __init__(self, unit_id, full_data_set):
def __init__(self, unit_id, full_data_set, members=None):
"""
Creates a new Genie unit connection.
:param unit_id: The id of the unit from the .dat file.
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(unit_id)
super().__init__(unit_id, members=members)

self.data = full_data_set
self.data.unit_connections.update({self.get_id(): self})
20 changes: 11 additions & 9 deletions openage/convert/dataformat/aoc/genie_effect.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
# Copyright 2019-2019 the openage authors. See copying.md for legal info.

from openage.convert.dataformat.converter_object import ConverterObject
from ...dataformat.converter_object import ConverterObject


class GenieEffectObject(ConverterObject):
"""
Single effect contained in GenieEffectBundle.
"""

def __init__(self, effect_id, bundle_id, full_data_set):
def __init__(self, effect_id, bundle_id, full_data_set, members=None):
"""
Creates a new Genie effect object.
:param effect_id: The index of the effect in the .dat file's effect
bundle. (the index is referenced as tech_effect_id by techs)
:param bundle_id: The index of the effect bundle that the effect belongs to.
(the index is referenced as tech_effect_id by techs)
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(effect_id)
super().__init__(effect_id, members=members)

self.bundle_id = bundle_id

self.data = full_data_set
self.data.genie_effect_bundles.update({self.get_id(): self})


class GenieEffectBundle(ConverterObject):
"""
A set of effects of a tech.
"""

def __init__(self, bundle_id, full_data_set):
def __init__(self, bundle_id, effects, full_data_set, members=None):
"""
Creates a new Genie effect bundle.
:param bundle_id: The index of the effect in the .dat file's effect
block. (the index is referenced as tech_effect_id by techs)
:param effects: Effects of the bundle as list of GenieEffectObject.
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(bundle_id)
super().__init__(bundle_id, members=members)

self.effects = []
self.effects = effects

self.data = full_data_set
self.data.genie_effect_bundles.update({self.get_id(): self})
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# Copyright 2019-2019 the openage authors. See copying.md for legal info.

from bin.openage.convert.dataformat.converter_object import ConverterObject
from ...dataformat.converter_object import ConverterObject


class GenieGraphic(ConverterObject):
"""
Graphic definition from a .dat file.
"""

def __init__(self, graphic_id, full_data_set):
def __init__(self, graphic_id, full_data_set, members=None):
"""
Creates a new Genie graphic object.
:param graphic_id: The graphic id from the .dat file.
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(graphic_id)
super().__init__(graphic_id, members=members)

self.data = full_data_set
self.data.genie_graphics.update({self.get_id(): self})
3 changes: 2 additions & 1 deletion openage/convert/dataformat/aoc/genie_object_container.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2019-2019 the openage authors. See copying.md for legal info.

from openage.convert.dataformat.converter_object import ConverterObjectContainer
from ...dataformat.converter_object import ConverterObjectContainer


class GenieObjectContainer(ConverterObjectContainer):
Expand All @@ -26,6 +26,7 @@ def __init__(self):
self.tech_connections = {}
self.genie_graphics = {}
self.genie_sounds = {}
self.genie_terrains = {}

# ConverterObjectGroup types (things that will become
# nyan objects)
Expand Down
7 changes: 4 additions & 3 deletions openage/convert/dataformat/aoc/genie_sound.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# Copyright 2019-2019 the openage authors. See copying.md for legal info.

from bin.openage.convert.dataformat.converter_object import ConverterObject
from ...dataformat.converter_object import ConverterObject


class GenieSound(ConverterObject):
"""
Sound definition from a .dat file.
"""

def __init__(self, sound_id, full_data_set):
def __init__(self, sound_id, full_data_set, members=None):
"""
Creates a new Genie sound object.
:param sound_id: The sound id from the .dat file.
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(sound_id)
super().__init__(sound_id, members=members)

self.data = full_data_set
self.data.genie_sounds.update({self.get_id(): self})
7 changes: 4 additions & 3 deletions openage/convert/dataformat/aoc/genie_tech.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019-2019 the openage authors. See copying.md for legal info.


from openage.convert.dataformat.converter_object import ConverterObject,\
from ...dataformat.converter_object import ConverterObject,\
ConverterObjectGroup


Expand All @@ -14,17 +14,18 @@ class GenieTechObject(ConverterObject):
(excluding team boni).
"""

def __init__(self, tech_id, full_data_set):
def __init__(self, tech_id, full_data_set, members=None):
"""
Creates a new Genie tech object.
:param tech_id: The internal tech_id from the .dat file.
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(tech_id)
super().__init__(tech_id, members=members)

self.data = full_data_set
self.data.genie_techs.update({self.get_id(): self})
Expand Down
27 changes: 27 additions & 0 deletions openage/convert/dataformat/aoc/genie_terrain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2019-2019 the openage authors. See copying.md for legal info.


from ...dataformat.converter_object import ConverterObject


class GenieTerrainObject(ConverterObject):
"""
Terrain definition from a .dat file.
"""

def __init__(self, terrain_id, full_data_set, members=None):
"""
Creates a new Genie terrain object.
:param terrain_id: The index of the terrain in the .dat file's terrain
block. (the index is referenced by other terrains)
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(terrain_id, members=members)

self.data = full_data_set
self.data.genie_terrains.update({self.get_id(): self})
7 changes: 4 additions & 3 deletions openage/convert/dataformat/aoc/genie_unit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019-2019 the openage authors. See copying.md for legal info.


from openage.convert.dataformat.converter_object import ConverterObject,\
from ...dataformat.converter_object import ConverterObject,\
ConverterObjectGroup


Expand All @@ -10,17 +10,18 @@ class GenieUnitObject(ConverterObject):
Ingame object in AoE2.
"""

def __init__(self, unit_id, full_data_set):
def __init__(self, unit_id, full_data_set, members=None):
"""
Creates a new Genie unit object.
:param unit_id: The internal unit_id of the unit.
:param full_data_set: GenieObjectContainer instance that
contains all relevant data for the conversion
process.
:param members: An already existing member dict.
"""

super().__init__(unit_id)
super().__init__(unit_id, members=members)

self.data = full_data_set
self.data.genie_units.update({self.get_id(): self})
Expand Down
Loading

0 comments on commit 6d93a4a

Please sign in to comment.