ip for click to play

This commit is contained in:
Alessandro Autiero
2022-10-25 19:42:09 +02:00
parent 691cd53f26
commit ef7f34e0e3
26 changed files with 509 additions and 725 deletions

View File

@@ -1,13 +1,10 @@
import 'dart:convert';
import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:reboot_launcher/src/model/fortnite_version.dart';
import 'package:reboot_launcher/src/model/game_type.dart';
import 'package:ini/ini.dart';
import 'package:reboot_launcher/src/util/os.dart';
import 'package:system_theme/system_theme.dart';
import 'package:reboot_launcher/src/util/server.dart';
class SettingsController extends GetxController {
late final GetStorage _storage;
@@ -15,7 +12,7 @@ class SettingsController extends GetxController {
late final TextEditingController rebootDll;
late final TextEditingController consoleDll;
late final TextEditingController craniumDll;
late final RxBool autoUpdate;
late final TextEditingController matchmakingIp;
SettingsController() {
_storage = GetStorage("settings");
@@ -23,9 +20,23 @@ class SettingsController extends GetxController {
rebootDll = _createController("reboot", "reboot.dll");
consoleDll = _createController("console", "console.dll");
craniumDll = _createController("cranium", "cranium.dll");
autoUpdate = RxBool(_storage.read("auto_update") ?? true);
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");
}
autoUpdate.listen((value) => _storage.write("auto_update", value));
serverConfig.writeAsString(config.toString());
}
});
}
TextEditingController _createController(String key, String name) {