-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTable.cs
90 lines (80 loc) · 3.23 KB
/
Table.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
Persona 3 Table Exporter, a tool for exporting data tables from Persona 3 for analysis.
Copyright (C) 2021 James Pelster "CaptainSwag101"
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using P3TableExporter.TableSegments;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace P3TableExporter
{
class Table
{
public List<TableSegment> Segments { get; set; }
public Table()
{
Segments = new();
}
public Table(FileInfo info)
{
Segments = new();
using FileStream stream = info.OpenRead();
using BinaryReader reader = new(stream);
// Determine what table segments we need based on the table filename
string tableName = info.Name.ToUpperInvariant().Split(".")[0];
if (tableName == "PERSONA" || tableName == "PERSONA_F")
{
Segments.Add(new PersonaDataArray(reader));
Utils.ReadPadding(reader, 16);
Segments.Add(new PersonaGrowthAndSkillsArray(reader));
Utils.ReadPadding(reader, 16);
Segments.Add(new PartyMemberPersonas(reader));
Utils.ReadPadding(reader, 16);
}
else if (tableName == "ENCOUNT")
{
Segments.Add(new EnemyEncounters(reader));
Utils.ReadPadding(reader, 16);
Segments.Add(new UnknownSegment(reader, 10));
Utils.ReadPadding(reader, 16);
Segments.Add(new UnknownSegment(reader, 10));
Utils.ReadPadding(reader, 16);
Segments.Add(new UnknownSegment(reader));
Utils.ReadPadding(reader, 16);
Segments.Add(new UnknownSegment(reader));
Utils.ReadPadding(reader, 16);
}
else if (tableName == "MSG")
{
Segments.Add(new ArcanaNames(reader));
Utils.ReadPadding(reader, 16);
Segments.Add(new SkillNames(reader));
Utils.ReadPadding(reader, 16);
Segments.Add(new EnemyNames(reader));
Utils.ReadPadding(reader, 16);
Segments.Add(new PersonaNames(reader));
Utils.ReadPadding(reader, 16);
Segments.Add(new TextBMDs(reader));
Utils.ReadPadding(reader, 16);
}
else
{
throw new NotImplementedException($"Table type {tableName} is not currently supported.");
}
return;
}
}
}