Tastudio - Saving and loading of column info to the .tasproj file, loading is still problematic because it is being whacked by code that rebuilds the columns later, need to unspeghettify some things
This commit is contained in:
parent
ce58f0e803
commit
e6cec0f52f
|
@ -25,7 +25,8 @@ namespace BizHawk.Client.Common
|
|||
LagLog,
|
||||
Greenzone,
|
||||
GreenzoneSettings,
|
||||
Markers
|
||||
Markers,
|
||||
ClientSettings
|
||||
}
|
||||
|
||||
public static class BinaryStateFileNames
|
||||
|
@ -59,6 +60,7 @@ namespace BizHawk.Client.Common
|
|||
AddLumpName(BinaryStateLump.Greenzone, "GreenZone");
|
||||
AddLumpName(BinaryStateLump.GreenzoneSettings, "GreenZoneSettings.txt");
|
||||
AddLumpName(BinaryStateLump.Markers, "Markers.txt");
|
||||
AddLumpName(BinaryStateLump.ClientSettings, "ClientSettings.json");
|
||||
}
|
||||
|
||||
public static string GetReadName(BinaryStateLump lump)
|
||||
|
|
|
@ -10,6 +10,9 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public partial class TasMovie
|
||||
{
|
||||
public Func<string> ClientSettingsForSave { get; set; }
|
||||
public Action<string> GetClientSettingsOnLoad { get; set; }
|
||||
|
||||
protected override void Write(string fn)
|
||||
{
|
||||
var file = new FileInfo(fn);
|
||||
|
@ -48,6 +51,12 @@ namespace BizHawk.Client.Common
|
|||
bs.PutLump(BinaryStateLump.Corestate, (BinaryWriter bw) => bw.Write(BinarySavestate));
|
||||
}
|
||||
}
|
||||
|
||||
if (ClientSettingsForSave != null)
|
||||
{
|
||||
var clientSettingsJson = ClientSettingsForSave();
|
||||
bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
|
||||
}
|
||||
}
|
||||
|
||||
Changes = false;
|
||||
|
@ -173,6 +182,24 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (GetClientSettingsOnLoad != null)
|
||||
{
|
||||
string clientSettings = string.Empty;
|
||||
bl.GetLump(BinaryStateLump.ClientSettings, true, delegate(TextReader tr)
|
||||
{
|
||||
string line;
|
||||
while ((line = tr.ReadLine()) != null)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
clientSettings = line;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
GetClientSettingsOnLoad(clientSettings);
|
||||
}
|
||||
}
|
||||
|
||||
Changes = false;
|
||||
|
@ -184,10 +211,5 @@ namespace BizHawk.Client.Common
|
|||
LagLog.Clear();
|
||||
StateManager.Clear();
|
||||
}
|
||||
|
||||
private void RestoreLagLog(byte[] buffer)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin.MainForm.PauseOnFrame = null;
|
||||
GlobalWin.OSD.AddMessage("TAStudio engaged");
|
||||
_currentTasMovie = Global.MovieSession.Movie as TasMovie;
|
||||
SetTasMovieCallbacks();
|
||||
SetTextProperty();
|
||||
GlobalWin.MainForm.PauseEmulator();
|
||||
GlobalWin.MainForm.RelinquishControl(this);
|
||||
|
@ -99,6 +100,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Global.MovieSession.Movie = new TasMovie();
|
||||
_currentTasMovie = Global.MovieSession.Movie as TasMovie;
|
||||
SetTasMovieCallbacks();
|
||||
_currentTasMovie.PropertyChanged += new PropertyChangedEventHandler(this.TasMovie_OnPropertyChanged);
|
||||
_currentTasMovie.Filename = DefaultTasProjName(); // TODO don't do this, take over any mainform actions that can crash without a filename
|
||||
_currentTasMovie.PopulateWithDefaultHeaderValues();
|
||||
|
@ -112,6 +114,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
PathManager.FilesystemSafeName(Global.Game) + "." + TasMovie.Extension);
|
||||
}
|
||||
|
||||
private void SetTasMovieCallbacks()
|
||||
{
|
||||
_currentTasMovie.ClientSettingsForSave = ClientSettingsForSave;
|
||||
_currentTasMovie.GetClientSettingsOnLoad = GetClientSettingsOnLoad;
|
||||
}
|
||||
|
||||
private void StartNewTasMovie()
|
||||
{
|
||||
if (AskSaveChanges())
|
||||
|
@ -125,6 +133,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private string ClientSettingsForSave()
|
||||
{
|
||||
return TasView.UserSettingsSerialized();
|
||||
}
|
||||
|
||||
private void GetClientSettingsOnLoad(string settingsJson)
|
||||
{
|
||||
TasView.LoadSettingsSerialized(settingsJson);
|
||||
TasView.Refresh();
|
||||
}
|
||||
|
||||
private void SetTextProperty()
|
||||
{
|
||||
var text = "TAStudio";
|
||||
|
@ -140,9 +159,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (AskSaveChanges())
|
||||
{
|
||||
var movie = new TasMovie()
|
||||
var movie = new TasMovie
|
||||
{
|
||||
Filename = path
|
||||
Filename = path,
|
||||
ClientSettingsForSave = ClientSettingsForSave,
|
||||
GetClientSettingsOnLoad = GetClientSettingsOnLoad
|
||||
};
|
||||
|
||||
movie.PropertyChanged += TasMovie_OnPropertyChanged;
|
||||
|
@ -168,8 +189,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
return false;
|
||||
}
|
||||
|
||||
WantsToControlStopMovie = true;
|
||||
_currentTasMovie = Global.MovieSession.Movie as TasMovie;
|
||||
SetTasMovieCallbacks();
|
||||
|
||||
WantsToControlStopMovie = true;
|
||||
Global.Config.RecentTas.Add(path);
|
||||
Text = "TAStudio - " + _currentTasMovie.Name;
|
||||
|
||||
|
|
Loading…
Reference in New Issue