A bit more snap generation prep
This commit is contained in:
parent
6fef3f1abb
commit
4801af9c59
|
@ -88,23 +88,13 @@ class NetConnlessJson(TypedDict):
|
||||||
name: list[str]
|
name: list[str]
|
||||||
members: list[NetConnlessMemberJson]
|
members: list[NetConnlessMemberJson]
|
||||||
|
|
||||||
class SnapObjMemberJson(TypedDict):
|
|
||||||
name: list[str]
|
|
||||||
type: NetMessageMemberTypeJson
|
|
||||||
|
|
||||||
class SnapObjJson(TypedDict):
|
|
||||||
id: int
|
|
||||||
name: list[str]
|
|
||||||
members: list[SnapObjMemberJson]
|
|
||||||
attributes: list[str]
|
|
||||||
|
|
||||||
class SpecJson(TypedDict):
|
class SpecJson(TypedDict):
|
||||||
constants: list[ConstantJson]
|
constants: list[ConstantJson]
|
||||||
game_enumerations: list[GameEnumJson]
|
game_enumerations: list[GameEnumJson]
|
||||||
game_messages: list[NetMessageJson]
|
game_messages: list[NetMessageJson]
|
||||||
system_messages: list[NetMessageJson]
|
system_messages: list[NetMessageJson]
|
||||||
connless_messages: list[NetConnlessJson]
|
connless_messages: list[NetConnlessJson]
|
||||||
snapshot_objects: list[SnapObjJson]
|
snapshot_objects: list[NetMessageJson]
|
||||||
|
|
||||||
def gen_match_file_connless7(
|
def gen_match_file_connless7(
|
||||||
messages: list[NetConnlessJson]
|
messages: list[NetConnlessJson]
|
||||||
|
@ -720,7 +710,7 @@ class CodeGenerator():
|
||||||
out_file.write(',\n'.join(args) + '\n')
|
out_file.write(',\n'.join(args) + '\n')
|
||||||
out_file.write(' ) -> None:\n')
|
out_file.write(' ) -> None:\n')
|
||||||
|
|
||||||
def generate_snap_obj7(self, obj: SnapObjJson) -> None:
|
def generate_snap_obj7(self, obj: NetMessageJson) -> None:
|
||||||
name_snake = name_to_snake(obj['name'])
|
name_snake = name_to_snake(obj['name'])
|
||||||
name_camel = name_to_camel(obj['name'])
|
name_camel = name_to_camel(obj['name'])
|
||||||
dirname = os.path.dirname(__file__)
|
dirname = os.path.dirname(__file__)
|
||||||
|
@ -734,6 +724,13 @@ class CodeGenerator():
|
||||||
out_file.write('\n')
|
out_file.write('\n')
|
||||||
out_file.write('from twnet_parser.pretty_print import PrettyPrint\n')
|
out_file.write('from twnet_parser.pretty_print import PrettyPrint\n')
|
||||||
out_file.write(f'class Obj{name_camel}(PrettyPrint):\n')
|
out_file.write(f'class Obj{name_camel}(PrettyPrint):\n')
|
||||||
|
# self.write_init_method_header_connless7(out_file, obj, name_snake)
|
||||||
|
out_file.write(f" self.item_name: str = 'connless.{name_snake}'\n")
|
||||||
|
out_file.write(f" self.type_id: int = {obj['id']}\n")
|
||||||
|
out_file.write(f" self.id: int = 0\n")
|
||||||
|
out_file.write('\n')
|
||||||
|
self.generate_field_assignments_in_initialize(obj, out_file)
|
||||||
|
out_file.write('\n')
|
||||||
|
|
||||||
def generate_msg_connless(
|
def generate_msg_connless(
|
||||||
self,
|
self,
|
||||||
|
@ -966,7 +963,7 @@ class CodeGenerator():
|
||||||
game_messages: list[NetMessageJson] = spec_data['game_messages']
|
game_messages: list[NetMessageJson] = spec_data['game_messages']
|
||||||
system_messages: list[NetMessageJson] = spec_data['system_messages']
|
system_messages: list[NetMessageJson] = spec_data['system_messages']
|
||||||
connless_messages: list[NetConnlessJson] = spec_data['connless_messages']
|
connless_messages: list[NetConnlessJson] = spec_data['connless_messages']
|
||||||
snapshot_objects: list[SnapObjJson] = spec_data['snapshot_objects']
|
snapshot_objects: list[NetMessageJson] = spec_data['snapshot_objects']
|
||||||
self.gen_enum_file7()
|
self.gen_enum_file7()
|
||||||
gen_match_file7('game', game_messages)
|
gen_match_file7('game', game_messages)
|
||||||
gen_match_file7('system', system_messages)
|
gen_match_file7('system', system_messages)
|
||||||
|
@ -977,8 +974,8 @@ class CodeGenerator():
|
||||||
self.generate_msg(msg, 'system')
|
self.generate_msg(msg, 'system')
|
||||||
for connless_msg in connless_messages:
|
for connless_msg in connless_messages:
|
||||||
self.generate_msg_connless(connless_msg)
|
self.generate_msg_connless(connless_msg)
|
||||||
# for obj in snapshot_objects:
|
for obj in snapshot_objects:
|
||||||
# self.generate_snap_obj7(obj)
|
self.generate_snap_obj7(obj)
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
dirname = os.path.dirname(__file__)
|
dirname = os.path.dirname(__file__)
|
||||||
|
|
Loading…
Reference in a new issue