Implement the file export. Now the Variable Export fully works.
This commit is contained in:
parent
bf552d9a28
commit
382bf61271
@ -117,7 +117,6 @@ namespace rabi_splitter_WPF
|
||||
if (InGame())
|
||||
{
|
||||
inGameState.nRestarts++;
|
||||
UpdateTextFile();
|
||||
}
|
||||
DebugLog("Reload Game! " + snapshot.playtime + " <- " + inGameState.lastNonZeroPlayTime);
|
||||
}
|
||||
@ -197,7 +196,6 @@ namespace rabi_splitter_WPF
|
||||
if (InGame())
|
||||
{
|
||||
inGameState.nDeaths++;
|
||||
UpdateTextFile();
|
||||
}
|
||||
DebugLog("Death!");
|
||||
}
|
||||
@ -297,15 +295,6 @@ namespace rabi_splitter_WPF
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTextFile()
|
||||
{
|
||||
//return;
|
||||
string text = $"Deaths: {inGameState.nDeaths}\nResets: {inGameState.nRestarts}";
|
||||
System.IO.StreamWriter file = new System.IO.StreamWriter("deaths_restarts.txt");
|
||||
file.WriteLine(text);
|
||||
file.Close();
|
||||
}
|
||||
|
||||
private void StartNewGame()
|
||||
{
|
||||
inGameState = new InGameState();
|
||||
|
@ -36,7 +36,8 @@ namespace rabi_splitter_WPF
|
||||
|
||||
foreach (var ves in _variableExportSettings)
|
||||
{
|
||||
ves.OutputUpdate(variableValues, updateFile);
|
||||
ves.UpdateText(variableValues);
|
||||
if (updateFile) ves.MaybeUpdateFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ namespace rabi_splitter_WPF
|
||||
private string _formatPreview;
|
||||
private bool _isExporting;
|
||||
private bool _isPreviewingFormat;
|
||||
private bool _hasChangedSinceLastFileOutput;
|
||||
|
||||
public VariableExportSetting()
|
||||
{
|
||||
@ -90,6 +91,7 @@ namespace rabi_splitter_WPF
|
||||
_outputFormat = "";
|
||||
_isExporting = false;
|
||||
_isPreviewingFormat = false;
|
||||
_hasChangedSinceLastFileOutput = true;
|
||||
}
|
||||
|
||||
#region Logic
|
||||
@ -105,17 +107,27 @@ namespace rabi_splitter_WPF
|
||||
}
|
||||
}
|
||||
|
||||
internal void OutputUpdate(Dictionary<string, object> variableValues, bool updateFile)
|
||||
internal void UpdateText(Dictionary<string, object> variableValues)
|
||||
{
|
||||
var formattedOutput = FormatOutput(variableValues);
|
||||
if (formattedOutput == FormatPreview) return;
|
||||
FormatPreview = formattedOutput;
|
||||
if (updateFile)
|
||||
if (formattedOutput != FormatPreview)
|
||||
{
|
||||
// TODO: Write to file
|
||||
FormatPreview = formattedOutput;
|
||||
_hasChangedSinceLastFileOutput = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal void MaybeUpdateFile()
|
||||
{
|
||||
if (!_hasChangedSinceLastFileOutput || !IsExporting) return;
|
||||
|
||||
System.IO.StreamWriter file = new System.IO.StreamWriter(OutputFileName);
|
||||
file.WriteLine(FormatPreview);
|
||||
file.Close();
|
||||
|
||||
_hasChangedSinceLastFileOutput = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Parameters
|
||||
@ -128,6 +140,7 @@ namespace rabi_splitter_WPF
|
||||
if (value.Equals(_outputFileName)) return;
|
||||
_outputFileName = value;
|
||||
OnPropertyChanged(nameof(OutputFileName));
|
||||
_hasChangedSinceLastFileOutput = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user