mirror of
https://github.com/zontreck/NBTEditor
synced 2024-11-21 13:48:56 -07:00
Adds in image icons
This commit is contained in:
parent
7836668d4c
commit
192f039421
21 changed files with 88 additions and 51 deletions
|
@ -11,7 +11,7 @@ import 'package:libac_dart/nbt/impl/CompoundTag.dart';
|
|||
import 'package:nbteditor/Consts2.dart';
|
||||
|
||||
const HEADER =
|
||||
"nbt2snbt\nCopyright Piccari Creations 2024 - Tara Piccari\nVersion: ${VERSION}\n\n";
|
||||
"nbt2snbt\nCopyright Piccari Creations 2024 - Tara Piccari\nVersion: $VERSION\n\n";
|
||||
void main(List<String> args) async {
|
||||
Arguments usage = ArgumentsBuilder.builder()
|
||||
.withArgument(
|
||||
|
|
|
@ -11,7 +11,7 @@ import 'package:libac_dart/nbt/impl/CompoundTag.dart';
|
|||
import 'package:nbteditor/Consts2.dart';
|
||||
|
||||
const HEADER =
|
||||
"snbt2nbt\nCopyright Piccari Creations 2024 - Tara Piccari\nVersion: ${VERSION}\n\n";
|
||||
"snbt2nbt\nCopyright Piccari Creations 2024 - Tara Piccari\nVersion: $VERSION\n\n";
|
||||
void main(List<String> args) async {
|
||||
Arguments usage = ArgumentsBuilder.builder()
|
||||
.withArgument(
|
||||
|
@ -45,10 +45,11 @@ void main(List<String> args) async {
|
|||
print("Missing required argument: out");
|
||||
exit(2);
|
||||
} else {
|
||||
if (!vArgs.hasArg("compress"))
|
||||
if (!vArgs.hasArg("compress")) {
|
||||
NbtIo.write(vArgs.getArg("out")!.getValue() as String, ct);
|
||||
else
|
||||
} else {
|
||||
NbtIo.writeCompressed(vArgs.getArg("out")!.getValue() as String, ct);
|
||||
}
|
||||
print("Wrote NBT output to file");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,11 @@ class EditorState extends State<Editor> {
|
|||
}
|
||||
late TreeViewController controller;
|
||||
factory EditorState() {
|
||||
if (_inst == null)
|
||||
if (_inst == null) {
|
||||
return EditorState._();
|
||||
else
|
||||
} else {
|
||||
return _inst!;
|
||||
}
|
||||
}
|
||||
|
||||
void update() {
|
||||
|
@ -106,9 +107,9 @@ class EditorState extends State<Editor> {
|
|||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text("R A W"),
|
||||
subtitle: Text("Edit as raw SNBT"),
|
||||
leading: Icon(Icons.edit),
|
||||
title: const Text("R A W"),
|
||||
subtitle: const Text("Edit as raw SNBT"),
|
||||
leading: const Icon(Icons.edit),
|
||||
onTap: () async {
|
||||
await Navigator.pushNamed(context, "/snbt");
|
||||
setState(() {});
|
||||
|
|
|
@ -16,8 +16,8 @@ class MainApp extends StatelessWidget {
|
|||
theme: ThemeData.dark(),
|
||||
routes: {
|
||||
"/": (context) => const Editor(),
|
||||
"/add": (context) => AddPage(),
|
||||
"/snbt": (context) => SnbtEdit()
|
||||
"/add": (context) => const AddPage(),
|
||||
"/snbt": (context) => const SnbtEdit()
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ import 'package:libac_dart/nbt/Tag.dart';
|
|||
import 'package:nbteditor/Constants.dart';
|
||||
|
||||
class AddPage extends StatefulWidget {
|
||||
const AddPage({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => AddState();
|
||||
}
|
||||
|
@ -17,10 +19,10 @@ class AddState extends State<AddPage> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Add Tag"),
|
||||
title: const Text("Add Tag"),
|
||||
backgroundColor: Constants.TITLEBAR_COLOR,
|
||||
),
|
||||
body: Padding(
|
||||
body: const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class RenamePrompt extends StatefulWidget {
|
||||
const RenamePrompt({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return RenameState();
|
||||
|
@ -20,14 +22,14 @@ class RenameState extends State<RenamePrompt> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
icon: Icon(Icons.edit_attributes),
|
||||
title: Text("Edit Tag Name"),
|
||||
icon: const Icon(Icons.edit_attributes),
|
||||
title: const Text("Edit Tag Name"),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context, name.text);
|
||||
},
|
||||
child: Text("SUBMIT")),
|
||||
child: const Text("SUBMIT")),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
|
|
|
@ -7,6 +7,8 @@ import 'package:nbteditor/Constants.dart';
|
|||
import 'package:nbteditor/SessionData.dart';
|
||||
|
||||
class SnbtEdit extends StatefulWidget {
|
||||
const SnbtEdit({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return SnbtState();
|
||||
|
@ -27,7 +29,7 @@ class SnbtState extends State<SnbtEdit> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("SNBT Editor"),
|
||||
title: const Text("SNBT Editor"),
|
||||
backgroundColor: Constants.TITLEBAR_COLOR,
|
||||
),
|
||||
floatingActionButton: ElevatedButton(
|
||||
|
@ -42,18 +44,18 @@ class SnbtState extends State<SnbtEdit> {
|
|||
});
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Successfully edited NBT data")));
|
||||
const SnackBar(content: Text("Successfully edited NBT data")));
|
||||
|
||||
Navigator.pop(context);
|
||||
} catch (E) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text("FATAL ERROR: Your SNBT Syntax is not valid")));
|
||||
}
|
||||
},
|
||||
child: Text("Compile"),
|
||||
child: const Text("Compile"),
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: CodeTheme(
|
||||
data: CodeThemeData(styles: vsTheme),
|
||||
child: SingleChildScrollView(
|
||||
|
|
|
@ -22,6 +22,7 @@ extension ByteArrayTagExt on ByteArrayTag {
|
|||
Widget render(BuildContext context) {
|
||||
return ListTile(
|
||||
title: Text("TAG_ByteArray (${getKey()})"),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/ByteArray.png")),
|
||||
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
||||
false, canBeNamed(this), this, context),
|
||||
);
|
||||
|
|
|
@ -12,7 +12,8 @@ extension ByteTagExt on ByteTag {
|
|||
return ListTile(
|
||||
title: Text("TAG_Byte (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor(
|
||||
"${value}", false, true, canBeNamed(this), this, context),
|
||||
"$value", false, true, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/Byte.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,16 @@ import 'package:nbteditor/tags/Tag.dart';
|
|||
extension CompoundTagExt on CompoundTag {
|
||||
Widget render(BuildContext context) {
|
||||
return ListTile(
|
||||
title: Text("TAG_Compound (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor(
|
||||
"${value.length} tag${value.length > 1 ? "s" : ""}",
|
||||
true,
|
||||
false,
|
||||
canBeNamed(this),
|
||||
this,
|
||||
context));
|
||||
title: Text("TAG_Compound (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor(
|
||||
"${value.length} tag${value.length > 1 ? "s" : ""}",
|
||||
true,
|
||||
false,
|
||||
canBeNamed(this),
|
||||
this,
|
||||
context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/Compound.png")),
|
||||
);
|
||||
}
|
||||
|
||||
Node getNode(String path) {
|
||||
|
|
|
@ -12,7 +12,8 @@ extension DoubleTagExt on DoubleTag {
|
|||
return ListTile(
|
||||
title: Text("TAG_Double (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor(
|
||||
"${value}", false, true, canBeNamed(this), this, context),
|
||||
"$value", false, true, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/Double.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ extension FloatTagExt on FloatTag {
|
|||
return ListTile(
|
||||
title: Text("TAG_Float (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor(
|
||||
"${value}", false, true, canBeNamed(this), this, context),
|
||||
"$value", false, true, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/Float.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ extension IntArrayTagExt on IntArrayTag {
|
|||
title: Text("TAG_IntArray (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
||||
false, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/IntegerArray.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ extension IntTagExt on IntTag {
|
|||
return ListTile(
|
||||
title: Text("TAG_Int (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor(
|
||||
"${value}", false, true, canBeNamed(this), this, context),
|
||||
"$value", false, true, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/Integer.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,13 @@ extension ListTagExt on ListTag {
|
|||
|
||||
Widget render(BuildContext context) {
|
||||
TagType type = TagType.End;
|
||||
if (value.length > 0) type = get(0).getTagType();
|
||||
if (value.isNotEmpty) type = get(0).getTagType();
|
||||
|
||||
return ListTile(
|
||||
title: Text("TAG_List (${getKey()}) (${type})"),
|
||||
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
||||
false, canBeNamed(this), this, context));
|
||||
title: Text("TAG_List (${getKey()}) ($type)"),
|
||||
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
||||
false, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/List.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ extension LongArrayTagExt on LongArrayTag {
|
|||
title: Text("TAG_LongArray (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
||||
false, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/LongArray.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ extension LongTagExt on LongTag {
|
|||
return ListTile(
|
||||
title: Text("TAG_Long (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor(
|
||||
"${value}", false, true, canBeNamed(this), this, context),
|
||||
"$value", false, true, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/Long.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ extension ShortTagExt on ShortTag {
|
|||
return ListTile(
|
||||
title: Text("TAG_Short (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor(
|
||||
"${value}", false, true, canBeNamed(this), this, context),
|
||||
"$value", false, true, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/Short.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ extension StringTagExt on StringTag {
|
|||
return ListTile(
|
||||
title: Text("TAG_String (${getKey()})"),
|
||||
subtitle: TagExt.getElementDescriptor(
|
||||
"${value}", false, true, canBeNamed(this), this, context),
|
||||
value, false, true, canBeNamed(this), this, context),
|
||||
leading: const Image(image: AssetImage("Icons/PNG/String.png")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class TagExt {
|
|||
}
|
||||
case TagType.End:
|
||||
{
|
||||
return SizedBox();
|
||||
return const SizedBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ class TagExt {
|
|||
}
|
||||
case TagType.End:
|
||||
{
|
||||
return Node(key: "ENDTAG", label: "");
|
||||
return const Node(key: "ENDTAG", label: "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ class TagExt {
|
|||
return Row(
|
||||
children: [
|
||||
Text(descript),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 100,
|
||||
),
|
||||
if (canAddElements)
|
||||
|
@ -160,10 +160,10 @@ class TagExt {
|
|||
List<TagType> allowedTypes = [];
|
||||
if (tag is CompoundTag) allowAllTagTypes = true;
|
||||
if (tag is ListTag) {
|
||||
ListTag lst = tag as ListTag;
|
||||
if (lst.size() == 0)
|
||||
ListTag lst = tag;
|
||||
if (lst.size() == 0) {
|
||||
allowAllTagTypes = true;
|
||||
else {
|
||||
} else {
|
||||
allowAllTagTypes = false;
|
||||
allowedTypes = [lst.get(0).getTagType()];
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class TagExt {
|
|||
isArray: isArray,
|
||||
allowedTagTypes: allowedTypes));
|
||||
},
|
||||
child: Icon(Icons.add)),
|
||||
child: const Icon(Icons.add)),
|
||||
if (isNamed)
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
|
@ -201,19 +201,19 @@ class TagExt {
|
|||
context: ctx,
|
||||
routeSettings: RouteSettings(arguments: tag.getKey()),
|
||||
builder: (B) {
|
||||
return RenamePrompt();
|
||||
return const RenamePrompt();
|
||||
});
|
||||
|
||||
if (response is String) {
|
||||
tag.setKey(response as String);
|
||||
tag.setKey(response);
|
||||
|
||||
EditorState state = EditorState();
|
||||
state.update();
|
||||
}
|
||||
},
|
||||
child: Text("R E N A M E")),
|
||||
child: const Text("R E N A M E")),
|
||||
if (editableValue)
|
||||
ElevatedButton(onPressed: () {}, child: Text("E D I T"))
|
||||
ElevatedButton(onPressed: () {}, child: const Text("E D I T"))
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
15
pubspec.yaml
15
pubspec.yaml
|
@ -25,3 +25,18 @@ dev_dependencies:
|
|||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
assets:
|
||||
- "Icons/PNG/Boolean.png"
|
||||
- "Icons/PNG/Byte.png"
|
||||
- "Icons/PNG/ByteArray.png"
|
||||
- "Icons/PNG/Compound.png"
|
||||
- "Icons/PNG/Double.png"
|
||||
- "Icons/PNG/Float.png"
|
||||
- "Icons/PNG/Integer.png"
|
||||
- "Icons/PNG/IntegerArray.png"
|
||||
- "Icons/PNG/List.png"
|
||||
- "Icons/PNG/Long.png"
|
||||
- "Icons/PNG/LongArray.png"
|
||||
- "Icons/PNG/Short.png"
|
||||
- "Icons/PNG/String.png"
|
||||
|
|
Loading…
Reference in a new issue