Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OoT] OoT Object changes & small changes/fixes/removals #95

Merged
merged 60 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
4e3b654
Use XML for Object List
May 18, 2022
78cca84
Deleted ``oot_parse.py`` as it's not used anymore
May 18, 2022
174c8e4
Replaced ``\t`` by ``indent`` from ``oot_utility``
May 18, 2022
538a498
add defines for actor and object lists lengths
May 18, 2022
fba8210
Add missing objects when exporting, fixed scene obj selected, removed…
May 19, 2022
a7d8f53
removed another unused file
May 19, 2022
43983f9
removed undefines
May 19, 2022
c05a036
obj_gameplay_XXX check fix when adding missing objects
May 22, 2022
5c633c0
check if ObjectKey is None
May 22, 2022
506261e
review part 1
May 27, 2022
9be6795
actor list name update
May 27, 2022
e2536db
upgrade objects from old blends (review part 2)
May 27, 2022
5477dea
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
May 27, 2022
aed04fe
removed defines from header
Jun 11, 2022
18ecd93
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Jul 2, 2022
4e8964b
black formatting
Yanis42 Jul 2, 2022
afc97d9
bug fix + black
Yanis42 Jul 2, 2022
e0737af
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Jul 2, 2022
7cbdea2
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Jul 3, 2022
fad1f80
``.format`` -> f-string
Yanis42 Jul 3, 2022
f824c47
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Sep 5, 2022
097f1a3
OoT Data system
Yanis42 Sep 26, 2022
ffbffb3
revert formatting on unmodified files
Yanis42 Sep 26, 2022
0c5c4f6
revert unwanted changes
Yanis42 Sep 26, 2022
29b2976
enhancements
Yanis42 Sep 26, 2022
1340946
review
Yanis42 Sep 26, 2022
01409bd
review 2
Yanis42 Sep 26, 2022
f2d525b
review 3
Yanis42 Sep 26, 2022
f7bd548
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Sep 27, 2022
5c0d988
review 4
Yanis42 Sep 28, 2022
d136201
black
Yanis42 Sep 28, 2022
b0337d7
add back ID in objects names,
Yanis42 Sep 28, 2022
941c1d3
review 5
Yanis42 Sep 28, 2022
8d37c65
suggestions and fixed the actor xml
Yanis42 Sep 28, 2022
4f8c5dc
small issue fix
Yanis42 Sep 28, 2022
da03cf6
fixed typo
Yanis42 Sep 28, 2022
8594bdf
small detail
Yanis42 Sep 28, 2022
5caffb3
review 6
Yanis42 Sep 28, 2022
4953e1c
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Sep 28, 2022
351d759
fixed v5 merge unwanted change,
Yanis42 Sep 28, 2022
aa2646c
set version when adding something
Yanis42 Sep 29, 2022
b3d9534
fixed some object having the wrong name
Yanis42 Sep 29, 2022
41b39b5
fixed upgrade and adding object to prop issues
Yanis42 Sep 29, 2022
5138f18
split object funcs to their own files
Yanis42 Sep 29, 2022
1ee4d04
black
Yanis42 Sep 29, 2022
4676674
annotations
Yanis42 Sep 29, 2022
257d285
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Sep 29, 2022
562b227
ran black on (already formatted) modified files
Yanis42 Sep 29, 2022
c2ee070
review 7
Yanis42 Sep 29, 2022
70dd778
review 7.1
Yanis42 Sep 29, 2022
18c53b7
review 8
Yanis42 Sep 30, 2022
71a4d83
review + bugfix
Yanis42 Oct 2, 2022
5693835
review 10
Yanis42 Oct 13, 2022
06ee33c
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Oct 15, 2022
19040ac
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Nov 12, 2022
ff1734f
explained in a comment why checking actorID none
Yanis42 Nov 13, 2022
f76959b
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Nov 14, 2022
f8913ae
Merge remote-tracking branch 'upstream/main' into objects_and_fixes
Yanis42 Nov 16, 2022
a2b32ca
improved upgrade system
Yanis42 Nov 16, 2022
a18f0aa
fixed object list import
Yanis42 Nov 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ def upgrade_changed_props():
"""Set scene properties after a scene loads, used for migrating old properties"""
SM64_Properties.upgrade_changed_props()
SM64_ObjectProperties.upgrade_changed_props()
OOT_ObjectProperties.upgrade_changed_props()


def upgrade_scene_props_node():
Expand Down
48 changes: 48 additions & 0 deletions fast64_internal/oot/data/oot_actor_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from os import path
from dataclasses import dataclass
from .oot_getters import getXMLRoot
from .oot_data import OoT_BaseElement


