Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Commit

Permalink
fix: can't launch server
Browse files Browse the repository at this point in the history
  • Loading branch information
SiongSng committed Apr 25, 2022
1 parent a594c53 commit 81a42cc
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 38 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,28 +140,26 @@ jobs:
dart pub global activate cider
dart pub global run cider version ${{ env.rwl_version_full }}
flutter build macos --dart-define="build_id=${{ github.run_number }}" --dart-define="version_type=${{ env.version_type }}" --dart-define="version=${{ secrets.VERSION }}" --release
cp assets/images/MacOS_Logo_Icon.icns build/macos/Build/Products
cp assets/images/macOS_logo_icon.icns build/macos/Build/Products
cd build/macos/Build/Products
brew install create-dmg
create-dmg \
--volname "RPMLauncher Installer" \
--volicon "MacOS_Logo_Icon.icns" \
--volname "RPMLauncher Installer (${{ env.rwl_version_full }})" \
--volicon "macOS_logo_icon.icns" \
--window-pos 200 120 \
--window-size 800 529 \
--icon-size 130 \
--text-size 14 \
--icon "rpmlauncher.app" 260 250 \
--hide-extension "rpmlauncher.app" \
--app-drop-link 540 250 \
--hdiutil-quiet \
"RPMLauncher-MacOS-Installer.dmg" \
"RPMLauncher-macOS-Installer-${{ env.rwl_version_full }}.dmg" \
"Release/"
continue-on-error: true
- name: Upload File
uses: actions/upload-artifact@v2
with:
name: RPMLauncher-MacOS
path: build/macos/Build/Products/RPMLauncher-MacOS-Installer.dmg
path: build/macos/Build/Products/RPMLauncher-macOS-Installer.dmg
retention-days: 1
Release:
needs: ["Build-Linux", "Build-Windows", "Build-macOS"]
Expand Down Expand Up @@ -213,7 +211,7 @@ jobs:
RPMLauncher-Linux.zip
RPMLauncher-Linux.AppImage
RPMLauncher-Linux.deb
RPMLauncher-MacOS/RPMLauncher-MacOS-Installer.dmg
RPMLauncher-MacOS/RPMLauncher-macOS-Installer.dmg
- name: Upload to Arch User Repository
env:
Expand Down Expand Up @@ -307,7 +305,7 @@ jobs:
continue-on-error: true

Coverage:
if: ${{ !contains(github.event.head_commit.message,'[ci skip]') }}
if: ${{ !contains(github.event.head_commit.message,'[ci skip]') }}
strategy:
matrix:
runs-on: [ubuntu-latest, windows-latest, macos-latest]
Expand Down
File renamed without changes.
7 changes: 6 additions & 1 deletion lib/model/Game/Instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ class Instance {
if (config.sideEnum.isServer) {
File eulaFile = File(join(path, 'eula.txt'));
if (!eulaFile.existsSync()) {
eulaFile.writeAsStringSync("eula=false");
const Properties properties = Properties({
'eula': 'false',
});

eulaFile.writeAsStringSync(
Properties.encode(properties));
}

try {
Expand Down
21 changes: 12 additions & 9 deletions lib/model/IO/Properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ import 'dart:collection';
import 'dart:convert';

class Properties with MapMixin<String, String> {
final Map<String, String> _map = {};
final comments = <String>[];
final Map<String, String> _map;
final List<String> comments;

Properties();
const Properties(this._map, {this.comments = const []});

static Properties decode(String text, {String splitChar = "="}) {
final Properties properties = Properties();
final Map<String, String> map = {};
final List<String> comments = [];

final List<String> lines = const LineSplitter().convert(text);
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
line = line.trim();

/// 註解處理
if (line.startsWith('#')) {
properties.comments.add(line.replaceFirst("#", ""));
comments.add(line.replaceFirst("#", ""));
continue;
} else if (line.isEmpty) {
continue;
Expand All @@ -26,21 +28,22 @@ class Properties with MapMixin<String, String> {
final kv = line.split(splitChar);
final k = kv[0];
final v = kv.getRange(1, (kv.length)).join("");
properties[k] = v;
map[k] = v;
} catch (e) {
throw DecodePropertiesError('$i 解析失敗,該字串為: $line');
}
}
}

return properties;
return Properties(map, comments: comments);
}

static encode(Properties properties, {String splitChar = "="}) {
final lines = <String>[];
static String encode(Properties properties, {String splitChar = "="}) {
final List<String> lines = [];
properties.forEach((k, v) {
lines.add('$k$splitChar$v');
});

return lines.join('\n');
}

Expand Down
36 changes: 17 additions & 19 deletions lib/screen/CheckAssets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,39 @@ class _CheckAssetsScreenState extends State<CheckAssetsScreen> {
void initState() {
super.initState();

InstanceConfig instanceConfig =
final InstanceConfig instanceConfig =
InstanceRepository.instanceConfig(basename(widget.instanceDir.path))!;

if (checkAssets && instanceConfig.sideEnum.isClient) {
//是否檢查資源檔案完整性
thread(instanceConfig);
} else {
checkAssetsProgress = 1.0;
check();
}
}

thread(InstanceConfig config) async {
ReceivePort port = ReceivePort();
compute(instanceAssets, IsolateOption.create(config, ports: [port]))
.then((value) {
if (mounted) {
setState(() {
checkAssetsProgress = 1.0;
});
}
});
void check() {
if (checkAssetsProgress == 1.0) {
Navigator.pop(this.context);
WindowHandler.create(
"/instance/${InstanceRepository.getUUIDByDir(widget.instanceDir)}/launcher",
);
} else {
setState(() {});
}
}

Future<void> thread(InstanceConfig config) async {
ReceivePort port = ReceivePort();
port.listen((message) {
if (mounted) {
checkAssetsProgress = double.parse(message.toString());
if (checkAssetsProgress == 1.0) {
Navigator.pop(this.context);
WindowHandler.create(
"/instance/${InstanceRepository.getUUIDByDir(widget.instanceDir)}/launcher",
);
} else {
setState(() {});
}
check();
}
});

await compute(instanceAssets, IsolateOption.create(config, ports: [port]));
}

static instanceAssets(IsolateOption<InstanceConfig> option) async {
Expand Down

0 comments on commit 81a42cc

Please sign in to comment.