Skip to content

Commit

Permalink
descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanis002 committed Jan 8, 2024
1 parent 0bc1c93 commit 251ecf7
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 35 deletions.
4 changes: 4 additions & 0 deletions fast64_internal/oot/exporter/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class RoomFile:
header: str = ""

def write(self):
"""Writes the room files"""

if self.singleFileExport:
roomMainPath = f"{self.name}.c"
self.roomMain += self.roomModelInfo + self.roomModel
Expand Down Expand Up @@ -52,6 +54,7 @@ def __post_init__(self):
self.hasSceneTextures = len(self.sceneTextures) > 0

def getSourceWithSceneInclude(self, sceneInclude: str, source: str):
"""Returns the source with the includes if missing"""
ret = ""
if sceneInclude not in source:
ret = sceneInclude
Expand Down Expand Up @@ -80,6 +83,7 @@ def setIncludeData(self):
self.sceneCutscenes[i] = self.getSourceWithSceneInclude(csInclude, self.sceneCutscenes[i])

def write(self):
"""Writes the scene files"""
self.setIncludeData()

for room in self.roomList.values():
Expand Down
2 changes: 2 additions & 0 deletions fast64_internal/oot/exporter/collision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def __post_init__(self):
self.waterbox = WaterBoxes(self.sceneObj, self.transform, f"{self.sceneName}_waterBoxes", self.useMacros)

def getCmd(self):
"""Returns the collision header scene command"""

return indent + f"SCENE_CMD_COL_HEADER(&{self.name}),\n"

def getC(self):
Expand Down
1 change: 1 addition & 0 deletions fast64_internal/oot/exporter/collision/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __post_init__(self):

def getInfoEntryC(self, posDataName: str):
"""Returns an entry for the camera information array"""

ptr = f"&{posDataName}[{self.arrayIndex}]" if self.hasPosData else "NULL"
return indent + "{ " + f"{self.setting}, {self.count}, {ptr}" + " },\n"

Expand Down
25 changes: 1 addition & 24 deletions fast64_internal/oot/exporter/collision/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ....utility import CData, indent


@dataclass
@dataclass(unsafe_hash=True)
class SurfaceType:
"""This class defines a single surface type"""

Expand Down Expand Up @@ -32,29 +32,6 @@ class SurfaceType:
canHookshotC: Optional[str] = None
isWallDamageC: Optional[str] = None

def __hash__(self):
return hash(
(
self.bgCamIndex,
self.exitIndex,
self.floorType,
self.unk18,
self.wallType,
self.floorProperty,
self.isSoft,
self.isHorseBlocked,
self.material,
self.floorEffect,
self.lightSetting,
self.echo,
self.canHookshot,
self.conveyorSpeed,
self.conveyorDirection,
self.isWallDamage,
self.conveyorKeepMomentum,
)
)

def __post_init__(self):
if self.conveyorKeepMomentum:
self.conveyorSpeed += 4
Expand Down
19 changes: 9 additions & 10 deletions fast64_internal/oot/exporter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,30 @@ def getNewScene(self):

try:
sceneName = f"{toAlnum(self.sceneName)}_scene"
sceneData = Scene(
newScene = Scene(
self.sceneObj,
self.transform,
self.useMacros,
sceneName,
self.saveTexturesAsPNG,
OOTModel(f"{sceneName}_dl", self.dlFormat, False),
)
sceneData.validateScene()
newScene.validateScene()

if sceneData.mainHeader.cutscene is not None:
self.hasCutscenes = len(sceneData.mainHeader.cutscene.entries) > 0
if newScene.mainHeader.cutscene is not None:
self.hasCutscenes = len(newScene.mainHeader.cutscene.entries) > 0

if not self.hasCutscenes:
for cs in sceneData.altHeader.cutscenes:
for cs in newScene.altHeader.cutscenes:
if len(cs.cutscene.entries) > 0:
self.hasCutscenes = True
break

ootCleanupScene(self.originalSceneObj, allObjs)
except Exception as e:
ootCleanupScene(self.originalSceneObj, allObjs)
raise Exception(str(e))
finally:
ootCleanupScene(self.originalSceneObj, allObjs)

return sceneData
return newScene

def export(self):
"""Main function"""
Expand Down Expand Up @@ -139,6 +138,6 @@ def export(self):
os.path.join(exportPath, "include/config/config_debug.h")
if not isCustomExport
else os.path.join(self.path, "config_bootup.h"),
"ENTR_" + self.sceneName.upper() + "_" + str(self.hackerootBootOption.spawnIndex),
f"ENTR_{self.sceneName.upper()}_{self.hackerootBootOption.spawnIndex}",
self.hackerootBootOption,
)
7 changes: 7 additions & 0 deletions fast64_internal/oot/exporter/room/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

