Skip to content

Commit

Permalink
fixed possible issues with consecutive directives and fixed scene nam…
Browse files Browse the repository at this point in the history
…e having the wrong capitalization (#340)
  • Loading branch information
Yanis002 authored May 4, 2024
1 parent b7ad65c commit d425992
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fast64_internal/oot/scene/exporter/to_c/scene_table_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SceneTableEntry:
original: Optional[str] # the original line from the parsed file
scene: Optional[OOTScene] = None
exportName: Optional[str] = None
isCustomScene: bool = False
prefix: Optional[str] = None # ifdefs, endifs, comments etc, everything before the current entry
suffix: Optional[str] = None # remaining data after the last entry
parsed: Optional[str] = None
Expand Down Expand Up @@ -72,7 +73,7 @@ def setParametersFromScene(self, scene: Optional[OOTScene] = None):
# TODO: Implement title cards
name = scene.name if scene is not None else self.exportName
self.setParameters(
f"{scene.name.lower()}_scene",
f"{scene.name.lower() if self.isCustomScene else scene.name}_scene",
"none",
ootSceneNameToID.get(name, f"SCENE_{name.upper()}"),
getCustomProperty(scene.sceneTableEntry, "drawConfig"),
Expand Down Expand Up @@ -134,6 +135,9 @@ def __post_init__(self):
prefix = ""
entryIndex += 1
else:
if prefix.startswith("#") and line.startswith("#"):
# add newline if there's two consecutive preprocessor directives
prefix += "\n"
prefix += line

# add whatever's after the last entry
Expand Down Expand Up @@ -303,10 +307,10 @@ def modifySceneTable(scene: Optional[OOTScene], exportInfo: ExportInfo):
sceneTable.remove(sceneTable.selectedSceneIndex)
elif sceneTable.selectedSceneIndex == SceneIndexType.CUSTOM and sceneTable.customSceneIndex is None:
# custom mode: new custom scene
sceneTable.append(SceneTableEntry(len(sceneTable.entries) - 1, None, scene, exportInfo.name))
sceneTable.append(SceneTableEntry(len(sceneTable.entries) - 1, None, scene, exportInfo.name, True))
elif sceneTable.selectedSceneIndex == SceneIndexType.VANILLA_REMOVED:
# insert mode
sceneTable.insert(SceneTableEntry(sceneTable.getInsertionIndex(), None, scene, exportInfo.name))
sceneTable.insert(SceneTableEntry(sceneTable.getInsertionIndex(), None, scene, exportInfo.name, False))
else:
# update mode (for both vanilla and custom scenes since they already exist in the table)
sceneTable.entries[sceneTable.getIndex()].setParametersFromScene(scene)
Expand Down
3 changes: 3 additions & 0 deletions fast64_internal/oot/scene/exporter/to_c/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def __post_init__(self):
parsedLines = []
else:
# else, if between 2 segments and the line is something we don't need
if prefix.startswith("#") and line.startswith("#"):
# add newline if there's two consecutive preprocessor directives
prefix += "\n"
prefix += line
# set the last's entry's suffix to the remaining prefix
self.entries[-1].suffix = prefix.removesuffix("\n")
Expand Down

0 comments on commit d425992

Please sign in to comment.