Got more things functional
This commit is contained in:
parent
a1141cd2b8
commit
fc0c1c7e7a
23 changed files with 1080 additions and 876 deletions
|
@ -22,69 +22,64 @@ class ModManagerState extends State<ModManager> {
|
|||
title: Text("Conan Exiles Server Manager - Mod Manager"),
|
||||
backgroundColor: Color.fromARGB(255, 100, 0, 0),
|
||||
),
|
||||
body: WillPopScope(
|
||||
child: ReorderableListView.builder(
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
if (oldIndex < newIndex) {
|
||||
// From top to Bottom
|
||||
int end = newIndex - 1;
|
||||
Mod item = settings.inst!.mods[oldIndex];
|
||||
int i = 0;
|
||||
int local = oldIndex;
|
||||
do {
|
||||
settings.inst!.mods[local] = settings.inst!.mods[++local];
|
||||
i++;
|
||||
} while (i < end - oldIndex);
|
||||
settings.inst!.mods[end] = item;
|
||||
} else if (oldIndex > newIndex) {
|
||||
//From bottom to top
|
||||
Mod item = settings.inst!.mods[oldIndex];
|
||||
for (int i = oldIndex; i > newIndex; i--) {
|
||||
settings.inst!.mods[i] = settings.inst!.mods[i - 1];
|
||||
}
|
||||
settings.inst!.mods[newIndex] = item;
|
||||
body: ReorderableListView.builder(
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
if (oldIndex < newIndex) {
|
||||
// From top to Bottom
|
||||
int end = newIndex - 1;
|
||||
Mod item = settings.inst!.mods[oldIndex];
|
||||
int i = 0;
|
||||
int local = oldIndex;
|
||||
do {
|
||||
settings.inst!.mods[local] = settings.inst!.mods[++local];
|
||||
i++;
|
||||
} while (i < end - oldIndex);
|
||||
settings.inst!.mods[end] = item;
|
||||
} else if (oldIndex > newIndex) {
|
||||
//From bottom to top
|
||||
Mod item = settings.inst!.mods[oldIndex];
|
||||
for (int i = oldIndex; i > newIndex; i--) {
|
||||
settings.inst!.mods[i] = settings.inst!.mods[i - 1];
|
||||
}
|
||||
setState(() {
|
||||
settings.Write();
|
||||
});
|
||||
},
|
||||
itemBuilder: (ctx, idx) {
|
||||
Mod mod = settings.inst!.mods[idx];
|
||||
return Padding(
|
||||
key: Key(mod.mod_instance_id()),
|
||||
padding: EdgeInsets.all(12),
|
||||
child: ListTile(
|
||||
title: Text(mod.mod_name),
|
||||
subtitle: Text("ID: ${mod.mod_id}"),
|
||||
onTap: () async {
|
||||
final reply = await Navigator.pushNamed(
|
||||
context, "/server/mods/edit",
|
||||
arguments: Mod(
|
||||
mod_id: mod.mod_id,
|
||||
mod_name: mod.mod_name,
|
||||
mod_pak: mod.mod_pak,
|
||||
mod_hash: mod.mod_hash,
|
||||
newMod: false));
|
||||
settings.inst!.mods[newIndex] = item;
|
||||
}
|
||||
setState(() {
|
||||
settings.Write();
|
||||
});
|
||||
},
|
||||
itemBuilder: (ctx, idx) {
|
||||
Mod mod = settings.inst!.mods[idx];
|
||||
return Padding(
|
||||
key: Key(mod.mod_instance_id()),
|
||||
padding: EdgeInsets.all(12),
|
||||
child: ListTile(
|
||||
title: Text(mod.mod_name),
|
||||
subtitle: Text("ID: ${mod.mod_id}\nLoad Order: ${idx}"),
|
||||
onTap: () async {
|
||||
final reply = await Navigator.pushNamed(
|
||||
context, "/server/mods/edit",
|
||||
arguments: Mod(
|
||||
mod_id: mod.mod_id,
|
||||
mod_name: mod.mod_name,
|
||||
mod_pak: mod.mod_pak,
|
||||
mod_hash: mod.mod_hash,
|
||||
newMod: false));
|
||||
|
||||
if (reply != null) {
|
||||
setState(() {
|
||||
settings.inst!.mods[idx] = reply as Mod;
|
||||
});
|
||||
} else {
|
||||
if (reply != null) {
|
||||
if (reply is bool) {
|
||||
setState(() {
|
||||
settings.inst!.mods.removeAt(idx);
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: settings.inst!.mods.length,
|
||||
),
|
||||
onWillPop: () async {
|
||||
Navigator.pop(context);
|
||||
return true;
|
||||
setState(() {
|
||||
settings.inst!.mods[idx] = reply as Mod;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: settings.inst!.mods.length,
|
||||
),
|
||||
floatingActionButton: ElevatedButton(
|
||||
child: Icon(Icons.add),
|
||||
|
@ -93,11 +88,10 @@ class ModManagerState extends State<ModManager> {
|
|||
final reply = await Navigator.pushNamed(context, "/server/mods/edit",
|
||||
arguments: Mod(newMod: true));
|
||||
|
||||
if (reply != null) {
|
||||
if (reply != null && reply is! bool) {
|
||||
Mod mod = reply as Mod;
|
||||
setState(() {
|
||||
settings.inst!.mods.add(mod);
|
||||
settings.Write();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -137,96 +131,94 @@ class ModPage extends StatelessWidget {
|
|||
title: Text("Mod Editor"),
|
||||
backgroundColor: Color.fromARGB(255, 100, 0, 0),
|
||||
),
|
||||
body: WillPopScope(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 150,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.abc_rounded),
|
||||
title: Text("Mod Name"),
|
||||
)),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: name,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(4)))),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 150,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.perm_identity),
|
||||
title: Text("Mod ID")),
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: id,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(4))),
|
||||
))
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Mod Instance ID"),
|
||||
subtitle: Text(instance),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Mod Pak File: $pak"),
|
||||
subtitle:
|
||||
Text("Mod pak file name as detected during downloading"),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Mod Hash"),
|
||||
subtitle: Text("$hash"),
|
||||
),
|
||||
if (!isNewMod)
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
willDelete = true;
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.delete),
|
||||
SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text("Remove Mod")
|
||||
],
|
||||
))
|
||||
]),
|
||||
),
|
||||
onWillPop: () async {
|
||||
floatingActionButton: ElevatedButton(
|
||||
child: Text("Save"),
|
||||
onPressed: () {
|
||||
int idVal = 0;
|
||||
try {
|
||||
idVal = int.parse(id.text);
|
||||
} catch (E) {}
|
||||
|
||||
if (willDelete) {
|
||||
Navigator.pop(context, null);
|
||||
Navigator.pop(context, true);
|
||||
} else {
|
||||
Navigator.pop(context,
|
||||
Mod(mod_id: idVal, mod_name: name.text, newMod: false));
|
||||
}
|
||||
return true;
|
||||
},
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 150,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.abc_rounded),
|
||||
title: Text("Mod Name"),
|
||||
)),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: name,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(4)))),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 150,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.perm_identity), title: Text("Mod ID")),
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: id,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(4))),
|
||||
))
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Mod Instance ID"),
|
||||
subtitle: Text(instance),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Mod Pak File: $pak"),
|
||||
subtitle: Text("Mod pak file name as detected during downloading"),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Mod Hash"),
|
||||
subtitle: Text(hash),
|
||||
),
|
||||
if (!isNewMod)
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
willDelete = true;
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.delete),
|
||||
SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text("Remove Mod")
|
||||
],
|
||||
))
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue