@@ -65,11 +65,10 @@ public async Task<int> CreateWizardModPack(ModPackData modPackData, IProgress<do
65
65
var dir = Path . Combine ( Path . GetTempPath ( ) , guid . ToString ( ) ) ;
66
66
Directory . CreateDirectory ( dir ) ;
67
67
68
-
69
68
_tempMPD = Path . Combine ( dir , "TTMPD.mpd" ) ;
70
69
_tempMPL = Path . Combine ( dir , "TTMPL.mpl" ) ;
71
70
72
- var imageList = new Dictionary < string , string > ( ) ;
71
+ var imageList = new HashSet < string > ( ) ;
73
72
var pageCount = 1 ;
74
73
75
74
var modPackJson = new ModPackJson
@@ -109,19 +108,20 @@ public async Task<int> CreateWizardModPack(ModPackData modPackData, IProgress<do
109
108
110
109
foreach ( var modOption in modGroup . OptionList )
111
110
{
112
- var randomFileName = "" ;
113
-
111
+ var imageFileName = "" ;
114
112
if ( modOption . Image != null )
115
113
{
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 ) ;
118
118
}
119
119
120
120
var modOptionJson = new ModOptionJson
121
121
{
122
122
Name = modOption . Name ,
123
123
Description = modOption . Description ,
124
- ImagePath = randomFileName ,
124
+ ImagePath = "images/" + Path . GetFileName ( imageFileName ) ,
125
125
GroupName = modOption . GroupName ,
126
126
SelectionType = modOption . SelectionType ,
127
127
IsChecked = modOption . IsChecked ,
@@ -179,11 +179,13 @@ public async Task<int> CreateWizardModPack(ModPackData modPackData, IProgress<do
179
179
180
180
var zf = new ZipFile ( ) ;
181
181
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
+
184
186
foreach ( var image in imageList )
185
187
{
186
- zf . AddFile ( image . Value , image . Key ) ;
188
+ zf . AddFile ( image , "images" ) ;
187
189
}
188
190
zf . Save ( modPackPath ) ;
189
191
@@ -300,8 +302,8 @@ public async Task<int> CreateSimpleModPack(SimpleModPackData modPackData, Direct
300
302
301
303
var zf = new ZipFile ( ) ;
302
304
zf . CompressionLevel = Ionic . Zlib . CompressionLevel . None ;
303
- zf . AddFile ( _tempMPL ) ;
304
- zf . AddFile ( _tempMPD ) ;
305
+ zf . AddFile ( _tempMPL , "" ) ;
306
+ zf . AddFile ( _tempMPD , "" ) ;
305
307
zf . Save ( modPackPath ) ;
306
308
}
307
309
finally
@@ -332,7 +334,7 @@ public async Task<int> CreateSimpleModPack(SimpleModPackData modPackData, Direct
332
334
333
335
using ( var zf = ZipFile . Read ( modPackDirectory . FullName ) )
334
336
{
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/" ) ) ;
336
338
var mpl = zf . Entries . First ( x => x . FileName . EndsWith ( ".mpl" ) ) ;
337
339
338
340
using ( var streamReader = new StreamReader ( mpl . OpenReader ( ) ) )
0 commit comments