@dataclass
class HeaderBase(Base):
"""Defines the base of a room header"""

name: Optional[str] = None
props: Optional[OOTRoomHeaderProperty] = None
sceneObj: Optional[Object] = None
Expand Down Expand Up @@ -67,6 +69,7 @@ def __post_init__(self):
self.strength = self.props.windStrength if self.props.setWind else None

def getCmds(self):
"""Returns the echo settings, room behavior, skybox disables and time settings room commands"""
showInvisActors = "true" if self.showInvisActors else "false"
disableWarpSongs = "true" if self.disableWarpSongs else "false"
disableSkybox = "true" if self.disableSky else "false"
Expand Down Expand Up @@ -105,6 +108,8 @@ def getDefineName(self):
return f"LENGTH_{self.name.upper()}"

def getCmd(self):
"""Returns the object list room command"""

return indent + f"SCENE_CMD_OBJECT_LIST({self.getDefineName()}, {self.name}),\n"

def getC(self):
Expand Down Expand Up @@ -179,6 +184,8 @@ def getDefineName(self):
return f"LENGTH_{self.name.upper()}"

def getCmd(self):
"""Returns the actor list room command"""

return indent + f"SCENE_CMD_ACTOR_LIST({self.getDefineName()}, {self.name}),\n"

def getC(self):
Expand Down
2 changes: 2 additions & 0 deletions fast64_internal/oot/exporter/room/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def getRoomHeaderFromIndex(self, headerIndex: int) -> RoomHeader | None:
return None

def getCmdList(self, curHeader: RoomHeader, hasAltHeaders: bool):
"""Returns the room commands list"""

cmdListData = CData()
listName = f"SceneCmd {curHeader.name}"

Expand Down
4 changes: 4 additions & 0 deletions fast64_internal/oot/exporter/room/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

@dataclass
class RoomShapeBase:
"""This class defines the basic informations of a non-image room shape"""

type: str
props: OOTRoomHeaderProperty
mesh: OOTRoomMesh
Expand Down Expand Up @@ -304,6 +306,8 @@ def getName(self):
raise PluginError("ERROR: Name not found!")

def getCmd(self):
"""Returns the room shape room command"""

return indent + f"SCENE_CMD_ROOM_SHAPE(&{self.getName()}),\n"

def getRoomShapeBgImgDataC(self, roomMesh: OOTRoomMesh, textureSettings: TextureExportSettings):
Expand Down
4 changes: 3 additions & 1 deletion fast64_internal/oot/exporter/scene/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def getSceneHeaderFromIndex(self, headerIndex: int) -> SceneHeader | None:
return None

def getCmdList(self, curHeader: SceneHeader, hasAltHeaders: bool):
"""Returns the scene's commands list"""

cmdListData = CData()
listName = f"SceneCmd {curHeader.name}"

Expand Down Expand Up @@ -198,7 +200,7 @@ def getSceneTexturesC(self, textureExportSettings: TextureExportSettings):
return self.model.to_c(textureExportSettings, OOTGfxFormatter(ScrollMethod.Vertex)).all()

def getNewSceneFile(self, path: str, isSingleFile: bool, textureExportSettings: TextureExportSettings):
"""Gets and sets C data for every scene elements"""
"""Returns a new scene file containing the C data"""

