Implement sussing active mods
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rimworld_modman/modloader.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const RimWorldModManager());
|
||||
ConfigFile(path: configPath).load();
|
||||
// runApp(const RimWorldModManager());
|
||||
}
|
||||
|
||||
class RimWorldModManager extends StatelessWidget {
|
||||
@@ -48,9 +50,7 @@ class _ModManagerHomePageState extends State<ModManagerHomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('RimWorld Mod Manager'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('RimWorld Mod Manager')),
|
||||
body: _pages[_selectedIndex],
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _selectedIndex,
|
||||
@@ -60,10 +60,7 @@ class _ModManagerHomePageState extends State<ModManagerHomePage> {
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.list),
|
||||
label: 'Mods',
|
||||
),
|
||||
BottomNavigationBarItem(icon: Icon(Icons.list), label: 'Mods'),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.reorder),
|
||||
label: 'Load Order',
|
||||
@@ -90,10 +87,7 @@ class ModListPage extends StatelessWidget {
|
||||
children: [
|
||||
const Icon(Icons.extension, size: 64),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Mod List',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
Text('Mod List', style: Theme.of(context).textTheme.headlineMedium),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Here you\'ll see your installed mods.',
|
||||
@@ -124,10 +118,7 @@ class LoadOrderPage extends StatelessWidget {
|
||||
children: [
|
||||
const Icon(Icons.reorder, size: 64),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Load Order',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
Text('Load Order', style: Theme.of(context).textTheme.headlineMedium),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Manage your mod loading order with dependency resolution.',
|
||||
|
@@ -1,13 +1,76 @@
|
||||
const root = r'C:\Users\Administrator\Seafile\Games-Rimworld';
|
||||
const modsRoot = '$root\294100';
|
||||
const configRoot = '$root\AppData\RimWorld by Ludeon Studios\Config';
|
||||
import 'dart:io';
|
||||
import 'package:xml/xml.dart';
|
||||
|
||||
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 {
|
||||
final String name; // ModMetaData.name
|
||||
final String id; // ModMetaData.packageId
|
||||
final String path; // figure it out
|
||||
final List<String> versions; // ModMetaData.supportedVersions
|
||||
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> 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"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -208,6 +216,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.3.1"
|
||||
xml:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: xml
|
||||
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.5.0"
|
||||
sdks:
|
||||
dart: ">=3.7.2 <4.0.0"
|
||||
flutter: ">=3.18.0-18.0.pre.54"
|
||||
|
@@ -34,6 +34,7 @@ dependencies:
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.8
|
||||
xml: ^6.5.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Reference in New Issue
Block a user