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 {
|
||||
@@ -38,7 +40,7 @@ class ModManagerHomePage extends StatefulWidget {
|
||||
|
||||
class _ModManagerHomePageState extends State<ModManagerHomePage> {
|
||||
int _selectedIndex = 0;
|
||||
|
||||
|
||||
final List<Widget> _pages = [
|
||||
const ModListPage(),
|
||||
const LoadOrderPage(),
|
||||
@@ -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}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user