Change out the file selector
This commit is contained in:
parent
887a0638cd
commit
31d6cee09b
11 changed files with 42 additions and 22 deletions
|
@ -29,6 +29,7 @@ The following is the build instructions for this project.
|
|||
4. To build the installer you will need Inno Setup installed.
|
||||
5. Add the path you installed IS to your path.
|
||||
6. Run compile.bat to both build and generate the setup file which will be placed into the out folder.
|
||||
7. Enable Developer Mode if you wish to run the output
|
||||
|
||||
# MacOS
|
||||
|
||||
|
@ -36,6 +37,6 @@ The following is the build instructions for this project.
|
|||
2. Install XCode
|
||||
3. Install any necessary command line developer tools from XCode
|
||||
4. Developer mode?
|
||||
5. Run the command? `flutter build mac` or `flutter build macos`
|
||||
5. Run the command `flutter build macos`
|
||||
|
||||
**Testing needed** I do not own a Mac, testing by a Mac user will be required.
|
||||
|
|
|
@ -12,7 +12,7 @@ Future<int> main(List<String> args) async {
|
|||
if (parsed.hasArg("help") || parsed.count == 0) {
|
||||
// Print help information
|
||||
print(
|
||||
"NBT Editor Command Line Interface\nCopyright 2025 Piccari Creations\nLicensed under the GPL\nVersion: ${VERSION}\n\n");
|
||||
"NBT Editor Command Line Interface\nCopyright 2025 Piccari Creations\nLicensed under the GPL\nVersion: $VERSION\n\n");
|
||||
|
||||
var defaults = ArgumentsBuilder.builder()
|
||||
.withArgument(BoolArgument(name: "help", value: null))
|
||||
|
|
|
@ -1 +1 @@
|
|||
const VERSION = "1.1.020225+1616";
|
||||
const VERSION = "1.1.020325+1153";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:file_selector/file_selector.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_treeview/flutter_treeview.dart';
|
||||
|
@ -16,7 +16,6 @@ import 'package:nbteditor/Constants.dart';
|
|||
import 'package:nbteditor/Consts2.dart';
|
||||
import 'package:nbteditor/SessionData.dart';
|
||||
import 'package:nbteditor/main.dart';
|
||||
import 'package:nbteditor/pages/EditValue.dart';
|
||||
import 'package:nbteditor/tags/ArrayEntry.dart';
|
||||
import 'package:nbteditor/tags/CompoundTag.dart';
|
||||
import 'package:nbteditor/tags/Tag.dart';
|
||||
|
@ -118,12 +117,15 @@ class EditorState extends State<Editor> {
|
|||
Navigator.pushNamed(context, "/perms");
|
||||
return;
|
||||
}
|
||||
XTypeGroup typeGroup = const XTypeGroup(
|
||||
label: 'NBT', extensions: <String>["nbt", "snbt", "dat"]);
|
||||
var result =
|
||||
await openFile(acceptedTypeGroups: <XTypeGroup>[typeGroup]);
|
||||
String? filePath;
|
||||
var result = await FilePicker.platform.pickFiles();
|
||||
if (result != null) {
|
||||
// Do something with the selected file path
|
||||
print('Selected file path: $filePath');
|
||||
filePath = result.files.first.path;
|
||||
filePath = result.path;
|
||||
} else {
|
||||
// User canceled the picker
|
||||
print('File selection canceled.');
|
||||
|
@ -136,8 +138,9 @@ class EditorState extends State<Editor> {
|
|||
CompoundTag ct = CompoundTag();
|
||||
if (filePath.endsWith(".txt") || filePath.endsWith(".snbt")) {
|
||||
ct = await SnbtIo.readFromFile(filePath) as CompoundTag;
|
||||
} else
|
||||
} else {
|
||||
ct = await NbtIo.read(filePath);
|
||||
}
|
||||
|
||||
SessionData.ROOT_TAG = ct;
|
||||
}
|
||||
|
@ -190,11 +193,11 @@ class EditorState extends State<Editor> {
|
|||
|
||||
// Prompt for where to save
|
||||
print("Begin picking file to save to");
|
||||
var FSL = await FilePicker.platform.saveFile(bytes: Uint8List(0));
|
||||
var FSL = await getSaveLocation();
|
||||
String? filePath;
|
||||
|
||||
if (FSL != null) {
|
||||
filePath = FSL;
|
||||
filePath = FSL.path;
|
||||
}
|
||||
|
||||
if (filePath == null) {
|
||||
|
@ -203,12 +206,15 @@ class EditorState extends State<Editor> {
|
|||
}
|
||||
print(filePath);
|
||||
CompoundTag tag = controller.children[0].data as CompoundTag;
|
||||
Uint8List data = Uint8List(0);
|
||||
if (result == null) {
|
||||
// Save uncompressed
|
||||
NbtIo.write(filePath, tag);
|
||||
data = await NbtIo.writeToStream(tag);
|
||||
} else {
|
||||
NbtIo.writeCompressed(filePath, tag);
|
||||
data = await NbtIo.writeToStreamCompressed(tag);
|
||||
}
|
||||
var dataFile = XFile.fromData(data);
|
||||
await dataFile.saveTo(filePath);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
|
@ -224,11 +230,11 @@ class EditorState extends State<Editor> {
|
|||
}
|
||||
// Prompt for where to save
|
||||
print("Begin picking file to save to");
|
||||
var FSL = await FilePicker.platform.saveFile(bytes: Uint8List(0));
|
||||
var FSL = await getSaveLocation();
|
||||
String? filePath;
|
||||
|
||||
if (FSL != null) {
|
||||
filePath = FSL;
|
||||
filePath = FSL.path;
|
||||
}
|
||||
|
||||
if (filePath == null) {
|
||||
|
@ -236,9 +242,13 @@ class EditorState extends State<Editor> {
|
|||
return;
|
||||
}
|
||||
print(filePath);
|
||||
Uint8List data = Uint8List(0);
|
||||
|
||||
SnbtIo.writeToFile(
|
||||
filePath, controller.children[0].data as CompoundTag);
|
||||
String str = SnbtIo.writeToString(
|
||||
controller.children[0].data as CompoundTag);
|
||||
|
||||
var dataFile = XFile.fromData(Uint8List.fromList(str.codeUnits));
|
||||
await dataFile.saveTo(filePath);
|
||||
},
|
||||
)
|
||||
]),
|
||||
|
|
|
@ -7,7 +7,6 @@ import 'package:libac_dart/nbt/impl/CompoundTag.dart';
|
|||
import 'package:libacflutter/Prompt.dart';
|
||||
import 'package:nbteditor/Constants.dart';
|
||||
import 'package:nbteditor/SessionData.dart';
|
||||
import 'package:nbteditor/pages/EditValue.dart';
|
||||
|
||||
class SnbtEdit extends StatefulWidget {
|
||||
const SnbtEdit({super.key});
|
||||
|
@ -46,7 +45,7 @@ class SnbtState extends State<SnbtEdit> {
|
|||
type: InputPromptType.Text);
|
||||
});
|
||||
},
|
||||
icon: Icon(CupertinoIcons.search))
|
||||
icon: const Icon(CupertinoIcons.search))
|
||||
],
|
||||
),
|
||||
floatingActionButton: ElevatedButton(
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_linux
|
||||
url_launcher_linux
|
||||
)
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import file_picker
|
||||
import file_selector_macos
|
||||
import url_launcher_macos
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
name: nbteditor
|
||||
description: A Minecraft NBT Editor written in Flutter
|
||||
publish_to: "none"
|
||||
version: 1.1.020225+1616
|
||||
version: 1.1.020325+1153
|
||||
|
||||
environment:
|
||||
sdk: ^3.6.1
|
||||
|
||||
dependencies:
|
||||
file_picker: ^8.0.6
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_code_editor: ^0.3.2
|
||||
|
@ -23,7 +22,9 @@ dependencies:
|
|||
libacflutter:
|
||||
hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/
|
||||
version: ^1.0.013125+1423
|
||||
file_selector: ^1.0.3
|
||||
|
||||
flutter_highlight: any
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
|
|
@ -6,10 +6,13 @@
|
|||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_windows/file_selector_windows.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
FileSelectorWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_windows
|
||||
permission_handler_windows
|
||||
url_launcher_windows
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue