private string GetCurrentSplit(LogicManager logic, SplitterSettings settings)
 {
     if (logic.CurrentSplit >= settings.Autosplits.Count)
     {
         return("N/A");
     }
     return(settings.Autosplits[logic.CurrentSplit].ToString());
 }
 public UserSettings(LiveSplitState state, LogManager log)
 {
     InitializeComponent();
     Settings = new SplitterSettings();
     State    = state;
     Log      = log;
     Dock     = DockStyle.Fill;
 }
        public void Update(LogicManager logic, SplitterSettings settings)
        {
            if (!EnableLogging)
            {
                return;
            }

            lock (currentValues) {
                DateTime date      = DateTime.Now;
                IntPtr   savedGame = logic.Memory.SavedGame();
                bool     updateLog = savedGame != IntPtr.Zero;

                foreach (LogObject key in Enum.GetValues(typeof(LogObject)))
                {
                    string previous = currentValues[key];
                    string current  = null;

                    switch (key)
                    {
                    case LogObject.CurrentSplit: current = $"{logic.CurrentSplit} ({GetCurrentSplit(logic, settings)})"; break;

                    case LogObject.Pointers: current = logic.Memory.GamePointers(); break;

                    case LogObject.Version: current = MemoryManager.Version.ToString(); break;

                    case LogObject.Loading: current = logic.Memory.IsLoading().ToString(); break;

                    case LogObject.Scene: current = logic.Memory.SceneName(); break;

                    case LogObject.SavedGame: current = savedGame.ToString("X"); break;

                    case LogObject.TotalTime: current = updateLog ? logic.Memory.TotalPlayTime().ToString() : previous; break;

                    case LogObject.SceneType: current = logic.Memory.GameSceneType().ToString(); break;

                    case LogObject.Quests: if (updateLog)
                        {
                            CheckItems <Quest>(key, currentQuests, logic.Memory.Quests());
                        }
                        break;

                    case LogObject.Chests: if (updateLog)
                        {
                            CheckItems <GuidItem>(key, currentChests, logic.Memory.Chests());
                        }
                        break;

                    case LogObject.Spells: if (updateLog)
                        {
                            CheckItems <Spell>(key, currentSpells, logic.Memory.Spells());
                        }
                        break;

                    case LogObject.Keys: if (updateLog)
                        {
                            CheckItems <GuidItem>(key, currentKeys, logic.Memory.Keys());
                        }
                        break;

                    case LogObject.Equipment: if (updateLog)
                        {
                            CheckItems <Equipment>(key, currentEquipment, logic.Memory.Equipment());
                        }
                        break;

                    case LogObject.Gold: current = updateLog ? logic.Memory.Gold().ToString() : previous; break;

                    case LogObject.Level: current = updateLog ? logic.Memory.Level().ToString() : previous; break;

                    case LogObject.Experience: current = updateLog ? logic.Memory.Experience().ToString() : previous; break;

                    case LogObject.Dungeons: current = updateLog ? logic.Memory.DungeonsCleared().ToString() : previous; break;

                    case LogObject.RoyalArts: current = updateLog ? logic.Memory.PlayerRoyalArts().ToString() : previous; break;

                    case LogObject.FinalQuest: current = updateLog ? logic.Memory.FinalQuestCompleted().ToString() : previous; break;

                    case LogObject.Catnap: current = updateLog ? logic.Memory.Catnap().ToString() : previous; break;
                    }

                    if (previous != current)
                    {
                        AddEntryUnlocked(new ValueLogEntry(date, key, previous, current));
                        currentValues[key] = current;
                    }
                }
            }
        }