diff --git a/rabi_splitter_WPF/MainContext.cs b/rabi_splitter_WPF/MainContext.cs index c70e4ef..b545002 100644 --- a/rabi_splitter_WPF/MainContext.cs +++ b/rabi_splitter_WPF/MainContext.cs @@ -4,10 +4,33 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Text; +using System.Windows.Data; using rabi_splitter_WPF.Annotations; namespace rabi_splitter_WPF { + [ValueConversion(typeof(bool), typeof(bool))] + public class InverseBooleanConverter : IValueConverter + { + #region IValueConverter Members + + public object Convert(object value, Type targetType, object parameter, + System.Globalization.CultureInfo culture) + { + if (targetType != typeof(bool)) + throw new InvalidOperationException("The target must be a boolean"); + + return !(bool)value; + } + + public object ConvertBack(object value, Type targetType, object parameter, + System.Globalization.CultureInfo culture) + { + throw new NotSupportedException(); + } + + #endregion + } public class BossData:INotifyPropertyChanged { private int _bossIdx; @@ -122,7 +145,7 @@ namespace rabi_splitter_WPF private string _gameVer; private string _gameMusic; private bool _igt; - + public bool _autoReset; public bool Noah1Reload { get { return _noah1Reload; } @@ -277,6 +300,18 @@ namespace rabi_splitter_WPF } } + public bool AutoReset + { + get { return _autoReset; } + set + { + if (value == _autoReset) return; + _autoReset = value; + OnPropertyChanged(nameof(AutoReset)); + + } + } + public string oldtitle; public int veridx; @@ -304,6 +339,7 @@ namespace rabi_splitter_WPF this.ServerPort = 16834; this.Igt = true; this.Noah1Reload = false; + this.AutoReset = true; } diff --git a/rabi_splitter_WPF/MainWindow.xaml b/rabi_splitter_WPF/MainWindow.xaml index 7e3c21d..7e90e3d 100644 --- a/rabi_splitter_WPF/MainWindow.xaml +++ b/rabi_splitter_WPF/MainWindow.xaml @@ -5,13 +5,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:rabi_splitter_WPF" mc:Ignorable="d" SizeToContent="Width" - Title="Irisu is watching you" d:DataContext="{d:DesignData local:MainContext}" d:DesignWidth="835.476" Height="391.628"> + Title="Irisu is watching you" d:DataContext="{d:DesignData local:MainContext}" d:DesignWidth="835.476" Height="403.069"> + - + @@ -31,11 +32,12 @@ - - + + + diff --git a/rabi_splitter_WPF/MainWindow.xaml.cs b/rabi_splitter_WPF/MainWindow.xaml.cs index e66e63a..56281ac 100644 --- a/rabi_splitter_WPF/MainWindow.xaml.cs +++ b/rabi_splitter_WPF/MainWindow.xaml.cs @@ -80,11 +80,6 @@ namespace rabi_splitter_WPF { sendigt((float)igt / 60); } - if (igt > 0 && igt < 3600) - { - mainContext.AliusI = true; - mainContext.Noah1Reload = false; - } #endregion @@ -128,90 +123,101 @@ namespace rabi_splitter_WPF DebugLog("new music:" + musicid + ":" + StaticData.MusicNames[musicid]); mainContext.GameMusic = StaticData.MusicNames[musicid]; - var bossmusicflag = StaticData.BossMusics.Contains(musicid); - if (bossmusicflag) + if ((musicid == 45 || musicid == 46 || musicid == 53) && mainContext.AutoReset) + { + //reset + sendreset(); + mainContext.AliusI = true; + mainContext.Noah1Reload = false; + } + + else { - if (mainContext.bossbattle) + var bossmusicflag = StaticData.BossMusics.Contains(musicid); + if (bossmusicflag) { - if (mainContext.Noah1Reload && (mainContext.lastmusicid == 52 || musicid == 52)) + if (mainContext.bossbattle) { - DebugLog("noah 1 reload? ignore"); - } - else - { - if (mainContext.MusicStart || mainContext.MusicEnd) + if (mainContext.Noah1Reload && (mainContext.lastmusicid == 52 || musicid == 52)) { - sendsplit(); - DebugLog("new boss music, split"); - + DebugLog("noah 1 reload? ignore"); } - if (musicid == 37) + else { - mainContext.Noah1Reload = true; - DebugLog("noah1 music start, ignore MR forever"); - } - } + if (mainContext.MusicStart || mainContext.MusicEnd) + { + sendsplit(); + DebugLog("new boss music, split"); - mainContext.lastmusicid = musicid; - return; - } - } - if (!mainContext.bossbattle) - { + } + if (musicid == 37) + { + mainContext.Noah1Reload = true; + DebugLog("noah1 music start, ignore MR forever"); + } + } - if (musicid == 54 && mainContext.AliusI) - { - mainContext.bossbattle = false; - mainContext.AliusI = false; - DebugLog("Alius music, ignore once"); - - } - else if (musicid == 42 && mapid == 1 && mainContext.Irisu1) - { - mainContext.bossbattle = false; - DebugLog("Irisu P1, ignore"); - + mainContext.lastmusicid = musicid; + return; + } } - else + if (!mainContext.bossbattle) { - if (bossmusicflag) + + if (musicid == 54 && mainContext.AliusI) { - if (mapid == 5 && musicid == 44 && mainContext.SideCh) - { - mainContext.bossbattle = false; - DebugLog("sidechapter, ignore"); + mainContext.bossbattle = false; + mainContext.AliusI = false; + DebugLog("Alius music, ignore once"); - } - else + } + else if (musicid == 42 && mapid == 1 && mainContext.Irisu1) + { + mainContext.bossbattle = false; + DebugLog("Irisu P1, ignore"); + + } + else + { + if (bossmusicflag) { - mainContext.bossbattle = true; - mainContext.lastbosslist = new List(); - mainContext.lastnoah3hp = -1; - if (musicid == 37) + if (mapid == 5 && musicid == 44 && mainContext.SideCh) { - mainContext.Noah1Reload = true; - DebugLog("noah1 music start, ignore MR forever"); + mainContext.bossbattle = false; + DebugLog("sidechapter, ignore"); + } - if (mainContext.MusicStart) + else { - sendsplit(); - DebugLog("music start, split"); - + mainContext.bossbattle = true; + mainContext.lastbosslist = new List(); + mainContext.lastnoah3hp = -1; + if (musicid == 37) + { + mainContext.Noah1Reload = true; + DebugLog("noah1 music start, ignore MR forever"); + } + if (mainContext.MusicStart) + { + sendsplit(); + DebugLog("music start, split"); + + } } } } } - } - else - { - if (!bossmusicflag) //boss music end! + else { - mainContext.bossbattle = false; - if (mainContext.MusicEnd) + if (!bossmusicflag) //boss music end! { - sendsplit(); - DebugLog("music end, split"); - + mainContext.bossbattle = false; + if (mainContext.MusicEnd) + { + sendsplit(); + DebugLog("music end, split"); + + } } } } @@ -391,6 +397,22 @@ namespace rabi_splitter_WPF } } + private void sendreset() + { + if (tcpclient != null && tcpclient.Connected) + { + try + { + var b = Encoding.UTF8.GetBytes("reset\r\n"); + networkStream.Write(b, 0, b.Length); + } + catch (Exception) + { + + disconnect(); + } + } + } private void sendigt(float time) { if (tcpclient != null && tcpclient.Connected)