rokojori_action_library/Runtime/App/Settings/Actions/LoadAppSettings.cs

68 lines
1.4 KiB
C#
Raw Normal View History

2026-02-26 14:06:27 +00:00
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class LoadAppSettings:Action
{
[Export]
public string savePath = "";
[Export]
public App app;
[Export]
public bool writeDefaults = true;
protected override void _OnTrigger()
{
this.LogInfo( "Loading App Settings" );
var data = GDFilesSync.LoadJSON<Dictionary<string,string>>( savePath );
this.LogInfo( "App Settings", data );
foreach ( var vk in data )
{
app.settings.ApplySetting( app, vk.Key, vk.Value );
}
// var settings =
// this.LogInfo( JSON.StringifyObject( data ) );
// var resolvedApp = app ?? Unique<App>.Get();
// var data = resolvedApp.GetAppSettingsData();
// var saveMap = new Dictionary<string,string>();
// foreach ( var kv in data ){ saveMap[ kv.Key ] = kv.Value; }
// if ( writeDefaults )
// {
// app.settings.categories.ForEach(
// ( c )=>
// {
// c.settings.ForEach(
// ( appSetting )=>
// {
// if ( saveMap.ContainsKey( appSetting.id ) )
// {
// return;
// }
// saveMap[ appSetting.id ] = appSetting.GetDefaultValue();
// }
// );
// }
// );
// }
}
}
}