diff --git a/docs/gsf/gsf_full.jpeg b/docs/gsf/gsf_full.jpeg new file mode 100644 index 0000000..35f02fc Binary files /dev/null and b/docs/gsf/gsf_full.jpeg differ diff --git a/docs/gsf/kaitai/gsf.ksy b/docs/gsf/kaitai/gsf.ksy new file mode 100644 index 0000000..a43c10d --- /dev/null +++ b/docs/gsf/kaitai/gsf.ksy @@ -0,0 +1,1034 @@ +meta: + id: gsf + file-extension: gsf + application: ParaWorld + license: CC0-1.0 + endian: le +seq: + - id: magic + contents: [0x47, 0x53, 0x46, 0x00] + - id: version + contents: [0x00, 0x00, 0x00, 0x00] + - id: header2_offset + type: u4 + - id: header + type: header + - id: padding + size: header2_offset - _io.pos +instances: + header2: + pos: header2_offset + type: header2 +types: + header: + seq: + - id: num_chars + type: u4 + - id: file_name + type: str + size: num_chars + encoding: ASCII + - id: num_models + type: u4 + - id: model_info_table + type: model_info_table + repeat: expr + repeat-expr: num_models + - id: num_sounds + type: u4 + - id: sound_table + type: sound_table + repeat: expr + repeat-expr: num_sounds + - id: num_dusttrails + type: u4 + - id: dusttrail_table + type: dusttrail_table + repeat: expr + repeat-expr: num_dusttrails + - id: num_anim_flags + type: u4 + - id: anim_flags_table + type: anim_flags_table + repeat: expr + repeat-expr: num_anim_flags + - id: num_walk_transitions + type: u4 + - id: walk_transition_table + type: walk_transition_table + repeat: expr + repeat-expr: num_walk_transitions + header2: + seq: + - id: zero + contents: [0x00, 0x00, 0x00, 0x00] + - id: num_models2 + type: u4 + - id: num_anims + type: u4 + - id: zero2 + contents: [0x00, 0x00, 0x00, 0x00] + - id: model_settings_offset + type: u4 + - id: num_model_settings + type: u4 + - id: anim_settings_offset + type: u4 + - id: num_anim_settings + type: u4 + - id: materials_header + type: materials_header + instances: + model_settings: + pos: model_settings_offset + _io.pos + 16 + type: model_settings(_io.pos) + size: 84 + repeat: expr + repeat-expr: num_model_settings + if: model_settings_offset != 0x80000000 + anim_settings: + pos: anim_settings_offset + _io.pos + 24 + type: anim_settings(_io.pos) + size: 28 + repeat: expr + repeat-expr: num_anim_settings + if: anim_settings_offset != 0x80000000 + model_info_table: + seq: + - id: num_chars + type: u4 + - id: model_name + type: str + size: num_chars + encoding: ASCII + - id: model_index + type: u4 + - id: num_model_anim + type: u4 + - id: model_anim + type: model_anim + repeat: expr + repeat-expr: num_model_anim + if: num_model_anim != 0 + - id: num_walksets + type: u4 + - id: walkset + type: walkset + repeat: expr + repeat-expr: num_walksets + if: num_walksets != 0 + model_anim: + seq: + - id: num_chars + type: u4 + - id: model_anim_name + type: str + size: num_chars + encoding: ASCII + - id: anim_index + type: u4 + - id: num_sound_indices + type: u4 + - id: sound_indices + type: u4 + repeat: expr + repeat-expr: num_sound_indices + - id: unk_idle_mgr + type: u4 + #1 = idle anim + #2 = walk anim? + walkset: + seq: + - id: walk_1_anim_index + type: u1 + - id: walk_2_anim_index + type: u1 + - id: walk_3_anim_index + type: u1 + - id: walk_4_anim_index + type: u1 + - id: walk_1_end_s_anim_index + type: u1 + - id: walk_1_end_m_anim_index + type: u1 + - id: walk_1_end_l_anim_index + type: u1 + - id: walk_2_end_s_anim_index + type: u1 + - id: walk_2_end_m_anim_index + type: u1 + - id: walk_2_end_l_anim_index + type: u1 + - id: walk_3_end_s_anim_index + type: u1 + - id: walk_3_end_m_anim_index + type: u1 + - id: walk_3_end_l_anim_index + type: u1 + - id: walk_4_end_s_anim_index + type: u1 + - id: walk_4_end_m_anim_index + type: u1 + - id: walk_4_end_l_anim_index + type: u1 + - id: standing_turn_right_anim_index + type: u1 + - id: standing_turn_left_anim_index + type: u1 + - id: unk_anim_index + # all_characters.gsf + type: u1 + - id: accel_1_2_anim_index + type: u1 + - id: accel_2_3_anim_index + type: u1 + - id: accel_3_4_anim_index + type: u1 + - id: brake_4_3_anim_index + type: u1 + - id: brake_3_2_anim_index + type: u1 + - id: brake_2_1_anim_index + type: u1 + - id: walk_left_anim_index + type: u1 + - id: walk_right_anim_index + type: u1 + - id: unk_anim_index2 + # all_characters.gsf + type: u1 + - id: walk_transition_index + type: u1 + - id: growup_anim_index + type: u1 + - id: sail_up_anim_index + type: u1 + - id: sail_down_anim_index + type: u1 + - id: standanim_anim_index + type: u1 + - id: walk_to_swim_2_anim_index + type: u1 + - id: unk_bytes + # contents: [0x00, 0x00, 0x00, 0x00] + # all_characters.gsf + type: u4 + - id: unk_bytes2 + # contents: [0x00, 0x00, 0x00, 0x00] + # all_characters.gsf + type: u4 + - id: walkset_name + type: str + size: 4 + encoding: ASCII + sound_table: + seq: + - id: num_chars + type: u4 + - id: sound_name + type: str + size: num_chars + encoding: ASCII + - id: start_frame + type: u4 + - id: volume + type: u4 + - id: speed + type: f4 + - id: unk_bytes + size: 16 + - id: num_snd_group_chars + type: u4 + - id: snd_group_name + type: str + size: num_snd_group_chars + encoding: ASCII + dusttrail_table: + seq: + - id: model_info_index + type: u4 + - id: unk_bytes + type: u2 + - id: dusttrail_name_num_chars + type: u4 + - id: dusttrail_name + type: str + size: dusttrail_name_num_chars + encoding: ASCII + - id: unk_bytes_bone_index + type: u4 + - id: num_entries + type: u4 + - id: dusttrail_entry + type: dusttrail_entry + repeat: expr + repeat-expr: num_entries + dusttrail_entry: + seq: + - id: entry_name_num_chars + type: u4 + - id: entry_name + type: str + size: entry_name_num_chars + encoding: ASCII + - id: value_num_chars + type: u4 + - id: value + type: str + size: value_num_chars + encoding: ASCII + anim_flags_table: + seq: + - id: num_chars + type: u4 + - id: anim_flag + type: str + size: num_chars + encoding: ASCII + walk_transition_table: + seq: + - id: num_chars + type: u4 + - id: walk_transition_name + type: str + size: num_chars + encoding: ASCII + materials_header: + seq: + - id: num_material + type: u4 + - id: materials_offset + type: u4 + - id: num_max_entries + type: u4 + instances: + materials: + pos: materials_offset + _io.pos + 36 + type: material(_io.pos) + repeat: expr + repeat-expr: num_max_entries + if: materials_offset != 0x80000000 + material: + params: + - id: pos + type: s4 + seq: + - id: bitset_material_attributes1 + size: 4 + - id: bitset_material_attributes2 + size: 4 + - id: texture_name_offset + type: u4 + - id: nm_name_offset + type: u4 + - id: env_name_offset + type: u4 + - id: zero + contents: [0x00, 0x00, 0x00, 0x00] + instances: + texture_name: + io: _root._io + pos: pos + texture_name_offset + 8 + type: texture_name + if: texture_name_offset != 0x80000000 + nm_name: + io: _root._io + pos: pos + nm_name_offset + 12 + type: nm_name + if: nm_name_offset != 0x80000000 + env_name: + io: _root._io + pos: pos + env_name_offset + 16 + type: env_name + if: env_name_offset != 0x80000000 + texture_name: + seq: + - id: num_strings + type: u4 + - id: num_max_chars + type: u4 + - id: num_chars + type: u4 + - id: texture_name + type: str + size: num_chars + encoding: ASCII + - id: padding + size: num_max_chars - num_chars + nm_name: + seq: + - id: num_strings + type: u4 + - id: num_max_chars + type: u4 + - id: num_chars + type: u4 + - id: nm_name + type: str + size: num_chars + encoding: ASCII + - id: padding + size: num_max_chars - num_chars + env_name: + seq: + - id: num_strings + type: u4 + - id: num_max_chars + type: u4 + - id: num_chars + type: u4 + - id: env_name + type: str + size: num_chars + encoding: ASCII + - id: padding + size: num_max_chars - num_chars + model_settings: + params: + - id: pos + type: s4 + seq: + - id: fourcc + type: str + size: 4 + encoding: ASCII + - id: object_name_offset + type: u4 + - id: chunks_table_offset + type: u4 + - id: num_chunks + type: u4 + - id: fallback_table_offset + type: u4 + - id: read_data_true_false + type: u4 + - id: model_settings_num_unk + type: u2 + - id: num_additional_effects + type: u2 + - id: num_chunks_before_links + type: u2 + - id: num_links + type: u2 + - id: model_settings_unk + type: u4 + - id: model_settings_unk2 + type: u4 + - id: unused_offset + contents: [0x00, 0x00, 0x00, 0x80] + - id: pathfinder_table_offset + type: u4 + - id: num_pathfinder_tables + type: u4 + - id: bbox_min_x + type: f4 + - id: bbox_min_y + type: f4 + - id: bbox_min_z + type: f4 + - id: bbox_max_x + type: f4 + - id: bbox_max_y + type: f4 + - id: bbox_max_z + type: f4 + - id: anim_chunks_table_header_offset + type: u4 + - id: num_object_anim + type: u4 + instances: + object_name: + io: _root._io + pos: pos + object_name_offset - 80 + type: object_name + if: object_name_offset != 0x80000000 + chunks_table: + io: _root._io + pos: pos + chunks_table_offset - 76 + type: chunk_neg_offset(_io.pos, _index) + repeat: expr + repeat-expr: num_chunks + if: chunks_table_offset != 0x80000000 + fallback_table: + io: _root._io + pos: pos + fallback_table_offset - 68 + type: fallback_table + if: fallback_table_offset != 0x80000000 + pathfinder_table: + io: _root._io + pos: pos + pathfinder_table_offset - 40 + type: pathfinder_table + repeat: expr + repeat-expr: num_pathfinder_tables + if: pathfinder_table_offset != 0x80000000 + anim_attr_table: + io: _root._io + pos: pos + anim_chunks_table_header_offset - 8 + type: anim_chunks_table_header(_io.pos, _index) + repeat: expr + repeat-expr: num_object_anim + if: anim_chunks_table_header_offset != 0x80000000 + object_name: + seq: + - id: num_strings + type: u4 + - id: num_max_chars + type: u4 + - id: num_chars + type: u4 + - id: object_name + type: str + size: num_chars + encoding: ASCII + - id: padding + size: num_max_chars - num_chars + chunk_neg_offset: + params: + - id: pos + type: s4 + - id: i + type: s4 + seq: + - id: chunk_neg_offset + type: s4 + instances: + chunk: + #wip pos is working but ugly + io: _root._io + pos: _parent.chunks_table_offset + _parent.pos + pos + chunk_neg_offset - 160 + i*4 + type: chunk + chunk: + seq: + - id: chunk_type_enum + type: u4 + enum: mesh_chunk_type + - id: chunk_info + type: + switch-on: chunk_type_enum + cases: + mesh_chunk_type::pos_link: pos_link_chunk + mesh_chunk_type::bone_link: bone_link_chunk + mesh_chunk_type::skeleton: skeleton_chunk(_io.pos) + mesh_chunk_type::mesh_transformation: mesh_transformation_chunk + mesh_chunk_type::mesh: mesh_chunk + pos_link_chunk: + seq: + - id: attributes + type: u4 + - id: guid + type: u4 + - id: pos_x + type: f4 + - id: pos_y + type: f4 + - id: pos_z + type: f4 + - id: guat_1 + type: f4 + - id: guat_i + type: f4 + - id: guat_j + type: f4 + - id: guat_k + type: f4 + - id: link_fourcc + type: str + size: 4 + encoding: ASCII + bone_link_chunk: + seq: + - id: attributes + type: u4 + - id: guid + type: u4 + - id: pos_x + type: f4 + - id: pos_y + type: f4 + - id: pos_z + type: f4 + - id: guat_1 + type: f4 + - id: guat_i + type: f4 + - id: guat_j + type: f4 + - id: guat_k + type: f4 + - id: link_fourcc + type: str + size: 4 + encoding: ASCII + - id: zero + contents: [0x00, 0x00, 0x00, 0x00] + - id: bone_id + type: u4 + - id: bone_weight + type: u4 + skeleton_chunk: + params: + - id: pos + type: s4 + seq: + - id: attributes + type: u4 + - id: guid + type: u4 + - id: skeleton_index + type: u4 + - id: skeleton_guid + type: u4 + - id: flags + type: u4 + - id: anim_pos_x + type: f4 + - id: anim_pos_y + type: f4 + - id: anim_pos_z + type: f4 + - id: scale_x + type: f4 + - id: scale_y + type: f4 + - id: scale_z + type: f4 + - id: guat_1 + type: f4 + - id: guat_i + type: f4 + - id: guat_j + type: f4 + - id: guat_k + type: f4 + - id: bones_count1 + type: u4 + - id: next_bone_offset + type: u4 + - id: bones_count2 + type: u4 + - id: bind_pose_offset + type: u4 + - id: num_all_bones + type: u4 + - id: num_all_bones2 + type: u4 + - id: num_unk2 + type: u4 + - id: bone + type: bone_chunk + repeat: expr + repeat-expr: num_all_bones - 1 + instances: + bind_pose_chunk: + io: _root._io + #pos: _parent.anim_chunks_table_header_offset - 88 + _parent.pos + pos + anim_chunks_table_offset + i*12 + pos: pos + bind_pose_offset + 72 + type: bind_pose_chunk + repeat: expr + repeat-expr: num_all_bones + if: bind_pose_offset != 0x80000000 + bone_chunk: + seq: + - id: guid + type: u4 + - id: flags + type: u4 + - id: anim_pos_x + type: f4 + - id: anim_pos_y + type: f4 + - id: anim_pos_z + type: f4 + - id: scale_x + type: f4 + - id: scale_y + type: f4 + - id: scale_z + type: f4 + - id: guat_1 + type: f4 + - id: guat_i + type: f4 + - id: guat_j + type: f4 + - id: guat_k + type: f4 + - id: bones_count1 + type: u4 + - id: next_bone_offset + type: u4 + - id: bones_count2 + type: u4 + bind_pose_chunk: + seq: + - id: float1_1 + type: f4 + - id: float1_2 + type: f4 + - id: float1_3 + type: f4 + - id: float1_4 + type: f4 + - id: float2_1 + type: f4 + - id: float2_2 + type: f4 + - id: float2_3 + type: f4 + - id: float2_4 + type: f4 + - id: float3_1 + type: f4 + - id: float3_2 + type: f4 + - id: float3_3 + type: f4 + - id: float3_4 + type: f4 + - id: float4_1 + type: f4 + - id: float4_2 + type: f4 + - id: float4_3 + type: f4 + - id: float4_4 + type: f4 + mesh_transformation_chunk: + seq: + - id: attributes + type: u4 + - id: guid + type: u4 + - id: scale_x + type: f4 + - id: stretch_y + type: f4 + - id: stretch_z_x + type: f4 + - id: float_1 + type: f4 + - id: stretch_x + type: f4 + - id: scale_y + type: f4 + - id: stretch_z_y + type: f4 + - id: float_2 + type: f4 + - id: shear_x + type: f4 + - id: shear_y + type: f4 + - id: scale_z + type: f4 + - id: float_3 + type: f4 + - id: pos_x + type: f4 + - id: pos_y + type: f4 + - id: pos_z + type: f4 + - id: float_4 + type: f4 + mesh_chunk: + seq: + - id: mesh_type_enum + type: u4 + enum: mesh_type + - id: mesh_info + type: + switch-on: mesh_type_enum + cases: + mesh_type::particle: particle_chunk + mesh_type::mesh: mesh_data_chunk + particle_chunk: + seq: + - id: guid + type: u4 + - id: unk + size: 8 + - id: unk_float + type: f4 + - id: unk2 + size: 16 + - id: unk_float2 + type: f4 + - id: unk_float3 + type: f4 + - id: unk_float4 + type: f4 + - id: spread + type: f4 + - id: num_unk + type: u4 + - id: unk_float5 + type: f4 + - id: num_unk2 + type: u4 + - id: num_unk3 + type: u4 + - id: num_unk4 + type: u4 + - id: num_unk5 + type: u4 + - id: num_unk6 + type: u4 + - id: num_strings + type: u4 + - id: num_max_chars + type: u4 + - id: num_chars_bugged + type: u4 + - id: particle_name + type: str + size: num_max_chars + encoding: ASCII + - id: unk_atlas_stuff + size: 4 + - id: unk5 + size: 5 + - id: particle_size + type: f4 + - id: particle_speed + type: f4 + - id: unk_float6 + type: f4 + - id: unk_float7 + type: f4 + - id: unk_float8 + type: f4 + - id: unk_float9 + type: f4 + - id: unk6 + size: 4 + - id: color_fade_out_speed + type: f4 + - id: color_fade_in_speed + type: f4 + - id: emitter_speed + type: f4 + - id: scale + type: f4 + - id: particle_scale + type: f4 + - id: red_rnd_mul + type: u4 + - id: green_rnd_mul + type: u4 + - id: blue_rnd_mul + type: u4 + - id: red_mul + type: f4 + - id: green_mul + type: f4 + - id: blue_mul + type: f4 + - id: red_strength + type: u4 + - id: green_strength + type: u4 + - id: blue_strength + type: u4 + - id: unk7 + size: 12 + - id: unk_float10 + type: f4 + - id: unk9 + size: 16 + mesh_data_chunk: + seq: + - id: unk + type: u4 + fallback_table: + seq: + - id: header2_neg_offset + type: u4 + - id: model_settings_neg_offset + type: u4 + pathfinder_table: + seq: + - id: pathfinder_enum + type: u4 + enum: pf_type + - id: pathfinder + type: + switch-on: pathfinder_enum + cases: + pf_type::hit_collision: hit_collision_struct + pf_type::path_blocker: path_blocker_struct + hit_collision_struct: + seq: + - id: pos_x + type: f4 + - id: pos_y + type: f4 + - id: pos_z + type: f4 + - id: sphere_size + type: f4 + - id: guid + type: u4 + - id: zero + contents: [0x00, 0x00, 0x00, 0x00] + - id: unk + type: u4 + path_blocker_struct: + seq: + - id: pos_x + type: f4 + - id: pos_y + type: f4 + - id: pos_z + type: f4 + - id: size_x + type: f4 + - id: size_y + type: f4 + - id: size_z + type: f4 + - id: unk + type: u4 + anim_chunks_table_header: + params: + - id: pos + type: s4 + - id: i + type: s4 + seq: + - id: model_settings_neg_offset + type: u4 + - id: anim_chunks_table_offset + type: u4 + - id: num_offsets + type: u4 + instances: + anim_chunks_table: + #wip pos is working but ugly + io: _root._io + pos: _parent.anim_chunks_table_header_offset - 88 + _parent.pos + pos + anim_chunks_table_offset + i*12 + type: anim_chunks_table + repeat: expr + repeat-expr: num_offsets + if: anim_chunks_table_offset != 0x80000000 + anim_chunks_table: + seq: + - id: anim_chunk_neg_offset + type: u4 + - id: num_anim_frames + type: u4 + anim_settings: + params: + - id: pos + type: s4 + seq: + - id: fourcc + type: str + size: 4 + encoding: ASCII + - id: anim_header_offset + type: u4 + - id: anim_start_pointer_offset + type: u4 + - id: num_anim_start_pointer_offsets + type: u4 + - id: stand_pos_obj_offset + type: u4 + - id: num_stand_pos_obj_offsets + type: u4 + - id: num_frames + type: u4 + instances: + anim_header: + io: _root._io + pos: pos + anim_header_offset - 24 + type: anim_header + if: anim_header_offset != 0x80000000 + anim_start_pointer: + io: _root._io + pos: pos + anim_start_pointer_offset - 20 + type: anim_start_neg_offset + repeat: expr + repeat-expr: num_anim_start_pointer_offsets + if: anim_start_pointer_offset != 0x80000000 + stand_pos_obj: + io: _root._io + pos: pos + stand_pos_obj_offset - 12 + type: stand_pos_obj(_io.pos) + repeat: expr + repeat-expr: num_stand_pos_obj_offsets + if: stand_pos_obj_offset != 0x80000000 + anim_header: + seq: + - id: num_strings + type: u4 + - id: num_max_chars + type: u4 + - id: num_chars + type: u4 + - id: anim_name + type: str + size: num_chars + encoding: ASCII + - id: padding + size: num_max_chars - num_chars + anim_start_neg_offset: + seq: + - id: anim_start_neg_offset + type: u4 + stand_pos_obj: + params: + - id: pos + type: s4 + seq: + - id: header2_neg_offset + type: u4 + - id: materials_header_neg_offset + type: u4 + - id: anim_texture_table_offset + type: u4 + - id: unk1 + type: u4 + - id: unk2 + type: u4 + - id: chunk_type + type: u4 + - id: attributes + type: u4 + - id: guid + type: u4 + - id: bbox_min_x + type: f4 + - id: bbox_min_y + type: f4 + - id: bbox_min_z + type: f4 + - id: bbox_max_x + type: f4 + - id: bbox_max_y + type: f4 + - id: bbox_max_z + type: f4 + instances: + anim_texture_table: + io: _root._io + pos: pos + anim_texture_table_offset + 48 + type: anim_texture_table + if: anim_texture_table_offset != 0x80000000 + anim_texture_table: + seq: + - id: unk_wip + type: u4 +enums: + pf_type: + 0x00000000: hit_collision + 0x00000001: path_blocker + mesh_chunk_type: + 0x0000000B: pos_link + 0x8000000B: bone_link + 0x00000005: skeleton + 0x80000000: mesh_transformation + 0x00000002: mesh + mesh_type: + 0x0000001F: particle + 0x00000000: mesh \ No newline at end of file diff --git a/lib/classes/gsf/gsf.dart b/lib/classes/gsf/gsf.dart index 5412b7d..8ed1dd0 100644 --- a/lib/classes/gsf/gsf.dart +++ b/lib/classes/gsf/gsf.dart @@ -1,15 +1,20 @@ import 'dart:typed_data'; -import 'package:paraworld_gsf_viewer/classes/gsf/header.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/header.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header2/header2.dart'; class GSF { - const GSF({ + GSF({ required this.header, + required this.header2, }); final Header header; + late final Header2 header2; - GSF.fromBytes(Uint8List bytes) : header = Header.fromBytes(bytes); + GSF.fromBytes(Uint8List bytes) : header = Header.fromBytes(bytes) { + header2 = Header2.fromBytes(bytes, header.getEndOffset()); + } @override String toString() { diff --git a/lib/classes/gsf/header/anim_flags_table.dart b/lib/classes/gsf/header/anim_flags_table.dart new file mode 100644 index 0000000..a40907c --- /dev/null +++ b/lib/classes/gsf/header/anim_flags_table.dart @@ -0,0 +1,32 @@ +import 'dart:typed_data'; + +import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; + +class AnimFlagTable extends GsfPart { + late final Standard4BytesData nameLength; + + AnimFlagTable.fromBytes(Uint8List bytes, int offset) : super(offset: offset) { + nameLength = Standard4BytesData( + position: 0, + bytes: bytes, + offset: offset, + ); + + name = GsfData.fromPosition( + relativePos: nameLength.relativeEnd, + length: nameLength.value, + bytes: bytes, + offset: offset, + ); + } + + @override + int getEndOffset() { + return name.offsettedLength; + } + + @override + String toString() { + return 'AnimFlagsTable: $name'; + } +} diff --git a/lib/classes/gsf/dust_trail_info.dart b/lib/classes/gsf/header/dust_trail_info.dart similarity index 94% rename from lib/classes/gsf/dust_trail_info.dart rename to lib/classes/gsf/header/dust_trail_info.dart index a225400..d2a608d 100644 --- a/lib/classes/gsf/dust_trail_info.dart +++ b/lib/classes/gsf/header/dust_trail_info.dart @@ -41,7 +41,7 @@ class DustTrailInfo extends GsfPart { bytes, entries.isNotEmpty ? entries.last.getEndOffset() - : entryCount.offsettedLength(offset), + : entryCount.offsettedLength, )); } } @@ -51,7 +51,7 @@ class DustTrailInfo extends GsfPart { int getEndOffset() { return entries.isNotEmpty ? entries.last.getEndOffset() - : entryCount.offsettedLength(offset); + : entryCount.offsettedLength; } @override @@ -87,6 +87,6 @@ class DustTrailEntry extends GsfPart { @override int getEndOffset() { - return valueChars.offsettedLength(offset); + return valueChars.offsettedLength; } } diff --git a/lib/classes/gsf/dust_trail_table.dart b/lib/classes/gsf/header/dust_trail_table.dart similarity index 87% rename from lib/classes/gsf/dust_trail_table.dart rename to lib/classes/gsf/header/dust_trail_table.dart index f694abd..102033d 100644 --- a/lib/classes/gsf/dust_trail_table.dart +++ b/lib/classes/gsf/header/dust_trail_table.dart @@ -1,6 +1,6 @@ import 'dart:typed_data'; -import 'package:paraworld_gsf_viewer/classes/gsf/dust_trail_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/dust_trail_info.dart'; import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; class DustTrailTable extends GsfPart { @@ -23,7 +23,7 @@ class DustTrailTable extends GsfPart { bytes, dustTrailInfos.isNotEmpty ? dustTrailInfos.last.getEndOffset() - : dustTrailCount.offsettedLength(offset), + : dustTrailCount.offsettedLength, ), ); } @@ -33,7 +33,7 @@ class DustTrailTable extends GsfPart { int getEndOffset() { return dustTrailInfos.isNotEmpty ? dustTrailInfos.last.getEndOffset() - : dustTrailCount.offsettedLength(offset); + : dustTrailCount.offsettedLength; } @override diff --git a/lib/classes/gsf/header.dart b/lib/classes/gsf/header/header.dart similarity index 54% rename from lib/classes/gsf/header.dart rename to lib/classes/gsf/header/header.dart index c1f693f..22ce97b 100644 --- a/lib/classes/gsf/header.dart +++ b/lib/classes/gsf/header/header.dart @@ -1,20 +1,18 @@ import 'dart:typed_data'; -import 'package:paraworld_gsf_viewer/classes/gsf/dust_trail_table.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/model_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/sound_table.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/walk_transition_table.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/anim_flags_table.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/dust_trail_table.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/model_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/sound_table.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/walk_transition_table.dart'; import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; class Header extends GsfPart { Header({ - required this.name, required this.modelCount, required this.soundTable, required this.modelInfos, required this.dustTrailTable, - required this.walkTransitionTable1, - required this.walkTransitionTable2, }) : super(offset: 0); late final GsfData _magic; @@ -22,14 +20,14 @@ class Header extends GsfPart { late final Standard4BytesData contentTableOffset; late final Standard4BytesData nameLength; - late final GsfData name; late final Standard4BytesData modelCount; late final List modelInfos; late final SoundTable soundTable; late final DustTrailTable dustTrailTable; - late final WalkTransitionTable walkTransitionTable1; - late final WalkTransitionTable - walkTransitionTable2; // there seems to be 2 transitions tables + late final Standard4BytesData animFlagsCount; + late final List animFlagsTables = []; + late final Standard4BytesData walkTransitionsCount; + late final List walkTransitionTables = []; Header.fromBytes(Uint8List bytes) : super(offset: 0) { _magic = GsfData.fromPosition( @@ -51,7 +49,10 @@ class Header extends GsfPart { ); modelCount = Standard4BytesData( - position: name.relativeEnd, bytes: bytes, offset: offset); + position: name.relativeEnd, + bytes: bytes, + offset: offset, + ); print("modelCount: $modelCount"); modelInfos = []; for (var i = 0; i < modelCount.value; i++) { @@ -60,7 +61,7 @@ class Header extends GsfPart { bytes, modelInfos.isNotEmpty ? modelInfos.last.getEndOffset() - : modelCount.offsettedLength(offset), + : modelCount.offsettedLength, ), ); } @@ -68,7 +69,7 @@ class Header extends GsfPart { bytes, modelInfos.isNotEmpty ? modelInfos.last.getEndOffset() - : modelCount.offsettedLength(offset), + : modelCount.offsettedLength, ); dustTrailTable = DustTrailTable.fromBytes( @@ -76,15 +77,41 @@ class Header extends GsfPart { soundTable.getEndOffset(), ); - walkTransitionTable1 = WalkTransitionTable.fromBytes( - bytes, - dustTrailTable.getEndOffset(), + animFlagsCount = Standard4BytesData( + position: dustTrailTable.getEndOffset() - offset, + bytes: bytes, + offset: offset, ); - walkTransitionTable2 = WalkTransitionTable.fromBytes( - bytes, - walkTransitionTable1.getEndOffset(), + for (var i = 0; i < animFlagsCount.value; i++) { + animFlagsTables.add( + AnimFlagTable.fromBytes( + bytes, + animFlagsTables.isNotEmpty + ? animFlagsTables.last.getEndOffset() + : animFlagsCount.offsettedLength, + ), + ); + } + + walkTransitionsCount = Standard4BytesData( + position: animFlagsTables.isNotEmpty + ? animFlagsTables.last.getEndOffset() - offset + : animFlagsCount.offsettedLength, + bytes: bytes, + offset: offset, ); + + for (var i = 0; i < walkTransitionsCount.value; i++) { + walkTransitionTables.add( + WalkTransitionTable.fromBytes( + bytes, + walkTransitionTables.isNotEmpty + ? walkTransitionTables.last.getEndOffset() + : walkTransitionsCount.offsettedLength, + ), + ); + } } @override @@ -101,6 +128,8 @@ class Header extends GsfPart { @override int getEndOffset() { - return walkTransitionTable2.getEndOffset(); + return walkTransitionTables.isNotEmpty + ? walkTransitionTables.last.getEndOffset() + : walkTransitionsCount.offsettedLength; } } diff --git a/lib/classes/gsf/model_anim.dart b/lib/classes/gsf/header/model_anim.dart similarity index 87% rename from lib/classes/gsf/model_anim.dart rename to lib/classes/gsf/header/model_anim.dart index e9594e9..280eec3 100644 --- a/lib/classes/gsf/model_anim.dart +++ b/lib/classes/gsf/header/model_anim.dart @@ -1,13 +1,12 @@ import 'dart:typed_data'; -import 'package:paraworld_gsf_viewer/classes/gsf/sound_indices.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/sound_indices.dart'; import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; class ModelAnim extends GsfPart { ModelAnim({required super.offset}); late final Standard4BytesData nameLength; - late final GsfData name; late final Standard4BytesData index; late final SoundIndices soundIndices; late final Standard4BytesData unknownData; @@ -25,7 +24,7 @@ class ModelAnim extends GsfPart { index = Standard4BytesData( position: name.relativeEnd, bytes: bytes, offset: offset); - soundIndices = SoundIndices.fromBytes(bytes, index.offsettedLength(offset)); + soundIndices = SoundIndices.fromBytes(bytes, index.offsettedLength); unknownData = Standard4BytesData( position: index.relativeEnd + soundIndices.length, bytes: bytes, @@ -35,7 +34,7 @@ class ModelAnim extends GsfPart { @override int getEndOffset() { - return unknownData.offsettedLength(offset); + return unknownData.offsettedLength; } @override diff --git a/lib/classes/gsf/model_info.dart b/lib/classes/gsf/header/model_info.dart similarity index 85% rename from lib/classes/gsf/model_info.dart rename to lib/classes/gsf/header/model_info.dart index 383d4c5..010dac2 100644 --- a/lib/classes/gsf/model_info.dart +++ b/lib/classes/gsf/header/model_info.dart @@ -1,13 +1,12 @@ import 'dart:typed_data'; -import 'package:paraworld_gsf_viewer/classes/gsf/model_anim.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/walk_set_table.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/model_anim.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/walk_set_table.dart'; import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; class ModelInfo extends GsfPart { ModelInfo({ required offset, - required this.name, required this.index, required this.animCount, required this.modelAnims, @@ -15,7 +14,6 @@ class ModelInfo extends GsfPart { }) : super(offset: offset); late final Standard4BytesData nameLength; - late final GsfData name; late final Standard4BytesData index; late final Standard4BytesData animCount; late final List @@ -46,7 +44,7 @@ class ModelInfo extends GsfPart { bytes, modelAnims.isNotEmpty ? modelAnims.last.getEndOffset() - : animCount.offsettedLength(offset), + : animCount.offsettedLength, )); } } @@ -55,7 +53,7 @@ class ModelInfo extends GsfPart { bytes, modelAnims.isNotEmpty ? modelAnims.last.getEndOffset() - : animCount.offsettedLength(offset), + : animCount.offsettedLength, ); } diff --git a/lib/classes/gsf/sound_indices.dart b/lib/classes/gsf/header/sound_indices.dart similarity index 89% rename from lib/classes/gsf/sound_indices.dart rename to lib/classes/gsf/header/sound_indices.dart index 63d5cee..fdf7e07 100644 --- a/lib/classes/gsf/sound_indices.dart +++ b/lib/classes/gsf/header/sound_indices.dart @@ -23,6 +23,6 @@ class SoundIndices extends GsfPart { @override int getEndOffset() { - return count.offsettedLength(offset) + indices.length * 4; + return indices.isNotEmpty ? indices.last.offsettedLength : count.offsettedLength ; } } diff --git a/lib/classes/gsf/sound_info.dart b/lib/classes/gsf/header/sound_info.dart similarity index 92% rename from lib/classes/gsf/sound_info.dart rename to lib/classes/gsf/header/sound_info.dart index 17909be..ad1bd17 100644 --- a/lib/classes/gsf/sound_info.dart +++ b/lib/classes/gsf/header/sound_info.dart @@ -4,10 +4,9 @@ import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; class SoundInfo extends GsfPart { late final Standard4BytesData nameLength; - late final GsfData name; late final Standard4BytesData startFrame; late final Standard4BytesData volume; - late final Standard4BytesData speed; + late final Standard4BytesData speed; late final GsfData unknownData; // 16 unknown bytes late final Standard4BytesData soundGroupNameLength; late final GsfData soundGroupName; @@ -48,7 +47,7 @@ class SoundInfo extends GsfPart { @override int getEndOffset() { - return soundGroupName.offsettedLength(offset); + return soundGroupName.offsettedLength; } @override diff --git a/lib/classes/gsf/sound_table.dart b/lib/classes/gsf/header/sound_table.dart similarity index 87% rename from lib/classes/gsf/sound_table.dart rename to lib/classes/gsf/header/sound_table.dart index a0d84bb..763d524 100644 --- a/lib/classes/gsf/sound_table.dart +++ b/lib/classes/gsf/header/sound_table.dart @@ -1,6 +1,6 @@ import 'dart:typed_data'; -import 'package:paraworld_gsf_viewer/classes/gsf/sound_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/sound_info.dart'; import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; class SoundTable extends GsfPart { @@ -21,7 +21,7 @@ class SoundTable extends GsfPart { bytes, soundInfos.isNotEmpty ? soundInfos.last.getEndOffset() - : soundCount.offsettedLength(offset), + : soundCount.offsettedLength, ), ); } @@ -31,7 +31,7 @@ class SoundTable extends GsfPart { int getEndOffset() { return soundInfos.isNotEmpty ? soundInfos.last.getEndOffset() - : soundCount.offsettedLength(offset); + : soundCount.offsettedLength; } @override diff --git a/lib/classes/gsf/walk_set.dart b/lib/classes/gsf/header/walk_set.dart similarity index 99% rename from lib/classes/gsf/walk_set.dart rename to lib/classes/gsf/header/walk_set.dart index 1501a68..88b86ab 100644 --- a/lib/classes/gsf/walk_set.dart +++ b/lib/classes/gsf/header/walk_set.dart @@ -277,6 +277,6 @@ class WalkSet extends GsfPart { @override int getEndOffset() { - return name.offsettedLength(offset); + return name.offsettedLength; } } diff --git a/lib/classes/gsf/walk_set_table.dart b/lib/classes/gsf/header/walk_set_table.dart similarity index 83% rename from lib/classes/gsf/walk_set_table.dart rename to lib/classes/gsf/header/walk_set_table.dart index ae7faec..b06c671 100644 --- a/lib/classes/gsf/walk_set_table.dart +++ b/lib/classes/gsf/header/walk_set_table.dart @@ -1,6 +1,6 @@ import 'dart:typed_data'; -import 'package:paraworld_gsf_viewer/classes/gsf/walk_set.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/walk_set.dart'; import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; class WalkSetTable extends GsfPart { @@ -16,7 +16,7 @@ class WalkSetTable extends GsfPart { bytes, walkSets.isNotEmpty ? walkSets.last.getEndOffset() - : count.offsettedLength(offset), + : count.offsettedLength, )); } } @@ -24,7 +24,7 @@ class WalkSetTable extends GsfPart { @override int getEndOffset() => walkSets.isNotEmpty ? walkSets.last.getEndOffset() - : count.offsettedLength(offset); + : count.offsettedLength; @override String toString() { diff --git a/lib/classes/gsf/walk_transition_info.dart b/lib/classes/gsf/header/walk_transition_table.dart similarity index 79% rename from lib/classes/gsf/walk_transition_info.dart rename to lib/classes/gsf/header/walk_transition_table.dart index b4eadb2..499a60c 100644 --- a/lib/classes/gsf/walk_transition_info.dart +++ b/lib/classes/gsf/header/walk_transition_table.dart @@ -2,10 +2,10 @@ import 'dart:typed_data'; import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; -class WalkTransitionInfo extends GsfPart { +class WalkTransitionTable extends GsfPart { late final Standard4BytesData nameLength; - WalkTransitionInfo.fromBytes(Uint8List bytes, int offset) + WalkTransitionTable.fromBytes(Uint8List bytes, int offset) : super(offset: offset) { nameLength = Standard4BytesData( position: 0, @@ -23,7 +23,7 @@ class WalkTransitionInfo extends GsfPart { @override int getEndOffset() { - return name.offsettedLength(offset); + return name.offsettedLength; } @override diff --git a/lib/classes/gsf/header2/header2.dart b/lib/classes/gsf/header2/header2.dart new file mode 100644 index 0000000..3aa53b9 --- /dev/null +++ b/lib/classes/gsf/header2/header2.dart @@ -0,0 +1,32 @@ + +import 'dart:typed_data'; + +import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; + +class Header2 extends GsfPart { + + late final Standard4BytesData modelsCount; + late final Standard4BytesData animCount; + late final Standard4BytesData zeroData; + late final Standard4BytesData modelSettingsOffset; + late final Standard4BytesData modelsSettingCount; + late final Standard4BytesData animSettingsOffset; + late final Standard4BytesData animSettingsCount; + // todo: material Header + + + Header2.fromBytes(Uint8List bytes, int offset) : super(offset: offset) { + modelsCount = Standard4BytesData(position: 0, bytes: bytes, offset: offset); + animCount = Standard4BytesData(position: modelsCount.relativeEnd, bytes: bytes, offset: offset); + zeroData = Standard4BytesData(position: animCount.relativeEnd, bytes: bytes, offset: offset); + modelSettingsOffset = Standard4BytesData(position: zeroData.relativeEnd, bytes: bytes, offset: offset); + modelsSettingCount = Standard4BytesData(position: modelSettingsOffset.relativeEnd, bytes: bytes, offset: offset); + animSettingsOffset = Standard4BytesData(position: modelsSettingCount.relativeEnd, bytes: bytes, offset: offset); + animSettingsCount = Standard4BytesData(position: animSettingsOffset.relativeEnd, bytes: bytes, offset: offset); + } + + @override + int getEndOffset() { + return animSettingsCount.offsettedLength; + } +} \ No newline at end of file diff --git a/lib/classes/gsf/walk_transition_table.dart b/lib/classes/gsf/walk_transition_table.dart deleted file mode 100644 index 8046561..0000000 --- a/lib/classes/gsf/walk_transition_table.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'dart:typed_data'; - -import 'package:paraworld_gsf_viewer/classes/gsf/walk_transition_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf_data.dart'; - -class WalkTransitionTable extends GsfPart { - WalkTransitionTable({ - required offset, - required this.transitionCount, - }) : super(offset: offset); - - late final Standard4BytesData transitionCount; - late final List transitionInfos; - - WalkTransitionTable.fromBytes(Uint8List bytes, int offset) - : super(offset: offset) { - transitionCount = - Standard4BytesData(position: 0, bytes: bytes, offset: offset); - transitionInfos = []; - for (var i = 0; i < transitionCount.value; i++) { - transitionInfos.add( - WalkTransitionInfo.fromBytes( - bytes, - transitionInfos.isNotEmpty - ? transitionInfos.last.getEndOffset() - : transitionCount.offsettedLength(offset), - ), - ); - } - } - - @override - int getEndOffset() { - return transitionInfos.isNotEmpty - ? transitionInfos.last.getEndOffset() - : transitionCount.offsettedLength(offset); - } - - @override - String toString() { - return 'WalkTransitionTable: $transitionCount transitions.'; - } - - @override - bool operator ==(Object other) => - other is WalkTransitionTable && - other.transitionCount == transitionCount && - other.transitionInfos == transitionInfos; - - @override - int get hashCode => transitionCount.hashCode ^ transitionInfos.hashCode; -} diff --git a/lib/classes/gsf_data.dart b/lib/classes/gsf_data.dart index 6b5d5d8..ccd06da 100644 --- a/lib/classes/gsf_data.dart +++ b/lib/classes/gsf_data.dart @@ -46,7 +46,7 @@ class GsfData { required Uint8List bytes, required this.offset, }) { - parseValue(bytes, offset); + parseValue(bytes); } GsfData.fromValue( @@ -65,36 +65,36 @@ class GsfData { int get relativeEnd => relativePos + length; int get offsettedPos => relativePos + offset; - int offsettedLength(int offset) => offsettedPos + length; + int get offsettedLength => offsettedPos + length; - parseValue(Uint8List bytes, int offset) { + parseValue(Uint8List bytes) { switch (T) { case int: - value = getAsUint(bytes, offset) as T; + value = getAsUint(bytes) as T; case double: - value = getAsFloat(bytes, offset) as T; + value = getAsFloat(bytes) as T; case String: - value = getAsAsciiString(bytes, offset) as T; + value = getAsAsciiString(bytes) as T; case UnknowData: - value = bytes.sublist(offsettedPos, offsettedLength(offset)) as T; + value = bytes.sublist(offsettedPos, offsettedLength) as T; default: throw Exception('Invalid type'); } } - String getAsAsciiString(Uint8List bytes, int offset) { - final stringBytes = bytes.sublist(offsettedPos, offsettedLength(offset)); + String getAsAsciiString(Uint8List bytes) { + final stringBytes = bytes.sublist(offsettedPos, offsettedLength); assert(stringBytes.last == 0); // all names should have a 0 name terminator return const AsciiDecoder() .convert(stringBytes.sublist(0, stringBytes.length - 1)); } - ByteData getBytesData(Uint8List bytes, int offset) { - return ByteData.sublistView(bytes, offsettedPos, offsettedLength(offset)); + ByteData getBytesData(Uint8List bytes) { + return ByteData.sublistView(bytes, offsettedPos, offsettedLength); } - int getAsUint(Uint8List bytes, int offset) { - final data = getBytesData(bytes, offset); + int getAsUint(Uint8List bytes) { + final data = getBytesData(bytes); int value; switch (length) { case >= 8: @@ -109,8 +109,8 @@ class GsfData { return value; } - double getAsFloat(Uint8List bytes, int offset) { - final data = getBytesData(bytes, offset); + double getAsFloat(Uint8List bytes) { + final data = getBytesData(bytes); switch (length) { case >= 8: return data.getFloat64(0, Endian.little); @@ -123,9 +123,12 @@ class GsfData { @override String toString() { - return T == int - ? '$value (0x${(value as int).toRadixString(16)})' - : value.toString(); + switch (T) { + case int: + return '$value (0x${(value as int).toRadixString(16)})'; + default: + return value.toString(); + } } } @@ -135,22 +138,22 @@ class Standard4BytesData extends GsfData { {required int position, required Uint8List bytes, required int offset}) : super() { super._init(relativePos: position, length: 4, offset: offset); - super.parseValue(bytes, offset); + super.parseValue(bytes); } @override - int getAsUint(Uint8List bytes, int offset) { - return super.getBytesData(bytes, offset).getUint32(0, Endian.little); + int getAsUint(Uint8List bytes) { + return super.getBytesData(bytes).getUint32(0, Endian.little); } @override - double getAsFloat(Uint8List bytes, int offset) { - return super.getBytesData(bytes, offset).getFloat32(0, Endian.little); + double getAsFloat(Uint8List bytes) { + return super.getBytesData(bytes).getFloat32(0, Endian.little); } @override - String getAsAsciiString(Uint8List bytes, int offset) { - final stringBytes = bytes.sublist(offsettedPos, offsettedLength(offset)); + String getAsAsciiString(Uint8List bytes) { + final stringBytes = bytes.sublist(offsettedPos, offsettedLength); return const AsciiDecoder().convert(stringBytes); } } @@ -159,23 +162,23 @@ class DoubleByteData extends GsfData { DoubleByteData( {required int pos, required Uint8List bytes, required int offset}) { super._init(relativePos: pos, length: 2, offset: offset); - super.parseValue(bytes, offset); + super.parseValue(bytes); } @override - int getAsUint(Uint8List bytes, int offset) { - return super.getBytesData(bytes, offset).getUint16(0, Endian.little); + int getAsUint(Uint8List bytes) { + return super.getBytesData(bytes).getUint16(0, Endian.little); } @override - double getAsFloat(Uint8List bytes, int offset) { + double getAsFloat(Uint8List bytes) { throw Exception('Double byte data cannot be converted to float'); } @override - String getAsAsciiString(Uint8List bytes, int offset) { + String getAsAsciiString(Uint8List bytes) { return const AsciiDecoder() - .convert(bytes.sublist(offsettedPos, offsettedLength(offset))); + .convert(bytes.sublist(offsettedPos, offsettedLength)); } } @@ -195,12 +198,12 @@ class VariableTwoBytesData extends GsfData { } else { length = 1; } - value = (getAsUint(bytes, offset) & 0x7FFF) as T; + value = (getAsUint(bytes) & 0x7FFF) as T; } @override - int getAsUint(Uint8List bytes, int offset) { - final bytesData = super.getBytesData(bytes, offset); + int getAsUint(Uint8List bytes) { + final bytesData = super.getBytesData(bytes); switch (length) { case 2: return bytesData.getUint16( @@ -219,21 +222,21 @@ class SingleByteData extends GsfData { throw Exception('Invalid type, single byte data can only be int'); } super._init(relativePos: pos, length: 1, offset: offset); - value = getAsUint(bytes, offset); + value = getAsUint(bytes); } @override - int getAsUint(Uint8List bytes, int offset) { - return super.getBytesData(bytes, offset).getUint8(0); + int getAsUint(Uint8List bytes) { + return super.getBytesData(bytes).getUint8(0); } @override - double getAsFloat(Uint8List bytes, int offset) { + double getAsFloat(Uint8List bytes) { throw Exception('Single byte data cannot be converted to float'); } @override - String getAsAsciiString(Uint8List bytes, int offset) { + String getAsAsciiString(Uint8List bytes) { throw Exception('Single byte data cannot be converted to string'); } } diff --git a/lib/widgets/header/display.dart b/lib/widgets/header/display.dart index 14162d6..d3c3fae 100644 --- a/lib/widgets/header/display.dart +++ b/lib/widgets/header/display.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/dust_trail_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/dust_trail_info.dart'; import 'package:paraworld_gsf_viewer/classes/gsf/gsf.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/model_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/sound_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/model_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/sound_info.dart'; import 'package:paraworld_gsf_viewer/providers/gsf.dart'; import 'package:paraworld_gsf_viewer/widgets/header/widgets/dust_trail.dart'; import 'package:paraworld_gsf_viewer/widgets/header/widgets/model_infos.dart'; @@ -129,21 +129,21 @@ class _Data extends ConsumerWidget { .setDustTrailInfo(part as DustTrailInfo), ), GsfDataTile( - label: 'Walk Transition Count', - data: header.walkTransitionTable1.transitionCount, + label: 'anim flags count ', + data: header.animFlagsCount, bold: true, ), - ...header.walkTransitionTable1.transitionInfos + ...header.animFlagsTables .map((part) => Label.regular( 'Walk Transition: ${part.name} (0x${part.offset.toRadixString(16)})', )) .toList(), GsfDataTile( - label: 'Walk Transition 2 Count', - data: header.walkTransitionTable2.transitionCount, + label: 'Walk Transitions conunt', + data: header.walkTransitionsCount, bold: true, ), - ...header.walkTransitionTable2.transitionInfos + ...header.walkTransitionTables .map((part) => Label.regular( 'Walk Transition: ${part.name} (0x${part.offset.toRadixString(16)})', )) diff --git a/lib/widgets/header/notifier.dart b/lib/widgets/header/notifier.dart index 7d5b0eb..f45ad1a 100644 --- a/lib/widgets/header/notifier.dart +++ b/lib/widgets/header/notifier.dart @@ -1,9 +1,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/dust_trail_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/model_anim.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/model_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/sound_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/walk_set.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/dust_trail_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/model_anim.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/model_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/sound_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/walk_set.dart'; import 'package:paraworld_gsf_viewer/widgets/header/state.dart'; class HeaderStateNotifier extends Notifier { diff --git a/lib/widgets/header/state.dart b/lib/widgets/header/state.dart index ab12295..7818428 100644 --- a/lib/widgets/header/state.dart +++ b/lib/widgets/header/state.dart @@ -1,10 +1,10 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:flutter/foundation.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/dust_trail_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/model_anim.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/model_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/sound_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/walk_set.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/dust_trail_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/model_anim.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/model_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/sound_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/walk_set.dart'; part 'state.freezed.dart'; @freezed diff --git a/lib/widgets/header/widgets/dust_trail.dart b/lib/widgets/header/widgets/dust_trail.dart index eac87fb..d6de1cb 100644 --- a/lib/widgets/header/widgets/dust_trail.dart +++ b/lib/widgets/header/widgets/dust_trail.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/dust_trail_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/dust_trail_info.dart'; import 'package:paraworld_gsf_viewer/widgets/utils/label.dart'; import 'package:paraworld_gsf_viewer/widgets/utils/data_display.dart'; diff --git a/lib/widgets/header/widgets/model_infos.dart b/lib/widgets/header/widgets/model_infos.dart index 9086192..dbccc8e 100644 --- a/lib/widgets/header/widgets/model_infos.dart +++ b/lib/widgets/header/widgets/model_infos.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/model_anim.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/model_info.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/walk_set.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/model_anim.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/model_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/walk_set.dart'; import 'package:paraworld_gsf_viewer/widgets/header/providers.dart'; import 'package:paraworld_gsf_viewer/widgets/utils/label.dart'; import 'package:paraworld_gsf_viewer/widgets/utils/data_display.dart'; diff --git a/lib/widgets/header/widgets/sound.dart b/lib/widgets/header/widgets/sound.dart index 41ba0d2..38d1515 100644 --- a/lib/widgets/header/widgets/sound.dart +++ b/lib/widgets/header/widgets/sound.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:paraworld_gsf_viewer/classes/gsf/sound_info.dart'; +import 'package:paraworld_gsf_viewer/classes/gsf/header/sound_info.dart'; import 'package:paraworld_gsf_viewer/widgets/utils/label.dart'; import 'package:paraworld_gsf_viewer/widgets/utils/data_display.dart';