Skip to content

Commit

Permalink
Fix Wwise IDs refresh bug after IDs Generation
Browse files Browse the repository at this point in the history
An issue arose where Wwise IDs were not updating correctly in the custom nodes browser due to Godot's resource reloading and cache system. To rectify this problem, the commit enforces the resave of the script resource, ensuring the accurate updating of IDs and resolving the issue effectively.
  • Loading branch information
alessandrofama committed Sep 19, 2023
1 parent cd2bc38 commit a1b4288
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Dictionary AkInspectorTree::get_wwise_ids(const AkUtils::AkType ak_type)

if (!path.is_empty())
{
Ref<Script> script = ResourceLoader::get_singleton()->load(path);
Ref<Script> script = ResourceLoader::get_singleton()->load(
path, String(), ResourceLoader::CacheMode::CACHE_MODE_IGNORE);

Dictionary script_constants = script->get_script_constant_map();

String type_constant{};
Expand Down Expand Up @@ -345,6 +347,7 @@ void AkInspectorEditorProperty::init(const AkUtils::AkType type, const Dictionar
void AkInspectorEditorProperty::open_popup()
{
add_child(window);
window->tree->populate_browser("");

double editor_scale = WwiseEditorScale::get_singleton()->get_editor_scale();

Expand Down Expand Up @@ -442,7 +445,6 @@ void AkInspectorEditorProperty::_update_property()
close_popup();

get_edited_object()->notify_property_list_changed();
window->tree->populate_browser("");

updating = false;
}
Expand Down
23 changes: 15 additions & 8 deletions addons/Wwise/native/src/editor/waapi_picker/waapi_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void WaapiPicker::create_project_objects_tree()
for (int64_t i = 0; i < data_array.size(); i++)
{
Dictionary object = data_array[i];
if (object["type"] == "Project")
if (object["type"] == String("Project"))
{
root->set_text(0, object["name"]);
break;
Expand All @@ -75,7 +75,7 @@ void WaapiPicker::create_project_objects_tree()
{
Dictionary object = data_array[i];

if (object["type"] == "WorkUnit")
if (object["type"] == String("WorkUnit"))
{
TreeItem* item{};

Expand Down Expand Up @@ -839,18 +839,25 @@ void WaapiPicker::_on_file_dialog_file_selected(const String& path)
return;
}

Ref<FileAccess> wwise_ids_gd_file = FileAccess::open(path, FileAccess::WRITE);
wwise_ids_gd_file->store_string(final_text);
wwise_ids_gd_file->close();
bool file_exists = FileAccess::file_exists(path);

if (!file_exists)
{
Ref<FileAccess> wwise_ids_gd_file = FileAccess::open(path, FileAccess::WRITE);
wwise_ids_gd_file->close();
EditorFileSystem* filesystem = get_editor_interface()->get_resource_filesystem();
filesystem->update_file(path);
}

Ref<Script> script = ResourceLoader::get_singleton()->load(path, "Script", ResourceLoader::CACHE_MODE_REPLACE);
script->set_source_code(final_text);
ResourceSaver::get_singleton()->save(script, path);

UtilityFunctions::print("[Wwise] Generated IDs at " + path);

file_dialog->queue_free();
final_text = "";

EditorFileSystem* filesystem = get_editor_interface()->get_resource_filesystem();
filesystem->update_file(path);

if (Waapi::get_singleton()->is_client_connected())
{
Waapi::get_singleton()->disconnect_client();
Expand Down
1 change: 1 addition & 0 deletions addons/Wwise/native/src/editor/waapi_picker/waapi_picker.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <godot_cpp/classes/packed_scene.hpp>
#include <godot_cpp/classes/project_settings.hpp>
#include <godot_cpp/classes/resource_loader.hpp>
#include <godot_cpp/classes/resource_saver.hpp>
#include <godot_cpp/classes/script.hpp>
#include <godot_cpp/classes/tree.hpp>
#include <godot_cpp/classes/tree_item.hpp>
Expand Down

0 comments on commit a1b4288

Please sign in to comment.