Skip to content

Commit

Permalink
Change file extension, add additional info to servers
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Oct 11, 2024
1 parent 7af6845 commit 7af2120
Show file tree
Hide file tree
Showing 20 changed files with 212 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ jobs:
dart pub get
cd ..
dart run tools/generate.dart
cp app/assets/pack.qka server/server-build/packs/.qka
cp app/assets/pack.stnx server/server-build/packs/.stnx
- name: Archive
uses: actions/upload-artifact@v4
with:
Expand Down
13 changes: 13 additions & 0 deletions api/lib/src/models/server.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:dart_mappable/dart_mappable.dart';

import '../event/event.dart';
import 'meta.dart';

part 'server.mapper.dart';

Expand Down Expand Up @@ -54,9 +55,15 @@ Uri buildServerAddress(String input, bool secure, {bool webSockets = true}) {
@MappableClass()
class GameProperty with GamePropertyMappable {
final String description;
final int? maxPlayers;
final int currentPlayers;
final Map<String, FileMetadata> packsSignature;

const GameProperty({
this.description = '',
this.maxPlayers,
this.currentPlayers = 0,
this.packsSignature = const {},
});

static const defaultProperty = GameProperty(
Expand All @@ -70,7 +77,10 @@ class LanProperty extends GameProperty with LanPropertyMappable {

const LanProperty({
this.port = kDefaultPort,
super.currentPlayers,
super.maxPlayers,
super.description,
super.packsSignature,
});
}

Expand All @@ -80,6 +90,9 @@ class ListProperty extends GameProperty with ListPropertyMappable {

const ListProperty({
required this.index,
super.currentPlayers,
super.maxPlayers,
super.description,
super.packsSignature,
});
}
161 changes: 145 additions & 16 deletions api/lib/src/models/server.mapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ class GamePropertyMapper extends ClassMapperBase<GameProperty> {
MapperContainer.globals.use(_instance = GamePropertyMapper._());
LanPropertyMapper.ensureInitialized();
ListPropertyMapper.ensureInitialized();
FileMetadataMapper.ensureInitialized();
}
return _instance!;
}
Expand All @@ -322,14 +323,32 @@ class GamePropertyMapper extends ClassMapperBase<GameProperty> {
static String _$description(GameProperty v) => v.description;
static const Field<GameProperty, String> _f$description =
Field('description', _$description, opt: true, def: '');
static int? _$maxPlayers(GameProperty v) => v.maxPlayers;
static const Field<GameProperty, int> _f$maxPlayers =
Field('maxPlayers', _$maxPlayers, opt: true);
static int _$currentPlayers(GameProperty v) => v.currentPlayers;
static const Field<GameProperty, int> _f$currentPlayers =
Field('currentPlayers', _$currentPlayers, opt: true, def: 0);
static Map<String, FileMetadata> _$packsSignature(GameProperty v) =>
v.packsSignature;
static const Field<GameProperty, Map<String, FileMetadata>>
_f$packsSignature =
Field('packsSignature', _$packsSignature, opt: true, def: const {});

@override
final MappableFields<GameProperty> fields = const {
#description: _f$description,
#maxPlayers: _f$maxPlayers,
#currentPlayers: _f$currentPlayers,
#packsSignature: _f$packsSignature,
};

static GameProperty _instantiate(DecodingData data) {
return GameProperty(description: data.dec(_f$description));
return GameProperty(
description: data.dec(_f$description),
maxPlayers: data.dec(_f$maxPlayers),
currentPlayers: data.dec(_f$currentPlayers),
packsSignature: data.dec(_f$packsSignature));
}

@override
Expand Down Expand Up @@ -384,7 +403,13 @@ extension GamePropertyValueCopy<$R, $Out>

abstract class GamePropertyCopyWith<$R, $In extends GameProperty, $Out>
implements ClassCopyWith<$R, $In, $Out> {
$R call({String? description});
MapCopyWith<$R, String, FileMetadata,
FileMetadataCopyWith<$R, FileMetadata, FileMetadata>> get packsSignature;
$R call(
{String? description,
int? maxPlayers,
int? currentPlayers,
Map<String, FileMetadata>? packsSignature});
GamePropertyCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t);
}

Expand All @@ -397,11 +422,28 @@ class _GamePropertyCopyWithImpl<$R, $Out>
late final ClassMapperBase<GameProperty> $mapper =
GamePropertyMapper.ensureInitialized();
@override
$R call({String? description}) => $apply(
FieldCopyWithData({if (description != null) #description: description}));
MapCopyWith<$R, String, FileMetadata,
FileMetadataCopyWith<$R, FileMetadata, FileMetadata>>
get packsSignature => MapCopyWith($value.packsSignature,
(v, t) => v.copyWith.$chain(t), (v) => call(packsSignature: v));
@override
GameProperty $make(CopyWithData data) =>
GameProperty(description: data.get(#description, or: $value.description));
$R call(
{String? description,
Object? maxPlayers = $none,
int? currentPlayers,
Map<String, FileMetadata>? packsSignature}) =>
$apply(FieldCopyWithData({
if (description != null) #description: description,
if (maxPlayers != $none) #maxPlayers: maxPlayers,
if (currentPlayers != null) #currentPlayers: currentPlayers,
if (packsSignature != null) #packsSignature: packsSignature
}));
@override
GameProperty $make(CopyWithData data) => GameProperty(
description: data.get(#description, or: $value.description),
maxPlayers: data.get(#maxPlayers, or: $value.maxPlayers),
currentPlayers: data.get(#currentPlayers, or: $value.currentPlayers),
packsSignature: data.get(#packsSignature, or: $value.packsSignature));

@override
GamePropertyCopyWith<$R2, GameProperty, $Out2> $chain<$R2, $Out2>(
Expand All @@ -417,6 +459,7 @@ class LanPropertyMapper extends ClassMapperBase<LanProperty> {
if (_instance == null) {
MapperContainer.globals.use(_instance = LanPropertyMapper._());
GamePropertyMapper.ensureInitialized();
FileMetadataMapper.ensureInitialized();
}
return _instance!;
}
Expand All @@ -427,19 +470,36 @@ class LanPropertyMapper extends ClassMapperBase<LanProperty> {
static int _$port(LanProperty v) => v.port;
static const Field<LanProperty, int> _f$port =
Field('port', _$port, opt: true, def: kDefaultPort);
static int _$currentPlayers(LanProperty v) => v.currentPlayers;
static const Field<LanProperty, int> _f$currentPlayers =
Field('currentPlayers', _$currentPlayers, opt: true, def: 0);
static int? _$maxPlayers(LanProperty v) => v.maxPlayers;
static const Field<LanProperty, int> _f$maxPlayers =
Field('maxPlayers', _$maxPlayers, opt: true);
static String _$description(LanProperty v) => v.description;
static const Field<LanProperty, String> _f$description =
Field('description', _$description, opt: true, def: '');
static Map<String, FileMetadata> _$packsSignature(LanProperty v) =>
v.packsSignature;
static const Field<LanProperty, Map<String, FileMetadata>> _f$packsSignature =
Field('packsSignature', _$packsSignature, opt: true, def: const {});

@override
final MappableFields<LanProperty> fields = const {
#port: _f$port,
#currentPlayers: _f$currentPlayers,
#maxPlayers: _f$maxPlayers,
#description: _f$description,
#packsSignature: _f$packsSignature,
};

static LanProperty _instantiate(DecodingData data) {
return LanProperty(
port: data.dec(_f$port), description: data.dec(_f$description));
port: data.dec(_f$port),
currentPlayers: data.dec(_f$currentPlayers),
maxPlayers: data.dec(_f$maxPlayers),
description: data.dec(_f$description),
packsSignature: data.dec(_f$packsSignature));
}

@override
Expand Down Expand Up @@ -494,7 +554,15 @@ extension LanPropertyValueCopy<$R, $Out>
abstract class LanPropertyCopyWith<$R, $In extends LanProperty, $Out>
implements GamePropertyCopyWith<$R, $In, $Out> {
@override
$R call({int? port, String? description});
MapCopyWith<$R, String, FileMetadata,
FileMetadataCopyWith<$R, FileMetadata, FileMetadata>> get packsSignature;
@override
$R call(
{int? port,
int? currentPlayers,
int? maxPlayers,
String? description,
Map<String, FileMetadata>? packsSignature});
LanPropertyCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t);
}

Expand All @@ -507,14 +575,31 @@ class _LanPropertyCopyWithImpl<$R, $Out>
late final ClassMapperBase<LanProperty> $mapper =
LanPropertyMapper.ensureInitialized();
@override
$R call({int? port, String? description}) => $apply(FieldCopyWithData({
MapCopyWith<$R, String, FileMetadata,
FileMetadataCopyWith<$R, FileMetadata, FileMetadata>>
get packsSignature => MapCopyWith($value.packsSignature,
(v, t) => v.copyWith.$chain(t), (v) => call(packsSignature: v));
@override
$R call(
{int? port,
int? currentPlayers,
Object? maxPlayers = $none,
String? description,
Map<String, FileMetadata>? packsSignature}) =>
$apply(FieldCopyWithData({
if (port != null) #port: port,
if (description != null) #description: description
if (currentPlayers != null) #currentPlayers: currentPlayers,
if (maxPlayers != $none) #maxPlayers: maxPlayers,
if (description != null) #description: description,
if (packsSignature != null) #packsSignature: packsSignature
}));
@override
LanProperty $make(CopyWithData data) => LanProperty(
port: data.get(#port, or: $value.port),
description: data.get(#description, or: $value.description));
currentPlayers: data.get(#currentPlayers, or: $value.currentPlayers),
maxPlayers: data.get(#maxPlayers, or: $value.maxPlayers),
description: data.get(#description, or: $value.description),
packsSignature: data.get(#packsSignature, or: $value.packsSignature));

@override
LanPropertyCopyWith<$R2, LanProperty, $Out2> $chain<$R2, $Out2>(
Expand All @@ -530,6 +615,7 @@ class ListPropertyMapper extends ClassMapperBase<ListProperty> {
if (_instance == null) {
MapperContainer.globals.use(_instance = ListPropertyMapper._());
GamePropertyMapper.ensureInitialized();
FileMetadataMapper.ensureInitialized();
}
return _instance!;
}
Expand All @@ -539,19 +625,37 @@ class ListPropertyMapper extends ClassMapperBase<ListProperty> {

static int _$index(ListProperty v) => v.index;
static const Field<ListProperty, int> _f$index = Field('index', _$index);
static int _$currentPlayers(ListProperty v) => v.currentPlayers;
static const Field<ListProperty, int> _f$currentPlayers =
Field('currentPlayers', _$currentPlayers, opt: true, def: 0);
static int? _$maxPlayers(ListProperty v) => v.maxPlayers;
static const Field<ListProperty, int> _f$maxPlayers =
Field('maxPlayers', _$maxPlayers, opt: true);
static String _$description(ListProperty v) => v.description;
static const Field<ListProperty, String> _f$description =
Field('description', _$description, opt: true, def: '');
static Map<String, FileMetadata> _$packsSignature(ListProperty v) =>
v.packsSignature;
static const Field<ListProperty, Map<String, FileMetadata>>
_f$packsSignature =
Field('packsSignature', _$packsSignature, opt: true, def: const {});

@override
final MappableFields<ListProperty> fields = const {
#index: _f$index,
#currentPlayers: _f$currentPlayers,
#maxPlayers: _f$maxPlayers,
#description: _f$description,
#packsSignature: _f$packsSignature,
};

static ListProperty _instantiate(DecodingData data) {
return ListProperty(
index: data.dec(_f$index), description: data.dec(_f$description));
index: data.dec(_f$index),
currentPlayers: data.dec(_f$currentPlayers),
maxPlayers: data.dec(_f$maxPlayers),
description: data.dec(_f$description),
packsSignature: data.dec(_f$packsSignature));
}

@override
Expand Down Expand Up @@ -607,7 +711,15 @@ extension ListPropertyValueCopy<$R, $Out>
abstract class ListPropertyCopyWith<$R, $In extends ListProperty, $Out>
implements GamePropertyCopyWith<$R, $In, $Out> {
@override
$R call({int? index, String? description});
MapCopyWith<$R, String, FileMetadata,
FileMetadataCopyWith<$R, FileMetadata, FileMetadata>> get packsSignature;
@override
$R call(
{int? index,
int? currentPlayers,
int? maxPlayers,
String? description,
Map<String, FileMetadata>? packsSignature});
ListPropertyCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t);
}

Expand All @@ -620,14 +732,31 @@ class _ListPropertyCopyWithImpl<$R, $Out>
late final ClassMapperBase<ListProperty> $mapper =
ListPropertyMapper.ensureInitialized();
@override
$R call({int? index, String? description}) => $apply(FieldCopyWithData({
MapCopyWith<$R, String, FileMetadata,
FileMetadataCopyWith<$R, FileMetadata, FileMetadata>>
get packsSignature => MapCopyWith($value.packsSignature,
(v, t) => v.copyWith.$chain(t), (v) => call(packsSignature: v));
@override
$R call(
{int? index,
int? currentPlayers,
Object? maxPlayers = $none,
String? description,
Map<String, FileMetadata>? packsSignature}) =>
$apply(FieldCopyWithData({
if (index != null) #index: index,
if (description != null) #description: description
if (currentPlayers != null) #currentPlayers: currentPlayers,
if (maxPlayers != $none) #maxPlayers: maxPlayers,
if (description != null) #description: description,
if (packsSignature != null) #packsSignature: packsSignature
}));
@override
ListProperty $make(CopyWithData data) => ListProperty(
index: data.get(#index, or: $value.index),
description: data.get(#description, or: $value.description));
currentPlayers: data.get(#currentPlayers, or: $value.currentPlayers),
maxPlayers: data.get(#maxPlayers, or: $value.maxPlayers),
description: data.get(#description, or: $value.description),
packsSignature: data.get(#packsSignature, or: $value.packsSignature));

@override
ListPropertyCopyWith<$R2, ListProperty, $Out2> $chain<$R2, $Out2>(
Expand Down
2 changes: 1 addition & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
/node_modules

# Runtime related
assets/pack.qka
assets/pack.stnx
2 changes: 1 addition & 1 deletion app/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.988.0)
aws-partitions (1.989.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
Expand Down
Binary file added app/assets/pack.qka
Binary file not shown.
4 changes: 2 additions & 2 deletions app/lib/api/open.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Future<void> importFile(
acceptedTypeGroups: [
fs.XTypeGroup(
label: AppLocalizations.of(context).packs,
extensions: const ['qka'],
extensions: const ['stnx'],
uniformTypeIdentifiers: const ['dev.linwood.setonix.pack'],
mimeTypes: const ['application/octet-stream', 'application/zip'],
)
Expand All @@ -46,7 +46,7 @@ Future<void> importFile(
}

Future<SetonixData?> getCorePack() async => SetonixData.fromData(
(await rootBundle.load('assets/pack.qka')).buffer.asUint8List());
(await rootBundle.load('assets/pack.stnx')).buffer.asUint8List());

Future<void> importFileData(BuildContext context, SetonixFileSystem fileSystem,
SetonixData data) async {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/api/save.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Future<void> exportData(BuildContext context, SetonixData data, String name) =>
exportFile(
context: context,
bytes: data.exportAsBytes(),
fileExtension: 'qka',
fileExtension: 'stnx',
fileName: name,
label: AppLocalizations.of(context).game,
mimeType: 'application/octet-stream',
Expand Down
Loading

0 comments on commit 7af2120

Please sign in to comment.