mirror of
https://github.com/ApfelTeeSaft/lightspeed64.git
synced 2026-09-02 12:23:33 +00:00
Merge remote-tracking branch 'origin/main' into CITexFixes
This commit is contained in:
+3
-4
@@ -165,7 +165,7 @@ class F3D_GlobalSettingsPanel(bpy.types.Panel):
|
||||
col.prop(context.scene, "saveTextures")
|
||||
col.prop(context.scene, "f3d_simple", text="Simple Material UI")
|
||||
col.prop(context.scene, "generateF3DNodeGraph", text="Generate F3D Node Graph For Materials")
|
||||
col.prop(context.scene, "exportInlineF3D", text="Export Mesh F3D as single DL")
|
||||
col.prop(context.scene, "exportInlineF3D", text="Bleed and Inline Material Exports")
|
||||
col.prop(context.scene, "decomp_compatible", invert_checkbox=True, text="Homebrew Compatibility")
|
||||
col.prop(context.scene, "ignoreTextureRestrictions")
|
||||
if context.scene.ignoreTextureRestrictions:
|
||||
@@ -472,9 +472,8 @@ def register():
|
||||
bpy.types.Scene.saveTextures = bpy.props.BoolProperty(name="Save Textures As PNGs (Breaks CI Textures)")
|
||||
bpy.types.Scene.generateF3DNodeGraph = bpy.props.BoolProperty(name="Generate F3D Node Graph", default=True)
|
||||
bpy.types.Scene.exportHiddenGeometry = bpy.props.BoolProperty(name="Export Hidden Geometry", default=True)
|
||||
bpy.types.Scene.exportInlineF3D = bpy.props.BoolProperty(name="Export Inline F3D", \
|
||||
description = "F3D for each mesh will be one Gfx list instead of having different Gfx lists for each component of the mesh.\n\
|
||||
This will cause repeated F3D cmds. This option does not work on armature exports.", default=False)
|
||||
bpy.types.Scene.exportInlineF3D = bpy.props.BoolProperty(name="Bleed and Inline Material Exports", \
|
||||
description = "Inlines and bleeds materials in a single mesh. GeoLayout + Armature exports bleed over entire model", default=False)
|
||||
bpy.types.Scene.blenderF3DScale = bpy.props.FloatProperty(
|
||||
name="F3D Blender Scale", default=100, update=on_update_render_settings
|
||||
)
|
||||
|
||||
@@ -165,20 +165,20 @@ enumRGBDither = [
|
||||
]
|
||||
|
||||
enumCombKey = [
|
||||
("G_CK_NONE", "None", "None"),
|
||||
("G_CK_KEY", "Key", "Key"),
|
||||
("G_CK_NONE", "None", "Disables chroma key."),
|
||||
("G_CK_KEY", "Key", "Enables chroma key."),
|
||||
]
|
||||
|
||||
enumTextConv = [
|
||||
("G_TC_CONV", "Convert", "Convert"),
|
||||
("G_TC_FILTCONV", "Filter And Convert", "Filter And Convert"),
|
||||
("G_TC_FILT", "Filter", "Filter"),
|
||||
("G_TC_CONV", "Convert", "Convert YUV to RGB"),
|
||||
("G_TC_FILTCONV", "Filter And Convert", "Applies chosen filter on cycle 1 and converts YUB to RGB in the second cycle"),
|
||||
("G_TC_FILT", "Filter", "Applies chosen filter on textures with no color conversion"),
|
||||
]
|
||||
|
||||
enumTextFilt = [
|
||||
("G_TF_POINT", "Point", "Point"),
|
||||
("G_TF_AVERAGE", "Average", "Average"),
|
||||
("G_TF_BILERP", "Bilinear", "Bilinear"),
|
||||
("G_TF_POINT", "Point", "Point filtering"),
|
||||
("G_TF_AVERAGE", "Average", "Four sample filter, not recommended except for pixel aligned texrects"),
|
||||
("G_TF_BILERP", "Bilinear", "Standard N64 filtering with 3 point sample"),
|
||||
]
|
||||
|
||||
enumTextLUT = [
|
||||
@@ -188,14 +188,14 @@ enumTextLUT = [
|
||||
]
|
||||
|
||||
enumTextLOD = [
|
||||
("G_TL_TILE", "Tile", "Tile"),
|
||||
("G_TL_LOD", "LOD", "LOD"),
|
||||
("G_TL_TILE", "Tile", "Shows selected color combiner tiles"),
|
||||
("G_TL_LOD", "LoD", "Enables LoD calculations, LoD tile is base tile + clamp(log2(texel/pixel)), remainder of log2(texel/pixel) ratio gets stored to LoD Fraction in the color combiner"),
|
||||
]
|
||||
|
||||
enumTextDetail = [
|
||||
("G_TD_CLAMP", "Clamp", "Clamp"),
|
||||
("G_TD_SHARPEN", "Sharpen", "Sharpen"),
|
||||
("G_TD_DETAIL", "Detail", "Detail"),
|
||||
("G_TD_CLAMP", "Clamp", "Shows base tile for texel0 and texel 1 when magnifying (>1 texel/pixel), else shows LoD tiles"),
|
||||
("G_TD_SHARPEN", "Sharpen", "Sharpens pixel colors when magnifying (<1 texel/pixel), always shows LoD tiles"),
|
||||
("G_TD_DETAIL", "Detail", "Shows base tile when magnifying (<1 texel/pixel), else shows LoD tiles + 1"),
|
||||
]
|
||||
|
||||
enumTextPersp = [
|
||||
@@ -206,33 +206,33 @@ enumTextPersp = [
|
||||
enumCycleType = [
|
||||
("G_CYC_1CYCLE", "1 Cycle", "1 Cycle"),
|
||||
("G_CYC_2CYCLE", "2 Cycle", "2 Cycle"),
|
||||
("G_CYC_COPY", "Copy", "Copy"),
|
||||
("G_CYC_FILL", "Fill", "Fill"),
|
||||
("G_CYC_COPY", "Copy", "Copies texture values to framebuffer with no perspective correction or blending"),
|
||||
("G_CYC_FILL", "Fill", "Uses fill color to fill primitve"),
|
||||
]
|
||||
|
||||
enumColorDither = [("G_CD_DISABLE", "Disable", "Disable"), ("G_CD_ENABLE", "Enable", "Enable")]
|
||||
|
||||
enumPipelineMode = [
|
||||
("G_PM_1PRIMITIVE", "1 Primitive", "1 Primitive"),
|
||||
("G_PM_NPRIMITIVE", "N Primitive", "N Primitive"),
|
||||
("G_PM_1PRIMITIVE", "1 Primitive", "Adds in pipe sync after every tri draw. Adds significant amounts of lag. Only use in vanilla SM64 hacking projects"),
|
||||
("G_PM_NPRIMITIVE", "N Primitive", "No additional syncs are added after tri draws. Default option for every game but vanilla SM64"),
|
||||
]
|
||||
|
||||
enumAlphaCompare = [
|
||||
("G_AC_NONE", "None", "None"),
|
||||
("G_AC_THRESHOLD", "Threshold", "Threshold"),
|
||||
("G_AC_DITHER", "Dither", "Dither"),
|
||||
("G_AC_NONE", "None", "No alpha comparison is made, writing is based on coverage"),
|
||||
("G_AC_THRESHOLD", "Threshold", "Writes if alpha is greater than blend color alpha"),
|
||||
("G_AC_DITHER", "Dither", "Writes if alpha is greater than random value"),
|
||||
]
|
||||
|
||||
enumDepthSource = [
|
||||
("G_ZS_PIXEL", "Pixel", "Pixel"),
|
||||
("G_ZS_PRIM", "Primitive", "Primitive"),
|
||||
("G_ZS_PIXEL", "Pixel", "Z value is calculated per primitive pixel"),
|
||||
("G_ZS_PRIM", "Primitive", "Uses prim depth to set Z value, does not work on HLE emulation"),
|
||||
]
|
||||
|
||||
enumCoverage = [
|
||||
("CVG_DST_CLAMP", "Clamp", "Clamp"),
|
||||
("CVG_DST_WRAP", "Wrap", "Wrap"),
|
||||
("CVG_DST_FULL", "Full", "Full"),
|
||||
("CVG_DST_SAVE", "Save", "Save"),
|
||||
("CVG_DST_CLAMP", "Clamp", "Clamp if blending, else use new pixel coverage"),
|
||||
("CVG_DST_WRAP", "Wrap", "Wrap coverage"),
|
||||
("CVG_DST_FULL", "Full", "Force to full coverage"),
|
||||
("CVG_DST_SAVE", "Save", "Don't overwrite previous framebuffer coverage value"),
|
||||
]
|
||||
|
||||
enumZMode = [
|
||||
|
||||
@@ -2536,45 +2536,54 @@ class RDPSettings(bpy.types.PropertyGroup):
|
||||
name="Z Buffer",
|
||||
default=True,
|
||||
update=update_node_values_with_preset,
|
||||
description="Enables calculation of Z value for primitives. Disable if not reading or writing Z-Buffer in the blender"
|
||||
)
|
||||
g_shade: bpy.props.BoolProperty(
|
||||
name="Shading",
|
||||
default=True,
|
||||
update=update_node_values_with_preset,
|
||||
description="Computes shade coordinates for primitives. Disable if not using lighting, vertex colors or fog"
|
||||
)
|
||||
# v1/2 difference
|
||||
g_cull_front: bpy.props.BoolProperty(
|
||||
name="Cull Front",
|
||||
update=update_node_values_with_preset,
|
||||
description="Disables drawing of front faces"
|
||||
)
|
||||
# v1/2 difference
|
||||
g_cull_back: bpy.props.BoolProperty(
|
||||
name="Cull Back",
|
||||
default=True,
|
||||
update=update_node_values_with_preset,
|
||||
description="Disables drawing of back faces"
|
||||
)
|
||||
g_fog: bpy.props.BoolProperty(
|
||||
name="Fog",
|
||||
update=update_node_values_with_preset,
|
||||
description="Turns on/off fog calculation. Fog variable gets stored into shade alpha"
|
||||
)
|
||||
g_lighting: bpy.props.BoolProperty(
|
||||
name="Lighting",
|
||||
default=True,
|
||||
update=update_node_values_with_preset,
|
||||
description="Enables calculation shade color using lights. Turn off for vertex colors as shade color"
|
||||
)
|
||||
g_tex_gen: bpy.props.BoolProperty(
|
||||
name="Texture UV Generate",
|
||||
update=update_node_values_with_preset,
|
||||
description="Generates texture coordinates for reflection mapping based on vertex normals and lookat direction. On a skybox texture, maps the sky to the center of the texture and the ground to a circle inscribed in the border. Requires lighting enabled to use"
|
||||
)
|
||||
g_tex_gen_linear: bpy.props.BoolProperty(
|
||||
name="Texture UV Generate Linear",
|
||||
update=update_node_values_with_preset,
|
||||
description="Modifies the texgen mapping; enable with texgen. Use a normal panorama image for the texture, with the sky at the top and the ground at the bottom. Requires lighting enabled to use"
|
||||
)
|
||||
# v1/2 difference
|
||||
g_shade_smooth: bpy.props.BoolProperty(
|
||||
name="Smooth Shading",
|
||||
default=True,
|
||||
update=update_node_values_with_preset,
|
||||
description="Shades primitive smoothly using interpolation between shade values for each vertex (Gouraud shading)"
|
||||
)
|
||||
# f3dlx2 only
|
||||
g_clipping: bpy.props.BoolProperty(
|
||||
@@ -2589,6 +2598,7 @@ class RDPSettings(bpy.types.PropertyGroup):
|
||||
items=enumAlphaDither,
|
||||
default="G_AD_NOISE",
|
||||
update=update_node_values_with_preset,
|
||||
description="Applies your choice dithering type to output framebuffer alpha. Dithering is used to convert high precision source colors into lower precision framebuffer values"
|
||||
)
|
||||
# v2 only
|
||||
g_mdsft_rgb_dither: bpy.props.EnumProperty(
|
||||
@@ -2596,35 +2606,41 @@ class RDPSettings(bpy.types.PropertyGroup):
|
||||
items=enumRGBDither,
|
||||
default="G_CD_MAGICSQ",
|
||||
update=update_node_values_with_preset,
|
||||
description="Applies your choice dithering type to output framebuffer color. Dithering is used to convert high precision source colors into lower precision framebuffer values"
|
||||
)
|
||||
g_mdsft_combkey: bpy.props.EnumProperty(
|
||||
name="Chroma Key",
|
||||
items=enumCombKey,
|
||||
default="G_CK_NONE",
|
||||
update=update_node_values_with_preset,
|
||||
description="Turns on/off the chroma key. Chroma key requires a special setup to work properly"
|
||||
)
|
||||
g_mdsft_textconv: bpy.props.EnumProperty(
|
||||
name="Texture Convert",
|
||||
items=enumTextConv,
|
||||
default="G_TC_FILT",
|
||||
update=update_node_values_with_preset,
|
||||
description="Sets the function of the texture convert unit, to do texture filtering, YUV to RGB conversion, or both"
|
||||
)
|
||||
g_mdsft_text_filt: bpy.props.EnumProperty(
|
||||
name="Texture Filter",
|
||||
items=enumTextFilt,
|
||||
default="G_TF_BILERP",
|
||||
update=update_node_values_without_preset,
|
||||
description="Applies your choice of filtering to texels"
|
||||
)
|
||||
g_mdsft_textlut: bpy.props.EnumProperty(
|
||||
name="Texture LUT",
|
||||
items=enumTextLUT,
|
||||
default="G_TT_NONE",
|
||||
description="Changes texture look up table (LUT) behavior. This property is auto set if you choose a CI texture"
|
||||
)
|
||||
g_mdsft_textlod: bpy.props.EnumProperty(
|
||||
name="Texture LOD",
|
||||
items=enumTextLOD,
|
||||
default="G_TL_TILE",
|
||||
update=update_node_values_with_preset,
|
||||
description="Turns on/off the use of LoD on textures. LoD textures change the used tile based on the texel/pixel ratio"
|
||||
)
|
||||
num_textures_mipmapped: bpy.props.IntProperty(
|
||||
name="Number of Mipmaps",
|
||||
@@ -2638,18 +2654,21 @@ class RDPSettings(bpy.types.PropertyGroup):
|
||||
items=enumTextDetail,
|
||||
default="G_TD_CLAMP",
|
||||
update=update_node_values_with_preset,
|
||||
description="Changes type of LoD usage. Affects how tiles are selected based on texel magnification. Only works when G_TL_LOD is selected"
|
||||
)
|
||||
g_mdsft_textpersp: bpy.props.EnumProperty(
|
||||
name="Texture Perspective Correction",
|
||||
items=enumTextPersp,
|
||||
default="G_TP_PERSP",
|
||||
update=update_node_values_with_preset,
|
||||
description="Turns on/off texture perspective correction"
|
||||
)
|
||||
g_mdsft_cycletype: bpy.props.EnumProperty(
|
||||
name="Cycle Type",
|
||||
items=enumCycleType,
|
||||
default="G_CYC_1CYCLE",
|
||||
update=update_node_values_with_preset,
|
||||
description="Changes RDP pipeline configuration. For normal textured triangles use one or two cycle mode"
|
||||
)
|
||||
# v1 only
|
||||
g_mdsft_color_dither: bpy.props.EnumProperty(
|
||||
@@ -2657,12 +2676,14 @@ class RDPSettings(bpy.types.PropertyGroup):
|
||||
items=enumColorDither,
|
||||
default="G_CD_ENABLE",
|
||||
update=update_node_values_with_preset,
|
||||
description="Applies your choice dithering type to output frambuffer"
|
||||
)
|
||||
g_mdsft_pipeline: bpy.props.EnumProperty(
|
||||
name="Pipeline Span Buffer Coherency",
|
||||
items=enumPipelineMode,
|
||||
default="G_PM_1PRIMITIVE",
|
||||
update=update_node_values_with_preset,
|
||||
description="Changes primitive rasterization timing by adding syncs after tri draws. Vanilla SM64 has synchronization issues which could cause a crash if not using 1 prim. For any modern SM64 hacking project or other game N-prim should always be used"
|
||||
)
|
||||
|
||||
# lower half mode
|
||||
@@ -2671,12 +2692,14 @@ class RDPSettings(bpy.types.PropertyGroup):
|
||||
items=enumAlphaCompare,
|
||||
default="G_AC_NONE",
|
||||
update=update_node_values_with_preset,
|
||||
description="Uses alpha comparisons to decide if a pixel should be written. Applies before blending"
|
||||
)
|
||||
g_mdsft_zsrcsel: bpy.props.EnumProperty(
|
||||
name="Z Source Selection",
|
||||
items=enumDepthSource,
|
||||
default="G_ZS_PIXEL",
|
||||
update=update_node_values_with_preset,
|
||||
description="Changes screen-space Z value source used for Z-Buffer calculations"
|
||||
)
|
||||
|
||||
prim_depth: bpy.props.PointerProperty(
|
||||
@@ -2715,37 +2738,47 @@ class RDPSettings(bpy.types.PropertyGroup):
|
||||
)
|
||||
aa_en: bpy.props.BoolProperty(
|
||||
update=update_node_values_with_preset,
|
||||
description="Enables anti-aliasing to rasterized primitive edges. Uses coverage to determine edges"
|
||||
)
|
||||
z_cmp: bpy.props.BoolProperty(
|
||||
update=update_node_values_with_preset,
|
||||
description="Checks pixel Z value against Z-Buffer to test writing"
|
||||
)
|
||||
z_upd: bpy.props.BoolProperty(
|
||||
update=update_node_values_with_preset,
|
||||
description="Updates the Z-Buffer with the most recently written pixel Z value"
|
||||
)
|
||||
im_rd: bpy.props.BoolProperty(
|
||||
update=update_node_values_with_preset,
|
||||
description="Enables reading from framebuffer for blending calculations"
|
||||
)
|
||||
clr_on_cvg: bpy.props.BoolProperty(
|
||||
update=update_node_values_with_preset,
|
||||
description="Only draw on coverage (amount primitive covers target pixel) overflow"
|
||||
)
|
||||
cvg_dst: bpy.props.EnumProperty(
|
||||
name="Coverage Destination",
|
||||
items=enumCoverage,
|
||||
update=update_node_values_with_preset,
|
||||
description="Changes how coverage (amount primitive covers target pixel) gets retrieved/stored"
|
||||
)
|
||||
zmode: bpy.props.EnumProperty(
|
||||
name="Z Mode",
|
||||
items=enumZMode,
|
||||
update=update_node_values_with_preset,
|
||||
description="Changes Z calculation for different types of primitives"
|
||||
)
|
||||
cvg_x_alpha: bpy.props.BoolProperty(
|
||||
update=update_node_values_with_preset,
|
||||
description="Multiply coverage (amount primitive covers target pixel) with alpha and store result as coverage"
|
||||
)
|
||||
alpha_cvg_sel: bpy.props.BoolProperty(
|
||||
update=update_node_values_with_preset,
|
||||
description="Use coverage (amount primitive covers target pixel) as alpha instead of color combiner alpha"
|
||||
)
|
||||
force_bl: bpy.props.BoolProperty(
|
||||
update=update_node_values_with_preset,
|
||||
description="Always uses blending on. Default blending is conditionally only applied during partial coverage. Forcing blending will disable division step of the blender, so B input must be 1-A or there may be rendering issues. Always use this option when Z Buffering is off"
|
||||
)
|
||||
|
||||
# cycle dependent - (P * A + M - B) / (A + B)
|
||||
|
||||
@@ -30,7 +30,8 @@ def getTimeSettingsCmd(outRoom: OOTRoom):
|
||||
|
||||
def getWindSettingsCmd(outRoom: OOTRoom):
|
||||
return (
|
||||
indent + f"SCENE_CMD_WIND_SETTINGS({', '.join(f'{dir}' for dir in outRoom.windVector)}, {outRoom.windStrength})"
|
||||
indent
|
||||
+ f"SCENE_CMD_WIND_SETTINGS({', '.join(f'{dir}' for dir in outRoom.windVector)}, {outRoom.windStrength}),\n"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,23 @@ from ....oot_constants import ootEnumSceneID, ootSceneNameToID
|
||||
from ....oot_utility import getCustomProperty, ExportInfo
|
||||
|
||||
|
||||
def getSceneNameSettings(scene):
|
||||
if scene is not None:
|
||||
return bpy.context.scene.ootSceneExportSettings.option
|
||||
else:
|
||||
return bpy.context.scene.ootSceneRemoveSettings.option
|
||||
|
||||
|
||||
def getHackerOoTCheck(line: str):
|
||||
return (
|
||||
line != "\n"
|
||||
and '#include "config.h"\n' not in line
|
||||
and "#ifdef INCLUDE_TEST_SCENES" not in line
|
||||
and "#endif" not in line
|
||||
and not line.startswith("// ")
|
||||
)
|
||||
|
||||
|
||||
def getSceneTable(exportPath):
|
||||
"""Read and remove unwanted stuff from ``scene_table.h``"""
|
||||
dataList = []
|
||||
@@ -15,7 +32,7 @@ def getSceneTable(exportPath):
|
||||
with open(os.path.join(exportPath, "include/tables/scene_table.h")) as fileData:
|
||||
# keep the relevant data and do some formatting
|
||||
for i, line in enumerate(fileData):
|
||||
if not line.startswith("// "):
|
||||
if not bpy.context.scene.fast64.oot.hackerFeaturesEnabled or getHackerOoTCheck(line):
|
||||
if not (line.startswith("/**") or line.startswith(" *")):
|
||||
dataList.append(line[(line.find("(") + 1) :].rstrip(")\n").replace(" ", "").split(","))
|
||||
else:
|
||||
@@ -61,7 +78,7 @@ def getOriginalIndex(sceneName):
|
||||
raise PluginError("ERROR: Scene Index not found!")
|
||||
|
||||
|
||||
def getInsertionIndex(sceneNames, sceneName, index, mode):
|
||||
def getInsertionIndex(scene, sceneNames, sceneName, index, mode):
|
||||
"""Returns the index to know where to insert data"""
|
||||
# special case where the scene is "Inside the Great Deku Tree"
|
||||
# since it's the first scene simply return 0
|
||||
@@ -82,11 +99,7 @@ def getInsertionIndex(sceneNames, sceneName, index, mode):
|
||||
return i + 1
|
||||
# return an index to insert a comment
|
||||
elif mode == "EXPORT":
|
||||
return (
|
||||
i
|
||||
if not sceneName in sceneNames and sceneName != bpy.context.scene.ootSceneExportSettings.option
|
||||
else i + 1
|
||||
)
|
||||
return i if not sceneName in sceneNames and sceneName != getSceneNameSettings(scene) else i + 1
|
||||
# same but don't check for chosen scene
|
||||
elif mode == "REMOVE":
|
||||
return i if not sceneName in sceneNames else i + 1
|
||||
@@ -94,14 +107,14 @@ def getInsertionIndex(sceneNames, sceneName, index, mode):
|
||||
raise NotImplementedError
|
||||
|
||||
# if the index hasn't been found yet, do it again but decrement the index
|
||||
return getInsertionIndex(sceneNames, sceneName, currentIndex - 1, mode)
|
||||
return getInsertionIndex(scene, sceneNames, sceneName, currentIndex - 1, mode)
|
||||
|
||||
|
||||
def getSceneParams(scene, exportInfo, sceneNames):
|
||||
"""Returns the parameters that needs to be set in ``DEFINE_SCENE()``"""
|
||||
# in order to replace the values of ``unk10``, ``unk12`` and basically every parameters from ``DEFINE_SCENE``,
|
||||
# you just have to make it return something other than None, not necessarily a string
|
||||
sceneIndex = getSceneIndex(sceneNames, bpy.context.scene.ootSceneExportSettings.option)
|
||||
sceneIndex = getSceneIndex(sceneNames, getSceneNameSettings(scene))
|
||||
sceneName = sceneTitle = sceneID = sceneUnk10 = sceneUnk12 = None
|
||||
name = scene.name if scene is not None else exportInfo.name
|
||||
|
||||
@@ -124,8 +137,8 @@ def sceneTableToC(data, header, sceneNames, scene):
|
||||
mode = "EXPORT" if scene is not None else "REMOVE"
|
||||
|
||||
# get the index of the last non-debug scene
|
||||
lastNonDebugSceneIdx = getInsertionIndex(sceneNames, "SCENE_OUTSIDE_GANONS_CASTLE", None, mode)
|
||||
lastSceneIdx = getInsertionIndex(sceneNames, "SCENE_TESTROOM", None, mode)
|
||||
lastNonDebugSceneIdx = getInsertionIndex(scene, sceneNames, "SCENE_OUTSIDE_GANONS_CASTLE", None, mode)
|
||||
lastSceneIdx = getInsertionIndex(scene, sceneNames, "SCENE_TESTROOM", None, mode)
|
||||
|
||||
# add the actual lines with the same formatting
|
||||
for i in range(len(data)):
|
||||
@@ -158,6 +171,25 @@ def getDrawConfig(sceneName: str):
|
||||
raise PluginError(f"Scene name {sceneName} not found in scene table.")
|
||||
|
||||
|
||||
def addHackerOoTData(fileData: str):
|
||||
"""Reads the file and adds HackerOoT's modifications to the scene table file"""
|
||||
newFileData = ['#include "config.h"\n\n']
|
||||
|
||||
for line in fileData.splitlines():
|
||||
if "// Debug-only scenes" in line:
|
||||
newFileData.append("\n#ifdef INCLUDE_TEST_SCENES\n")
|
||||
|
||||
if "// Added scenes" in line:
|
||||
newFileData.append("#endif\n\n")
|
||||
|
||||
newFileData.append(f"{line}\n")
|
||||
|
||||
if not "// Added scenes" in fileData:
|
||||
newFileData.append("#endif\n")
|
||||
|
||||
return "".join(newFileData)
|
||||
|
||||
|
||||
def modifySceneTable(scene, exportInfo: ExportInfo):
|
||||
"""Edit the scene table with the new data"""
|
||||
exportPath = exportInfo.exportPath
|
||||
@@ -178,7 +210,7 @@ def modifySceneTable(scene, exportInfo: ExportInfo):
|
||||
# that means the selected scene has been removed from the table
|
||||
# however if the scene variable is not None
|
||||
# set it to "INSERT" because we need to insert the scene in the right place
|
||||
if sceneIndex is None and bpy.context.scene.ootSceneExportSettings.option == "Custom":
|
||||
if sceneIndex is None and getSceneNameSettings(scene) == "Custom":
|
||||
mode = "CUSTOM"
|
||||
elif sceneIndex is None and scene is not None:
|
||||
mode = "INSERT"
|
||||
@@ -213,7 +245,7 @@ def modifySceneTable(scene, exportInfo: ExportInfo):
|
||||
# if this the user chose a vanilla scene, removed it and want to export
|
||||
# insert the data in the normal location
|
||||
# shifted index = vanilla index - (vanilla last scene index - new last scene index)
|
||||
index = getInsertionIndex(sceneNames, sceneID, None, mode)
|
||||
index = getInsertionIndex(scene, sceneNames, sceneID, None, mode)
|
||||
sceneNames.insert(index, sceneParams[2])
|
||||
fileData.insert(index, sceneParams)
|
||||
|
||||
@@ -225,7 +257,12 @@ def modifySceneTable(scene, exportInfo: ExportInfo):
|
||||
else:
|
||||
raise PluginError("ERROR: Scene not found in ``scene_table.h``!")
|
||||
|
||||
# get the new file data
|
||||
newFileData = sceneTableToC(fileData, header, sceneNames, scene)
|
||||
|
||||
# apply HackerOoT changes if needed
|
||||
if bpy.context.scene.fast64.oot.hackerFeaturesEnabled:
|
||||
newFileData = addHackerOoTData(newFileData)
|
||||
|
||||
# write the file with the final data
|
||||
writeFile(
|
||||
os.path.join(exportPath, "include/tables/scene_table.h"), sceneTableToC(fileData, header, sceneNames, scene)
|
||||
)
|
||||
writeFile(os.path.join(exportPath, "include/tables/scene_table.h"), newFileData)
|
||||
|
||||
Reference in New Issue
Block a user