Skip to content

Commit

Permalink
Updating setup routine for 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrofama committed May 24, 2021
1 parent 284a2d9 commit 4465ab1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 90 deletions.
98 changes: 8 additions & 90 deletions integration-app/src/components/Installation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,39 +270,24 @@ export default {
const fs = require("fs").promises;
const multiini = require("multi-ini");
var globalOutputText;
var serializedIni;
var output;
var globalClassesAlreadyPresent = false;
var iniObj = multiini.read(godotFilePath, { keep_quotes: false });
if (!("autoload" in iniObj)) {
iniObj.autoload = {};
iniObj.autoload.WwiseSettings = '"res://wwise/wwise_settings.gd"';
iniObj.autoload.Wwise = '"*res://wwise/bin/wwise-gdnative.gdns"';
iniObj.autoload.Waapi = '"*res://wwise/bin/waapi-gdnative-debug.gdns"';
} else {
if (!("Wwise" in iniObj.autoload)) {
iniObj.autoload.WwiseSettings = '"res://wwise/wwise_settings.gd"';
iniObj.autoload.Wwise = '"*res://wwise/bin/wwise-gdnative.gdns"';
iniObj.autoload.Waapi = '"*res://wwise/bin/waapi-gdnative-debug.gdns"';
}
}
if (!("editor_plugins" in iniObj)) {
iniObj.editor_plugins = {};
iniObj.editor_plugins.enabled =
'PoolStringArray( "wwise_custom_nodes", "wwise_ids_converter", "waapi_picker", "wwise_build_export" )';
'PoolStringArray( "res://addons/wwise_setup/plugin.cfg" )';
} else {
if (!("enabled" in iniObj.editor_plugins)) {
iniObj.editor_plugins.enabled =
'PoolStringArray( "wwise_custom_nodes", "wwise_ids_converter", "waapi_picker", "wwise_build_export" )';
'PoolStringArray( "res://addons/wwise_setup/plugin.cfg" )';
} else {
if (!iniObj.editor_plugins.enabled.includes("wwise")) {
if (!iniObj.editor_plugins.enabled.includes("res://addons/wwise_setup/plugin.cfg")) {
// Wwise not present in enabled plugins
var toReplace = iniObj.editor_plugins.enabled.replace(
"PoolStringArray(",
'PoolStringArray( "wwise_custom_nodes", "wwise_ids_converter", "waapi_picker", "wwise_build_export", '
'PoolStringArray( "res://addons/wwise_setup/plugin.cfg", '
);
iniObj.editor_plugins.enabled = toReplace;
}
Expand All @@ -321,77 +306,8 @@ export default {
serializedIni = serializedIni.replace('"Pool', "Pool");
serializedIni = serializedIni.replace(')"', ")");
fs.readFile(godotFilePath, "utf-8").then((txt) => {
if (txt.includes('class": "AK",')) {
globalClassesAlreadyPresent = true;
} else {
globalClassesAlreadyPresent = false;
}
if (
txt.includes("_global_script_classes=[ {") &&
!globalClassesAlreadyPresent
) {
globalOutputText = txt.replace(
"_global_script_classes=[",
`
_global_script_classes=[ {
"base": "Reference",
"class": "AK",
"language": "GDScript",
"path": "res://wwise/GeneratedSoundBanks/wwise_ids.gd"
}, {
"base": "Reference",
"class": "AkUtils",
"language": "GDScript",
"path": "res://wwise/runtime/helpers/ak_utils.gd"
},`
);
} else if (
txt.includes("_global_script_classes=[") &&
!globalClassesAlreadyPresent
) {
globalOutputText = txt.replace(
"_global_script_classes=[ ",
`
_global_script_classes=[ {
"base": "Reference",
"class": "AK",
"language": "GDScript",
"path": "res://wwise/GeneratedSoundBanks/wwise_ids.gd"
}, {
"base": "Reference",
"class": "AkUtils",
"language": "GDScript",
"path": "res://wwise/runtime/helpers/ak_utils.gd"
}`
);
} else if (
!txt.includes("_global_script_classes=[ {") &&
!globalClassesAlreadyPresent
) {
globalOutputText = txt + `
_global_script_classes=[ {
"base": "Reference",
"class": "AK",
"language": "GDScript",
"path": "res://wwise/GeneratedSoundBanks/wwise_ids.gd"
}, {
"base": "Reference",
"class": "AkUtils",
"language": "GDScript",
"path": "res://wwise/runtime/helpers/ak_utils.gd"
} ]
_global_script_class_icons={
"AK": "",
"AkUtils": ""
} ]`;
} else {
globalOutputText = txt;
}
output = globalOutputText + "\n\n" + serializedIni;
fs.readFile(godotFilePath, "utf-8").then((txt) => { // eslint-disable-line no-unused-vars
output = serializedIni;
fs.writeFile(godotFilePath, output);
});
},
Expand Down Expand Up @@ -525,13 +441,15 @@ _global_script_class_icons={
var wwiseIdsConverterPath = path.join(addonsPath, "wwise_ids_converter");
var wwiseBuildExportPath = path.join(addonsPath, "wwise_build_export");
var waapiPickerAddonPath = path.join(addonsPath, "waapi_picker");
var wwiseSetupAddonPath = path.join(addonsPath, "wwise_setup");
var overrideFilePath = path.join(this.godotProjectPath, "override.cfg");
this.removeDirectory(wwisePath);
this.removeDirectory(wwiseAddonsPath);
this.removeDirectory(wwiseIdsConverterPath);
this.removeDirectory(wwiseBuildExportPath);
this.removeDirectory(waapiPickerAddonPath);
this.removeDirectory(wwiseSetupAddonPath);
if (fs.existsSync(overrideFilePath)) {
fs.unlinkSync(overrideFilePath);
Expand Down
7 changes: 7 additions & 0 deletions wwise-gdnative/gdnative-demo/addons/wwise_setup/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="Wwise Setup"
description=""
author=""
version="1.0"
script="wwise_setup.gd"
29 changes: 29 additions & 0 deletions wwise-gdnative/gdnative-demo/addons/wwise_setup/wwise_setup.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
tool
extends EditorPlugin

var timer:Timer

func _enter_tree():
timer = Timer.new()
timer.connect("timeout",self,"_on_timer_timeout")
timer.wait_time = 5
timer.one_shot = true
add_child(timer)
timer.start()
print("Starting Wwise Setup in 5 seconds...")

func _on_timer_timeout():
call_deferred("add_autoload_singleton", "WwiseSettings", "res://wwise/wwise_settings.gd")
call_deferred("add_autoload_singleton", "Wwise", "res://wwise/bin/wwise-gdnative.gdns")
call_deferred("add_autoload_singleton", "Waapi", "res://wwise/bin/waapi-gdnative-debug.gdns")
get_editor_interface().call_deferred("set_plugin_enabled", "res://addons/wwise_build_export/plugin.cfg", true)
get_editor_interface().call_deferred("set_plugin_enabled", "res://addons/wwise_ids_converter/plugin.cfg", true)
get_editor_interface().call_deferred("set_plugin_enabled", "res://addons/wwise_custom_nodes/plugin.cfg", true)
get_editor_interface().call_deferred("set_plugin_enabled", "res://addons/waapi_picker/plugin.cfg", true)
ProjectSettings.save()
timer.call_deferred("free")
get_editor_interface().call_deferred("set_plugin_enabled", "res://addons/wwise_setup/plugin.cfg", false)

func _exit_tree():
print("Wwise setup completed successfully")
ProjectSettings.save()

0 comments on commit 4465ab1

Please sign in to comment.