sceneMainData = self.getSceneMainC()
sceneCollisionData = self.colHeader.getC()
Expand Down
6 changes: 6 additions & 0 deletions fast64_internal/oot/exporter/scene/actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def __post_init__(self):
self.entries.append(transActor)

def getCmd(self):
"""Returns the transition actor list scene command"""

return indent + f"SCENE_CMD_TRANSITION_ACTOR_LIST({len(self.entries)}, {self.name}),\n"

def getC(self):
Expand Down Expand Up @@ -190,6 +192,8 @@ def __post_init__(self):
self.entries = list(entranceActorFromIndex.values())

def getCmd(self):
"""Returns the spawn list scene command"""

name = self.name if len(self.entries) > 0 else "NULL"
return indent + f"SCENE_CMD_SPAWN_LIST({len(self.entries)}, {name}),\n"

Expand Down Expand Up @@ -219,6 +223,8 @@ class SceneSpawns(Base):
entries: list[EntranceActor]

def getCmd(self):
"""Returns the entrance list scene command"""

return indent + f"SCENE_CMD_ENTRANCE_LIST({self.name if len(self.entries) > 0 else 'NULL'}),\n"

def getC(self):
Expand Down
4 changes: 4 additions & 0 deletions fast64_internal/oot/exporter/scene/cutscene.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,12 @@ def __post_init__(self):
)

def getCutsceneName(self, csObj: Object, customName: Optional[str] = None) -> str:
"""Returns the cutscene's name"""

return customName if customName is not None else csObj.name.removeprefix("Cutscene.")

def getCmd(self):
"""Returns the cutscene data scene command"""

csDataName = self.getCutsceneName(self.csObj)
return indent + f"SCENE_CMD_CUTSCENE_DATA({csDataName}),\n"
8 changes: 8 additions & 0 deletions fast64_internal/oot/exporter/scene/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def __post_init__(self):
)

def getCmd(self):
"""Returns the env light settings scene command"""

return (
indent + "SCENE_CMD_ENV_LIGHT_SETTINGS("
) + f"{len(self.settings)}, {self.name if len(self.settings) > 0 else 'NULL'}),\n"
Expand Down Expand Up @@ -190,6 +192,8 @@ def __post_init__(self):
self.sceneCamType = self.getPropValue(self.props, "cameraMode")

def getCmds(self, lights: SceneLighting):
"""Returns the sound settings, misc settings, special files and skybox settings scene commands"""

return (
indent
+ f",\n{indent}".join(
Expand All @@ -213,12 +217,16 @@ class SceneExits(Base):
exitList: list[tuple[int, str]] = field(default_factory=list)

def __post_init__(self):
# TODO: proper implementation of exits

for i, exitProp in enumerate(self.props.exitList):
if exitProp.exitIndex != "Custom":
raise PluginError("ERROR: Exits are unfinished, please use 'Custom'.")
self.exitList.append((i, exitProp.exitIndexCustom))

def getCmd(self):
"""Returns the exit list scene command"""

return indent + f"SCENE_CMD_EXIT_LIST({self.name}),\n"

def getC(self):
Expand Down
2 changes: 2 additions & 0 deletions fast64_internal/oot/exporter/scene/pathways.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def __post_init__(self):
self.pathList = list(pathFromIndex.values())

def getCmd(self):
"""Returns the path list scene command"""

return indent + f"SCENE_CMD_PATH_LIST({self.name}),\n" if len(self.pathList) > 0 else ""

def getC(self):
Expand Down
2 changes: 2 additions & 0 deletions fast64_internal/oot/exporter/scene/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def __post_init__(self):
self.entries = [roomDict[i] for i in range(min(roomDict.keys()), len(roomDict))]

def getCmd(self):
"""Returns the room list scene command"""

return indent + f"SCENE_CMD_ROOM_LIST({len(self.entries)}, {self.name}),\n"

def getC(self, useDummyRoomList: bool):
Expand Down

0 comments on commit 251ecf7

Please sign in to comment.