Files
MesenCE/UI/Config/Debugger/ScriptWindowConfig.cs
SourMesen ad0a1b9849 Lua: Misc. fixes & improvements (#250)
-Fixed getAccessCounters documentation (swapped param order)
-Fixed file watcher not being disabled properly when closing the script window, causing the script to run if changed on the disk, even if the script window is closed
-Prevent file watcher from triggering from writes done by the script window itself (which caused the script to be reloaded 2 or 3 times in a row)
-Fixed UI freezes when using emu.log() on a large table
-Fixed crash when 100k character limit (in the last 500 lines) for script log was reached (out of bounds read/write)
-Added "fps" value to "getState"
-Slightly improved getAccessCounters/getCdlData performance
-Added a new drawPixels API to improve performance when a script needs to draw a lot of individual pixels
2026-08-10 22:42:34 +09:00

52 lines
1.8 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Mesen.Config
{
public partial class ScriptWindowConfig : BaseWindowConfig<ScriptWindowConfig>
{
private const int MaxRecentScripts = 10;
[ObservableProperty] public partial List<string> RecentScripts { get; set; } = new List<string>();
[ObservableProperty] public partial int Zoom { get; set; } = 100;
[ObservableProperty] public partial double LogWindowHeight { get; set; } = 100;
[ObservableProperty] public partial ScriptStartupBehavior ScriptStartupBehavior { get; set; } = ScriptStartupBehavior.ShowTutorial;
[ObservableProperty] public partial bool SaveScriptBeforeRun { get; set; } = true;
[ObservableProperty] public partial bool AutoStartScriptOnLoad { get; set; } = true;
[ObservableProperty] public partial bool AutoReloadScriptWhenFileChanges { get; set; } = true;
[ObservableProperty] public partial bool AutoRestartScriptAfterPowerCycle { get; set; } = true;
[ObservableProperty] public partial bool AllowIoOsAccess { get; set; } = false;
[ObservableProperty] public partial bool AllowNetworkAccess { get; set; } = false;
[ObservableProperty] public partial bool ShowLineNumbers { get; set; } = true;
[ObservableProperty] public partial UInt32 ScriptTimeout { get; set; } = 1;
public void AddRecentScript(string scriptFile)
{
string? existingItem = RecentScripts.Where((file) => file == scriptFile).FirstOrDefault();
if(existingItem != null) {
RecentScripts.Remove(existingItem);
}
RecentScripts.Insert(0, scriptFile);
if(RecentScripts.Count > ScriptWindowConfig.MaxRecentScripts) {
RecentScripts.RemoveAt(ScriptWindowConfig.MaxRecentScripts);
}
}
}
public enum ScriptStartupBehavior
{
ShowTutorial = 0,
ShowBlankWindow = 1,
LoadLastScript = 2
}
}