Added stats to status bar display

This commit is contained in:
Me_TheCat 2019-03-31 07:46:45 +03:00
parent 3e69a177b9
commit 7de3bd345d
3 changed files with 85 additions and 9 deletions

View file

@ -22,7 +22,7 @@
<Button x:Name="bPatch" Content="Patch game (CTRL + P)" FontSize="14 px" HorizontalAlignment="Left" Margin="10,153,0,0" VerticalAlignment="Top" Width="277" Height="30"
BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Focusable="False" Click="BPatch_Click" />
<TextBox x:Name="tbStatus" Text="waiting for game..." TextAlignment="Center" HorizontalAlignment="Left" TextWrapping="NoWrap" Height="25" Margin="10,189,0,0" VerticalAlignment="Top" Width="277" FontSize="14 px" IsEnabled="False" FontWeight="Bold" />
<StackPanel HorizontalAlignment="Left" Height="304" Margin="12,219,0,0" VerticalAlignment="Top" Width="275">
<StackPanel HorizontalAlignment="Left" Height="329" Margin="12,219,0,0" VerticalAlignment="Top" Width="275">
<TextBlock HorizontalAlignment="Left" TextWrapping="WrapWithOverflow" VerticalAlignment="Top" FontSize="11 px" IsEnabled="False" Height="280">
<TextBlock.Inlines>
<Run FontWeight="Bold">If your monitor is 60 Hz you will have to use</Run>
@ -47,5 +47,32 @@
</Hyperlink>
</Label>
</StackPanel>
<StatusBar DockPanel.Dock="Bottom" 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>
</Grid>
</Window>

View file

@ -52,17 +52,21 @@ namespace SekiroFpsUnlockAndMore
internal const string deathCounterFilename = "DeathCouner.txt";
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;
internal string _logPath;
internal bool _retryAccess = true;
internal RECT _windowRect;
public MainWindow()
{
InitializeComponent();
}
{
InitializeComponent();
DataContext = _statViewModel;
}
/// <summary>
/// On window loaded.
@ -87,6 +91,7 @@ namespace SekiroFpsUnlockAndMore
_statRecordTimer.Elapsed += new ElapsedEventHandler(StatReadTimer);
_statRecordTimer.Interval = 1500;
_statRecordTimer.Start();
}
/// <summary>
@ -447,18 +452,19 @@ namespace SekiroFpsUnlockAndMore
/// </summary
private void StatReadTimer(object sender, EventArgs e)
{
if (_gameProc==IntPtr.Zero) return;
if (IsValid(_pointer_player_deaths))
{
int playerDeaths = Read<Int32>(_gameProc, _pointer_player_deaths);
//Debug.WriteLine("[STAT]Player deaths: " + playerDeaths);
LogStatFile(deathCounterFilename, playerDeaths.ToString());
_statViewModel.Deaths = playerDeaths;
if (_statLoggingEnabled) LogStatFile(deathCounterFilename, playerDeaths.ToString());
if (IsValid(_pointer_total_kills))
{
int totalKills = Read<Int32>(_gameProc, _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());
}
}
}
@ -698,7 +704,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);
}
}
}