Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed potential circular imports in formats #182

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bcmdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)

from mercury_engine_data_structures.common_types import Float, StrId
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

# Partial implementation to generate material variants
Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/bldef.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from construct import Construct, Container

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game


Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/blsnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)

from mercury_engine_data_structures.common_types import StrId, make_vector
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game, current_game_at_most

BLSND = Struct(
Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/bmbls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import construct

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMBLS = standard_format.create('base::animation::CBlendSpaceResource', 0x02020001)
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmdefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)

from mercury_engine_data_structures.common_types import StrId, make_vector
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

EnemyStruct = Struct(
Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/bmmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from construct import Construct, Container

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMMAP = standard_format.create('CMinimapData', 0x02000001)
Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/bmmdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from construct import Construct, Container

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMMDEF = standard_format.create('CMinimapDef', 0x02000001)
Expand Down
4 changes: 3 additions & 1 deletion src/mercury_engine_data_structures/formats/bmsad.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from mercury_engine_data_structures.construct_extensions.alignment import PrefixedAllowZeroLen
from mercury_engine_data_structures.construct_extensions.function_complex import ComplexIf, SwitchComplexKey
from mercury_engine_data_structures.construct_extensions.misc import ErrorWithMessage
from mercury_engine_data_structures.formats import BaseResource, dread_types
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.formats.bmsas import BMSAS_SR, Bmsas
from mercury_engine_data_structures.formats.property_enum import PropertyEnum
from mercury_engine_data_structures.game_check import Game, GameSpecificStruct
Expand Down Expand Up @@ -80,6 +80,8 @@

@functools.cache
def fieldtypes(game: Game) -> dict[str, Construct]:
from mercury_engine_data_structures.formats import dread_types

if game == Game.DREAD:
return {k: v for k, v in vars(dread_types).items() if isinstance(v, Construct)}
raise ValueError(f"No field types defined for {game}")
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmsas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from mercury_engine_data_structures.common_types import Char, CVector3D, DictAdapter, Float, make_vector
from mercury_engine_data_structures.common_types import StrId as StrIdSR
from mercury_engine_data_structures.construct_extensions.strings import PascalStringRobust
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.formats.property_enum import PropertyEnum, PropertyEnumDoubleUnsafe
from mercury_engine_data_structures.game_check import Game

Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmscc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from mercury_engine_data_structures import game_check
from mercury_engine_data_structures.common_types import StrId, UInt, make_vector
from mercury_engine_data_structures.construct_extensions.misc import ErrorWithMessage
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.formats.collision import collision_formats
from mercury_engine_data_structures.game_check import Game

Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/bmscu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from construct import Construct

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMSCU = standard_format.create('CCutSceneDef', 0x02030008)
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmsem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)

from mercury_engine_data_structures.common_types import StrId, make_vector
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMSEM = Struct(
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmses.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)

from mercury_engine_data_structures.common_types import StrId, make_vector
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMSES = Struct(
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmsld.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mercury_engine_data_structures.construct_extensions.misc import ErrorWithMessage
from mercury_engine_data_structures.construct_extensions.strings import StaticPaddedString
from mercury_engine_data_structures.crc import crc32
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.formats.collision import collision_formats
from mercury_engine_data_structures.game_check import Game

Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/bmslgroup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import construct

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMSLGROUP = standard_format.create('navmesh::CDynamicSmartLinkGroup', 0x02000001)
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmslink.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)

from mercury_engine_data_structures.common_types import Float, StrId
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

UnkStruct = Struct(
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmsmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)

from mercury_engine_data_structures.common_types import StrId, make_vector
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMSMD = Struct(
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmsmsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from construct.core import Const, Construct, Enum, FlagsEnum, Float32l, Hex, Int32sl, Int32ul, Struct

from mercury_engine_data_structures.common_types import CVector2D, CVector3D, StrId, make_vector
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

TileBorders = FlagsEnum(Int32sl,
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmsnav.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from construct.core import Array, Byte, Const, Construct, Flag, Hex, Int32ul, PrefixedArray, Struct, Terminated

from mercury_engine_data_structures.common_types import CVector2D, CVector3D, Float, StrId, make_dict
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

### A ton of barely-understood structs :]
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from mercury_engine_data_structures import game_check
from mercury_engine_data_structures.common_types import CVector3D, StrId, make_vector
from mercury_engine_data_structures.construct_extensions.strings import StaticPaddedString
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMSSD = Struct(
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmtre.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)

from mercury_engine_data_structures.common_types import Float, StrId
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.formats.property_enum import PropertyEnum
from mercury_engine_data_structures.game_check import Game

Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmtun.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from mercury_engine_data_structures.common_types import Char, CVector3D, Float, StrId, make_dict
from mercury_engine_data_structures.construct_extensions.misc import ErrorWithMessage
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

# Functions
Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/brem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import construct

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game


Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/bres.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import construct

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game


Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/brev.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import construct

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game


Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/brfld.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import construct

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

logger = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/brsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from construct import Construct, Container

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game


Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bsmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)

from mercury_engine_data_structures.common_types import Char, Float, StrId
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

# these seem to be using Unity ShaderLab, or at least the gist I borrowed this from uses similar teminology
Expand Down
3 changes: 2 additions & 1 deletion src/mercury_engine_data_structures/formats/gui_files.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from construct import Construct, Container

from mercury_engine_data_structures.formats import BaseResource, standard_format
from mercury_engine_data_structures.formats import standard_format
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMSCP = standard_format.create('GUI::CDisplayObjectContainer', 0x02020001, explicit_root=True)
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/lua.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import construct

from mercury_engine_data_structures.common_types import StrId
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

if typing.TYPE_CHECKING:
Expand Down
3 changes: 1 addition & 2 deletions src/mercury_engine_data_structures/formats/toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import construct

from mercury_engine_data_structures import common_types
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import NameOrAssetId, resolve_asset_id
from mercury_engine_data_structures.formats.base_resource import BaseResource, NameOrAssetId, resolve_asset_id
from mercury_engine_data_structures.game_check import Game

TOC_SR = construct.Struct(
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from mercury_engine_data_structures.common_types import DictAdapter, DictElement
from mercury_engine_data_structures.construct_extensions.strings import CStringRobust
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game, is_sr_or_else

_string_range = GreedyRange(DictElement(CStringRobust("utf-16-le")))
Expand Down