11import bpy
2+ import re
23
34from dataclasses import dataclass
45from typing import TYPE_CHECKING
@@ -53,7 +54,11 @@ def getCmdParams(self, data: str, cmdName: str, paramNumber: int):
5354 """Returns the list of every parameter of the given command"""
5455
5556 parenthesis = "(" if not cmdName .endswith ("(" ) else ""
56- params = data .strip ().removeprefix (f"{ cmdName } { parenthesis } " ).replace (" " , "" ).removesuffix (")" ).split ("," )
57+ data = data .strip ().removeprefix (f"{ cmdName } { parenthesis } " ).replace (" " , "" ).removesuffix (")" )
58+ if "CS_FLOAT" in data :
59+ data = re .sub (r"CS_FLOAT\([a-fA-F0-9x]*,([0-9e+-.f]*)\)" , r"\1" , data , re .DOTALL )
60+ data = re .sub (r"CS_FLOAT\([a-fA-F0-9x]*,([0-9e+-.f]*)" , r"\1" , data , re .DOTALL )
61+ params = data .split ("," )
5762 validTimeCmd = cmdName == "CS_TIME" and len (params ) == 6 and paramNumber == 5
5863 if len (params ) != paramNumber and not validTimeCmd :
5964 raise PluginError (
@@ -86,8 +91,11 @@ def getParsedCutscenes(self):
8691 for oldName in oldNames :
8792 fileData = fileData .replace (f"{ oldName } (" , f"{ ootCSLegacyToNewCmdNames [oldName ]} (" )
8893
94+ fileLines : list [str ] = []
95+ for line in fileData .split ("\n " ):
96+ fileLines .append (line .strip ())
97+
8998 # parse cutscenes
90- fileLines = fileData .split ("\n " )
9199 csData = []
92100 cutsceneList : list [list [str ]] = []
93101 foundCutscene = False
@@ -98,10 +106,11 @@ def getParsedCutscenes(self):
98106
99107 if foundCutscene :
100108 sLine = line .strip ()
101- if not sLine .endswith (")," ) and sLine .endswith ("," ):
102- line += fileLines [fileLines .index (line ) + 1 ].strip ()
109+ csCmd = sLine .split ("(" )[0 ]
110+ if "CutsceneData " not in line and "};" not in line and csCmd not in ootCutsceneCommandsC :
111+ csData [- 1 ] += line
103112
104- if len (csData ) == 0 or "CS_" in line :
113+ if len (csData ) == 0 or sLine . startswith ( "CS_" ) and not sLine . startswith ( "CS_FLOAT" ) :
105114 csData .append (line )
106115
107116 if "};" in line :
0 commit comments