Implement sussing active mods
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rimworld_modman/modloader.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const RimWorldModManager());
|
ConfigFile(path: configPath).load();
|
||||||
|
// runApp(const RimWorldModManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
class RimWorldModManager extends StatelessWidget {
|
class RimWorldModManager extends StatelessWidget {
|
||||||
@@ -38,7 +40,7 @@ class ModManagerHomePage extends StatefulWidget {
|
|||||||
|
|
||||||
class _ModManagerHomePageState extends State<ModManagerHomePage> {
|
class _ModManagerHomePageState extends State<ModManagerHomePage> {
|
||||||
int _selectedIndex = 0;
|
int _selectedIndex = 0;
|
||||||
|
|
||||||
final List<Widget> _pages = [
|
final List<Widget> _pages = [
|
||||||
const ModListPage(),
|
const ModListPage(),
|
||||||
const LoadOrderPage(),
|
const LoadOrderPage(),
|
||||||
@@ -48,9 +50,7 @@ class _ModManagerHomePageState extends State<ModManagerHomePage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(title: const Text('RimWorld Mod Manager')),
|
||||||
title: const Text('RimWorld Mod Manager'),
|
|
||||||
),
|
|
||||||
body: _pages[_selectedIndex],
|
body: _pages[_selectedIndex],
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
currentIndex: _selectedIndex,
|
currentIndex: _selectedIndex,
|
||||||
@@ -60,10 +60,7 @@ class _ModManagerHomePageState extends State<ModManagerHomePage> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: const [
|
items: const [
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(icon: Icon(Icons.list), label: 'Mods'),
|
||||||
icon: Icon(Icons.list),
|
|
||||||
label: 'Mods',
|
|
||||||
),
|
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: Icon(Icons.reorder),
|
icon: Icon(Icons.reorder),
|
||||||
label: 'Load Order',
|
label: 'Load Order',
|
||||||
@@ -90,10 +87,7 @@ class ModListPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const Icon(Icons.extension, size: 64),
|
const Icon(Icons.extension, size: 64),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text('Mod List', style: Theme.of(context).textTheme.headlineMedium),
|
||||||
'Mod List',
|
|
||||||
style: Theme.of(context).textTheme.headlineMedium,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Here you\'ll see your installed mods.',
|
'Here you\'ll see your installed mods.',
|
||||||
@@ -124,10 +118,7 @@ class LoadOrderPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const Icon(Icons.reorder, size: 64),
|
const Icon(Icons.reorder, size: 64),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text('Load Order', style: Theme.of(context).textTheme.headlineMedium),
|
||||||
'Load Order',
|
|
||||||
style: Theme.of(context).textTheme.headlineMedium,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Manage your mod loading order with dependency resolution.',
|
'Manage your mod loading order with dependency resolution.',
|
||||||
|
@@ -1,13 +1,76 @@
|
|||||||
const root = r'C:\Users\Administrator\Seafile\Games-Rimworld';
|
import 'dart:io';
|
||||||
const modsRoot = '$root\294100';
|
import 'package:xml/xml.dart';
|
||||||
const configRoot = '$root\AppData\RimWorld by Ludeon Studios\Config';
|
|
||||||
|
const root = r'C:/Users/Administrator/Seafile/Games-Rimworld';
|
||||||
|
const modsRoot = '$root/294100';
|
||||||
|
const configRoot = '$root/AppData/RimWorld by Ludeon Studios/Config';
|
||||||
|
const configPath = '$configRoot/ModsConfig.xml';
|
||||||
|
|
||||||
class Mod {
|
class Mod {
|
||||||
final String name; // ModMetaData.name
|
final String name; // ModMetaData.name
|
||||||
|
final String id; // ModMetaData.packageId
|
||||||
final String path; // figure it out
|
final String path; // figure it out
|
||||||
final List<String> versions; // ModMetaData.supportedVersions
|
final List<String> versions; // ModMetaData.supportedVersions
|
||||||
final String description; // ModMetaData.description
|
final String description; // ModMetaData.description
|
||||||
final List<String> hardDependencies; // ModMetaData.modDependencies - this is a li with packageId, displayName, steamWorkshopUrl and downloadUrl
|
final List<String>
|
||||||
|
hardDependencies; // ModMetaData.modDependencies - this is a li with packageId, displayName, steamWorkshopUrl and downloadUrl
|
||||||
final List<String> softDependencies; // ModMetaData.loadAfter
|
final List<String> softDependencies; // ModMetaData.loadAfter
|
||||||
final List<String> incompatabilities; // ModMetaData.incompatibleWith
|
final List<String> incompatabilities; // ModMetaData.incompatibleWith
|
||||||
|
final bool
|
||||||
|
enabled; // ConfigFile.mods.firstWhere((mod) => mod.id == id).enabled
|
||||||
|
|
||||||
|
Mod({
|
||||||
|
required this.name,
|
||||||
|
required this.id,
|
||||||
|
required this.path,
|
||||||
|
required this.versions,
|
||||||
|
required this.description,
|
||||||
|
required this.hardDependencies,
|
||||||
|
required this.softDependencies,
|
||||||
|
required this.incompatabilities,
|
||||||
|
required this.enabled,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class ModList {
|
||||||
|
final String path;
|
||||||
|
final List<Mod> mods;
|
||||||
|
|
||||||
|
ModList({required this.path, this.mods = const []});
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
final file = File(path);
|
||||||
|
print('Loading configuration from: $path');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConfigFile {
|
||||||
|
final String path;
|
||||||
|
List<Mod> mods;
|
||||||
|
|
||||||
|
ConfigFile({required this.path, this.mods = const []});
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
final file = File(path);
|
||||||
|
print('Loading configuration from: $path');
|
||||||
|
|
||||||
|
final xmlString = file.readAsStringSync();
|
||||||
|
print('XML content read successfully.');
|
||||||
|
|
||||||
|
final xmlDocument = XmlDocument.parse(xmlString);
|
||||||
|
print('XML document parsed successfully.');
|
||||||
|
|
||||||
|
final modConfigData = xmlDocument.findElements("ModsConfigData").first;
|
||||||
|
print('Found ModsConfigData element.');
|
||||||
|
|
||||||
|
final modsElement = modConfigData.findElements("activeMods").first;
|
||||||
|
print('Found activeMods element.');
|
||||||
|
|
||||||
|
final mods = modsElement.findElements("li");
|
||||||
|
print('Found ${mods.length} active mods.');
|
||||||
|
|
||||||
|
for (final mod in mods) {
|
||||||
|
print('Mod found: ${mod.innerText}');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
16
pubspec.lock
16
pubspec.lock
@@ -139,6 +139,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.9.1"
|
||||||
|
petitparser:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: petitparser
|
||||||
|
sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.1.0"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -208,6 +216,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "14.3.1"
|
version: "14.3.1"
|
||||||
|
xml:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: xml
|
||||||
|
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.5.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.7.2 <4.0.0"
|
dart: ">=3.7.2 <4.0.0"
|
||||||
flutter: ">=3.18.0-18.0.pre.54"
|
flutter: ">=3.18.0-18.0.pre.54"
|
||||||
|
@@ -34,6 +34,7 @@ dependencies:
|
|||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
|
xml: ^6.5.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user