diff --git a/.idea/.idea.导师模拟器/.idea/.gitignore b/.idea/.idea.导师模拟器/.idea/.gitignore
new file mode 100644
index 0000000..a149acc
--- /dev/null
+++ b/.idea/.idea.导师模拟器/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/projectSettingsUpdater.xml
+/modules.xml
+/contentModel.xml
+/.idea.导师模拟器.iml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/.idea.导师模拟器/.idea/.name b/.idea/.idea.导师模拟器/.idea/.name
new file mode 100644
index 0000000..ba0824d
--- /dev/null
+++ b/.idea/.idea.导师模拟器/.idea/.name
@@ -0,0 +1 @@
+导师模拟器
\ No newline at end of file
diff --git a/.idea/.idea.导师模拟器/.idea/encodings.xml b/.idea/.idea.导师模拟器/.idea/encodings.xml
new file mode 100644
index 0000000..df87cf9
--- /dev/null
+++ b/.idea/.idea.导师模拟器/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.导师模拟器/.idea/indexLayout.xml b/.idea/.idea.导师模拟器/.idea/indexLayout.xml
new file mode 100644
index 0000000..7b08163
--- /dev/null
+++ b/.idea/.idea.导师模拟器/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.导师模拟器/.idea/libraries/GdSdk.xml b/.idea/.idea.导师模拟器/.idea/libraries/GdSdk.xml
new file mode 100644
index 0000000..0059883
--- /dev/null
+++ b/.idea/.idea.导师模拟器/.idea/libraries/GdSdk.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.导师模拟器/.idea/vcs.xml b/.idea/.idea.导师模拟器/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/.idea.导师模拟器/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Animation/Boys.webp.import b/Animation/Boys.webp.import
index dd7c95a..661f64b 100644
--- a/Animation/Boys.webp.import
+++ b/Animation/Boys.webp.import
@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Boys.webp-0af0d9c9f992bee0cafbd796944d54c6.ct
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
diff --git a/Animation/Computer.webp.import b/Animation/Computer.webp.import
index ebc8ca4..c83b969 100644
--- a/Animation/Computer.webp.import
+++ b/Animation/Computer.webp.import
@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Computer.webp-2e3b416ea3dd9f581e6a312084a8305
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
diff --git a/Animation/Girls.webp.import b/Animation/Girls.webp.import
index de7826d..03eda48 100644
--- a/Animation/Girls.webp.import
+++ b/Animation/Girls.webp.import
@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Girls.webp-7896bb0d04300f585b9f8c2833d2181c.c
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
diff --git a/Animation/gBot_pieces.png.import b/Animation/gBot_pieces.png.import
index 2d2c3a6..00700e2 100644
--- a/Animation/gBot_pieces.png.import
+++ b/Animation/gBot_pieces.png.import
@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/gBot_pieces.png-4100bd82da00b463c87e490e5e954
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
diff --git a/Animation/test.webp.import b/Animation/test.webp.import
index 0e345dd..2a9de2b 100644
--- a/Animation/test.webp.import
+++ b/Animation/test.webp.import
@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/test.webp-533724a56189f1f938bc4f3155ee1b3b.ct
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
+compress/uastc_level=0
+compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
+process/channel_remap/red=0
+process/channel_remap/green=1
+process/channel_remap/blue=2
+process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
diff --git a/Node2d.cs.uid b/Node2d.cs.uid
new file mode 100644
index 0000000..7767da9
--- /dev/null
+++ b/Node2d.cs.uid
@@ -0,0 +1 @@
+uid://c0xdnf44f8p6e
diff --git a/addons/autosaver_editor/AutoSaverEditorPlugin.cs b/addons/autosaver_editor/AutoSaverEditorPlugin.cs
deleted file mode 100644
index 2cae818..0000000
--- a/addons/autosaver_editor/AutoSaverEditorPlugin.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-#if TOOLS
-using System.Text;
-using AutoSaverPlugin.UI;
-using AutoSaverPlugin.UI.GDComponent;
-using AutoSaverPlugin.Contracts;
-using AutoSaverPlugin.Shared;
-using Godot;
-using static AutoSaverPlugin.Shared.CommonUtils;
-using System;
-using System.Diagnostics;
-
-[Tool]
-public partial class AutoSaverEditorPlugin : EditorPlugin
-{
- private IAutoSaveManager _autoSaveManager;
- private IConfigurationManager _configManager;
-
- private PanelSettingsControlNode _panelConfigNode;
- private AutoSaveToggleMenuBuilder _menuTopBuilder;
- private CheckButton _menuAutoSaveToggle;
-
- public override string _GetPluginName() => _configManager.PluginFullName;
-
-
- public override Texture2D _GetPluginIcon()
- {
- return ResourceLoader.Load(_configManager.PluginIConResourcePath);
- }
-
-
- public override void _EnterTree()
- {
- InitializeDependencies();
- _autoSaveManager.Initialize(this);
- SetupAutoSaveToggle();
- SetupSettingsPanel();
- }
-
- public override void _ExitTree()
- {
- DetachEvents();
- CleanupUI();
- }
-
- private void InitializeDependencies()
- {
- ServiceProvider.Initialize();
-
- _autoSaveManager = ServiceProvider.GetService();
- _configManager = ServiceProvider.GetService();
- }
-
- private void SetupSettingsPanel()
- {
- _panelConfigNode = new PanelSettingsControlNode();
- AddControlToDock(DockSlot.LeftUr, _panelConfigNode);
- }
-
- private void SetupAutoSaveToggle()
- {
- _menuTopBuilder = new AutoSaveToggleMenuBuilder();
- _menuAutoSaveToggle = _menuTopBuilder.AutoSaveToggleButton;
- AddControlToContainer(CustomControlContainer.Toolbar, _menuAutoSaveToggle);
- _configManager.AutoSaverStateChanged += _menuTopBuilder.UpdateToggleStateFromSettings;
- }
-
- private void DetachEvents()
- {
- _menuTopBuilder.DetachAutoSaveToggleEvents();
- _configManager.AutoSaverStateChanged -= _menuTopBuilder.UpdateToggleStateFromSettings;
- }
-
- private void CleanupUI()
- {
- _autoSaveManager.Deactivate();
-
- RemoveControlFromDocks(_panelConfigNode);
- _panelConfigNode?.QueueFree();
-
- RemoveControlFromContainer(CustomControlContainer.Toolbar, _menuAutoSaveToggle);
- _menuAutoSaveToggle?.Free();
- }
-}
-#endif //TOOLS
diff --git a/addons/autosaver_editor/Contracts/IAutoSaveManager.cs b/addons/autosaver_editor/Contracts/IAutoSaveManager.cs
deleted file mode 100644
index fcb90dc..0000000
--- a/addons/autosaver_editor/Contracts/IAutoSaveManager.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.Text;
-
-namespace AutoSaverPlugin.Contracts;
-
-internal interface IAutoSaveManager
-{
- void Initialize(AutoSaverEditorPlugin plugin);
-
- void Activate();
-
- void Reactivate();
-
- void Deactivate();
-}
diff --git a/addons/autosaver_editor/Contracts/IConfigurationManager.cs b/addons/autosaver_editor/Contracts/IConfigurationManager.cs
deleted file mode 100644
index 459a7b7..0000000
--- a/addons/autosaver_editor/Contracts/IConfigurationManager.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Text;
-using AutoSaverPlugin.Shared;
-
-namespace AutoSaverPlugin.Contracts;
-
-internal interface IConfigurationManager
-{
- event Action AutoSaverStateChanged;
-
- string PluginFullName { get; }
- string PluginShortName { get; }
- string PluginVersion { get; }
-
- string PluginIConResourcePath { get; }
- VerboseLevel VerboseLevelSetting { get; }
- int AutoSaverIntervalSetting { get; }
- int PostponeTimeSetting { get; }
- int ActivityCheckWindowSetting { get; }
- bool IsOptionSaveScenesEnabled { get; }
- bool IsOptionSaveScriptsEnabled { get; }
- bool IsAutoSaverEnabled { get; }
-
- bool UseGDEditorSaveOnFocusLoss { get; }
- bool UseGDEditorAutosaveIntervalSecs { get; }
- bool GDEditor_save_on_focus_loss { get; }
- int GDEditor_autosave_interval_secs { get; }
- bool HasGDEditorAutosaveEnabled { get; }
-
- void SetEditorSaveOnFocusLoss(bool enabled);
-
- void SetEditorAutosaveIntervalSecs(int seconds);
-
- void LoadSettings();
-
- void SaveSettings();
-
- void SetAutoSaverEnabled(bool enabled, bool noEmitSignal = false);
-
- void SetSaverInterval(int seconds);
-
- void SetVerboseLevel(VerboseLevel level);
-
- void SetSceneEnabled(bool enabled);
-
- void SetScriptEnabled(bool enabled);
-}
diff --git a/addons/autosaver_editor/Contracts/IStatusReporter.cs b/addons/autosaver_editor/Contracts/IStatusReporter.cs
deleted file mode 100644
index 70636f6..0000000
--- a/addons/autosaver_editor/Contracts/IStatusReporter.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Collections.Generic;
-using Godot;
-
-namespace AutoSaverPlugin.Contracts;
-
-internal interface IStatusReporter
-{
- List FetchModifiedItems();
-}
-
-internal interface ISceneStatusReporter : IStatusReporter
-{ }
-
-internal interface IGDScriptStatusReporter : IStatusReporter
-{ }
-
diff --git a/addons/autosaver_editor/Contracts/ITimerService.cs b/addons/autosaver_editor/Contracts/ITimerService.cs
deleted file mode 100644
index 78377d4..0000000
--- a/addons/autosaver_editor/Contracts/ITimerService.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace AutoSaverPlugin.Contracts;
-
-public interface ITimerService
-{
- ITimerService AttachTo(AutoSaverEditorPlugin pluginCaller);
- ITimerService OnTimeout(Action onAutosaveTimerTimeout, bool oneShot = false);
- ITimerService Begin(float intervalSec);
- ITimerService End();
-}
diff --git a/addons/autosaver_editor/LICENSE b/addons/autosaver_editor/LICENSE
deleted file mode 100644
index 0e61dcf..0000000
--- a/addons/autosaver_editor/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2024 vrravalos
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/addons/autosaver_editor/README.pdf b/addons/autosaver_editor/README.pdf
deleted file mode 100644
index cafc6d8..0000000
Binary files a/addons/autosaver_editor/README.pdf and /dev/null differ
diff --git a/addons/autosaver_editor/Services/AutoSaveManager.cs b/addons/autosaver_editor/Services/AutoSaveManager.cs
deleted file mode 100644
index 2715560..0000000
--- a/addons/autosaver_editor/Services/AutoSaveManager.cs
+++ /dev/null
@@ -1,260 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using AutoSaverPlugin.Contracts;
-using AutoSaverPlugin.Services.GDComponent;
-using AutoSaverPlugin.Shared;
-using Godot;
-using static AutoSaverPlugin.Shared.CommonUtils;
-
-namespace AutoSaverPlugin.Services;
-
-internal sealed class AutoSaveManager : IAutoSaveManager
-{
- private readonly EditorInterface _editorInterface = EditorInterface.Singleton;
- private ScriptEditor _scriptEditor => _editorInterface.GetScriptEditor();
- private readonly ISceneStatusReporter _sceneReporter;
- private readonly IGDScriptStatusReporter _gdScriptReporter;
- private readonly ITimerService _timerAutoSaver;
- private readonly ITimerService _timerActivityUserCheck;
- private readonly IConfigurationManager _configManager;
- private readonly ILoggerService _logger;
- private AutoSaverEditorPlugin _plugin;
- private UserActivityMonitorNode _activityMonitor;
-
- public AutoSaveManager(ISceneStatusReporter sceneStatusReporter, IGDScriptStatusReporter scriptStatusReporter, IConfigurationManager configManager,
- ILoggerService loggerService, ITimerService timerAutoSaver, ITimerService timerActivity)
- {
- _sceneReporter = sceneStatusReporter ?? throw new ArgumentNullException(nameof(sceneStatusReporter));
- _gdScriptReporter = scriptStatusReporter ?? throw new ArgumentNullException(nameof(scriptStatusReporter));
- _configManager = configManager ?? throw new ArgumentNullException(nameof(configManager));
- _logger = loggerService ?? throw new ArgumentNullException(nameof(loggerService));
- _timerAutoSaver = timerAutoSaver ?? throw new ArgumentNullException(nameof(timerAutoSaver));
- _timerActivityUserCheck = timerActivity ?? throw new ArgumentNullException(nameof(timerActivity));
- }
-
- public void Initialize(AutoSaverEditorPlugin plugin)
- {
- LoadingConfiguration();
- _plugin = plugin ?? throw new ArgumentNullException(nameof(plugin));
- Activate();
- }
-
- private void LoadingConfiguration()
- {
- _configManager.LoadSettings();
- }
-
- public void Activate() => SetupAutoSave(restart: false);
-
- public void Reactivate() => SetupAutoSave(restart: true);
-
- public void Deactivate()
- {
- _logger.LogDiagnostic("Stopping autosaver service..");
- _timerAutoSaver.End();
- _timerActivityUserCheck.End();
- RemoveActivityMonitor();
- PrintStatus();
- }
-
- private void SetupAutoSave(bool restart)
- {
- _logger.LogDiagnostic($"{(restart ? "Restarting" : "Initializing")} autosaver service..");
- _configManager.LoadSettings();
- SetTimers();
- ManageActivityMonitor(add: true);
- PrintStatus();
- }
-
- private void SetTimers()
- {
- _logger.LogDebug("Setting timers..");
-
- int intervalSec = _configManager.AutoSaverIntervalSetting;
- int timeToStartCheck = Math.Clamp(intervalSec - _configManager.ActivityCheckWindowSetting, 1, intervalSec);
-
- _timerAutoSaver.End().AttachTo(_plugin).OnTimeout(OnAutosaveTimerTimeout);
- _timerActivityUserCheck.End().AttachTo(_plugin).OnTimeout(StartMonitoringUserActivity, oneShot: true);
-
- if (_configManager.IsAutoSaverEnabled)
- {
- _timerAutoSaver.Begin(intervalSec);
- _timerActivityUserCheck.Begin(timeToStartCheck);
- }
- }
-
- private void ManageActivityMonitor(bool add)
- {
- if (add)
- {
- _activityMonitor = new UserActivityMonitorNode();
- _activityMonitor.UserActivityDetected += OnUserActivityDetected;
- _plugin.AddChild(_activityMonitor);
- }
- else
- {
- if (_activityMonitor != null)
- {
- _activityMonitor.UserActivityDetected -= OnUserActivityDetected;
-
- if (_activityMonitor.IsInsideTree())
- _plugin?.RemoveChild(_activityMonitor);
-
- if (!_activityMonitor.IsQueuedForDeletion())
- _activityMonitor.QueueFree();
-
- _activityMonitor = null;
- }
- }
- }
-
- private void RemoveActivityMonitor() => ManageActivityMonitor(add: false);
-
- private void OnUserActivityDetected(string eventName, float lastActivityTimeSec) =>
- _logger.LogDebug($"User activity detected: {eventName} at last activity time: {lastActivityTimeSec}ms");
-
- private void StartMonitoringUserActivity()
- {
- _logger.LogDebug($"Starting user activity monitoring..@{GetCurrentTimestamp()}");
- _activityMonitor.StartMonitoring();
- }
-
- private void OnAutosaveTimerTimeout()
- {
- _logger.LogDiagnostic($"Running autosaver @{GetCurrentTimestamp()}");
- PerformAutoSaveIfNeeded();
- }
-
- private void PerformAutoSaveIfNeeded()
- {
- const float inTheLastMilliSecs = 500f; // 0.5 sec
- if (!_activityMonitor.IsMonitoring || _activityMonitor.NoActivityTriggered(thresholdMillisec: inTheLastMilliSecs))
- {
- PerformAutoSave();
- }
- else
- {
- PostponeAutoSave();
- }
- }
-
- private void PerformAutoSave()
- {
- _activityMonitor.StopMonitoring();
-
- var modifiedScenes = _configManager.IsOptionSaveScenesEnabled ? GetModifiedItems(_sceneReporter.FetchModifiedItems()) : new List();
- var modifiedScripts = _configManager.IsOptionSaveScriptsEnabled ? GetModifiedItems(_gdScriptReporter.FetchModifiedItems()) : new List();
-
- if (modifiedScenes.Count == 0 && modifiedScripts.Count == 0)
- {
- _logger.LogDiagnostic("No modified items. Skipping autosave.");
- return;
- }
-
- // save all scenes (also save all scripts)
- bool savedAll = SaveScenes(modifiedScenes);
-
- if (!savedAll && !_configManager.HasGDEditorAutosaveEnabled)
- SaveFiles(modifiedScripts);
-
- LogAutosaveResult(modifiedScenes.Count + modifiedScripts.Count, modifiedScenes.Concat(modifiedScripts).ToList());
- SetTimers(); // Restart timers
- }
-
- private bool SaveScenes(List modifiedScenes)
- {
- List savedFiles = new();
- var openScenes = _editorInterface.GetOpenScenes();
- var editedScene = _editorInterface.GetEditedSceneRoot();
- var fnSceneRoot = Path.GetFileName(editedScene.SceneFilePath).Split('.')[0];
- bool saveAllAtOnce = false;
- int numFilesSaved = 0;
-
- foreach (string scenePath in openScenes)
- {
- var fileNameScenePath = Path.GetFileName(scenePath).Split('.')[0];
- if (modifiedScenes.Contains(fileNameScenePath))
- {
- numFilesSaved++;
- savedFiles.Add(scenePath);
- saveAllAtOnce = saveAllAtOnce || fnSceneRoot != fileNameScenePath;
- }
- }
-
- if (saveAllAtOnce)
- {
- _editorInterface.SaveAllScenes();
- }
- else if (numFilesSaved == 1)
- {
- var err = _editorInterface.SaveScene();
- if (err != Error.Ok)
- {
- _logger.LogError($"Failed to autoSave scene: {fnSceneRoot}. Error: {err}");
- }
- }
-
- return saveAllAtOnce;
- }
-
- private void SaveFiles(List modifiedFiles)
- {
- if (modifiedFiles.Count > 0)
- _editorInterface.SaveAllScenes();
- }
-
- private void PostponeAutoSave()
- {
- _logger.LogDebug($"Postponing autoSave for {_configManager.PostponeTimeSetting}sec..");
- _timerAutoSaver.End().OnTimeout(OnAutosaveTimerTimeout).Begin(_configManager.PostponeTimeSetting);
- }
-
- private static List GetModifiedItems(List items)
- {
- var modifiedScripts = new List();
-
- foreach (var i in items)
- {
- if (i.Contains("*"))
- {
- modifiedScripts.Add(i.Replace("(*)", ""));
- }
- }
-
- return modifiedScripts;
- }
-
- private void LogAutosaveResult(int numFilesSaved, List savedFiles)
- {
- string currentTimestamp = GetCurrentTimestamp();
- if (numFilesSaved > 0)
- {
- _logger.LogInfo($"Autosave executed at {currentTimestamp}. {numFilesSaved} file(s) saved:");
- foreach (var file in savedFiles)
- {
- _logger.LogInfo($"- {file}");
- }
- }
- else
- {
- _logger.LogDiagnostic($"Autosave completed at {currentTimestamp}: No files saved.");
- }
- }
-
- private void PrintStatus()
- {
- string timestamp = GetCurrentTimestamp();
- string pluginSetTimestamp = $"Plugin set @{timestamp}.";
- string autosaveScene = $"scenes ({(_configManager.IsOptionSaveScenesEnabled ? "ON" : "OFF")})";
- string autosaveScript = $"GDScript files ({(_configManager.IsOptionSaveScriptsEnabled ? "ON" : "OFF")})";
- string verboseLevelMessage = $"Verbose level: {_configManager.VerboseLevelSetting}.";
- string editorMessage = $"[Editor] Autosave Interval: {_configManager.GDEditor_autosave_interval_secs}sec, [Editor] Save on focus loss: {_configManager.GDEditor_save_on_focus_loss}";
-
- string statusAutosaving = _configManager.IsAutoSaverEnabled ? "Autosaving every {_autoSaveConfig.AutoSaverIntervalSetting} seconds: {autosaveScene} and {autosaveScript}." : "Autosaving disabled.";
-
- _logger.LogInfo($"{pluginSetTimestamp} {statusAutosaving}");
- _logger.LogDiagnostic($"{verboseLevelMessage} {editorMessage}");
- }
-}
diff --git a/addons/autosaver_editor/Services/ConfigurationManager.cs b/addons/autosaver_editor/Services/ConfigurationManager.cs
deleted file mode 100644
index ba50adc..0000000
--- a/addons/autosaver_editor/Services/ConfigurationManager.cs
+++ /dev/null
@@ -1,252 +0,0 @@
-using System;
-using AutoSaverPlugin.Contracts;
-using AutoSaverPlugin.Shared;
-using Godot;
-
-namespace AutoSaverPlugin.Services;
-
-public sealed class ConfigurationManager : IConfigurationManager
-{
- // default autosaver settings
- private const int AS_AUTOSAVER_INTERVAL = 60;
-
- private const VerboseLevel AS_VERBOSE = VerboseLevel.OFF;
- private const int AS_POSTPONE_TIME = 5;
- private const int AS_ACTIVITY_CHECK_WINDOW = 1;
- private const bool AS_AUTOSAVE_SCENE = true;
- private const bool AS_AUTOSAVE_GDSCRIPT = true;
-
- // default Godot editor settings
- private const bool GDEDITOR_SAVE_ON_FOCUS_LOSS_DEFAULT = false;
-
- private const int GDEDITOR_AUTOSAVE_INTERVAL_SECS_DEFAULT = 0;
-
- // defines the use or not of Godot editor settings
- private const bool USE_GDEDITOR_SAVE_ON_FOCUS_LOSS = false;
-
- private const bool USE_GDEDITOR_AUTOSAVE_INTERVAL_SECS = true;
-
- private readonly ILoggerService _logger;
- private readonly ConfigFile _configFile = new ConfigFile();
- private readonly string _configFilePath;
- private EditorSettings _gdEditorSettings => EditorInterface.Singleton.GetEditorSettings();
-
- private VerboseLevel _verboseLevel = AS_VERBOSE;
-
- public VerboseLevel VerboseLevelSetting
- {
- get => _verboseLevel;
- private set
- {
- _verboseLevel = value;
- _logger?.SetOutput(value);
- }
- }
-
- public int AutoSaverIntervalSetting { get; private set; } = AS_AUTOSAVER_INTERVAL;
- public int PostponeTimeSetting { get; private set; } = AS_POSTPONE_TIME;
- public int ActivityCheckWindowSetting { get; private set; } = AS_ACTIVITY_CHECK_WINDOW;
- public bool IsOptionSaveScenesEnabled { get; private set; } = AS_AUTOSAVE_SCENE;
- public bool IsOptionSaveScriptsEnabled { get; private set; } = AS_AUTOSAVE_GDSCRIPT;
- public bool IsAutoSaverEnabled { get; private set; } = true;
- public bool GDEditor_save_on_focus_loss { get; private set; } = GDEDITOR_SAVE_ON_FOCUS_LOSS_DEFAULT;
- public int GDEditor_autosave_interval_secs { get; private set; } = GDEDITOR_AUTOSAVE_INTERVAL_SECS_DEFAULT;
-
- public string PluginFullName => PluginInfo.FullName;
- public string PluginShortName => PluginInfo.NameShort;
- public string PluginVersion { get; } = CommonUtils.GetPluginVersion();
-
- public string PluginIConResourcePath => PluginInfo.BaseResourcePath + PluginInfo.PluginIcon;
-
- public bool HasGDEditorAutosaveEnabled => GDEditor_autosave_interval_secs > 0;
-
- public bool UseGDEditorSaveOnFocusLoss { get; private set; } = USE_GDEDITOR_SAVE_ON_FOCUS_LOSS;
-
- public bool UseGDEditorAutosaveIntervalSecs { get; private set; } = USE_GDEDITOR_AUTOSAVE_INTERVAL_SECS;
-
- public event Action AutoSaverStateChanged;
-
- public ConfigurationManager(ILoggerService logger)
- {
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
- _configFilePath = DetermineConfigFilePath();
- }
-
- public void SetSaverInterval(int seconds) => AutoSaverIntervalSetting = seconds;
-
- public void SetVerboseLevel(VerboseLevel level)
- {
- VerboseLevelSetting = level;
- }
-
- public void SetEditorSaveOnFocusLoss(bool enabled)
- {
- GDEditor_save_on_focus_loss = enabled;
- _gdEditorSettings.SetSetting("interface/editor/save_on_focus_loss", enabled);
- }
-
- public void SetEditorAutosaveIntervalSecs(int seconds)
- {
- GDEditor_autosave_interval_secs = seconds;
- _gdEditorSettings.SetSetting("text_editor/behavior/files/autosave_interval_secs", seconds);
- }
-
- public void SetSceneEnabled(bool enabled) => IsOptionSaveScenesEnabled = enabled;
-
- public void SetScriptEnabled(bool enabled) => IsOptionSaveScriptsEnabled = enabled;
-
- public void LoadSettings()
- {
- LoadFromGodotEditorSettings();
-
- LoadFromConfigFile();
-
- SyncGodotEditorSettings();
- }
-
- public void ResetSettings()
- {
- ResetGodotEditorSettings();
-
- AutoSaverIntervalSetting = AS_AUTOSAVER_INTERVAL;
- VerboseLevelSetting = AS_VERBOSE;
- IsAutoSaverEnabled = true;
- PostponeTimeSetting = AS_POSTPONE_TIME;
- ActivityCheckWindowSetting = AS_ACTIVITY_CHECK_WINDOW;
- }
-
- public void SaveSettings()
- {
- SaveToConfigFile();
-
- if (IsAutoSaverEnabled)
- {
- SyncGodotEditorSettings();
- }
- else
- {
- ResetGodotEditorSettings();
- }
- }
-
- private void SyncGodotEditorSettings()
- {
- _logger.LogDiagnostic($"Syncing Godot editor settings.. UseGDEditorAutosaveIntervalSecs={UseGDEditorAutosaveIntervalSecs}:{AutoSaverIntervalSetting}, SetEditorSaveOnFocusLoss={UseGDEditorSaveOnFocusLoss}");
-
- // update Godot editor settings from config file
- if (UseGDEditorAutosaveIntervalSecs)
- SetEditorAutosaveIntervalSecs(seconds: AutoSaverIntervalSetting);
-
- if (UseGDEditorSaveOnFocusLoss)
- {
- SetEditorSaveOnFocusLoss(enabled: IsAutoSaverEnabled);
- }
- }
-
- private void ResetGodotEditorSettings()
- {
- _logger.LogDiagnostic($"Resetting Godot editor settings.. UseGDEditorAutosaveIntervalSecs={UseGDEditorAutosaveIntervalSecs}, SetEditorSaveOnFocusLoss={UseGDEditorSaveOnFocusLoss}");
-
- // update Godot editor settings from default values
- if (UseGDEditorAutosaveIntervalSecs)
- SetEditorAutosaveIntervalSecs(seconds: GDEDITOR_AUTOSAVE_INTERVAL_SECS_DEFAULT);
-
- if (UseGDEditorSaveOnFocusLoss)
- SetEditorSaveOnFocusLoss(enabled: GDEDITOR_SAVE_ON_FOCUS_LOSS_DEFAULT);
- }
-
- private void LoadFromGodotEditorSettings()
- {
- GDEditor_autosave_interval_secs = (int)_gdEditorSettings.GetSetting("text_editor/behavior/files/autosave_interval_secs");
- GDEditor_save_on_focus_loss = (bool)_gdEditorSettings.GetSetting("interface/editor/save_on_focus_loss");
- }
-
- public void SetAutoSaverEnabled(bool enabled, bool noEmitSignal = false)
- {
- IsAutoSaverEnabled = enabled;
-
- SaveSettings();
-
- if (!noEmitSignal)
- {
- AutoSaverStateChanged?.Invoke(enabled);
- }
- }
-
- private string DetermineConfigFilePath()
- {
- var debugConfigPath = FindConfigFile(".debug.ini");
- if (!string.IsNullOrEmpty(debugConfigPath))
- {
- _logger.LogDiagnostic($"Using debug config file: {debugConfigPath}");
- return debugConfigPath;
- }
-
- var standardConfigPath = FindConfigFile(".ini");
- if (!string.IsNullOrEmpty(standardConfigPath))
- {
- _logger.LogDiagnostic($"Using standard config file: {standardConfigPath}");
- return standardConfigPath;
- }
-
- _logger.LogDiagnostic("Config file not found, using project settings.");
- return null;
- }
-
- private string FindConfigFile(string extension)
- {
- var fileName = PluginInfo.SettingsFileName.Replace(".ini", extension);
- return CommonUtils.GetAllProjectFiles(extension).Find(f => f.Contains(fileName));
- }
-
- private bool LoadFromConfigFile()
- {
- _logger.LogDiagnostic($"Loading config file: {_configFilePath}");
- Error error = _configFile.Load(_configFilePath);
- if (error != Error.Ok)
- {
- _logger.LogError($"Failed to load config file: {_configFilePath}, error: {error}");
- ResetSettings();
- return false;
- }
-
- AutoSaverIntervalSetting = (int)_configFile.GetValue(PluginInfo.RootSettings, PluginInfo.KeyIntervalSec, AS_AUTOSAVER_INTERVAL);
-
- VerboseLevelSetting = Enum.TryParse((string)_configFile.GetValue(PluginInfo.RootSettings, PluginInfo.KeyVerbose, AS_VERBOSE.ToString()),
- out VerboseLevel result)
- ? result
- : AS_VERBOSE;
-
- IsAutoSaverEnabled = (bool)_configFile.GetValue(PluginInfo.RootSettings, PluginInfo.KeyEnabled, true);
- PostponeTimeSetting = (int)_configFile.GetValue(PluginInfo.RootSettings, PluginInfo.KeyPostponeTimeSec, AS_POSTPONE_TIME);
- ActivityCheckWindowSetting = (int)_configFile.GetValue(PluginInfo.RootSettings, PluginInfo.KeyActivityCheckWindowSec, AS_ACTIVITY_CHECK_WINDOW);
- IsOptionSaveScenesEnabled = (bool)_configFile.GetValue(PluginInfo.RootSettings, PluginInfo.KeyAutosaveScene, AS_AUTOSAVE_SCENE);
- IsOptionSaveScriptsEnabled = (bool)_configFile.GetValue(PluginInfo.RootSettings, PluginInfo.KeyAutosaveGDScript, AS_AUTOSAVE_GDSCRIPT);
- UseGDEditorAutosaveIntervalSecs = (bool)_configFile.GetValue(PluginInfo.RootSettings, PluginInfo.KeyUseGDEditorAutosaveInterval, USE_GDEDITOR_AUTOSAVE_INTERVAL_SECS);
- UseGDEditorSaveOnFocusLoss = (bool)_configFile.GetValue(PluginInfo.RootSettings, PluginInfo.KeyUseGDEditorSaveOnFocusLoss, USE_GDEDITOR_SAVE_ON_FOCUS_LOSS);
-
- return true;
- }
-
- private bool SaveToConfigFile()
- {
- _logger.LogDiagnostic($"Saving settings to config file: {_configFilePath}");
- _configFile.SetValue(PluginInfo.RootSettings, PluginInfo.KeyIntervalSec, AutoSaverIntervalSetting);
- _configFile.SetValue(PluginInfo.RootSettings, PluginInfo.KeyVerbose, VerboseLevelSetting.ToString());
- _configFile.SetValue(PluginInfo.RootSettings, PluginInfo.KeyEnabled, IsAutoSaverEnabled);
- _configFile.SetValue(PluginInfo.RootSettings, PluginInfo.KeyPostponeTimeSec, PostponeTimeSetting);
- _configFile.SetValue(PluginInfo.RootSettings, PluginInfo.KeyActivityCheckWindowSec, ActivityCheckWindowSetting);
- _configFile.SetValue(PluginInfo.RootSettings, PluginInfo.KeyAutosaveScene, IsOptionSaveScenesEnabled);
- _configFile.SetValue(PluginInfo.RootSettings, PluginInfo.KeyAutosaveGDScript, IsOptionSaveScriptsEnabled);
- _configFile.SetValue(PluginInfo.RootSettings, PluginInfo.KeyUseGDEditorAutosaveInterval, UseGDEditorAutosaveIntervalSecs);
- _configFile.SetValue(PluginInfo.RootSettings, PluginInfo.KeyUseGDEditorSaveOnFocusLoss, UseGDEditorSaveOnFocusLoss);
-
- var error = _configFile.Save(_configFilePath);
- if (error != Error.Ok)
- {
- _logger.LogError($"Failed to save config file: {_configFilePath}, error: {error}");
- return false;
- }
- return true;
- }
-}
diff --git a/addons/autosaver_editor/Services/GDComponent/UserActivityMonitorNode.cs b/addons/autosaver_editor/Services/GDComponent/UserActivityMonitorNode.cs
deleted file mode 100644
index 8c8459d..0000000
--- a/addons/autosaver_editor/Services/GDComponent/UserActivityMonitorNode.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using AutoSaverPlugin.Shared;
-using Godot;
-
-namespace AutoSaverPlugin.Services.GDComponent;
-
-internal partial class UserActivityMonitorNode : Node
-{
- public event Action UserActivityDetected;
-
- private bool _isMonitoring = false;
- private DateTime? _lastActivityTimeUtc;
- private readonly ILoggerService _logger = ServiceProvider.GetService();
-
- public bool IsMonitoring => _isMonitoring;
- public bool AnyUserActivityDetected => _lastActivityTimeUtc.HasValue;
-
- public UserActivityMonitorNode()
- {
- }
-
- public void StartMonitoring() => _isMonitoring = true;
-
- public void StopMonitoring() => _isMonitoring = false;
-
- public override void _Input(InputEvent @event)
- {
- if (!_isMonitoring || !(@event is InputEventMouseMotion || @event is InputEventKey)) return;
-
- _lastActivityTimeUtc = DateTime.UtcNow;
-
- string eventType = @event is InputEventMouseMotion ? "MouseMotion" : "Key";
- _logger.LogDebug($"{nameof(UserActivityMonitorNode)}: User activity detected: {eventType}, LastDetectedActivityTimeInMillisec = {LastDetectedActivityTimeInMillisec()}");
-
- UserActivityDetected?.Invoke(eventType, LastDetectedActivityTimeInMillisec());
- }
-
- internal float LastDetectedActivityTimeInMillisec()
- {
- return _lastActivityTimeUtc.HasValue
- ? (float)((DateTime.UtcNow - _lastActivityTimeUtc.Value).TotalMilliseconds)
- : 0;
- }
-
- public bool NoActivityTriggered(float thresholdMillisec)
- {
- _logger.LogDebug($"{nameof(UserActivityMonitorNode)}: Checking for no activity in the last {thresholdMillisec}ms. Last activity was {LastDetectedActivityTimeInMillisec()}ms ago.");
-
- return LastDetectedActivityTimeInMillisec() > thresholdMillisec;
- }
-}
diff --git a/addons/autosaver_editor/Services/GDScriptStatusReporter.cs b/addons/autosaver_editor/Services/GDScriptStatusReporter.cs
deleted file mode 100644
index 9dcd458..0000000
--- a/addons/autosaver_editor/Services/GDScriptStatusReporter.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using AutoSaverPlugin.Contracts;
-using AutoSaverPlugin.Shared;
-using Godot;
-
-namespace AutoSaverPlugin.Services
-{
- internal sealed class GDScriptStatusReporter : IGDScriptStatusReporter
- {
- private readonly ILoggerService _logger;
-
- public GDScriptStatusReporter(ILoggerService loggerService)
- {
- _logger = loggerService ?? throw new ArgumentNullException(nameof(loggerService));
- }
-
- public List FetchModifiedItems()
- {
- _logger.LogDebug("Fetching modified scripts...");
- ScriptEditor editor = EditorInterface.Singleton.GetScriptEditor();
-
- List listItemText = new();
-
- ItemList itemList = FindItemList(editor);
-
- if (itemList == null)
- {
- return listItemText;
- }
-
- for (int i = 0; i < itemList.ItemCount; i++)
- {
- var item = itemList.GetItemText(i);
- _logger.LogDiagnostic($"Script file[{i}]: {item}");
- listItemText.Add(item);
- }
-
- return listItemText;
- }
-
- private ItemList FindItemList(Node root)
- {
- if (root is ItemList itemList)
- {
- return itemList;
- }
-
- foreach (Node child in root.GetChildren())
- {
- var result = FindItemList(child);
- if (result != null)
- {
- return result;
- }
- }
-
- return null;
- }
- }
-}
diff --git a/addons/autosaver_editor/Services/SceneTabStatusReporter.cs b/addons/autosaver_editor/Services/SceneTabStatusReporter.cs
deleted file mode 100644
index f7c4582..0000000
--- a/addons/autosaver_editor/Services/SceneTabStatusReporter.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using AutoSaverPlugin.Contracts;
-using AutoSaverPlugin.Shared;
-using Godot;
-
-namespace AutoSaverPlugin.Services
-{
- internal sealed class SceneTabStatusReporter : ISceneStatusReporter
- {
- private readonly EditorInterface _editorInterface = EditorInterface.Singleton;
- private readonly ILoggerService _logger;
-
- public SceneTabStatusReporter(ILoggerService loggerService)
- {
- _logger = loggerService ?? throw new ArgumentNullException(nameof(loggerService));
- }
-
- public List FetchModifiedItems()
- {
- _logger.LogDebug("Fetching modified scenes...");
- var tabTitles = new List();
- var tabBar = FindTabBar(_editorInterface.GetBaseControl());
-
- if (tabBar == null)
- {
- _logger.LogError("Scene tab bar not found.");
- return tabTitles;
- }
-
- for (int i = 0; i < tabBar.TabCount; i++)
- {
- var title = tabBar.GetTabTitle(i);
- _logger.LogDiagnostic($"Scene tab[{i}]: {title}");
- tabTitles.Add(title);
- }
-
- return tabTitles;
- }
-
- private TabBar FindTabBar(Node root)
- {
- if (root is TabBar tabBar)
- {
- return tabBar;
- }
-
- foreach (Node child in root.GetChildren())
- {
- var result = FindTabBar(child);
- if (result != null)
- {
- return result;
- }
- }
-
- return null;
- }
- }
-}
diff --git a/addons/autosaver_editor/Services/TimerService.cs b/addons/autosaver_editor/Services/TimerService.cs
deleted file mode 100644
index 774e7d6..0000000
--- a/addons/autosaver_editor/Services/TimerService.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using AutoSaverPlugin.Contracts;
-using AutoSaverPlugin.Shared;
-using Godot;
-
-namespace AutoSaverPlugin.Services
-{
- internal sealed class TimerService : ITimerService
- {
- private Timer _timer;
- private AutoSaverEditorPlugin _plugin;
- private Action _timeoutAction;
- private ILoggerService _logger;
-
- public TimerService(ILoggerService loggerService)
- {
- _logger = loggerService ?? throw new ArgumentNullException(nameof(loggerService));
- }
-
- public ITimerService AttachTo(AutoSaverEditorPlugin plugin)
- {
- _plugin = plugin ?? throw new ArgumentNullException(nameof(plugin));
- return this;
- }
-
- public ITimerService OnTimeout(Action action, bool oneShot = false)
- {
- _timeoutAction = action ?? throw new ArgumentNullException(nameof(action));
- SetupTimer(oneShot);
- return this;
- }
-
- public ITimerService Begin(float intervalSeconds)
- {
- if (_timer == null)
- {
- _logger.LogError("Timer is not initialized. Call OnTimeout first.");
- return this;
- }
-
- _timer.WaitTime = intervalSeconds;
-
- if (!_timer.IsInsideTree())
- {
- _plugin.AddChild(_timer);
- }
-
- _timer.Start();
- return this;
- }
-
- public ITimerService End()
- {
- DisposeTimer();
- return this;
- }
-
- private void SetupTimer(bool oneShot)
- {
- DisposeTimer();
-
- _timer = new Timer
- {
- OneShot = oneShot
- };
-
- _timer.Timeout += OnTimerTimeout;
- }
-
- private void OnTimerTimeout()
- {
- _timeoutAction?.Invoke();
- }
-
- private void DisposeTimer()
- {
- if (_timer != null)
- {
- _timer.Stop();
- if (_timer.IsInsideTree())
- {
- _plugin.RemoveChild(_timer);
- }
-
- _timer.Timeout -= OnTimerTimeout;
- _timer.QueueFree();
- _timer = null;
- }
- }
- }
-}
diff --git a/addons/autosaver_editor/Shared/CommonUtils.cs b/addons/autosaver_editor/Shared/CommonUtils.cs
deleted file mode 100644
index c97ceec..0000000
--- a/addons/autosaver_editor/Shared/CommonUtils.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Godot;
-
-namespace AutoSaverPlugin.Shared
-{
- internal static class CommonUtils
- {
- internal static string GetCurrentTimestamp() => DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-
- internal static string GetPluginVersion() => $"{PluginInfo.PluginVersion}";
-
- internal static List GetAllProjectFiles(string extFileFilter = null)
- {
- List files = new List();
- EditorInterface editorInterface = EditorInterface.Singleton;
- EditorFileSystem fileSystem = editorInterface.GetResourceFilesystem();
-
- fileSystem.Scan();
- GetFilesRecursive(fileSystem.GetFilesystem(), files, extFileFilter);
-
- return files;
- }
-
- private static void GetFilesRecursive(EditorFileSystemDirectory directory, List files, string extensionFilter = null)
- {
- for (int i = 0; i < directory.GetFileCount(); i++)
- {
- string filePath = directory.GetFilePath(i);
- if (string.IsNullOrEmpty(extensionFilter) || filePath.EndsWith(extensionFilter))
- {
- files.Add(filePath);
- }
- }
-
- for (int i = 0; i < directory.GetSubdirCount(); i++)
- {
- GetFilesRecursive(directory.GetSubdir(i), files, extensionFilter);
- }
- }
- }
-}
diff --git a/addons/autosaver_editor/Shared/Logger.cs b/addons/autosaver_editor/Shared/Logger.cs
deleted file mode 100644
index e3f5271..0000000
--- a/addons/autosaver_editor/Shared/Logger.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-using Godot;
-
-namespace AutoSaverPlugin.Shared;
-
-public enum VerboseLevel
-{
- OFF = 0,
- MIN = 1,
- MAX = 2,
- SECRET = 3
-}
-
-public enum LogType
-{
- MINOR = 0,
- MAJOR = 1,
- WARN_ERR = 2,
- DEBUG = 3
-}
-
-public interface ILoggerService
-{
- bool IsLogInfoEnable { get; }
- void SetOutput(VerboseLevel verboseLevel);
- void Log(string message, LogType logLevel);
- void LogDiagnostic(string message);
- void LogInfo(string message);
- void LogError(string message);
- void LogDebug(string message);
-}
-
-internal sealed class Logger : ILoggerService
-{
- private VerboseLevel _configuredVerboseLevel = VerboseLevel.OFF;
-
- public VerboseLevel VerboseLevel => _configuredVerboseLevel;
-
- public bool IsLogInfoEnable => _configuredVerboseLevel >= VerboseLevel.MIN;
-
- public Logger() { }
-
- public void SetOutput(VerboseLevel verboseLevel)
- {
- _configuredVerboseLevel = verboseLevel;
- }
-
- // +----------------------+---------------+---------------------+---------------------+
- // | LogType\VerboseLevel | MIN | MAX | SECRET |
- // +----------------------+---------------+---------------------+---------------------+
- // | DEBUG | - | - | GD.Print("[DEBUG]") |
- // | MINOR | - | GD.Print("[INFO]") | GD.Print("[INFO]") |
- // | MAJOR | GD.Print() | GD.Print() | GD.Print() |
- // | ERROR | GD.PrintErr() | GD.PrintErr() | GD.PrintErr() |
- // +----------------------+---------------+---------------------+---------------------+
-
- public void Log(string message, LogType logType)
- {
- if (_configuredVerboseLevel == VerboseLevel.OFF) return;
-
- string prefix = $"[{PluginInfo.NameShort}]";
- switch (logType)
- {
- case LogType.DEBUG:
- if (_configuredVerboseLevel == VerboseLevel.SECRET)
- GD.Print($"{prefix}[DEBUG] {message}");
- break;
- case LogType.MINOR:
- if (_configuredVerboseLevel >= VerboseLevel.MAX)
- GD.Print($"{prefix} {message}"); // [INFO]
- break;
- case LogType.MAJOR:
- GD.Print($"{prefix} {message}");
- break;
- case LogType.WARN_ERR:
- GD.PrintErr($"{prefix}[ERROR] {message}");
- break;
- }
- }
-
- public void LogDebug(string message) => Log(message, LogType.DEBUG);
- public void LogDiagnostic(string message) => Log(message, LogType.MINOR);
- public void LogInfo(string message) => Log(message, LogType.MAJOR);
- public void LogError(string message) => Log(message, LogType.WARN_ERR);
-}
diff --git a/addons/autosaver_editor/Shared/PluginInfo.cs b/addons/autosaver_editor/Shared/PluginInfo.cs
deleted file mode 100644
index 3c5c8d6..0000000
--- a/addons/autosaver_editor/Shared/PluginInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace AutoSaverPlugin.Shared
-{
- internal static class PluginInfo
- {
- internal const string NameShort = "AutoSaver";
- internal const string FullName = "AutoSaver Toggle for Godot Editor (C#)";
- internal const string Description = "Auto Saver for Godot Editor: a peace of mind toggle to automatically save your workspace";
- internal const string Author = "Victor R. R. Avalos";
- internal const string RootSettings = "autosaver_editor";
- internal const string BaseFolderName = "autosaver_editor";
- internal const string BaseResourcePath = "res://addons/autosaver_editor/";
- internal const string SettingsFileName = "settings.ini";
- internal const string PluginVersion = "0.1.0";
- internal const string PluginIcon = "icon_autosaver.png";
-
-
- // settings
- internal const string KeyEnabled = "enabled";
- internal const string KeyIntervalSec = "interval";
- internal const string KeyVerbose = "verbose";
- internal const string KeyPostponeTimeSec = "postpone_time";
- internal const string KeyActivityCheckWindowSec = "activity_check";
- internal const string KeyAutosaveScene = "autosave_scene";
- internal const string KeyAutosaveGDScript = "autosave_gdscript";
-
- internal const string KeyUseGDEditorAutosaveInterval = "use_gd_editor_autosave_interval";
- internal const string KeyUseGDEditorSaveOnFocusLoss = "use_gd_editor_save_on_focus_loss";
- }
-}
diff --git a/addons/autosaver_editor/Shared/ServiceProvider.cs b/addons/autosaver_editor/Shared/ServiceProvider.cs
deleted file mode 100644
index 257352f..0000000
--- a/addons/autosaver_editor/Shared/ServiceProvider.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using AutoSaverPlugin.Contracts;
-using AutoSaverPlugin.Services;
-
-namespace AutoSaverPlugin.Shared;
-
-public static class ServiceProvider
-{
- private static readonly Dictionary> _services = new();
- private static readonly Dictionary _singletonInstances = new();
-
- public static void RegisterServiceAsTransient() where TImplementation : class, TInterface
- {
- _services[typeof(TInterface)] = () => CreateInstance();
- }
-
- public static void RegisterServiceAsSingleton() where TImplementation : class, TInterface, new()
- {
- _services[typeof(TInterface)] = () => GetOrCreateSingletonInstance(typeof(TInterface), () => new TImplementation());
- }
-
- public static void RegisterServiceAsSingleton(Func factory)
- {
- _services[typeof(TInterface)] = () => GetOrCreateSingletonInstance(typeof(TInterface), () => factory());
- }
-
- public static T GetService() where T : class
- {
- return (T)GetService(typeof(T));
- }
-
- private static object GetService(Type type)
- {
- if (_services.TryGetValue(type, out var serviceFactory))
- {
- return serviceFactory();
- }
- throw new InvalidOperationException($"Service of type {type} is not registered.");
- }
-
- private static T CreateInstance() where T : class
- {
- var type = typeof(T);
- var constructor = type.GetConstructors()[0];
- var parameters = constructor.GetParameters();
- var parameterInstances = parameters.Select(p => GetService(p.ParameterType)).ToArray();
- return (T)constructor.Invoke(parameterInstances);
- }
-
- private static object GetOrCreateSingletonInstance(Type type, Func