From 00025abd89fde0dbce86661604b0aec0c6df5de8 Mon Sep 17 00:00:00 2001 From: bitbrain Date: Sun, 7 Jul 2024 10:58:04 +0100 Subject: [PATCH] Ensure to correctly compress release builds, closes #184 --- addons/pandora/plugin.gd | 32 +++++++++---------- .../pandora/storage/json/json_data_storage.gd | 6 ++-- pandora/categories.gd | 19 ++++++++--- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/addons/pandora/plugin.gd b/addons/pandora/plugin.gd index 4ba7314..ffc5f8f 100644 --- a/addons/pandora/plugin.gd +++ b/addons/pandora/plugin.gd @@ -19,12 +19,12 @@ func _enter_tree() -> void: add_autoload_singleton("Pandora", "res://addons/pandora/api.gd") add_export_plugin(_exporter) PandoraSettings.initialize() - + if Engine.is_editor_hint(): editor_view = PandoraEditor.instantiate() editor_view.hide() get_editor_interface().get_editor_main_screen().add_child(editor_view) - + # connect signals for error handling get_editor_interface().get_resource_filesystem().resources_reimported.connect(func(res): if editor_view.has_method("reattempt_load_on_error"): editor_view.reattempt_load_on_error()) get_editor_interface().get_resource_filesystem().sources_changed.connect(func(res): if editor_view.has_method("reattempt_load_on_error"): editor_view.reattempt_load_on_error()) @@ -33,10 +33,10 @@ func _enter_tree() -> void: entity_inspector = PandoraEntityInspector.new() add_inspector_plugin(entity_inspector) - + _make_visible(false) - - + + func _apply_changes() -> void: if Engine.is_editor_hint() and is_instance_valid(editor_view): if editor_view.has_method("apply_changes"): @@ -48,9 +48,9 @@ func _exit_tree() -> void: remove_control_from_bottom_panel(editor_view) editor_view.queue_free() remove_inspector_plugin(entity_inspector) - + Engine.remove_meta("PandoraEditorPlugin") - + remove_export_plugin(_exporter) remove_autoload_singleton("Pandora") @@ -66,7 +66,7 @@ func _has_main_screen() -> bool: func _get_plugin_name() -> String: return "Pandora" - + func _get_plugin_icon() -> Texture2D: return PandoraIcon @@ -75,14 +75,14 @@ class PandoraExportPlugin extends EditorExportPlugin: # Override the _export_begin method to add the data.pandora file during export func _export_begin(features: PackedStringArray, is_debug: bool, path: String, flags: int): var pandora_path = "res://data.pandora" - var file: FileAccess - if is_debug: - file = FileAccess.open(pandora_path, FileAccess.READ) - else: - file = FileAccess.open_compressed(pandora_path, FileAccess.READ) - - if file: - add_file(pandora_path, file.get_buffer(file.get_length()), false) + var file = FileAccess.open(pandora_path, FileAccess.READ) + if not file: + printerr("Unable to export Pandora data: ", FileAccess.get_open_error()) + return + var data:PackedByteArray = file.get_buffer(file.get_length()) + if not is_debug: + data = data.compress() + add_file(pandora_path, data, false) func _get_name() -> String: return "PandoraExporter" diff --git a/addons/pandora/storage/json/json_data_storage.gd b/addons/pandora/storage/json/json_data_storage.gd index 1384b3a..9972047 100644 --- a/addons/pandora/storage/json/json_data_storage.gd +++ b/addons/pandora/storage/json/json_data_storage.gd @@ -25,7 +25,8 @@ func _init(data_dir: String): func store_all_data(data: Dictionary, context_id: String) -> Dictionary: var file_path = _get_file_path(context_id) var file: FileAccess - if OS.is_debug_build(): + # Ensure within the Godot Engine editor, Pandora remains uncompressed + if Engine.is_editor_hint() or OS.is_debug_build(): file = FileAccess.open(file_path, FileAccess.WRITE) file.store_string(JSON.stringify(data, "\t")) else: @@ -38,7 +39,8 @@ func store_all_data(data: Dictionary, context_id: String) -> Dictionary: func get_all_data(context_id: String) -> Dictionary: var file_path = _get_file_path(context_id) var file: FileAccess - if OS.is_debug_build(): + # Ensure within the Godot Engine editor, Pandora remains uncompressed + if Engine.is_editor_hint() or OS.is_debug_build(): file = FileAccess.open(file_path, FileAccess.READ) else: file = FileAccess.open_compressed(file_path, FileAccess.READ) diff --git a/pandora/categories.gd b/pandora/categories.gd index 2760b30..f849162 100644 --- a/pandora/categories.gd +++ b/pandora/categories.gd @@ -2,11 +2,22 @@ class_name PandoraCategories -const ROOT = "m0LT2ut_BO" +const ITEMS = "1" +const RARITY = "16" +const QUESTS = "27" +const DIALOGUES = "28" +const SPELLS = "29" +const MOCK_(REQUIRED_FOR_TESTING!) = "54" +const NPCS = "2" -class RootCategories: - const ITEMS = "dhuQ_I1owC" - const NPCS = "8-oXvCMZmH" +class ItemsCategories: + const ARMORY = "3" + const TOOLS = "4" + const ORES = "13" + + +class ArmoryCategories: + const SHIELDS = "8"