This commit is contained in:
Alessandro Autiero
2022-12-16 21:08:57 +01:00
parent ef7f34e0e3
commit 966b4b33fd
91 changed files with 388682 additions and 1005 deletions

View File

@@ -1,42 +1,41 @@
import 'package:dart_vlc/dart_vlc.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:ini/ini.dart';
import 'package:reboot_launcher/src/util/os.dart';
import 'package:reboot_launcher/src/util/server.dart';
import 'dart:ui';
class SettingsController extends GetxController {
late final GetStorage _storage;
late final String originalDll;
late final TextEditingController rebootDll;
late final TextEditingController consoleDll;
late final TextEditingController craniumDll;
late final TextEditingController authDll;
late final TextEditingController matchmakingIp;
late final Rx<PaneDisplayMode> displayType;
late double width;
late double height;
late double? offsetX;
late double? offsetY;
Player? player;
SettingsController() {
_storage = GetStorage("settings");
rebootDll = _createController("reboot", "reboot.dll");
consoleDll = _createController("console", "console.dll");
craniumDll = _createController("cranium", "cranium.dll");
authDll = _createController("cranium2", "craniumv2.dll");
matchmakingIp = TextEditingController(text: _storage.read("ip") ?? "127.0.0.1");
matchmakingIp.addListener(() async {
var text = matchmakingIp.text;
_storage.write("ip", text);
if(await serverConfig.exists()){
var config = Config.fromString(await serverConfig.readAsString());
if(text.contains(":")){
config.set("GameServer", "ip", text.substring(0, text.indexOf(":")));
config.set("GameServer", "port", text.substring(text.indexOf(":") + 1));
}else {
config.set("GameServer", "ip", text);
config.set("GameServer", "port", "7777");
}
serverConfig.writeAsString(config.toString());
}
});
width = _storage.read("width") ?? window.physicalSize.width;
height = _storage.read("height") ?? window.physicalSize.height;
offsetX = _storage.read("offset_x");
offsetY = _storage.read("offset_y");
displayType = Rx(PaneDisplayMode.top);
}
TextEditingController _createController(String key, String name) {
@@ -47,4 +46,14 @@ class SettingsController extends GetxController {
return controller;
}
void saveWindowSize() {
_storage.write("width", window.physicalSize.width);
_storage.write("height", window.physicalSize.height);
}
void saveWindowOffset(Offset position) {
_storage.write("offset_x", position.dx);
_storage.write("offset_y", position.dy);
}
}