feat: Add file selector support and enhance game data directory management
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -51,7 +51,7 @@ void main() {
|
||||
});
|
||||
|
||||
final persistence = DefaultGameDataDirectoryPersistence(
|
||||
filePath: '${tempDir.path}/data_source.json',
|
||||
filePath: '${tempDir.path}/settings.json',
|
||||
);
|
||||
|
||||
await persistence.saveDataDirectory('/tmp/wolf-data');
|
||||
@@ -70,7 +70,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
final path = '${tempDir.path}/data_source.json';
|
||||
final path = '${tempDir.path}/settings.json';
|
||||
final persistence = DefaultGameDataDirectoryPersistence(filePath: path);
|
||||
|
||||
await persistence.saveDataDirectory('/tmp/wolf-data');
|
||||
@@ -79,6 +79,39 @@ void main() {
|
||||
expect(await File(path).exists(), isFalse);
|
||||
expect(await persistence.loadDataDirectory(), isNull);
|
||||
});
|
||||
|
||||
test('preserves unrelated settings when updating data directory', () async {
|
||||
final tempDir = await Directory.systemTemp.createTemp(
|
||||
'wolf3d-data-config-',
|
||||
);
|
||||
addTearDown(() async {
|
||||
if (await tempDir.exists()) {
|
||||
await tempDir.delete(recursive: true);
|
||||
}
|
||||
});
|
||||
|
||||
final path = '${tempDir.path}/settings.json';
|
||||
final file = File(path);
|
||||
await file.parent.create(recursive: true);
|
||||
await file.writeAsString(
|
||||
'{"renderScale":2.0,"preferSoftwareRenderer":false}',
|
||||
);
|
||||
|
||||
final persistence = DefaultGameDataDirectoryPersistence(filePath: path);
|
||||
|
||||
await persistence.saveDataDirectory('/tmp/wolf-data');
|
||||
|
||||
final updated = await file.readAsString();
|
||||
expect(updated, contains('"renderScale":2.0'));
|
||||
expect(updated, contains('"preferSoftwareRenderer":false'));
|
||||
expect(updated, contains('"dataDirectory":"/tmp/wolf-data"'));
|
||||
|
||||
await persistence.saveDataDirectory(null);
|
||||
final cleared = await file.readAsString();
|
||||
expect(cleared, contains('"renderScale":2.0'));
|
||||
expect(cleared, contains('"preferSoftwareRenderer":false'));
|
||||
expect(cleared.contains('"dataDirectory"'), isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Wolf3dApp forwards configured directory to no-data screen', (
|
||||
|
||||
Reference in New Issue
Block a user