Skip to content

Commit

Permalink
Made IGT default in VM. Rerouted errors to the wpf UI instead of draw…
Browse files Browse the repository at this point in the history
…ing to livesplit's window. Couple more UI changes to better fit not running as a layout plugin.
  • Loading branch information
FrankvdStam committed Mar 20, 2022
1 parent 4afd98e commit 90269ac
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 95 deletions.
Binary file modified Components/SoulMemory.dll
Binary file not shown.
Binary file modified Components/SoulSplitter.dll
Binary file not shown.
12 changes: 12 additions & 0 deletions Components/Updates.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<updates>
<update version="0.0.13">
<files>
<file path="Components/SoulMemory.dll" status="changed" />
<file path="Components/SoulSplitter.dll" status="changed" />
</files>
<changelog>
<change>Changed default timing method from RTA to IGT.</change>
<change>Clarified in the UI that the initial black screen removal will only work if you let SoulSplitter auto-start.</change>
<change>Moved SoulSplitter's errors into it's UI instead of it being visible in livesplit's UI. Also added the version there for reference.</change>
<change>Couple more small UI fixes</change>
</changelog>
</update>
<update version="0.0.12">
<files>
<file path="Components/SoulMemory.dll" status="changed" />
Expand Down
2 changes: 1 addition & 1 deletion src/SoulMemory/EldenRing/EldenRing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public bool Refresh()
}
else
{
var pointerScanException = new Exception($"Pattern scan failed.\nIs EAC disabled?\n{Exception.Message}", Exception);
var pointerScanException = new Exception($"Pattern scan failed, is EAC disabled? {Exception.Message}", Exception);
Exception = pointerScanException;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/SoulMemory/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.12")]
[assembly: AssemblyFileVersion("0.0.12")]
[assembly: AssemblyVersion("0.0.13")]
[assembly: AssemblyFileVersion("0.0.13")]
4 changes: 2 additions & 2 deletions src/SoulSplitter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.12")]
[assembly: AssemblyFileVersion("0.0.12")]
[assembly: AssemblyVersion("0.0.13")]
[assembly: AssemblyFileVersion("0.0.13")]
68 changes: 5 additions & 63 deletions src/SoulSplitter/SoulComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using SoulSplitter.Splitters;
using SoulSplitter.UI;
using SoulSplitter.UI.ViewModel;
using Brushes = System.Drawing.Brushes;

namespace SoulSplitter
{
Expand All @@ -43,91 +42,34 @@ public void Update(IInvalidator invalidator, LiveSplitState state, float width,
try
{
_splitter.Update(MainControlFormsWrapper.MainViewModel.EldenRingViewModel);

//HorizontalWidth = width;
//VerticalHeight = height;
//if (mode == LayoutMode.Vertical)
//{
// HorizontalWidth = width;
// VerticalHeight = 0;
//}
//else
//{
// HorizontalWidth = 0;
// VerticalHeight = height;
//}


_liveSplitState = state;


if (_splitter.Exception != null)
{
WriteDebug(_splitter.Exception.Message);
MainControlFormsWrapper.MainViewModel.Error = _splitter.Exception.Message;
}
else
{
WriteDebug("");
}

if (_redraw)
{
invalidator?.Invalidate(0, 0, 1, 1);
MainControlFormsWrapper.MainViewModel.Error = "";
}
}
catch (Exception e)
{
WriteDebug(e.Message);
MainControlFormsWrapper.MainViewModel.Error = e.Message;
}
}



#region drawing ===================================================================================================================

public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion)
{
Draw(g);
}

public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion)
{
Draw(g);
}

private void WriteDebug(string s)
{
if (_debugOutput != s)
{
_redraw = true;
_debugOutput = s;
}
}

private string _debugOutput = "";
private bool _redraw = true;
public void Draw(Graphics g)
{
if (string.IsNullOrWhiteSpace(_debugOutput))
{
VerticalHeight = 0;
HorizontalWidth = 0;
}
else
{
VerticalHeight = g.MeasureString(_debugOutput, _liveSplitState.LayoutSettings.TextFont).Height + 2 * InternalPadding;

//Get longest string to base the width on
var longestStr = _debugOutput.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList().OrderByDescending(i => i.Length).FirstOrDefault();
HorizontalWidth = g.MeasureString(longestStr, _liveSplitState.LayoutSettings.TextFont).Width + 2 * InternalPadding;

g.FillRectangle(new SolidBrush(_liveSplitState.LayoutSettings.BackgroundColor), 0, 0, HorizontalWidth, VerticalHeight);
g.DrawString(_debugOutput, _liveSplitState.LayoutSettings.TextFont, Brushes.Crimson, InternalPadding, InternalPadding);
}

_redraw = false;
}


private const float InternalPadding = 7f;

public string ComponentName => Name;
public float HorizontalWidth { get; private set; } = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/SoulSplitter/SoulComponentFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class SoulComponentFactory : IComponentFactory

