mirror of
https://github.com/zeldaret/oot.git
synced 2025-06-08 09:31:52 +00:00
Assets system utilities (#2529)
This commit is contained in:
parent
a6162dc8e7
commit
f456bc6bf8
2 changed files with 32 additions and 1 deletions
|
@ -20,6 +20,11 @@ if TYPE_CHECKING:
|
||||||
VERBOSE_FILE_TRY_PARSE_DATA = 0
|
VERBOSE_FILE_TRY_PARSE_DATA = 0
|
||||||
VERBOSE_REPORT_RESBUF = False
|
VERBOSE_REPORT_RESBUF = False
|
||||||
|
|
||||||
|
DUMP_REPORTERS_IN_SOURCE = False
|
||||||
|
DUMP_XML_IN_SOURCE = False
|
||||||
|
|
||||||
|
DONT_MERGE_RESOURCE_BUFFERS_FROM_DIFFERENT_USERS = False
|
||||||
|
|
||||||
#
|
#
|
||||||
# file
|
# file
|
||||||
#
|
#
|
||||||
|
@ -446,7 +451,11 @@ class File:
|
||||||
else:
|
else:
|
||||||
assert i > 0
|
assert i > 0
|
||||||
prev = resource_buffer_markers[i - 1]
|
prev = resource_buffer_markers[i - 1]
|
||||||
if prev.file_end < rbm.file_start:
|
if prev.file_end < rbm.file_start or (
|
||||||
|
DONT_MERGE_RESOURCE_BUFFERS_FROM_DIFFERENT_USERS
|
||||||
|
and prev.file_end == rbm.file_start
|
||||||
|
and prev.users != rbm.users
|
||||||
|
):
|
||||||
# disjointed
|
# disjointed
|
||||||
if do_fuse(stride_first_i, i):
|
if do_fuse(stride_first_i, i):
|
||||||
return True
|
return True
|
||||||
|
@ -967,11 +976,27 @@ class Resource(abc.ABC):
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
def get_as_xml(self) -> str:
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
def write_c_definition(self, c: io.TextIOBase) -> bool:
|
def write_c_definition(self, c: io.TextIOBase) -> bool:
|
||||||
"""
|
"""
|
||||||
Returns True if something was written
|
Returns True if something was written
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if DUMP_REPORTERS_IN_SOURCE:
|
||||||
|
c.write(f"//R: {' '.join(_r.name for _r in self.reporters)}\n")
|
||||||
|
if DUMP_XML_IN_SOURCE:
|
||||||
|
try:
|
||||||
|
xml = self.get_as_xml()
|
||||||
|
except NotImplementedError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
c.write("/*\n")
|
||||||
|
c.write(xml)
|
||||||
|
c.write("\n")
|
||||||
|
c.write("*/\n")
|
||||||
|
|
||||||
if hasattr(self, "HACK_IS_STATIC_ON"):
|
if hasattr(self, "HACK_IS_STATIC_ON"):
|
||||||
c.write("static ")
|
c.write("static ")
|
||||||
c.write(self.get_c_declaration_base())
|
c.write(self.get_c_declaration_base())
|
||||||
|
|
|
@ -143,6 +143,12 @@ class VtxArrayResource(CDataResource):
|
||||||
self.cdata_ext = CDataExt_Array(self.element_cdata_ext, num)
|
self.cdata_ext = CDataExt_Array(self.element_cdata_ext, num)
|
||||||
super().__init__(file, range_start, name)
|
super().__init__(file, range_start, name)
|
||||||
|
|
||||||
|
def get_as_xml(self):
|
||||||
|
return f"""\
|
||||||
|
<Array Name="{self.symbol_name}" Count="{(self.range_end - self.range_start) // self.element_cdata_ext.size}" Offset="0x{self.range_start:X}">
|
||||||
|
<Vtx/>
|
||||||
|
</Array>"""
|
||||||
|
|
||||||
def get_c_declaration_base(self):
|
def get_c_declaration_base(self):
|
||||||
if hasattr(self, "HACK_IS_STATIC_ON"):
|
if hasattr(self, "HACK_IS_STATIC_ON"):
|
||||||
return f"Vtx {self.symbol_name}[{self.cdata_ext.length}]"
|
return f"Vtx {self.symbol_name}[{self.cdata_ext.length}]"
|
||||||
|
|
Loading…
Add table
Reference in a new issue