Added stats to status bar display

This commit is contained in:
Me_TheCat 2019-03-31 07:46:45 +03:00
parent bc92867063
commit 77a518da3b
3 changed files with 152 additions and 76 deletions

View file

@ -85,6 +85,33 @@
v1.1.0 - by uberhalit
</Hyperlink>
</Label>
<StatusBar DockPanel.Dock="Bottom" Margin="-10,0,-10,0" VerticalAlignment="Bottom">
<StatusBar.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</StatusBar.ItemsPanel>
<StatusBarItem Grid.Column="0">
<TextBlock Name="sbDeathCount">
<Run Text="Deaths:"/>
<Run Text="{Binding Deaths}"/>
</TextBlock>
</StatusBarItem>
<Separator Grid.Column="1" />
<StatusBarItem Grid.Column="2">
<TextBlock Name="sbKillCount">
<Run Text="Kills:"/>
<Run Text="{Binding Kills}"/>
</TextBlock>
</StatusBarItem>
</StatusBar>
</StackPanel>
</Grid>
</Window>

View file

@ -41,6 +41,8 @@ namespace SekiroFpsUnlockAndMore
internal SettingsService _settingsService;
internal const string totalKillsFilename = "TotalKillsCounter.txt";
internal StatViewModel _statViewModel = new StatViewModel();
private bool _statLoggingEnabled = false;
internal readonly Timer _statRecordTimer = new Timer();
internal readonly DispatcherTimer _dispatcherTimerCheck = new DispatcherTimer();
internal bool _running = false;
@ -48,9 +50,11 @@ namespace SekiroFpsUnlockAndMore
internal bool _retryAccess = true;
internal RECT _windowRect;
public MainWindow()
{
InitializeComponent();
DataContext = _statViewModel;
}
/// <summary>
@ -89,6 +93,7 @@ namespace SekiroFpsUnlockAndMore
_statRecordTimer.Elapsed += new ElapsedEventHandler(StatReadTimer);
_statRecordTimer.Interval = 1500;
_statRecordTimer.Start();
}
/// <summary>
@ -699,18 +704,19 @@ namespace SekiroFpsUnlockAndMore
/// </summary
private void StatReadTimer(object sender, EventArgs e)
{
if (_gameAccessHwndStatic == IntPtr.Zero) return;
if (IsValidAddress(_pointer_player_deaths))
{
int playerDeaths = Read<Int32>(_gameAccessHwndStatic, _pointer_player_deaths);
//Debug.WriteLine("[STAT]Player deaths: " + playerDeaths);
LogStatFile(deathCounterFilename, playerDeaths.ToString());
_statViewModel.Deaths = playerDeaths;
if (_statLoggingEnabled) LogStatFile(deathCounterFilename, playerDeaths.ToString());
if (IsValidAddress(_pointer_total_kills))
{
int totalKills = Read<Int32>(_gameAccessHwndStatic, _pointer_total_kills);
totalKills -= playerDeaths; //Since this value seems to track every death, including the player
//Debug.WriteLine("[STAT]Enemies killed: " + totalKills);
LogStatFile(totalKillsFilename, totalKills.ToString());
_statViewModel.Kills = totalKills;
if (_statLoggingEnabled) LogStatFile(totalKillsFilename, totalKills.ToString());
}
}
}
@ -1067,7 +1073,7 @@ namespace SekiroFpsUnlockAndMore
private void CbStatChanged(object sender, RoutedEventArgs e)
{
_statRecordTimer.Enabled = (bool)cbLogStats.IsChecked;
_statLoggingEnabled = (bool)cbLogStats.IsChecked;
}
private void BPatch_Click(object sender, RoutedEventArgs e)

View file

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace SekiroFpsUnlockAndMore
{
/// <summary>
/// For Status bar display
/// </summary>
class StatViewModel : INotifyPropertyChanged
{
private int _deaths = 0;
public int Deaths
{
get { return _deaths; }
set
{
_deaths = value;
OnPropertyChanged(new PropertyChangedEventArgs("Deaths"));
}
}
private int _kills = 0;
public int Kills
{
get { return _kills; }
set
{
_kills = value;
OnPropertyChanged(new PropertyChangedEventArgs("Kills"));
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(PropertyChangedEventArgs e)
{
PropertyChanged?.Invoke(this, e);
}
}
}