@@ -28,6 +28,7 @@ class CreateFinishViewModel with ChangeNotifier {
2828 bool isEphemeralBarExpanded = false ;
2929 bool isGenerating = false ;
3030 bool prependAlt = false ;
31+ bool compressFiles = false ;
3132 int totalFiles = 0 ;
3233 int filesProcessed = 0 ;
3334
@@ -46,6 +47,11 @@ class CreateFinishViewModel with ChangeNotifier {
4647 notifyListeners ();
4748 }
4849
50+ Future <void > onToggleCompressFiles (bool newCompressFilesValue) async {
51+ compressFiles = newCompressFilesValue;
52+ notifyListeners ();
53+ }
54+
4955 void reset () {
5056 currentState = AppState .none;
5157 totalFiles = 0 ;
@@ -166,7 +172,7 @@ class CreateFinishViewModel with ChangeNotifier {
166172
167173 isGenerating = true ;
168174 notifyListeners ();
169- await createGenerationIsolate (entries, outputFile, prependAlt);
175+ await createGenerationIsolate (entries, outputFile, prependAlt, compressFiles );
170176 // await compute(generateOTR, Tuple2(entries, outputFile));
171177 isGenerating = false ;
172178 notifyListeners ();
@@ -176,11 +182,11 @@ class CreateFinishViewModel with ChangeNotifier {
176182 }
177183
178184 Future createGenerationIsolate (HashMap <String , StageEntry > entries,
179- String outputFile, bool shouldPrependAlt) async {
185+ String outputFile, bool shouldPrependAlt, bool shouldCompress ) async {
180186 final receivePort = ReceivePort ();
181187 await Isolate .spawn (
182188 generateOTR,
183- Tuple4 (entries, outputFile, receivePort.sendPort, shouldPrependAlt),
189+ Tuple5 (entries, outputFile, receivePort.sendPort, shouldPrependAlt, shouldCompress ),
184190 onExit: receivePort.sendPort,
185191 onError: receivePort.sendPort,
186192 );
@@ -212,8 +218,9 @@ class CreateFinishViewModel with ChangeNotifier {
212218 }
213219}
214220
215- Future <void > generateOTR (Tuple4 <HashMap <String , StageEntry >, String , SendPort , bool > params) async {
221+ Future <void > generateOTR (Tuple5 <HashMap <String , StageEntry >, String , SendPort , bool , bool > params) async {
216222 try {
223+ final compress = params.item5;
217224 final arcFile = Arc (params.item2);
218225
219226 for (final entry in params.item1.entries) {
@@ -222,15 +229,15 @@ Future<void> generateOTR(Tuple4<HashMap<String, StageEntry>, String, SendPort, b
222229 final fileData = await file.readAsBytes ();
223230 final fileName =
224231 "${entry .key }/${p .normalize (file .path ).split ("/" ).last }" ;
225- arcFile.addFile (fileName, fileData);
232+ arcFile.addFile (fileName, fileData, compress : compress );
226233 params.item3.send (1 );
227234 }
228235 } else if (entry.value is CustomSequencesEntry ) {
229236 for (final pair in (entry.value as CustomSequencesEntry ).pairs) {
230237 final sequence = await compute (Sequence .fromSeqFile, pair);
231238 final fileName = '${entry .key }/${sequence .path }' ;
232239 final data = sequence.build ();
233- arcFile.addFile (fileName, data);
240+ arcFile.addFile (fileName, data, compress : compress );
234241 params.item3.send (1 );
235242 }
236243 } else if (entry.value is CustomTexturesEntry ) {
@@ -248,7 +255,7 @@ Future<void> generateOTR(Tuple4<HashMap<String, StageEntry>, String, SendPort, b
248255 continue ;
249256 }
250257
251- arcFile.addFile (texture.item1, texture.item2! );
258+ arcFile.addFile (texture.item1, texture.item2! , compress : compress );
252259 }
253260 }
254261 }
0 commit comments