OpenNaja / cobra-tools

A suite of GUI tools for extracting and modifying OVL and OVS archives, as well as editing the associated in-house file formats. Also includes a model plugin for Blender. For downloads, guides, and FAQs visit:
https://opennaja.github.io/cobra-tools/
GNU General Public License v3.0
98 stars 28 forks source link

Xml version filtering script. Three small updates to codegen. #286

Closed Candoran2 closed 1 year ago

Candoran2 commented 1 year ago

Summary:

  1. Added FilterXmlVersions.py. It is a class that can be used to generate a version-specific xml.
  2. Added setitem method to structs which have getitem method.
  3. Fixed slight issue with Version object ext parameter.
  4. Renamed UNKNOWN_GAME enum key to UNKNOWN.

Detailed:

  1. When initializing an object of this class, you specify either a version ID or an iterator of iterators which represents the verattr values. This object can then read an xml file. Only classes in main_tags and main_types are maintained (as long as they don't have any disqualifying conditions for that version). Other classes are all discarded unless they are used in one of the maintained types. In order to evaluate the vercond attribute, an evaluate method was added to the Expression class, which uses mapping of the operators to their python equivalents - rather than simply eval of the generated expression string, which is less safe.
  2. Obviously, if x = Vector3[1] needs to be possible, then Vector3[1] = x must also be possible. Not implementing __setitem__ was merely an oversight when first adding those functions being generated by the StructMetaClass.
  3. When there was only one ext parameter for a version, the parameter was passed as a tuple instead of an int . This was the result of the comma being misplaced.
  4. It was already in the games enum, so to specify GAME was not necessary.