From 1e57a0a221b5c5df24d8db5679a5a02b06366bf4 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 30 Jan 2016 19:20:52 -0500 Subject: [PATCH] Lua Console - remember column widths --- .../tools/Lua/LuaConsole.cs | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index c9364537d3..fe3e0f0d07 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -28,8 +28,28 @@ namespace BizHawk.Client.EmuHawk public bool IsRebootingCore; + public ToolDialogSettings.ColumnList Columns { get; set; } + + public class LuaConsoleSettings + { + public LuaConsoleSettings() + { + Columns = new ToolDialogSettings.ColumnList + { + new ToolDialogSettings.Column { Name = "Script", Visible = true, Index = 0, Width = 92 }, + new ToolDialogSettings.Column { Name = "PathName", Visible = true, Index = 0, Width = 195 } + }; + } + + public ToolDialogSettings.ColumnList Columns { get; set; } + } + + [ConfigPersist] + public LuaConsoleSettings Settings { get; set; } + public LuaConsole() { + Settings = new LuaConsoleSettings(); _sortReverse = false; _lastColumnSorted = string.Empty; _luaList = new LuaFileList @@ -44,6 +64,7 @@ namespace BizHawk.Client.EmuHawk { if (AskSaveChanges()) { + SaveColumnInfo(); CloseLua(); GlobalWin.DisplayManager.ClearLuaSurfaces(); } @@ -100,15 +121,40 @@ namespace BizHawk.Client.EmuHawk { if (Global.Config.RecentLuaSession.AutoLoad && !Global.Config.RecentLuaSession.Empty) { - LoadSessionFromRecent(Global.Config.RecentLuaSession[0]); + LoadSessionFromRecent(Global.Config.RecentLuaSession.MostRecent); } else if (Global.Config.RecentLua.AutoLoad) { if (!Global.Config.RecentLua.Empty) { - LoadLuaFromRecent(Global.Config.RecentLua[0]); + LoadLuaFromRecent(Global.Config.RecentLua.MostRecent); } } + + LoadColumnInfo(); + } + + private void LoadColumnInfo() + { + LuaListView.Columns.Clear(); + + var columns = Settings.Columns + .Where(c => c.Visible) + .OrderBy(c => c.Index); + + foreach (var column in columns) + { + LuaListView.AddColumn(column); + } + } + + private void SaveColumnInfo() + { + foreach (ColumnHeader column in LuaListView.Columns) + { + Settings.Columns[column.Name].Index = column.DisplayIndex; + Settings.Columns[column.Name].Width = column.Width; + } } public void Restart()