Skip to content

Commit ba8e47a

Browse files
committed
Add install to editor packs
1 parent aa0965b commit ba8e47a

File tree

9 files changed

+210
-191
lines changed

9 files changed

+210
-191
lines changed

api/lib/src/models/data.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ class SetonixData extends ArchiveData<SetonixData> {
3333
: identifier = '',
3434
super.empty();
3535

36-
factory SetonixData.fromData(Uint8List data, [String? identifier]) {
37-
return SetonixData(ZipDecoder().decodeBytes(data),
38-
identifier: identifier ?? createPackIdentifier(data));
39-
}
36+
SetonixData.fromData(super.data, [String? identifier])
37+
: identifier = identifier ?? createPackIdentifier(data),
38+
super.fromBytes();
4039

4140
GameTable? getTable([String name = '']) {
4241
final data = getAsset('$kGameTablePath/$name.json');
@@ -203,6 +202,10 @@ class SetonixData extends ArchiveData<SetonixData> {
203202
return MapEntry(e, translation);
204203
}).nonNulls;
205204

205+
@override
206+
Uint8List exportAsBytes() => ZipEncoder(password: state.password)
207+
.encodeBytes(export(), autoClose: true);
208+
206209
PackTranslation? getTranslation([String id = kFallbackLocale]) {
207210
final data = getAsset('$kPackTranslationsPath/$id.json');
208211
if (data == null) return null;
@@ -282,7 +285,7 @@ class SetonixFile {
282285
SetonixData load() => SetonixData.fromData(data, identifier);
283286
}
284287

285-
String createPackIdentifier(Uint8List data) {
288+
String createPackIdentifier(List<int> data) {
286289
final hash = sha512256.convert(data);
287290
return base64Encode(hash.bytes);
288291
}

app/android/Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GEM
1010
artifactory (3.0.17)
1111
atomos (0.1.3)
1212
aws-eventstream (1.3.0)
13-
aws-partitions (1.1040.0)
13+
aws-partitions (1.1041.0)
1414
aws-sdk-core (3.216.0)
1515
aws-eventstream (~> 1, >= 1.3.0)
1616
aws-partitions (~> 1, >= 1.992.0)
@@ -224,4 +224,4 @@ DEPENDENCIES
224224
screengrab
225225

226226
BUNDLED WITH
227-
2.6.2
227+
2.6.3

app/lib/pages/packs/dialog.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ class _PacksDialogState extends State<PacksDialog>
227227
child:
228228
Text(AppLocalizations.of(context).comingSoon),
229229
),
230-
if (bloc == null) _EditorPacksView(),
230+
if (bloc == null)
231+
_EditorPacksView(
232+
onReload: _reloadPacks,
233+
),
231234
],
232235
);
233236
});

app/lib/pages/packs/editor.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
part of 'dialog.dart';
22

