Skip to content

Commit

Permalink
reformat by using black
Browse files Browse the repository at this point in the history
  • Loading branch information
coco875 committed Feb 29, 2024
1 parent 758632c commit c41cbf2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
23 changes: 16 additions & 7 deletions fast64_internal/mk64/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
from ..utility import raisePluginError
from .f3d_course_parser import processCommands, parseCourseVtx


class MK64_Properties(PropertyGroup):
"""Global MK64 Scene Properties found under scene.fast64.mk64"""

version: bpy.props.IntProperty(name="MK64_Properties Version", default=0)


class MK64_ImportCourseDL(bpy.types.Operator):
# set bl_ properties
bl_idname = "object.f3d_course_import_dl"
Expand Down Expand Up @@ -43,15 +45,20 @@ def execute(self, context):

if "course_data" in importPath:
paths += [importPath.replace("course_data", "course_displaylists")]

paths += [importPath.replace("course_data.inc", "course_textures.linkonly").replace("course_displaylists.inc", "course_textures.linkonly")]

data = getImportData(paths)
paths += [
importPath.replace("course_data.inc", "course_textures.linkonly").replace(
"course_displaylists.inc", "course_textures.linkonly"
)
]

data = getImportData(paths)

f3d_context = F3DContext(get_F3D_GBI(), basePath, createF3DMat(None))
if "course_displaylists" in importPath or "course_data" in importPath:
vertexPath = importPath.replace("course_displaylists", "course_vertices").replace("course_data", "course_vertices")
vertexPath = importPath.replace("course_displaylists", "course_vertices").replace(
"course_data", "course_vertices"
)
print(vertexPath)
f3d_context.vertexData["0x4000000"] = parseCourseVtx(vertexPath, f3d_context.f3d)
f3d_context.processCommands = processCommands.__get__(f3d_context, F3DContext)
Expand Down Expand Up @@ -108,31 +115,33 @@ def draw(self, context):
# 'DLImportOtherFiles', context.scene, 'DLImportOtherFilesIndex')




mk64_classes = (MK64_Properties,)

mk64_panel_classes = (
MK64_ImportCourseDL,
MK64_ImportCourseDLPanel,
)


def mk64_panel_register():
for cls in mk64_panel_classes:
register_class(cls)


def mk64_panel_unregister():
for cls in mk64_panel_classes:
unregister_class(cls)


def mk64_register(registerPanels):
for cls in mk64_classes:
register_class(cls)
if registerPanels:
mk64_panel_register()


def mk64_unregister(registerPanel):
for cls in reversed(mk64_classes):
unregister_class(cls)
if registerPanel:
mk64_panel_unregister()
mk64_panel_unregister()
26 changes: 15 additions & 11 deletions fast64_internal/mk64/f3d_course_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
from ..f3d.f3d_writer import F3DVert
from ..utility import PluginError, float_from_u16_str, gammaInverseValue, int_from_s16_str, readFile, unpackNormal


def courseVertexFormatPatterns():
# position, uv, color/normal
return [
# decomp format
"\{\s*"
+ "\{+([^,\}]*),([^,\}]*),([^,\}]*)\}\s*,\s*"
+ "\{([^,\}]*),([^,\}]*)\}\s*,\s*"
+ "\{MACRO_COLOR_FLAG\(([^,\}]*),([^,\}]*),([^,\}]*),([^,\}])*\),([^,\}]*)\}\s*"
+ "\}",
][0]
# position, uv, color/normal
return [
# decomp format
"\{\s*"
+ "\{+([^,\}]*),([^,\}]*),([^,\}]*)\}\s*,\s*"
+ "\{([^,\}]*),([^,\}]*)\}\s*,\s*"
+ "\{MACRO_COLOR_FLAG\(([^,\}]*),([^,\}]*),([^,\}]*),([^,\}])*\),([^,\}]*)\}\s*"
+ "\}",
][0]


def parseCourseVtx(path: str, f3d):
data = readFile(path)
Expand All @@ -35,6 +37,7 @@ def parseCourseVtx(path: str, f3d):
)
return vertexData


def getVertexDataStart(vertexDataParam: str, f3d: F3D):
matchResult = re.search(r"\&?([A-Za-z0-9\_]*)\s*(\[([^\]]*)\])?\s*(\+(.*))?", vertexDataParam)
if matchResult is None:
Expand All @@ -45,14 +48,15 @@ def getVertexDataStart(vertexDataParam: str, f3d: F3D):
offset += math_eval(matchResult.group(3), f3d)
if matchResult.group(5):
offset += math_eval(matchResult.group(5), f3d)

name = matchResult.group(1)

if matchResult.group(1).startswith("0x04"):
offset = (int(matchResult.group(1), 16) - 0x04000000)//16
offset = (int(matchResult.group(1), 16) - 0x04000000) // 16
name = hex(0x04000000)
return name, offset


def processCommands(self, dlData: str, dlName: str, dlCommands: "list[ParsedMacro]"):
callStack = [F3DParsedCommands(dlName, dlCommands, 0)]
while len(callStack) > 0:
Expand Down
3 changes: 2 additions & 1 deletion fast64_internal/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class OOT_Panel(bpy.types.Panel):
@classmethod
def poll(cls, context):
return context.scene.gameEditorMode == "OOT"



class MK64_Panel(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
Expand Down

0 comments on commit c41cbf2

Please sign in to comment.