Skip to content

Commit

Permalink
Ensure to correctly compress release builds, closes #184
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbrain committed Jul 7, 2024
1 parent a4dcc34 commit 00025ab
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
32 changes: 16 additions & 16 deletions addons/pandora/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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"):
Expand All @@ -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")

Expand All @@ -66,7 +66,7 @@ func _has_main_screen() -> bool:

func _get_plugin_name() -> String:
return "Pandora"


func _get_plugin_icon() -> Texture2D:
return PandoraIcon
Expand All @@ -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"
6 changes: 4 additions & 2 deletions addons/pandora/storage/json/json_data_storage.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
19 changes: 15 additions & 4 deletions pandora/categories.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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"


0 comments on commit 00025ab

Please sign in to comment.