@dataclass
class OoT_ActorElement(OoT_BaseElement):
category: str
tiedObjects: list[str]


class OoT_ActorData:
"""Everything related to OoT Actors"""

def __init__(self):
# Path to the ``ActorList.xml`` file
actorXML = path.dirname(path.abspath(__file__)) + "/xml/ActorList.xml"
actorRoot = getXMLRoot(actorXML)

# general actor list
self.actorList: list[OoT_ActorElement] = []

for actor in actorRoot.iterfind("Actor"):
tiedObjects = []
objKey = actor.get("ObjectKey")
actorName = f"{actor.attrib['Name']} - {actor.attrib['ID'].removeprefix('ACTOR_')}"
if objKey is not None: # actors don't always use an object
tiedObjects = objKey.split(",")
self.actorList.append(
OoT_ActorElement(
actor.attrib["ID"],
actor.attrib["Key"],
actorName,
int(actor.attrib["Index"]),
actor.attrib["Category"],
tiedObjects,
)
)
self.actorsByKey = {actor.key: actor for actor in self.actorList}
self.actorsByID = {actor.id: actor for actor in self.actorList}

# list of tuples used by Blender's enum properties
lastIndex = max(1, *(actor.index for actor in self.actorList))
self.ootEnumActorID = [("None", f"{i} (Deleted from the XML)", "None") for i in range(lastIndex)]
self.ootEnumActorID.insert(0, ("Custom", "Custom Actor", "Custom"))
for actor in self.actorList:
self.ootEnumActorID[actor.index] = (actor.id, actor.name, actor.id)
21 changes: 21 additions & 0 deletions fast64_internal/oot/data/oot_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from dataclasses import dataclass


@dataclass
class OoT_BaseElement:
id: str
key: str
name: str
index: int


@dataclass
class OoT_Data:
"""Contains data related to OoT, like actors or objects"""

def __init__(self):
from .oot_object_data import OoT_ObjectData
from .oot_actor_data import OoT_ActorData

self.objectData = OoT_ObjectData()
self.actorData = OoT_ActorData()
11 changes: 11 additions & 0 deletions fast64_internal/oot/data/oot_getters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from xml.etree.ElementTree import parse as parseXML, Element


def getXMLRoot(xmlPath: str) -> Element:
"""Parse an XML file and return its root element"""
try:
return parseXML(xmlPath).getroot()
except:
from ...utility import PluginError

raise PluginError(f"ERROR: File '{xmlPath}' is missing or malformed.")
55 changes: 55 additions & 0 deletions fast64_internal/oot/data/oot_object_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from dataclasses import dataclass
from os import path
from ...utility import PluginError
from .oot_getters import getXMLRoot
from .oot_data import OoT_BaseElement

# Note: "object" in this context refers to an OoT Object file (like ``gameplay_keep``)


@dataclass
class OoT_ObjectElement(OoT_BaseElement):
pass


class OoT_ObjectData:
"""Everything related to OoT objects"""

def __init__(self):
# general object list
self.objectList: list[OoT_ObjectElement] = []

# Path to the ``ObjectList.xml`` file
objectXML = path.dirname(path.abspath(__file__)) + "/xml/ObjectList.xml"
objectRoot = getXMLRoot(objectXML)

for obj in objectRoot.iterfind("Object"):
objName = f"{obj.attrib['Name']} - {obj.attrib['ID'].removeprefix('OBJECT_')}"
self.objectList.append(
OoT_ObjectElement(obj.attrib["ID"], obj.attrib["Key"], objName, int(obj.attrib["Index"]))
)

self.objectsByID = {obj.id: obj for obj in self.objectList}
self.objectsByKey = {obj.key: obj for obj in self.objectList}

# list of tuples used by Blender's enum properties
self.deletedEntry = ("None", "(Deleted from the XML)", "None")
lastIndex = max(1, *(obj.index for obj in self.objectList))
self.ootEnumObjectKey = self.getObjectIDList(lastIndex + 1, False)

# create the legacy object list for old blends
self.ootEnumObjectIDLegacy = self.getObjectIDList(self.objectsByKey["obj_timeblock"].index + 1, True)

# validate the legacy list, if there's any None element then something's wrong
if self.deletedEntry in self.ootEnumObjectIDLegacy:
raise PluginError("ERROR: Legacy Object List doesn't match!")

def getObjectIDList(self, max: int, isLegacy: bool):
"""Generates and returns the object list in the right order"""
objList = [self.deletedEntry] * max
for obj in self.objectList:
if obj.index < max:
identifier = obj.id if isLegacy else obj.key
objList[obj.index] = (identifier, obj.name, obj.id)
objList[0] = ("Custom", "Custom Object", "Custom")
return objList
Loading