Repository for mbEditorPro 2.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.9 KiB

# • ▌ ▄ ·. ▄▄▄▄· ▄▄▄ .·▄▄▄▄ ▪ ▄▄▄▄▄ ▄▄▄ ▄▄▄·▄▄▄
# ·██ ▐███▪▐█ ▀█▪ ▀▄.▀·██▪ ██ ██ •██ ▪ ▀▄ █· ▐█ ▄█▀▄ █·▪
# ▐█ ▌▐▌▐█·▐█▀▀█▄ ▐▀▀▪▄▐█· ▐█▌▐█· ▐█.▪ ▄█▀▄ ▐▀▀▄ ██▀·▐▀▀▄ ▄█▀▄
# ██ ██▌▐█▌██▄▪▐█ ▐█▄▄▌██. ██ ▐█▌ ▐█▌·▐█▌.▐▌▐█•█▌ ▐█▪·•▐█•█▌▐█▌.▐▌
# ▀▀ █▪▀▀▀·▀▀▀▀ ▀▀▀ ▀▀▀▀▀• ▀▀▀ ▀▀▀ ▀█▄▀▪.▀ ▀ .▀ .▀ ▀ ▀█▄▀▪
# Magicbane Emulator Project © 2013 - 2022
# www.magicbane.com
from collections import OrderedDict
from arcane.enums.hashes import hash_to_string, string_to_hash
from arcane.util import ResStream
class ClassRequired:
def load_binary(self, stream: ResStream):
classs = stream.read_dword()
self.class_restrict = stream.read_bool()
self.class_values = [
stream.read_dword() for _ in range(classs)
]
def save_binary(self, stream: ResStream):
stream.write_dword(len(self.class_values))
stream.write_bool(self.class_restrict)
for cls in self.class_values:
stream.write_dword(cls)
def load_json(self, data):
self.class_restrict = data['restrict']
self.class_values = []
for cls in data['classes']:
self.class_values.append(string_to_hash(cls))
return data
def save_json(self):
data = OrderedDict()
data['restrict'] = self.class_restrict
data['classes'] = []
for cls in self.class_values:
data['classes'].append(hash_to_string(cls))
return data