Configure a few variable exports.
This commit is contained in:
parent
e99f23ee0d
commit
e63798bd3c
@ -27,6 +27,10 @@ namespace rabi_splitter_WPF
|
||||
return new MapTileCoordinate(x, y);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return $"({x}, {y})";
|
||||
}
|
||||
|
||||
#region Equals, Hashcode
|
||||
// override object.Equals
|
||||
public override bool Equals(object obj)
|
||||
|
@ -6,7 +6,7 @@ using System.Text;
|
||||
|
||||
namespace rabi_splitter_WPF
|
||||
{
|
||||
class RabiRibiDisplay
|
||||
partial class RabiRibiDisplay
|
||||
{
|
||||
private MainContext mainContext;
|
||||
private DebugContext debugContext;
|
||||
@ -36,6 +36,7 @@ namespace rabi_splitter_WPF
|
||||
this.mainWindow = mainWindow;
|
||||
this.memoryReadCount = 0;
|
||||
StartNewGame();
|
||||
ConfigureVariableExports();
|
||||
}
|
||||
|
||||
public void ReadMemory(Process process)
|
||||
|
103
rabi_splitter_WPF/VariableExportConfig.cs
Normal file
103
rabi_splitter_WPF/VariableExportConfig.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace rabi_splitter_WPF
|
||||
{
|
||||
partial class RabiRibiDisplay
|
||||
{
|
||||
void ConfigureVariableExports()
|
||||
{
|
||||
ExportableVariable.DefineVariableExports(new ExportableVariable[] {
|
||||
ExportVariable<int> (
|
||||
displayName: "Playtime",
|
||||
tracker: () => snapshot.playtime
|
||||
),
|
||||
|
||||
ExportVariable<int> (
|
||||
displayName: "Blackness",
|
||||
tracker: () => snapshot.blackness
|
||||
),
|
||||
|
||||
ExportVariable<int> (
|
||||
displayName: "Map Id",
|
||||
tracker: () => snapshot.mapid
|
||||
),
|
||||
|
||||
ExportVariable<string> (
|
||||
displayName: "Map",
|
||||
tracker: () => StaticData.GetMapName(snapshot.mapid)
|
||||
),
|
||||
|
||||
ExportVariable<int> (
|
||||
displayName: "Music Id",
|
||||
tracker: () => snapshot.musicid
|
||||
),
|
||||
|
||||
ExportVariable<string> (
|
||||
displayName: "Music",
|
||||
tracker: () => StaticData.GetMusicName(snapshot.musicid)
|
||||
),
|
||||
|
||||
ExportVariable<int> (
|
||||
displayName: "HP",
|
||||
tracker: () => snapshot.hp
|
||||
),
|
||||
|
||||
ExportVariable<float> (
|
||||
displayName: "Amulet",
|
||||
tracker: () => snapshot.amulet
|
||||
),
|
||||
|
||||
ExportVariable<int> (
|
||||
displayName: "Boost",
|
||||
tracker: () => snapshot.boost
|
||||
),
|
||||
|
||||
ExportVariable<float> (
|
||||
displayName: "MP",
|
||||
tracker: () => snapshot.mana
|
||||
),
|
||||
|
||||
ExportVariable<int> (
|
||||
displayName: "SP",
|
||||
tracker: () => snapshot.stamina
|
||||
),
|
||||
|
||||
ExportVariable<float> (
|
||||
displayName: "x",
|
||||
tracker: () => snapshot.px
|
||||
),
|
||||
|
||||
ExportVariable<float> (
|
||||
displayName: "y",
|
||||
tracker: () => snapshot.py
|
||||
),
|
||||
|
||||
ExportVariable<MapTileCoordinate> (
|
||||
displayName: "Map Tile",
|
||||
tracker: () => snapshot.mapTile
|
||||
),
|
||||
|
||||
ExportVariable<int> (
|
||||
displayName: "Deaths",
|
||||
tracker: () => inGameState.nDeaths
|
||||
),
|
||||
|
||||
ExportVariable<int> (
|
||||
displayName: "Restarts",
|
||||
tracker: () => inGameState.nRestarts
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
variableExportContext.NotifyExportableVariableUpdate();
|
||||
}
|
||||
|
||||
private ExportableVariable<T> ExportVariable<T>(string displayName, Func<T> tracker)
|
||||
{
|
||||
return new ExportableVariable<T>(displayName, tracker);
|
||||
}
|
||||
}
|
||||
}
|
@ -44,6 +44,13 @@ namespace rabi_splitter_WPF
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyExportableVariableUpdate()
|
||||
{
|
||||
foreach (var ves in _variableExportSettings)
|
||||
{
|
||||
ves.NotifyExportableVariableUpdate();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Variables
|
||||
|
@ -24,8 +24,10 @@ namespace rabi_splitter_WPF
|
||||
|
||||
public abstract class ExportableVariable
|
||||
{
|
||||
// Do not make these properties public.
|
||||
private static int nextAvailableId = 0;
|
||||
private static List<ExportableVariable> _variableExports;
|
||||
private static Dictionary<ExportableVariable, string> _variableCaptions = new Dictionary<ExportableVariable, string>();
|
||||
|
||||
private readonly int _id;
|
||||
private readonly string _displayName;
|
||||
|
||||
@ -46,13 +48,16 @@ namespace rabi_splitter_WPF
|
||||
}
|
||||
|
||||
internal abstract VariableTracker GetTracker();
|
||||
|
||||
public static List<ExportableVariable> GetAll()
|
||||
|
||||
public static void DefineVariableExports(ExportableVariable[] exports)
|
||||
{
|
||||
return new List<ExportableVariable>()
|
||||
{
|
||||
new ExportableVariable<int>("TestVariable", () => 1)
|
||||
};
|
||||
_variableExports = exports.ToList();
|
||||
_variableCaptions = exports.ToDictionary(ev => ev, ev => ev.DisplayName);
|
||||
}
|
||||
|
||||
public static Dictionary<ExportableVariable, string> VariableCaptions
|
||||
{
|
||||
get { return _variableCaptions; }
|
||||
}
|
||||
|
||||
#region Equals, GetHashCode
|
||||
@ -84,6 +89,7 @@ namespace rabi_splitter_WPF
|
||||
public override bool CheckForUpdate()
|
||||
{
|
||||
T newValue = tracker();
|
||||
|
||||
if (forceUpdate || !newValue.Equals(currentValue))
|
||||
{
|
||||
currentValue = newValue;
|
||||
@ -158,26 +164,29 @@ namespace rabi_splitter_WPF
|
||||
if (_variableTracker == null) return false;
|
||||
return _variableTracker.CheckForUpdate();
|
||||
}
|
||||
|
||||
public void NotifyExportableVariableUpdate()
|
||||
{
|
||||
OnPropertyChanged(nameof(VariableCaptions));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dictionaries
|
||||
private static Dictionary<ExportableVariable, string> _variableCaptions;
|
||||
|
||||
public Dictionary<ExportableVariable, string> VariableCaptions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_variableCaptions == null)
|
||||
{
|
||||
_variableCaptions = ExportableVariable.GetAll().ToDictionary(ev => ev, ev => ev.DisplayName);
|
||||
}
|
||||
return _variableCaptions;
|
||||
}
|
||||
get { return ExportableVariable.VariableCaptions; }
|
||||
}
|
||||
|
||||
|
||||
internal void DefaultButton_Click()
|
||||
{
|
||||
OutputFormat = "DEFAULT OUTPUT FORMAT: " + OutputFileName;
|
||||
if (_selectedVariable == null)
|
||||
{
|
||||
OutputFormat = "Variable not set.";
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputFormat = $"{_selectedVariable.DisplayName}: {{0}}";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -66,6 +66,7 @@
|
||||
<Compile Include="RabiRibiDisplay.cs" />
|
||||
<Compile Include="RabiRibiState.cs" />
|
||||
<Compile Include="StaticData.cs" />
|
||||
<Compile Include="VariableExportConfig.cs" />
|
||||
<Compile Include="VariableExportContext.cs" />
|
||||
<Compile Include="VariableExportSetting.cs" />
|
||||
<Compile Include="VariableExportTab.xaml.cs">
|
||||
|
Loading…
x
Reference in New Issue
Block a user