Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions exporters/scene_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@
step = "serializing GLTF document";
break;
case ERR_FILE_CORRUPT:
step = "GLTF is empty or corrupt";
step = "GLTF validation: scene is empty or corrupt";
break;
case ERR_BUG:
step = "GLTF conversion";
Expand Down Expand Up @@ -726,6 +726,10 @@
errors.append("** Errors during import parameter setting:");
errors.append_array(import_param_error_messages);
}
if (validation_error_messages.size() > 0) {
errors.append("** Errors during GLTF validation:");
errors.append_array(validation_error_messages);
}
other_error_messages.append_array(_get_logged_error_messages());
if (other_error_messages.size() > 0) {
errors.append("** Other errors:");
Expand Down Expand Up @@ -1894,7 +1898,7 @@
}
if (meshes.size() > 1) {
SurfaceTool surface_tool;
for (size_t i = 0; i < meshes.size(); i++) {

Check warning on line 1901 in exporters/scene_exporter.cpp

View workflow job for this annotation

GitHub Actions / Windows Editor

'<': signed/unsigned mismatch

Check warning on line 1901 in exporters/scene_exporter.cpp

View workflow job for this annotation

GitHub Actions / Windows Template Release

'<': signed/unsigned mismatch
for (size_t j = 0; j < meshes[i]->get_surface_count(); j++) {
if (i == 0 && j == 0) {
surface_tool.create_from(meshes[i], j);
Expand Down Expand Up @@ -2540,7 +2544,7 @@
String error_string;
Error load_err = load_model(p_dest_path, model, error_string);
if (load_err != OK) {
gltf_serialization_error_messages.append(error_string);
validation_error_messages.append(error_string);
return ERR_FILE_CORRUPT;
}
return OK;
Expand Down Expand Up @@ -2948,7 +2952,7 @@
canceled = true;
}

Error GLBExporterInstance::_get_return_error() {
Error GLBExporterInstance::_get_return_error(const String &p_dest_path) {
bool set_all_externals = !updating_import_info;
if (updating_import_info) {
set_all_externals = true;
Expand All @@ -2967,6 +2971,8 @@
Ref<RegEx> animation_error_re = RegEx::create_from_string(ANIMATION_ERROR_PATTERN);

static const Vector<String> errors_to_ignore = {
"Can't set_pixel() on compressed image, sorry", // GLTFDocument couldn't decompress image, but forgot to fail
"Can't get_pixel() on compressed image, sorry", // GLTFDocument couldn't decompress image, but forgot to fail
"A node was animated, but it wasn't found in the GLTFState", // animation track not found because it's not exported
"Parameter \"p_target_object\" is null.", // object property animated by track not found because it's not exportable by the exporter
"Image width specified (0 pixels) must be greater than 0 pixels", // texture export failure caused by zero-sized source images
Expand Down Expand Up @@ -3059,6 +3065,15 @@
}
}

// Check if the model can be loaded; minimum validation to ensure the model is valid
{
other_error_messages.append_array(_get_logged_error_messages());
if (_check_model_can_load(p_dest_path) != OK) {
validation_error_messages.append_array(_get_logged_error_messages());
err = ERR_FILE_CORRUPT;
GDRE_SCN_EXP_FAIL_V_MSG(ERR_FILE_CORRUPT, "");
}
}
if (had_gltf_serialization_errors) {
String _ = add_errors_to_report(ERR_BUG, "");
} else if ((!set_all_externals || missing_dependencies.size() > 0) && err == OK) {
Expand Down Expand Up @@ -3704,7 +3719,7 @@

{
const LocalVector<Animation::Track *> &tracks = reset_animation->get_tracks();
for (int i = 0; i < tracks.size(); i++) {

Check warning on line 3722 in exporters/scene_exporter.cpp

View workflow job for this annotation

GitHub Actions / Windows Editor

'<': signed/unsigned mismatch

Check warning on line 3722 in exporters/scene_exporter.cpp

View workflow job for this annotation

GitHub Actions / Windows Template Release

'<': signed/unsigned mismatch
Animation::Track *track = tracks[i];
if (track->path.get_subname_count() != 1 || !bone_track_types.has(track->type)) {
continue;
Expand Down Expand Up @@ -3816,6 +3831,7 @@
skeleton_path_to_skeleton.insert(node_name, skeleton);
}
}
Vector<StringName> skeleton_path_meshes_added;

for (auto &[skeleton_path, skeleton] : skeleton_path_to_skeleton) {
String skeleton_name = skeleton->get_name();
Expand All @@ -3831,9 +3847,10 @@
String child_name = child ? child->get_name().operator String() : skeleton_name + "_mesh_instance";
mesh_instance = memnew(MeshInstance3D);
Ref<Mesh> debug_bones_mesh = generate_debug_bones_mesh(skeleton);
ERR_CONTINUE_MSG(debug_bones_mesh.is_null(), vformat("Failed to generate debug bones mesh for skeleton %s in animation library %s", skeleton_name, p_original_path));
ERR_CONTINUE_MSG(debug_bones_mesh->get_surface_count() == 0, vformat("Generated debug bones mesh for skeleton %s in animation library %s has no surfaces!", skeleton_name, p_original_path));
Ref<Material> debug_bones_material = debug_bones_mesh->surface_get_material(0);
debug_bones_mesh->set_name(skeleton_name + "_debug_bones_mesh");
debug_bones_material->set_name(skeleton_name + "_debug_bones_material");
mesh_instance->set_mesh(debug_bones_mesh);
mesh_instance->set_name(child_name);
if (child) {
Expand All @@ -3844,10 +3861,17 @@
mesh_instance->set_owner(root);
}
mesh_instance->set_skeleton_path(NodePath(".."));
mesh_instance->set_surface_override_material(0, debug_bones_material);
if (debug_bones_material.is_valid()) {
debug_bones_material->set_name(skeleton_name + "_debug_bones_material");
mesh_instance->set_surface_override_material(0, debug_bones_material);
} else {
WARN_PRINT(vformat("No material found for debug bones mesh for skeleton %s in animation library %s", skeleton_name, p_original_path));
}
}
mesh_instance->set_skin(skin);
skeleton_path_meshes_added.append(skeleton_path);
}
ERR_FAIL_COND_V_MSG(skeleton_path_meshes_added.size() == 0, ERR_FILE_CORRUPT, vformat("No meshes added for skeleton paths in animation library %s", p_original_path));
AnimationPlayer *animation_player = memnew(AnimationPlayer);
animation_library->set_path_cache(p_original_path);
animation_player->set_name("AnimationPlayer");
Expand Down Expand Up @@ -4424,7 +4448,7 @@
Vector<String> GLBExporterInstance::_get_logged_error_messages() {
auto errors = supports_multithread() ? GDRELogger::get_thread_errors() : GDRELogger::get_errors();
Vector<String> ret;
for (auto &err : errors) {

Check warning on line 4451 in exporters/scene_exporter.cpp

View workflow job for this annotation

GitHub Actions / Windows Editor

declaration of 'err' hides class member

Check warning on line 4451 in exporters/scene_exporter.cpp

View workflow job for this annotation

GitHub Actions / Windows Template Release

declaration of 'err' hides class member
String lstripped = err.strip_edges(true, false);
if (!lstripped.begins_with("GDScript backtrace")) {
ret.push_back(err.strip_edges(false, true));
Expand Down Expand Up @@ -4462,12 +4486,8 @@
if (updating_import_info) {
_update_import_params(p_dest_path);
}
// Check if the model can be loaded; minimum validation to ensure the model is valid
err = _check_model_can_load(p_dest_path);
if (err) {
GDRE_SCN_EXP_FAIL_V_MSG(ERR_FILE_CORRUPT, "");
}
err = _get_return_error();

err = _get_return_error(p_dest_path);

return err;
}
3 changes: 2 additions & 1 deletion exporters/scene_exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class GLBExporterInstance {
Vector<String> import_param_error_messages;
Vector<String> dependency_resolution_list;
Vector<String> other_error_messages;
Vector<String> validation_error_messages;

constexpr static const char *const COPYRIGHT_STRING_FORMAT = "The Creators of '%s'";

Expand Down Expand Up @@ -180,7 +181,7 @@ class GLBExporterInstance {
void convert_animation_tracks_to_v4_for_player(AnimationPlayer *p_player);

void _unload_deps();
Error _get_return_error();
Error _get_return_error(const String &p_dest_path);
Node *_instantiate_scene(Ref<PackedScene> scene);

void set_path_options(Dictionary &import_opts, const String &path, const String &prefix = "save_to_file");
Expand Down
13 changes: 11 additions & 2 deletions standalone/gdre_main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
[ext_resource type="PackedScene" uid="uid://bhxdw5q2etvki" path="res://gdre_export_report.tscn" id="16_htlpu"]
[ext_resource type="PackedScene" uid="uid://8tgbmg7tg5ys" path="res://gdre_patch_translation.tscn" id="16_mjm1x"]

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6hx8r"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0

[sub_resource type="ButtonGroup" id="ButtonGroup_x51e8"]

[node name="root" type="GodotREEditorStandalone" unique_id=1603667437]
Expand Down Expand Up @@ -63,11 +69,14 @@ custom_minimum_size = Vector2(2.08165e-12, 36)
layout_mode = 2
placeholder_text = "<e.g. 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F>"

[node name="Label2" type="Label" parent="SetEncryptionKeyWindow/VBoxContainer" unique_id=1933890505]
[node name="Label2" type="RichTextLabel" parent="SetEncryptionKeyWindow/VBoxContainer" unique_id=1547524909]
custom_minimum_size = Vector2(2.08165e-12, 2.08165e-12)
layout_mode = 2
tooltip_text = "Optional decryption script for games with custom encryption"
text = "Set Custom Decryption Script..."
theme_override_styles/normal = SubResource("StyleBoxEmpty_6hx8r")
bbcode_enabled = true
text = "Set Custom Decryption Script... [url=https://github.com/GDRETools/gdsdecomp/blob/master/docs/custom_decryptors.md](What's this?)[/url]"
fit_content = true

[node name="HBoxContainer2" type="HBoxContainer" parent="SetEncryptionKeyWindow/VBoxContainer" unique_id=1842488725]
layout_mode = 2
Expand Down
11 changes: 9 additions & 2 deletions standalone/gdre_theme.tres
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ image = SubResource("Image_1dhk2")

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_qm34x"]

[sub_resource type="StyleBoxEmpty" id="1395"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0mbvf"]
content_margin_left = 6.0
content_margin_top = 4.0
Expand Down Expand Up @@ -973,8 +975,6 @@ content_margin_bottom = 1.0
texture = SubResource("529")
region_rect = Rect2(0, 0, 16, 16)

[sub_resource type="StyleBoxEmpty" id="1395"]

[sub_resource type="Image" id="Image_c0mi8"]
data = {
"data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 0, 112, 112, 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167, 167, 167, 16, 223, 223, 223, 152, 223, 223, 223, 151, 167, 167, 167, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167, 167, 167, 16, 223, 223, 223, 164, 222, 222, 222, 199, 222, 222, 222, 199, 223, 223, 223, 164, 167, 167, 167, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167, 167, 167, 16, 223, 223, 223, 163, 222, 222, 222, 199, 222, 222, 222, 164, 222, 222, 222, 164, 222, 222, 222, 199, 223, 223, 223, 163, 167, 167, 167, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167, 167, 167, 16, 223, 223, 223, 163, 222, 222, 222, 199, 222, 222, 222, 164, 165, 165, 165, 17, 165, 165, 165, 17, 222, 222, 222, 164, 222, 222, 222, 199, 223, 223, 223, 163, 167, 167, 167, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 0, 223, 223, 223, 156, 222, 222, 222, 199, 222, 222, 222, 165, 166, 166, 166, 17, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 17, 222, 222, 222, 165, 222, 222, 222, 199, 223, 223, 223, 156, 111, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 0, 222, 222, 222, 154, 222, 222, 222, 159, 166, 166, 166, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 18, 222, 222, 222, 159, 222, 222, 222, 154, 111, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 110, 110, 0, 111, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 0, 110, 110, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 0, 111, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 112, 112, 0, 111, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 0, 222, 222, 222, 150, 223, 223, 223, 152, 167, 167, 167, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167, 167, 167, 16, 223, 223, 223, 153, 222, 222, 222, 151, 111, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 0, 222, 222, 222, 156, 222, 222, 222, 199, 223, 223, 223, 164, 167, 167, 167, 16, 0, 0, 0, 0, 0, 0, 0, 0, 167, 167, 167, 16, 223, 223, 223, 164, 222, 222, 222, 199, 222, 222, 222, 156, 111, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 165, 165, 17, 222, 222, 222, 164, 222, 222, 222, 199, 223, 223, 223, 163, 167, 167, 167, 16, 167, 167, 167, 16, 223, 223, 223, 163, 222, 222, 222, 199, 222, 222, 222, 164, 165, 165, 165, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 17, 222, 222, 222, 165, 222, 222, 222, 199, 223, 223, 223, 163, 223, 223, 223, 163, 222, 222, 222, 199, 222, 222, 222, 165, 166, 166, 166, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 17, 223, 223, 223, 165, 222, 222, 222, 199, 222, 222, 222, 199, 223, 223, 223, 165, 166, 166, 166, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 18, 222, 222, 222, 153, 222, 222, 222, 153, 166, 166, 166, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 0, 111, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
Expand Down Expand Up @@ -1438,6 +1438,13 @@ FlatMenuButton/colors/icon_hover_color = Color(0.93845, 0.93845, 0.93845, 1)
FlatMenuButton/colors/icon_hover_pressed_color = Color(0.443137, 0.737255, 0.992157, 1)
FlatMenuButton/colors/icon_normal_color = Color(0.847474, 0.847474, 0.847474, 1)
FlatMenuButton/colors/icon_pressed_color = Color(0.443137, 0.737255, 0.992157, 1)
FlatRichTextLabel/colors/default_color = Color(0.79902, 0.807843, 0.827451, 1)
FlatRichTextLabel/colors/font_color_shadow = Color(0, 0, 0, 0)
FlatRichTextLabel/constants/shadow_as_outline = 0
FlatRichTextLabel/constants/shadow_offset_x = 1
FlatRichTextLabel/constants/shadow_offset_y = 1
FlatRichTextLabel/styles/focus = SubResource("1359")
FlatRichTextLabel/styles/normal = SubResource("1359")
FoldableContainer/styles/focus = SubResource("StyleBoxFlat_0mbvf")
FoldableContainer/styles/panel = SubResource("StyleBoxFlat_twpvv")
FoldableContainer/styles/title_collapsed_hover_panel = SubResource("StyleBoxFlat_e2oel")
Expand Down
56 changes: 47 additions & 9 deletions tests/test_gdre_project_loading.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "../compat/resource_compat_binary.h"
#include "../compat/resource_compat_text.h"

#include "test_common.h"
#include "tests/test_macros.h"

#include "bytecode/bytecode_base.h"
#include "utility/common.h"
#include "utility/gdre_settings.h"

Expand All @@ -25,12 +23,12 @@ namespace TestGdreProjectLoading {
// 32 0s
static const String empty_key = "0000000000000000000000000000000000000000000000000000000000000000";

inline Error create_test_pck(const String &pck_path, const HashMap<String, String> &paths, const String &key = empty_key, bool encrypt_directory = false) {
inline Error create_test_pck(const String &pck_path, const HashMap<String, String> &paths, const String &key = empty_key, bool encrypt_directory = false, bool encrypt_files = false) {
PCKPacker pck;
Error err = pck.pck_start(pck_path, 32, key, encrypt_directory);
ERR_FAIL_COND_V(err, err);
for (const auto &path : paths) {
err = pck.add_file(path.key, path.value);
err = pck.add_file(path.key, path.value, encrypt_files);
ERR_FAIL_COND_V(err, err);
}
err = pck.flush(false);
Expand Down Expand Up @@ -112,7 +110,7 @@ TEST_CASE("[GDSDecomp][ProjectConfigLoader] loading example from current engine"
gdre::rimraf(binary_project_path);
}

TEST_CASE("[GDSDecomp] GDRESettings project loading") {
TEST_CASE("[GDSDecomp][ProjectLoading] GDRESettings project loading") {
REQUIRE(gdre::ensure_dir(get_tmp_path()) == OK);
auto tmp_pck_path = get_tmp_path().path_join("test.pck");
auto tmp_project_path = get_tmp_path().path_join("project.binary");
Expand Down Expand Up @@ -147,7 +145,7 @@ TEST_CASE("[GDSDecomp] GDRESettings project loading") {
gdre::rimraf(tmp_pck_path);
}

TEST_CASE("[GDSDecomp] FileAccessGDRE tests") {
TEST_CASE("[GDSDecomp][ProjectLoading] FileAccessGDRE tests") {
CHECK(gdre::ensure_dir(get_tmp_path()) == OK);
auto tmp_pck_path = get_tmp_path().path_join("FileAccessGDRETest.pck");
auto tmp_test_file = get_tmp_path().path_join("test.txt");
Expand Down Expand Up @@ -179,7 +177,7 @@ TEST_CASE("[GDSDecomp] FileAccessGDRE tests") {
gdre::rimraf(tmp_pck_path);
}

TEST_CASE("[GDSDecomp] Check opening encrypted PCKs") {
TEST_CASE("[GDSDecomp][ProjectLoading] Check opening encrypted PCKs") {
REQUIRE(GDRESettings::get_singleton());
CHECK(gdre::ensure_dir(get_tmp_path()) == OK);
auto tmp_pck_path = get_tmp_path().path_join("test.pck");
Expand All @@ -195,7 +193,7 @@ TEST_CASE("[GDSDecomp] Check opening encrypted PCKs") {
};
static const String key = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";

CHECK(create_test_pck(tmp_pck_path, files, key, true) == OK);
CHECK(create_test_pck(tmp_pck_path, files, key, true, true) == OK);

auto settings = GDRESettings::get_singleton();
REQUIRE(settings);
Expand All @@ -206,6 +204,10 @@ TEST_CASE("[GDSDecomp] Check opening encrypted PCKs") {

test_pck_files(files);

Ref<FileAccessGDRE> fa = FileAccess::open("res://test.txt", FileAccess::READ);
REQUIRE(fa.is_valid());
CHECK(fa->get_proxy_class_name() == "FileAccessEncrypted");

CHECK(settings->unload_project() == OK);
settings->reset_encryption_key();
}
Expand All @@ -219,6 +221,9 @@ TEST_CASE("[GDSDecomp] Check opening encrypted PCKs") {
CHECK(settings->load_project({ tmp_pck_path }, false) == OK);

test_pck_files(files);
Ref<FileAccessGDRE> fa = FileAccess::open("res://test.txt", FileAccess::READ);
REQUIRE(fa.is_valid());
CHECK(fa->get_proxy_class_name() == "FileAccessEncryptedCustom");

CHECK(settings->unload_project() == OK);
settings->reset_custom_decryptor();
Expand All @@ -229,6 +234,39 @@ TEST_CASE("[GDSDecomp] Check opening encrypted PCKs") {
gdre::rimraf(tmp_pck_path);
}

TEST_CASE("[GDSDecomp][ProjectLoading] Check opening PCK with custom pack source") {
REQUIRE(GDRESettings::get_singleton());
CHECK(gdre::ensure_dir(get_tmp_path()) == OK);
auto tmp_pck_path = get_tmp_path().path_join("test.pck");
auto tmp_test_file = get_tmp_path().path_join("test.txt");
auto tmp_project_path = get_tmp_path().path_join("project.binary");
REQUIRE(ProjectSettings::get_singleton());
ProjectSettings::get_singleton()->save_custom(tmp_project_path);

CHECK(store_file_as_string(tmp_test_file, "dummy") == OK);
HashMap<String, String> files = {
{ "res://test.txt", tmp_test_file },
{ "res://project.binary", tmp_project_path }
};
CHECK(create_test_pck(tmp_pck_path, files) == OK);

auto settings = GDRESettings::get_singleton();
REQUIRE(settings);

GDScriptLanguage::get_singleton()->init();
CHECK(ClassDB::class_exists(StringName("PackSourceCustom")));
String custom_pack_source_script_path = get_gdsdecomp_path().path_join("docs/gdre_custom_pack_source.gd");
CHECK(settings->add_custom_pack_source_script(custom_pack_source_script_path) == OK);
CHECK(settings->load_project({ tmp_pck_path }, false) == OK);

test_pck_files(files);

CHECK(settings->unload_project() == OK);
settings->clear_custom_pack_source_script();

gdre::rimraf(tmp_test_file);
gdre::rimraf(tmp_pck_path);
}
// Disabling this for now; fragile and kind of redundant.
#if 0
static constexpr const char *const export_presets =
Expand Down
Loading
Loading