From 52458e06df6605417b83674b0d8c33f5e775a0b2 Mon Sep 17 00:00:00 2001 From: Copy Liu Date: Sun, 26 Feb 2017 00:43:11 +0800 Subject: [PATCH] v0.3 , fix #1 #3 --- rabi_splitter_WPF/MainContext.cs | 63 ++++++++++++++++++- rabi_splitter_WPF/MainWindow.xaml | 57 +++++++++-------- rabi_splitter_WPF/MainWindow.xaml.cs | 94 +++++++++++++++++++--------- 3 files changed, 155 insertions(+), 59 deletions(-) diff --git a/rabi_splitter_WPF/MainContext.cs b/rabi_splitter_WPF/MainContext.cs index 21a4333..c70e4ef 100644 --- a/rabi_splitter_WPF/MainContext.cs +++ b/rabi_splitter_WPF/MainContext.cs @@ -10,10 +10,42 @@ namespace rabi_splitter_WPF { public class BossData:INotifyPropertyChanged { + private int _bossIdx; + private int _bossId; + private int _bossHp; - public int BossIdx { get; set; } - public int BossID { get; set; } - public int BossHP { get; set; } + public int BossIdx + { + get { return _bossIdx; } + set + { + if (value == _bossIdx) return; + _bossIdx = value; + OnPropertyChanged(nameof(BossIdx)); + } + } + + public int BossID + { + get { return _bossId; } + set + { + if (value == _bossId) return; + _bossId = value; + OnPropertyChanged(nameof(BossID)); + } + } + + public int BossHP + { + get { return _bossHp; } + set + { + if (value == _bossHp) return; + _bossHp = value; + OnPropertyChanged(nameof(BossHP)); + } + } public event PropertyChangedEventHandler PropertyChanged; @@ -31,6 +63,18 @@ namespace rabi_splitter_WPF public ObservableCollection BossList = new ObservableCollection(); + public DebugContext() + { + BossList=new ObservableCollection(); + for (int i = 0; i < 50; i++) + { + BossList.Add(new BossData() + { + BossIdx = i + }); + } + } + public bool BossEvent { get { return _bossEvent; } @@ -79,6 +123,17 @@ namespace rabi_splitter_WPF private string _gameMusic; private bool _igt; + public bool Noah1Reload + { + get { return _noah1Reload; } + set + { + if (value == _noah1Reload) return; + _noah1Reload = value; + OnPropertyChanged(nameof(Noah1Reload)); + } + } + public bool MusicStart { get { return _musicStart; } @@ -233,6 +288,7 @@ namespace rabi_splitter_WPF public int lastnoah3hp; public int lastTM; public DateTime LastTMAddTime; + private bool _noah1Reload; public MainContext() { @@ -247,6 +303,7 @@ namespace rabi_splitter_WPF this.DebugArea = false; this.ServerPort = 16834; this.Igt = true; + this.Noah1Reload = false; } diff --git a/rabi_splitter_WPF/MainWindow.xaml b/rabi_splitter_WPF/MainWindow.xaml index 89b05c2..7e3c21d 100644 --- a/rabi_splitter_WPF/MainWindow.xaml +++ b/rabi_splitter_WPF/MainWindow.xaml @@ -4,13 +4,17 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:rabi_splitter_WPF" - mc:Ignorable="d" - Title="Irisu is watching you" d:DataContext="{d:DesignData local:MainContext}" SizeToContent="WidthAndHeight"> + mc:Ignorable="d" SizeToContent="Width" + Title="Irisu is watching you" d:DataContext="{d:DesignData local:MainContext}" d:DesignWidth="835.476" Height="391.628"> - + + + + + @@ -24,37 +28,38 @@ - - - - - - - - + + + + + + + + + - - - - - + + + + + + + + + - - - + + + - - - - - + - + diff --git a/rabi_splitter_WPF/MainWindow.xaml.cs b/rabi_splitter_WPF/MainWindow.xaml.cs index 8dcef21..e66e63a 100644 --- a/rabi_splitter_WPF/MainWindow.xaml.cs +++ b/rabi_splitter_WPF/MainWindow.xaml.cs @@ -80,6 +80,11 @@ namespace rabi_splitter_WPF { sendigt((float)igt / 60); } + if (igt > 0 && igt < 3600) + { + mainContext.AliusI = true; + mainContext.Noah1Reload = false; + } #endregion @@ -128,13 +133,25 @@ namespace rabi_splitter_WPF { if (mainContext.bossbattle) { - //直接换boss曲 - if (mainContext.MusicStart || mainContext.MusicEnd) + if (mainContext.Noah1Reload && (mainContext.lastmusicid == 52 || musicid == 52)) { - sendsplit(); - DebugLog("new boss music, split"); + DebugLog("noah 1 reload? ignore"); + } + else + { + if (mainContext.MusicStart || mainContext.MusicEnd) + { + sendsplit(); + DebugLog("new boss music, split"); + + } + if (musicid == 37) + { + mainContext.Noah1Reload = true; + DebugLog("noah1 music start, ignore MR forever"); + } } - debugContext.BossEvent = true; + mainContext.lastmusicid = musicid; return; } @@ -145,15 +162,13 @@ namespace rabi_splitter_WPF if (musicid == 54 && mainContext.AliusI) { mainContext.bossbattle = false; - debugContext.BossEvent = false; mainContext.AliusI = false; DebugLog("Alius music, ignore once"); } - if (musicid == 42 && mapid == 1 && mainContext.Irisu1) + else if (musicid == 42 && mapid == 1 && mainContext.Irisu1) { mainContext.bossbattle = false; - debugContext.BossEvent = false; DebugLog("Irisu P1, ignore"); } @@ -164,20 +179,24 @@ namespace rabi_splitter_WPF if (mapid == 5 && musicid == 44 && mainContext.SideCh) { mainContext.bossbattle = false; - debugContext.BossEvent = false; DebugLog("sidechapter, ignore"); } else { mainContext.bossbattle = true; - debugContext.BossEvent = 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"); + } } } @@ -192,6 +211,7 @@ namespace rabi_splitter_WPF { sendsplit(); DebugLog("music end, split"); + } } } @@ -236,7 +256,7 @@ namespace rabi_splitter_WPF } } - if (mainContext.MiruDe) + if (mainContext.MiruDe && mapid==8) { foreach (var boss in mainContext.lastbosslist) { @@ -319,32 +339,22 @@ namespace rabi_splitter_WPF if (mainContext.DebugArea) { int ptr = MemoryHelper.GetMemoryValue(process, StaticData.EnenyPtrAddr[mainContext.veridx]); -// List bosses = new List(); -// List HPS = new List(); - debugContext.BossList.Clear(); + // List bosses = new List(); + // List HPS = new List(); +// this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => debugContext.BossList.Clear())); // ptr += StaticData.EnenyEntitySize[mainContext.veridx] * 3; for (var i = 0; i < 50; i++) { ptr += StaticData.EnenyEntitySize[mainContext.veridx]; + debugContext.BossList[i].BossID = MemoryHelper.GetMemoryValue(process, + ptr + StaticData.EnenyEnitiyIDOffset[mainContext.veridx], false); + debugContext.BossList[i].BossHP = MemoryHelper.GetMemoryValue(process, + ptr + StaticData.EnenyEnitiyHPOffset[mainContext.veridx], false); - debugContext.BossList.Add(new BossData() - { - BossIdx = i, - BossID = MemoryHelper.GetMemoryValue(process, - ptr + StaticData.EnenyEnitiyIDOffset[mainContext.veridx], false), - BossHP = MemoryHelper.GetMemoryValue(process, - ptr + StaticData.EnenyEnitiyHPOffset[mainContext.veridx], false) - }); - -// this.Invoke(new Action(() => -// { -// t1.Text = string.Join("\n", bosses); -// t2.Text = string.Join("\n", HPS); -// })); - } + } debugContext.BossEvent = mainContext.bossbattle; } @@ -415,11 +425,21 @@ namespace rabi_splitter_WPF debugContext=new DebugContext(); this.DataContext = mainContext; DebugPanel.DataContext = debugContext; + this.Grid.ItemsSource = debugContext.BossList; + BossEventDebug.DataContext = debugContext; memoryThread = new Thread(() => { while (true) { - ReadMemory(); + try + { + ReadMemory(); + } + catch (Exception e) + { + DebugLog(e.ToString()); + } + Thread.Sleep(1000 / 60); } @@ -453,5 +473,19 @@ namespace rabi_splitter_WPF { Process.Start("https://github.com/copyliu/rabiribi_splitter"); } + + private void CheckBox_Click(object sender, RoutedEventArgs e) + { + + } + + private void TextBox_TextChanged(object sender, TextChangedEventArgs e) + { + var s = sender as TextBox; + if (s != null) + { + s.ScrollToEnd(); + } + } } }