public string UpdateURL => "https://raw.githubusercontent.com/FrankvdStam/SoulSplitter/main/";

public Version Version => new Version(0, 0, 12);
public Version Version => VersionHelper.Version;

public IComponent Create(LiveSplitState state)
{
Expand Down
1 change: 1 addition & 0 deletions src/SoulSplitter/SoulSplitter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Compile Include="UI\EnumDisplayNameConverter.cs" />
<Compile Include="Splitters\Timer.cs" />
<Compile Include="Splitters\TimingMethod.cs" />
<Compile Include="VersionHelper.cs" />
<Compile Include="XmlSerializableWrapper.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/SoulSplitter/UI/EldenRing/EldenRingControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<CheckBox
Grid.Row="1"
Margin="5"
Content="Start automatically"
Content="Start automatically with initial black screen removal"
IsChecked="{Binding StartAutomatically}"/>
</Grid>
</UserControl>
2 changes: 1 addition & 1 deletion src/SoulSplitter/UI/EldenRing/EldenRingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public bool StartAutomatically
}


private TimingMethod _timingMethod = TimingMethod.RtaWithLoadRemoval;
private TimingMethod _timingMethod = TimingMethod.Igt;
public TimingMethod TimingMethod
{
get => _timingMethod;
Expand Down
57 changes: 33 additions & 24 deletions src/SoulSplitter/UI/MainControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:System="clr-namespace:System;assembly=mscorlib"
xmlns:Local="clr-namespace:SoulSplitter.Splits"
xmlns:ui="clr-namespace:SoulSplitter.UI"
xmlns:viewModel="clr-namespace:SoulSplitter.UI.ViewModel"
mc:Ignorable="d"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
xmlns:darkSouls1="clr-namespace:SoulSplitter.UI.DarkSouls1"
xmlns:darkSouls2="clr-namespace:SoulSplitter.UI.DarkSouls2"
xmlns:eldenRing="clr-namespace:SoulSplitter.UI.EldenRing"
Width="460"
Height="524"
>
Width="451"
Height="497">

<UserControl.Resources>
<ResourceDictionary>
Expand All @@ -34,20 +29,34 @@
<ui:MainViewModel/>
</UserControl.DataContext>

<TabControl
SelectedIndex="{Binding SelectedGameIndex}">
<TabItem Header="Dark Souls 1" IsEnabled="False">
<darkSouls1:DarkSouls1Control DataContext="{Binding DarkSouls1ViewModel}"/>
</TabItem>
<!-- DataContext="{Binding DarkSouls2ViewModel}" -->
<TabItem Header="Dark Souls 2" IsEnabled="False">
<darkSouls2:DarkSouls2Control DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=DataContext.DarkSouls2ViewModel}"/>
</TabItem>

<TabItem Header="Elden Ring">
<eldenRing:EldenRingControl DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=DataContext.EldenRingViewModel}"/>
</TabItem>
</TabControl>


<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<StackPanel
Orientation="Horizontal">
<TextBlock Text="SoulSplitter version "/>
<TextBlock Text="{Binding Version}"/>

<TextBlock Text="{Binding Error}" Margin="10,0,0,0" Foreground="Red"/>
</StackPanel>

<TabControl
Grid.Row="1"
SelectedIndex="{Binding SelectedGameIndex}">
<TabItem Header="Dark Souls 1" IsEnabled="False">
<darkSouls1:DarkSouls1Control DataContext="{Binding DarkSouls1ViewModel}"/>
</TabItem>
<!-- DataContext="{Binding DarkSouls2ViewModel}" -->
<TabItem Header="Dark Souls 2" IsEnabled="False">
<darkSouls2:DarkSouls2Control DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=DataContext.DarkSouls2ViewModel}"/>
</TabItem>

<TabItem Header="Elden Ring">
<eldenRing:EldenRingControl DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=DataContext.EldenRingViewModel}"/>
</TabItem>
</TabControl>
</Grid>
</UserControl>
13 changes: 13 additions & 0 deletions src/SoulSplitter/UI/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using SoulSplitter.Splits;
using SoulSplitter.UI.DarkSouls1;
using SoulSplitter.UI.ViewModel;
Expand All @@ -22,7 +23,19 @@ public void Update(MainViewModel mainViewModel)
DarkSouls2ViewModel = mainViewModel.DarkSouls2ViewModel;
}

[XmlIgnore]
public string Error
{
get => _error;
set
{
_error = value;
OnPropertyChanged();
}
}
private string _error;

public string Version { get; set; } = VersionHelper.Version.ToString();

public int SelectedGameIndex
{
Expand Down
13 changes: 13 additions & 0 deletions src/SoulSplitter/VersionHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoulSplitter
{
internal static class VersionHelper
{
public static Version Version => new Version(0, 0, 13);
}
}

0 comments on commit 90269ac

Please sign in to comment.