forked from IS4Code/AlbLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameData.cs
190 lines (157 loc) · 6.55 KB
/
GameData.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* Date: 11.8.2014, Time: 13:59 */
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text.RegularExpressions;
using AlbLib.Imaging;
using AlbLib.Items;
using AlbLib.Mapping;
using AlbLib.SaveGame;
using AlbLib.Sounds;
using AlbLib.Texts;
using AlbLib.XLD;
namespace AlbLib
{
public static class GameData
{
public static readonly XLDRepository<SaveGame.NPC> NPCCharacters = new XLDRepository<SaveGame.NPC>(
() => Paths.NPCCharacters,
(i, s, l) => new SaveGame.NPC(s)
);
public static readonly XLDRepository<SaveGame.Character> PartyCharacters = new XLDRepository<SaveGame.Character>(
() => Paths.PartyCharacters,
(i, s, l) => new SaveGame.Character(s)
);
public static readonly XLDRepository<SaveGame.Monster> MonsterCharacters = new XLDRepository<SaveGame.Monster>(
() => Paths.MonsterChars,
(i, s, l) => new SaveGame.Monster(s)
);
public static readonly XLDRepository<Scripting.EventSet> EventSets = new XLDRepository<Scripting.EventSet>(
() => Paths.EventSets,
(i, s, l) => new Scripting.EventSet(s)
);
#region Maps
public static readonly XLDRepository<Map> Maps = new XLDRepository<Map>(
()=>Paths.MapData,
(i,s,l)=>new Map(i,s)
);
#region 3D
public static readonly XLDRepository<LabData> LabData = new XLDRepository<LabData>(
()=>Paths.LabData,
(i,s,l)=>new LabData(s)
);
public static readonly XLDRepository<AutoGFX> AutomapGraphics = new XLDRepository<AutoGFX>(
()=>Paths.AutomapGraphics,
(i,s,l)=>new AutoGFX(s,l)
);
public static readonly XLDRepository<HeaderedImage>
Backgrounds3D = GetHeaderedImages(()=>Paths.Backgrounds3D, true);
public static readonly XLDRepository<RawImage>
Objects3D = GetRawImages(()=>Paths.Objects3D);
public static readonly XLDRepository<RawImage>
Walls3D = GetRawImages(()=>Paths.Walls3D);
public static readonly XLDRepository<RawImage>
Overlays3D = GetRawImages(()=>Paths.Overlays3D);
public static readonly XLDRepository<HeaderedImage>
BodyImages = GetHeaderedImages(()=>Paths.BodyImages, true);
public static readonly XLDRepository<RawImage>
Floors3D = GetRawImages(()=>Paths.Floors3D, 64, 64);
#endregion
#region 2D
public static readonly XLDRepository<HeaderedImage>
BigNPC = GetHeaderedImages(()=>Paths.NPCBig, true);
public static readonly XLDRepository<HeaderedImage>
SmallNPC = GetHeaderedImages(()=>Paths.NPCSmall, true);
public static readonly XLDRepository<HeaderedImage>
BigParty = GetHeaderedImages(()=>Paths.PartyBig, true);
public static readonly XLDRepository<HeaderedImage>
SmallParty = GetHeaderedImages(()=>Paths.PartySmall, true);
public static readonly ArrayXLDRepository<TileData> MapIcons = new ArrayXLDRepository<TileData>(
()=>Paths.IconData,
(i,s,l)=>AlbLib.Mapping.MapIcons.ReadIconData(s,l)
);
public static readonly ArrayXLDRepository<RawImage> IconGraphics = new ArrayXLDRepository<RawImage>(
()=>Paths.IconGraphics,
(i,s,l)=>AlbLib.Mapping.MapIcons.ReadIconGraphics(s,l)
);
#endregion
#endregion
#region Cutscenes
public static readonly XLDRepository<ILBMImage> Pictures = new XLDRepository<ILBMImage>(
()=>Paths.Pictures,
(i,s,l)=>ILBMImage.FromStream(s)
);
public static readonly XLDRepository<XLDSubfile> Flics = new XLDRepository<XLDSubfile>(
()=>Paths.Flics.WithDefaultLanguage(),
(i,s,l)=>new XLDSubfile(s,l)
);
#endregion
#region Combat
public static readonly XLDRepository<RawImage>
CombatBackgrounds = GetRawImages(()=>Paths.CombatBackgrounds, 360);
public static readonly XLDRepository<HeaderedImage>
CombatGraphics = GetHeaderedImages(() => Paths.CombatGraphics, false);
public static readonly XLDRepository<Monster> Monsters = new XLDRepository<Monster>(
()=>Paths.MonsterChars,
(i,s,l)=>new Monster(s)
);
public static readonly XLDRepository<TransparencyTable> TransparencyTables = new XLDRepository<TransparencyTable>(
()=>Paths.TransparencyTables,
(i,s,l)=>new TransparencyTable(i,s)
);
#endregion
#region Texts
public static readonly SysTextRepository SystemTexts = new SysTextRepository(
()=>Paths.SystemTexts.WithDefaultLanguage()
);
public static readonly XLDRepository<TextLibrary>
EventTexts = GetTexts(()=>Paths.EventTexts.WithDefaultLanguage());
public static readonly XLDRepository<TextLibrary>
MapTexts = GetTexts(()=>Paths.MapTexts.WithDefaultLanguage());
#endregion
public static readonly XLDRepository<WaveLib> WaveLibs = new XLDRepository<WaveLib>(
()=>Paths.WaveLibs,
(i,s,l)=>new WaveLib(s)
);
public static readonly SimpleRepository<ImagePalette> FullPalettes = new SimpleRepository<ImagePalette>(
(i)=>Palettes.Open(i)+ImagePalette.GetGlobalPalette(),
()=>Palettes.IndexEnumerate().Select(p => new KeyValuePair<int,ImagePalette>(p.Key, p.Value+ImagePalette.GetGlobalPalette()))
);
public static readonly XLDRepository<ImagePalette> Palettes = new XLDRepository<ImagePalette>(
()=>Paths.PaletteN,
(i,s,l)=>ImagePalette.Load(s,l/3,PaletteFormat.Binary)
);
public static readonly SimpleRepository<ItemType> Items = new SimpleRepository<ItemType>(
(i)=>ItemType.GetItemType(i),
()=>(IList<ItemType>)ItemType.GetItemTypes()
);
private static XLDRepository<HeaderedImage> GetHeaderedImages(Func<XLDPathInfo> path, bool constsize)
{
return new XLDRepository<HeaderedImage>(path, (i,s,l)=>new HeaderedImage(s, constsize));
}
private static XLDRepository<RawImage> GetRawImages(Func<XLDPathInfo> path)
{
return new XLDRepository<RawImage>(path, (i,s,l)=>new RawImage(s,l));
}
private static XLDRepository<RawImage> GetRawImages(Func<XLDPathInfo> path, int width)
{
return new XLDRepository<RawImage>(path, (i,s,l)=>new RawImage(s,width,(l+width-1)/width));
}
private static XLDRepository<RawImage> GetRawImages(Func<XLDPathInfo> path, int width, int height)
{
return new XLDRepository<RawImage>(path, (i,s,l)=>new RawImage(s,width,height));
}
private static XLDRepository<TextLibrary> GetTexts(Func<XLDPathInfo> path)
{
return new XLDRepository<TextLibrary>(path, (i,s,l)=>new TextLibrary(s));
}
public static IEnumerable<IRepository> GetRepositories()
{
return typeof(GameData).GetFields(BindingFlags.Public | BindingFlags.Static).Where(f => f.IsInitOnly).Select(f => f.GetValue(null)).OfType<IRepository>();
}
}
}