ref: 979b3767410248893bf0411706aca9e3a68196da
parent: a049ef74f88a98a0925f5b918578608945445c8e
author: Bryan Bishop <[email protected]>
date: Wed May 16 20:40:40 EDT 2012
generate helpful labels for maps
--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -4026,11 +4026,14 @@
self.dependencies = None
if not label:
label = self.base_label + hex(address)
- self.label = Label(name=label, address=address, object=self)
+ self.label = Label(address=address, object=self)
self.last_address = address + 9
script_parse_table[address : self.last_address] = self
self.parse()
+ def make_label(self):
+ return map_names[self.map_group][self.map_id]["label"] + "_MapHeader"
+
def parse(self):
address = self.address
print "parsing a MapHeader at " + hex(address)
@@ -4121,11 +4124,14 @@
self.dependencies = None
if not label:
label = self.base_label + hex(address)
- self.label = Label(name=label, address=address, object=self)
+ self.label = Label(address=address, object=self)
self.last_address = address+12
#i think it's always a static size?
script_parse_table[address : self.last_address] = self
self.parse()
+
+ def make_label(self):
+ return map_names[self.map_group][self.map_id]["label"] + "_SecondMapHeader"
def parse(self):
address = self.address
@@ -4272,10 +4278,13 @@
raise Exception, "MapBlockData needs to know the width/height of its map"
if not label:
label = self.base_label + hex(address)
- self.label = Label(name=label, address=address, object=self)
+ self.label = Label(address=address, object=self)
self.last_address = self.address + (self.width.byte * self.height.byte)
script_parse_table[address : self.last_address] = self
self.parse()
+
+ def make_label(self):
+ return map_names[self.map_group][self.map_id]["label"] + "_BlockData"
def save_to_file(self):
#check if the file exists already
@@ -4310,9 +4319,12 @@
self.dependencies = None
if not label:
label = self.base_label + hex(address)
- self.label = Label(name=label, address=address, object=self)
+ self.label = Label(address=address, object=self)
self.parse()
script_parse_table[address : self.last_address] = self
+
+ def make_label(self):
+ return map_names[self.map_group][self.map_id]["label"] + "_MapEventHeader"
def parse(self):
map_group, map_id, debug = self.map_group, self.map_id, self.debug
@@ -4533,9 +4545,12 @@
self.dependencies = None
if not label:
label = self.base_label + hex(address)
- self.label = Label(name=label, address=address, object=self)
+ self.label = Label(address=address, object=self)
self.parse()
script_parse_table[address : self.last_address] = self
+
+ def make_label(self):
+ return map_names[self.map_group][self.map_id]["label"] + "_MapScriptHeader"
def parse(self):
address = self.address
@@ -6177,11 +6192,10 @@
been previously written to file.
"""
def __init__(self, name=None, address=None, line_number=None, object=None, is_in_file=None, address_is_in_file=None, add_to_globals=True):
- assert name!=None, "need a name"
- assert address!=None, "need an address"
+ assert address != None, "need an address"
assert is_valid_address(address), "address must be valid"
+ assert object != None, "need an object to relate with"
- self.name = name
self.address = address
self.object = object
@@ -6193,23 +6207,17 @@
# -- better.
#
# check if the label is in the file already
- #self.is_in_file = is_in_file
- #if is_in_file == None:
- # self.old_check_is_in_file()
- #
# check if the address of this label is already in use
- #self.address_is_in_file = address_is_in_file
- #if address_is_in_file == None:
- # self.old_check_address_is_in_file()
self.is_in_file = is_in_file
- #if is_in_file == None and add_to_globals:
- # self.check_is_in_file()
self.address_is_in_file = address_is_in_file
- #if address_is_in_file == None and add_to_globals:
- # self.check_address_is_in_file()
+
+ if name == None:
+ name = object.base_label + "_" + hex(object.address)
+ self.name = name
+
if add_to_globals:
all_new_labels.append(self)
@@ -6278,6 +6286,13 @@
return True
else:
return False
+
+ def make_label(self):
+ """ Generates a label name based on parents and self.object.
+ """
+ object = self.object
+ name = object.make_label()
+ return name
def line_has_comment_address(line, returnable={}, bank=None):
"""checks that a given line has a comment