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';
|
import 'package:nbteditor/Consts2.dart';
|
||||||
|
|
||||||
const HEADER =
|
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 {
|
void main(List<String> args) async {
|
||||||
Arguments usage = ArgumentsBuilder.builder()
|
Arguments usage = ArgumentsBuilder.builder()
|
||||||
.withArgument(
|
.withArgument(
|
||||||
|
|
|
@ -11,7 +11,7 @@ import 'package:libac_dart/nbt/impl/CompoundTag.dart';
|
||||||
import 'package:nbteditor/Consts2.dart';
|
import 'package:nbteditor/Consts2.dart';
|
||||||
|
|
||||||
const HEADER =
|
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 {
|
void main(List<String> args) async {
|
||||||
Arguments usage = ArgumentsBuilder.builder()
|
Arguments usage = ArgumentsBuilder.builder()
|
||||||
.withArgument(
|
.withArgument(
|
||||||
|
@ -45,10 +45,11 @@ void main(List<String> args) async {
|
||||||
print("Missing required argument: out");
|
print("Missing required argument: out");
|
||||||
exit(2);
|
exit(2);
|
||||||
} else {
|
} else {
|
||||||
if (!vArgs.hasArg("compress"))
|
if (!vArgs.hasArg("compress")) {
|
||||||
NbtIo.write(vArgs.getArg("out")!.getValue() as String, ct);
|
NbtIo.write(vArgs.getArg("out")!.getValue() as String, ct);
|
||||||
else
|
} else {
|
||||||
NbtIo.writeCompressed(vArgs.getArg("out")!.getValue() as String, ct);
|
NbtIo.writeCompressed(vArgs.getArg("out")!.getValue() as String, ct);
|
||||||
|
}
|
||||||
print("Wrote NBT output to file");
|
print("Wrote NBT output to file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,11 @@ class EditorState extends State<Editor> {
|
||||||
}
|
}
|
||||||
late TreeViewController controller;
|
late TreeViewController controller;
|
||||||
factory EditorState() {
|
factory EditorState() {
|
||||||
if (_inst == null)
|
if (_inst == null) {
|
||||||
return EditorState._();
|
return EditorState._();
|
||||||
else
|
} else {
|
||||||
return _inst!;
|
return _inst!;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
|
@ -106,9 +107,9 @@ class EditorState extends State<Editor> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text("R A W"),
|
title: const Text("R A W"),
|
||||||
subtitle: Text("Edit as raw SNBT"),
|
subtitle: const Text("Edit as raw SNBT"),
|
||||||
leading: Icon(Icons.edit),
|
leading: const Icon(Icons.edit),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Navigator.pushNamed(context, "/snbt");
|
await Navigator.pushNamed(context, "/snbt");
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
|
@ -16,8 +16,8 @@ class MainApp extends StatelessWidget {
|
||||||
theme: ThemeData.dark(),
|
theme: ThemeData.dark(),
|
||||||
routes: {
|
routes: {
|
||||||
"/": (context) => const Editor(),
|
"/": (context) => const Editor(),
|
||||||
"/add": (context) => AddPage(),
|
"/add": (context) => const AddPage(),
|
||||||
"/snbt": (context) => SnbtEdit()
|
"/snbt": (context) => const SnbtEdit()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ import 'package:libac_dart/nbt/Tag.dart';
|
||||||
import 'package:nbteditor/Constants.dart';
|
import 'package:nbteditor/Constants.dart';
|
||||||
|
|
||||||
class AddPage extends StatefulWidget {
|
class AddPage extends StatefulWidget {
|
||||||
|
const AddPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => AddState();
|
State<StatefulWidget> createState() => AddState();
|
||||||
}
|
}
|
||||||
|
@ -17,10 +19,10 @@ class AddState extends State<AddPage> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Add Tag"),
|
title: const Text("Add Tag"),
|
||||||
backgroundColor: Constants.TITLEBAR_COLOR,
|
backgroundColor: Constants.TITLEBAR_COLOR,
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: const Padding(
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class RenamePrompt extends StatefulWidget {
|
class RenamePrompt extends StatefulWidget {
|
||||||
|
const RenamePrompt({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
return RenameState();
|
return RenameState();
|
||||||
|
@ -20,14 +22,14 @@ class RenameState extends State<RenamePrompt> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
icon: Icon(Icons.edit_attributes),
|
icon: const Icon(Icons.edit_attributes),
|
||||||
title: Text("Edit Tag Name"),
|
title: const Text("Edit Tag Name"),
|
||||||
actions: [
|
actions: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context, name.text);
|
Navigator.pop(context, name.text);
|
||||||
},
|
},
|
||||||
child: Text("SUBMIT")),
|
child: const Text("SUBMIT")),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
|
@ -7,6 +7,8 @@ import 'package:nbteditor/Constants.dart';
|
||||||
import 'package:nbteditor/SessionData.dart';
|
import 'package:nbteditor/SessionData.dart';
|
||||||
|
|
||||||
class SnbtEdit extends StatefulWidget {
|
class SnbtEdit extends StatefulWidget {
|
||||||
|
const SnbtEdit({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
return SnbtState();
|
return SnbtState();
|
||||||
|
@ -27,7 +29,7 @@ class SnbtState extends State<SnbtEdit> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("SNBT Editor"),
|
title: const Text("SNBT Editor"),
|
||||||
backgroundColor: Constants.TITLEBAR_COLOR,
|
backgroundColor: Constants.TITLEBAR_COLOR,
|
||||||
),
|
),
|
||||||
floatingActionButton: ElevatedButton(
|
floatingActionButton: ElevatedButton(
|
||||||
|
@ -42,18 +44,18 @@ class SnbtState extends State<SnbtEdit> {
|
||||||
});
|
});
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text("Successfully edited NBT data")));
|
const SnackBar(content: Text("Successfully edited NBT data")));
|
||||||
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (E) {
|
} catch (E) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||||
content: Text("FATAL ERROR: Your SNBT Syntax is not valid")));
|
content: Text("FATAL ERROR: Your SNBT Syntax is not valid")));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text("Compile"),
|
child: const Text("Compile"),
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
child: CodeTheme(
|
child: CodeTheme(
|
||||||
data: CodeThemeData(styles: vsTheme),
|
data: CodeThemeData(styles: vsTheme),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
|
|
@ -22,6 +22,7 @@ extension ByteArrayTagExt on ByteArrayTag {
|
||||||
Widget render(BuildContext context) {
|
Widget render(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("TAG_ByteArray (${getKey()})"),
|
title: Text("TAG_ByteArray (${getKey()})"),
|
||||||
|
leading: const Image(image: AssetImage("Icons/PNG/ByteArray.png")),
|
||||||
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
||||||
false, canBeNamed(this), this, context),
|
false, canBeNamed(this), this, context),
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,8 @@ extension ByteTagExt on ByteTag {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("TAG_Byte (${getKey()})"),
|
title: Text("TAG_Byte (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor(
|
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 {
|
extension CompoundTagExt on CompoundTag {
|
||||||
Widget render(BuildContext context) {
|
Widget render(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("TAG_Compound (${getKey()})"),
|
title: Text("TAG_Compound (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor(
|
subtitle: TagExt.getElementDescriptor(
|
||||||
"${value.length} tag${value.length > 1 ? "s" : ""}",
|
"${value.length} tag${value.length > 1 ? "s" : ""}",
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
canBeNamed(this),
|
canBeNamed(this),
|
||||||
this,
|
this,
|
||||||
context));
|
context),
|
||||||
|
leading: const Image(image: AssetImage("Icons/PNG/Compound.png")),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node getNode(String path) {
|
Node getNode(String path) {
|
||||||
|
|
|
@ -12,7 +12,8 @@ extension DoubleTagExt on DoubleTag {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("TAG_Double (${getKey()})"),
|
title: Text("TAG_Double (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor(
|
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(
|
return ListTile(
|
||||||
title: Text("TAG_Float (${getKey()})"),
|
title: Text("TAG_Float (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor(
|
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()})"),
|
title: Text("TAG_IntArray (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
||||||
false, canBeNamed(this), this, context),
|
false, canBeNamed(this), this, context),
|
||||||
|
leading: const Image(image: AssetImage("Icons/PNG/IntegerArray.png")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@ extension IntTagExt on IntTag {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("TAG_Int (${getKey()})"),
|
title: Text("TAG_Int (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor(
|
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) {
|
Widget render(BuildContext context) {
|
||||||
TagType type = TagType.End;
|
TagType type = TagType.End;
|
||||||
if (value.length > 0) type = get(0).getTagType();
|
if (value.isNotEmpty) type = get(0).getTagType();
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("TAG_List (${getKey()}) (${type})"),
|
title: Text("TAG_List (${getKey()}) ($type)"),
|
||||||
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
||||||
false, canBeNamed(this), this, context));
|
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()})"),
|
title: Text("TAG_LongArray (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
|
||||||
false, canBeNamed(this), this, context),
|
false, canBeNamed(this), this, context),
|
||||||
|
leading: const Image(image: AssetImage("Icons/PNG/LongArray.png")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@ extension LongTagExt on LongTag {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("TAG_Long (${getKey()})"),
|
title: Text("TAG_Long (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor(
|
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(
|
return ListTile(
|
||||||
title: Text("TAG_Short (${getKey()})"),
|
title: Text("TAG_Short (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor(
|
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(
|
return ListTile(
|
||||||
title: Text("TAG_String (${getKey()})"),
|
title: Text("TAG_String (${getKey()})"),
|
||||||
subtitle: TagExt.getElementDescriptor(
|
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:
|
case TagType.End:
|
||||||
{
|
{
|
||||||
return SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ class TagExt {
|
||||||
}
|
}
|
||||||
case TagType.End:
|
case TagType.End:
|
||||||
{
|
{
|
||||||
return Node(key: "ENDTAG", label: "");
|
return const Node(key: "ENDTAG", label: "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ class TagExt {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Text(descript),
|
Text(descript),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
width: 100,
|
width: 100,
|
||||||
),
|
),
|
||||||
if (canAddElements)
|
if (canAddElements)
|
||||||
|
@ -160,10 +160,10 @@ class TagExt {
|
||||||
List<TagType> allowedTypes = [];
|
List<TagType> allowedTypes = [];
|
||||||
if (tag is CompoundTag) allowAllTagTypes = true;
|
if (tag is CompoundTag) allowAllTagTypes = true;
|
||||||
if (tag is ListTag) {
|
if (tag is ListTag) {
|
||||||
ListTag lst = tag as ListTag;
|
ListTag lst = tag;
|
||||||
if (lst.size() == 0)
|
if (lst.size() == 0) {
|
||||||
allowAllTagTypes = true;
|
allowAllTagTypes = true;
|
||||||
else {
|
} else {
|
||||||
allowAllTagTypes = false;
|
allowAllTagTypes = false;
|
||||||
allowedTypes = [lst.get(0).getTagType()];
|
allowedTypes = [lst.get(0).getTagType()];
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ class TagExt {
|
||||||
isArray: isArray,
|
isArray: isArray,
|
||||||
allowedTagTypes: allowedTypes));
|
allowedTagTypes: allowedTypes));
|
||||||
},
|
},
|
||||||
child: Icon(Icons.add)),
|
child: const Icon(Icons.add)),
|
||||||
if (isNamed)
|
if (isNamed)
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
@ -201,19 +201,19 @@ class TagExt {
|
||||||
context: ctx,
|
context: ctx,
|
||||||
routeSettings: RouteSettings(arguments: tag.getKey()),
|
routeSettings: RouteSettings(arguments: tag.getKey()),
|
||||||
builder: (B) {
|
builder: (B) {
|
||||||
return RenamePrompt();
|
return const RenamePrompt();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response is String) {
|
if (response is String) {
|
||||||
tag.setKey(response as String);
|
tag.setKey(response);
|
||||||
|
|
||||||
EditorState state = EditorState();
|
EditorState state = EditorState();
|
||||||
state.update();
|
state.update();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text("R E N A M E")),
|
child: const Text("R E N A M E")),
|
||||||
if (editableValue)
|
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:
|
flutter:
|
||||||
uses-material-design: true
|
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…
Add table
Add a link
Reference in a new issue