ZontreckWebsite/lib/pages/nbt/NBTEditor.dart

120 lines
6.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:libac_dart/nbt/SnbtIo.dart';
import 'package:libac_dart/nbt/impl/CompoundTag.dart';
import 'package:libac_dart/nbt/impl/IntTag.dart';
import 'package:libac_dart/nbt/impl/ShortTag.dart';
import 'package:libac_dart/nbt/impl/StringTag.dart';
import 'package:zontreck/Constants.dart';
class AboutNBTEditor extends StatelessWidget {
TextStyle style = TextStyle(fontSize: 18);
CompoundTag ct = CompoundTag();
@override
Widget build(BuildContext context) {
if (ct.isEmpty) {
ct.put("sample", ShortTag.valueOf(4));
CompoundTag ct2 = CompoundTag();
ct2.put("intTest", IntTag.valueOf(8891));
ct2.put("name", StringTag.valueOf("str"));
ct.put("sample_nested", ct2);
}
return Scaffold(
appBar: AppBar(
title: Text("Project: Named Binary Tag Editor"),
backgroundColor: Constants.TITLEBAR_COLOR),
body: Padding(
padding: EdgeInsets.all(4),
child: SingleChildScrollView(
child: Column(
children: [
Row(
children: [
SizedBox(
width: 600,
child: ListTile(
title: Text("About the NBT Editor"),
),
),
Image.asset(
"images/nbteditor_icon.png",
width: 128,
height: 128,
)
],
),
Text(
"This editor began out of a need for being able to edit NBT data on a Linux system. I could not find a single editor for Linux. All of them required either outdated versions of Java and were unmaintained with poor interfaces, or required Wine and were barely even usable, if at all.",
style: style,
),
Text(
"As I explore my options, I decided on one thing: Cross Platform. You see, every editor up to this point was designed with one platform in mind, Windows. I wanted mine to be independent of all platforms.",
style: style,
),
Text(
"How did I accomplish this though?",
style: style,
),
Text(
"That answer is simple. I decided on Flutter. It has a programming language that was easy to pick up. One code base for all platforms, and on top of all of that, the language is similar to others I already knew. I was sold. So i began to learn the ins and outs of Dart. I quickly discovered however, that no NBT Library existed for Dart.. This would be a problem. So, to solve this problem, I created a brand new NBT library. I designed it based upon my knowledge and experience of coding Minecraft Mods. I knew how i expected the API to work, so i based it upon that. Now to make a Compound Tag, it is literally as simple as `CompoundTag ct = CompoundTag()`. The difference here between my implementation and Mojang's is significant, but the usage of the API is near identical. You just leave out the 'new' keyword as Dart does not require it.",
style: style,
),
SizedBox(
height: 40,
),
Text(
"So, next we come across the first significant hurdle in this entire project. Java's implementation of UUIDs. NBT allows serializing a UUID and deserializing it using helper methods. If my implementation was to be truely compatible, I would require a UUID implementation that was identical. So my painful journey began, I researched how Java's UUID worked, looked through Java source code. Finally after much trial and error, the library had a fully functional UUID implementation with a working generator that could actually accept two longs. See in Java, a UUID constists of two long values 'MSB' and 'LSB'. And dart's internal implementation does not expose these values, if it even uses them at all. The only problem is dart's web code does not actually support MSB and LSB. I had to create a secondary uuid class just for the web which operates on strings instead of the proper implementation using two long values.",
style: style),
SizedBox(
height: 40,
),
Text(
"The next challenge in my project was SNBT. This came with a significant number of problems. For one, the SNBT protocol is completely undocumented. Which meant much trial and error, saving SNBT documents from a sample minecraft mod, testing import, etc. I had to get everything just right. The tag element below is infact a SNBT tag.",
style: style),
ListTile(
title: Text("Sample SNBT"),
subtitle: Text(SnbtIo.writeToString(ct)),
),
SizedBox(
height: 40,
),
Text(
"The next challenge was the layout of the editor and the tag icons! I quickly grabbed the public domain icons for the tags from the Minecraft Wiki, then proceeded to embed them. And have a look below, You be the judge on if I accomplished my task.",
style: style),
Image.asset(
"images/nbteditor_tagdisplay.png",
width: 1024,
height: 1024,
),
Image.asset(
"images/nbteditor_menu.png",
width: 1024,
height: 1024,
),
Row(children: [
Expanded(
child: Text(
"And finally.. now that everything was in place, it was time to add the NBT Editor's raw data editor... which lets you edit it as SNBT!",
style: style,
),
),
Image.asset(
"images/nbteditor_snbt.png",
width: 800,
height: 800,
)
]),
SizedBox(
height: 40,
),
Text(
"Now.. it is important to edit this off with a note. This project is far from complete. I am a single person who made something I care deeply about, a utility for linux. I am not a UX designer. This was the best I could do with the limited knowledge on UX design that i have. I am far better at backend coding where I do not need to give the user any amount of controls or info. That being said, my CI server builds changes to the editor with every commit. Builds are produced for Windows and Linux, but not for Mac at this time. An android build is produced, but that is mostly as a for fun type of deal, as it is fairly useless on a phone without open or save functionality.",
style: style,
)
],
),
),
),
);
}
}