void InitializeToolTab() { btnAddAddr.Text = btnRemoveAddr.Text = btnMoveDownAddr.Text = btnMoveUpAddr.Text = string.Empty; btnAddAddr.BackgroundImage = Resources.Add; btnRemoveAddr.BackgroundImage = Resources.Remove; btnMoveUpAddr.BackgroundImage = Resources.UpArrow; btnMoveDownAddr.BackgroundImage = Resources.DownArrow; foreach (var btn in tlpListBtn.Controls.OfType <Button>()) { btn.FlatAppearance.MouseOverBackColor = Color.LightGray; btn.FlatAppearance.MouseDownBackColor = SystemColors.ControlLight; } _runningTools = new List <ApplicationContext>(); var data = new SkyrimData(); _addrHiddenFromRamWatch = new HashSet <string>() { data.Location.Name, }; var ramWatchAddresses = new BindingList <MemoryWatcher>() { data.WorldID, data.CellX, data.CellY }; ramWatchAddresses.ListChanged += RamWatchAddresses_ListChanged; lstAddresses.DataSource = ramWatchAddresses; lstAddresses.DisplayMember = "Name"; lstAddresses.SelectedIndex = -1; }
public SkyrimSettings(SkyrimComponent component, LiveSplitState state) { InitializeComponent(); _component = component; _state = state; _uiThread = SynchronizationContext.Current; PRESETS_FILE_PATH = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + PRESETS_FILE_NAME; // defaults AutoStart = DEFAULT_AUTOSTART; AutoReset = DEFAULT_AUTORESET; AutoUpdatePresets = DEFAULT_AUTOUPDATEPRESETS; CustomAutosplits = new AutoSplitList(DEFAULT_PRESET_NAME); AutoSplitList = new AutoSplitList(); Presets = new BindingList <AutoSplitList>() { CustomAutosplits }; var addr = new SkyrimData(); _hiddenAddresses = new HashSet <string>() { addr.IsQuickSaving.Name, addr.Location.Name, addr.WorldID.Name, addr.CellX.Name, addr.CellY.Name }; _autoSplitEnv = new AutoSplitEnv() { Addresses = addr.Where(w => !_hiddenAddresses.Contains(w.Name)), Events = GameEvent.GetValues(typeof(SkyrimEvent)), Presets = Presets.Except(new AutoSplitList[] { CustomAutosplits }), DefaultVariableType = typeof(AutoSplitData.Variables.LoadScreen) }; if (File.Exists(PRESETS_FILE_PATH)) { LoadPresets(); } Preset = DEFAULT_PRESET_NAME; BearCartPBNotification = DEFAULT_BEARCARTPBNOTIFICATION; PlayBearCartSound = DEFAULT_PLAYBEARCARTSOUND; BearCartSoundPath = string.Empty; IsBearCartSecret = true; PlayBearCartSoundOnlyOnPB = DEFAULT_PLAYBEARCARTSOUNDONLYONPB; LoadBearCartConfig(); InitializeFormLogic(); InitializeToolTab(); }
void btnLaunchRamWatch_Click(object sender, EventArgs e) { btnLaunchRamWatch.Enabled = false; LaunchTool <RamWatch>(form => form.Invoke((MethodInvoker) delegate() { form.Disposed += (s, ee) => _uiThread.Send(d => btnLaunchRamWatch.Enabled = true, null); var data = new SkyrimData(); form.CustomFormatting.Add(nameof(data.WorldID), value => (value == null) ? null : ((int)value).ToString("X8")); form.AddAddresses((IEnumerable <MemoryWatcher>)lstAddresses.DataSource); form.Attach(_component.AutoSplitManager); })); }
void btnAddAddr_Click(object sender, EventArgs e) { var cmsAddAddr = new ContextMenuStrip(); cmsAddAddr.MaximumSize = new Size(0, 450); var list = (BindingList <MemoryWatcher>)lstAddresses.DataSource; var addresses = new SkyrimData() .Where(w => !_addrHiddenFromRamWatch.Contains(w.Name) && !list.Any(x => x.Name == w.Name)) .OrderBy(x => x.Name); foreach (var watcher in addresses) { cmsAddAddr.Items.Add(watcher.Name, null, (s, ee) => list.Add(watcher)); } cmsAddAddr.Show(btnAddAddr, new Point(0, 0)); }
void MemoryReadThread(object obj) { Trace.WriteLine("[NoLoads] MemoryReadThread"); while (!_cancelSource.IsCancellationRequested) { try { Trace.WriteLine("[NoLoads] Waiting for TESV.exe..."); Process game; while ((game = GetGameProcess()) == null) { Thread.Sleep(250); if (_cancelSource.IsCancellationRequested) { return; } } Trace.WriteLine("[NoLoads] Got TESV.exe!"); _data = new SkyrimData(); uint?frameCountAtLoadScreenEnd = null; while (!game.HasExited) { _data.UpdateAll(game); if (_data.IsLoading.Changed) { if (_data.IsLoading.Current) { Trace.WriteLine($"[NoLoads] Load Start - {_data.FrameCounter}"); FireEvent(OnLoadStarted); } else { Trace.WriteLine($"[NoLoads] Load End - {_data.FrameCounter}"); if (!_data.LoadScreenFadeoutStarted && !_data.IsLoadingScreen.Old) { if (_data.QuickLoadFadeoutStarted) { Debug.WriteLine($"[NoLoads] Quickload - {_data.FrameCounter}"); AutoSplitManager.Update(_data, SkyrimEvent.QuickLoad); } else { Debug.WriteLine($"[NoLoads] Quicksave - {_data.FrameCounter}"); AutoSplitManager.Update(_data, SkyrimEvent.QuickSave); } } FireEvent(OnLoadFinished); } } if (_data.IsLoadingScreen.Changed) { if (_data.IsLoadingScreen.Current) { Trace.WriteLine($"[NoLoads] LoadScreen Start at {_data.WorldID.Current.ToString("X8")} X: {_data.CellX.Current} Y: {_data.CellY.Current} - {_data.FrameCounter}"); _data.LoadingScreenStarted = true; _data.LoadScreenStartLocation = _data.Location.Current; _data.LoadScreenFadeoutStarted = _data.IsInFadeOut.Current; _data.IsLoadingSaveFromMenu = _data.IsInEscapeMenu.Current; frameCountAtLoadScreenEnd = null; // if it isn't a loadscreen from loading a save if (!_data.IsLoadingSaveFromMenu) { _data.IsWaitingLocationIDUpdate = true; AutoSplitManager.Update(_data, SkyrimEvent.LoadScreenStart); } else { _data.IsWaitingLocationIDUpdate = false; } } else { Trace.WriteLine($"[NoLoads] LoadScreen End at {_data.WorldID.Current.ToString("X8")} X: {_data.CellX.Current} Y: {_data.CellY.Current} - {_data.FrameCounter}"); _data.LoadingScreenStarted = false; _data.IsLoadingSaveFromMenu = false; frameCountAtLoadScreenEnd = _data.FrameCounter; AutoSplitManager.Update(_data, SkyrimEvent.LoadScreenLoadEnd); } } if (_data.IsInFadeOut.Changed) { if (_data.IsInFadeOut.Current) { Debug.WriteLine($"[NoLoads] Fadeout started - {_data.FrameCounter}"); if (_data.IsLoadingScreen.Current) { _data.LoadScreenFadeoutStarted = true; } else if (_data.IsQuickSaving.Current) { _data.QuickLoadFadeoutStarted = true; } } else { Debug.WriteLine($"[NoLoads] Fadeout ended - {_data.FrameCounter}"); // if loadscreen fadeout finishes in helgen if (_data.IsInFadeOut.Old && _data.LoadScreenFadeoutStarted && _data.WorldID.Current == (int)Worlds.Tamriel && _data.Position.Current.DistanceXY(SkyrimData.StartPosition) <= 200) { // start and reset Trace.WriteLine($"[NoLoads] Reset and Start - {_data.FrameCounter}"); FireEvent(OnStartSaveLoad); } _data.LoadScreenFadeoutStarted = false; _data.QuickLoadFadeoutStarted = false; } } //sometimes the locationID changes a few frames after the end of the loadscreen, wait 2 frames max to trigger the event if (_data.IsWaitingLocationIDUpdate && (_data.WorldID.Changed || (frameCountAtLoadScreenEnd != null && _data.FrameCounter - frameCountAtLoadScreenEnd >= 2))) { _data.IsWaitingLocationIDUpdate = false; if (_data.WorldID.Current == (int)Worlds.SkyHavenTemple) { _data.IsSkyHavenTempleVisited.Current = true; } // if loadscreen starts while leaving the Sleeping Giant Inn and ends in front of its door if (_data.LoadScreenStartLocation.ID == (int)Worlds.RiverwoodSleepingGiantInn && _data.Location.Current == new Location((int)Worlds.Tamriel, 5, -11)) { _data.LeaveSleepingGiantInnCounter.Current++; } AutoSplitManager.Update(_data, SkyrimEvent.LoadScreenEnd); } if (_data.WorldID.Current == (int)Worlds.HelgenKeep01 && _data.BearCartHealth.Current < 0 && _data.BearCartHealth.Old >= 0 && _data.FrameCounter > 1) { Debug.WriteLine($"[NoLoads] BEAR CART! HP: {_data.BearCartHealth.Current} - {_data.FrameCounter}"); FireEvent(OnBearCart); } if (!_data.IsAlduin1Defeated.Current && _data.Alduin1Health.Current < 0) { Debug.WriteLine($"[NoLoads] Alduin 1 has been defeated - {_data.FrameCounter}"); _data.IsAlduin1Defeated.Current = true; } // the only mainquest you can complete here is the council if (_data.MainQuestsCompleted.Current == _data.MainQuestsCompleted.Old + 1 && _data.WorldID.Current == (int)Worlds.HighHrothgar) { _data.IsCouncilDone.Current = true; } // reset lastQuest 100 frames (1.5 seconds) after a completion to avoid splitting on a wrong questline. if (_data.FrameCounter >= _data.LastQuestframeCounter + 100 && _data.LastQuestCompleted != Questlines.None) { _data.LastQuestCompleted = Questlines.None; } if (_data.CollegeOfWinterholdQuestsCompleted.Current > _data.CollegeOfWinterholdQuestsCompleted.Old) { Debug.WriteLine($"[NoLoads] A College of Winterhold quest has been completed - {_data.FrameCounter}"); _data.LastQuestCompleted = Questlines.CollegeOfWinterhold; _data.LastQuestframeCounter = _data.FrameCounter; } else if (_data.CompanionsQuestsCompleted.Current > _data.CompanionsQuestsCompleted.Old) { Debug.WriteLine($"[NoLoads] A Companions quest has been completed - {_data.FrameCounter}"); _data.LastQuestCompleted = Questlines.Companions; _data.LastQuestframeCounter = _data.FrameCounter; } else if (_data.DarkBrotherhoodQuestsCompleted.Current > _data.DarkBrotherhoodQuestsCompleted.Old) { Debug.WriteLine($"[NoLoads] A Dark Brotherhood quest has been completed - {_data.FrameCounter}"); _data.LastQuestCompleted = Questlines.DarkBrotherhood; _data.LastQuestframeCounter = _data.FrameCounter; } else if (_data.ThievesGuildQuestsCompleted.Current > _data.ThievesGuildQuestsCompleted.Old) { Debug.WriteLine($"[NoLoads] A Thieves' Guild quest has been completed - {_data.FrameCounter}"); _data.LastQuestCompleted = Questlines.ThievesGuild; _data.LastQuestframeCounter = _data.FrameCounter; } AutoSplitManager.Update(_data, GameEvent.Always); Debug.WriteLineIf(_data.MiscObjectivesCompleted.Changed, $"[NoLoads] MiscObjectivesCompleted changed from {_data.MiscObjectivesCompleted.Old} to {_data.MiscObjectivesCompleted.Current} - {_data.FrameCounter}"); Debug.WriteLineIf(_data.WorldID.Changed, $"[NoLoads] Location changed to {_data.WorldID.Current.ToString("X8")} - {_data.FrameCounter}"); Debug.WriteLineIf(_data.CellX.Changed || _data.CellY.Changed, $"[NoLoads] Coords changed to X: {_data.CellX.Current} Y: {_data.CellY.Current} - {_data.FrameCounter}"); Debug.WriteLineIf(_data.IsInEscapeMenu.Changed, $"[NoLoads] isInEscapeMenu changed to {_data.IsInEscapeMenu.Current} - {_data.FrameCounter}"); _data.FrameCounter++; Thread.Sleep(15); if (_cancelSource.IsCancellationRequested) { return; } } //pause time when game crashes or closes FireEvent(OnLoadStarted); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); Thread.Sleep(1000); } } }
internal static void ShowEditor(SkyrimData skyrimData, GameEvent[] gameEvent, object autoSplitList) { throw new NotImplementedException(); }