Skip to content

Commit 52277bc

Browse files
committed
- Fix for advanced modpack errors.
1 parent 4e0199c commit 52277bc

File tree

1 file changed

+15
-13
lines changed
  • xivModdingFramework/Mods/FileTypes

1 file changed

+15
-13
lines changed

xivModdingFramework/Mods/FileTypes/TTMP.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ public async Task<int> CreateWizardModPack(ModPackData modPackData, IProgress<do
6565
var dir = Path.Combine(Path.GetTempPath(), guid.ToString());
6666
Directory.CreateDirectory(dir);
6767

68-
6968
_tempMPD = Path.Combine(dir, "TTMPD.mpd");
7069
_tempMPL = Path.Combine(dir, "TTMPL.mpl");
7170

72-
var imageList = new Dictionary<string, string>();
71+
var imageList = new HashSet<string>();
7372
var pageCount = 1;
7473

7574
var modPackJson = new ModPackJson
@@ -109,19 +108,20 @@ public async Task<int> CreateWizardModPack(ModPackData modPackData, IProgress<do
109108

110109
foreach (var modOption in modGroup.OptionList)
111110
{
112-
var randomFileName = "";
113-
111+
var imageFileName = "";
114112
if (modOption.Image != null)
115113
{
116-
randomFileName = $"{Path.GetRandomFileName()}.png";
117-
imageList.Add(randomFileName, modOption.ImageFileName);
114+
var fname = Path.GetFileName(modOption.ImageFileName);
115+
imageFileName = Path.Combine(dir, fname);
116+
File.Copy(modOption.ImageFileName, imageFileName);
117+
imageList.Add(imageFileName);
118118
}
119119

120120
var modOptionJson = new ModOptionJson
121121
{
122122
Name = modOption.Name,
123123
Description = modOption.Description,
124-
ImagePath = randomFileName,
124+
ImagePath = "images/" + Path.GetFileName(imageFileName),
125125
GroupName = modOption.GroupName,
126126
SelectionType = modOption.SelectionType,
127127
IsChecked=modOption.IsChecked,
@@ -179,11 +179,13 @@ public async Task<int> CreateWizardModPack(ModPackData modPackData, IProgress<do
179179

180180
var zf = new ZipFile();
181181
zf.CompressionLevel = Ionic.Zlib.CompressionLevel.None;
182-
zf.AddFile(_tempMPL, "TTMPL.mpl");
183-
zf.AddFile(_tempMPD, "TTMPD.mpd");
182+
zf.AddFile(_tempMPL, "");
183+
zf.AddFile(_tempMPD, "");
184+
zf.Save(modPackPath);
185+
184186
foreach (var image in imageList)
185187
{
186-
zf.AddFile(image.Value, image.Key);
188+
zf.AddFile(image, "images");
187189
}
188190
zf.Save(modPackPath);
189191

@@ -300,8 +302,8 @@ public async Task<int> CreateSimpleModPack(SimpleModPackData modPackData, Direct
300302

301303
var zf = new ZipFile();
302304
zf.CompressionLevel = Ionic.Zlib.CompressionLevel.None;
303-
zf.AddFile(_tempMPL);
304-
zf.AddFile(_tempMPD);
305+
zf.AddFile(_tempMPL, "");
306+
zf.AddFile(_tempMPD, "");
305307
zf.Save(modPackPath);
306308
}
307309
finally
@@ -332,7 +334,7 @@ public async Task<int> CreateSimpleModPack(SimpleModPackData modPackData, Direct
332334

333335
using (var zf = ZipFile.Read(modPackDirectory.FullName))
334336
{
335-
var images = zf.Entries.Where(x => x.FileName.EndsWith(".png"));
337+
var images = zf.Entries.Where(x => x.FileName.EndsWith(".png") || x.FileName.StartsWith("images/"));
336338
var mpl = zf.Entries.First(x => x.FileName.EndsWith(".mpl"));
337339

338340
using (var streamReader = new StreamReader(mpl.OpenReader()))

0 commit comments

Comments
 (0)