33
class _EditorPacksView extends StatefulWidget {
4-
const _EditorPacksView();
4+
final VoidCallback onReload;
5+
6+
const _EditorPacksView({
7+
required this.onReload,
8+
});
59

610
@override
711
State<_EditorPacksView> createState() => _EditorPacksViewState();
@@ -63,6 +67,15 @@ class _EditorPacksViewState extends State<_EditorPacksView> {
6367
);
6468
},
6569
menuChildren: [
70+
MenuItemButton(
71+
leadingIcon: const Icon(PhosphorIconsLight.download),
72+
child: Text(AppLocalizations.of(context).install),
73+
onPressed: () async {
74+
await importFileData(context, _fileSystem,
75+
SetonixFile(data.exportAsBytes()));
76+
widget.onReload();
77+
},
78+
),
6679
MenuItemButton(
6780
leadingIcon: const Icon(PhosphorIconsLight.export),
6881
child: Text(AppLocalizations.of(context).export),

app/pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,10 @@ packages:
561561
dependency: "direct main"
562562
description:
563563
name: http
564-
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
564+
sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f
565565
url: "https://pub.dev"
566566
source: hosted
567-
version: "1.2.2"
567+
version: "1.3.0"
568568
http_multi_server:
569569
dependency: transitive
570570
description:

docs/pnpm-lock.yaml

Lines changed: 160 additions & 160 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/pubspec.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ packages:
5858
dependency: "direct main"
5959
description:
6060
name: bloc
61-
sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e"
61+
sha256: "52c10575f4445c61dd9e0cafcc6356fdd827c4c64dd7945ef3c4105f6b6ac189"
6262
url: "https://pub.dev"
6363
source: hosted
64-
version: "8.1.4"
64+
version: "9.0.0"
6565
bloc_concurrency:
6666
dependency: "direct main"
6767
description:
6868
name: bloc_concurrency
69-
sha256: "456b7a3616a7c1ceb975c14441b3f198bf57d81cb95b7c6de5cb0c60201afcd8"
69+
sha256: "86b7b17a0a78f77fca0d7c030632b59b593b22acea2d96972588f40d4ef53a94"
7070
url: "https://pub.dev"
7171
source: hosted
72-
version: "0.2.5"
72+
version: "0.3.0"
7373
boolean_selector:
7474
dependency: transitive
7575
description:
@@ -205,7 +205,7 @@ packages:
205205
path: "packages/dart_leap"
206206
ref: db69a03082e6811c58dc2d0e5c23d04305e1623f
207207
resolved-ref: db69a03082e6811c58dc2d0e5c23d04305e1623f
208-
url: "https://github.com/LinwoodDev/dart_pkgs"
208+
url: "https://github.com/LinwoodDev/dart_pkgs.git"
209209
source: git
210210
version: "1.0.0"
211211
dart_mappable:
@@ -342,7 +342,7 @@ packages:
342342
path: "packages/lw_file_system_api"
343343
ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
344344
resolved-ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
345-
url: "https://github.com/LinwoodDev/dart_pkgs"
345+
url: "https://github.com/LinwoodDev/dart_pkgs.git"
346346
source: git
347347
version: "1.0.0"
348348
macros:
@@ -381,18 +381,18 @@ packages:
381381
dependency: "direct main"
382382
description:
383383
path: "packages/networker/networker"
384-
ref: "071e02761bf55a47bcde0cdc2a711b8ff5fbbb18"
385-
resolved-ref: "071e02761bf55a47bcde0cdc2a711b8ff5fbbb18"
386-
url: "https://github.com/LinwoodDev/dart_pkgs"
384+
ref: "0bdc62d3af7f31e19a694d9cd39fe020dced8754"
385+
resolved-ref: "0bdc62d3af7f31e19a694d9cd39fe020dced8754"
386+
url: "https://github.com/LinwoodDev/dart_pkgs.git"
387387
source: git
388388
version: "1.0.0"
389389
networker_socket:
390390
dependency: "direct main"
391391
description:
392392
path: "packages/networker/networker_socket"
393-
ref: "2400638352d6c877d09b97dd4030382f88deb2a4"
394-
resolved-ref: "2400638352d6c877d09b97dd4030382f88deb2a4"
395-
url: "https://github.com/LinwoodDev/dart_pkgs"
393+
ref: fa036587c2a26db6455dd063701aef32b3531800
394+
resolved-ref: fa036587c2a26db6455dd063701aef32b3531800
395+
url: "https://github.com/LinwoodDev/dart_pkgs.git"
396396
source: git
397397
version: "1.0.0"
398398
node_preamble:

server/pubspec.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ environment:
88

99
dependencies:
1010
args: ^2.4.2
11-
bloc: ^8.1.4
11+
bloc: ^9.0.0
1212
logging: ^1.2.0
1313
networker:
1414
git:
15-
url: https://github.com/LinwoodDev/dart_pkgs
16-
ref: 071e02761bf55a47bcde0cdc2a711b8ff5fbbb18
15+
url: https://github.com/LinwoodDev/dart_pkgs.git
16+
ref: 0bdc62d3af7f31e19a694d9cd39fe020dced8754
1717
path: packages/networker/networker
1818
networker_socket:
1919
git:
20-
url: https://github.com/LinwoodDev/dart_pkgs
21-
ref: 2400638352d6c877d09b97dd4030382f88deb2a4
20+
url: https://github.com/LinwoodDev/dart_pkgs.git
21+
ref: fa036587c2a26db6455dd063701aef32b3531800
2222
path: packages/networker/networker_socket
2323
consoler:
2424
git:
@@ -28,7 +28,7 @@ dependencies:
2828
path: ^1.9.0
2929
setonix_api:
3030
path: ../api
31-
bloc_concurrency: ^0.2.5
31+
bloc_concurrency: ^0.3.0
3232
dart_mappable: ^4.2.2
3333

3434
dev_dependencies:

tools/pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ packages:
7878
dependency: transitive
7979
description:
8080
name: http
81-
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
81+
sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f
8282
url: "https://pub.dev"
8383
source: hosted
84-
version: "1.2.2"
84+
version: "1.3.0"
8585
http_parser:
8686
dependency: transitive
8787
description:

0 commit comments

Comments
 (0)