public LaMulanaComponent(LiveSplitState state) { this.state = state; if (timer == null || timer.CurrentState != state) { timer = new TimerModel { CurrentState = state } } ; settings_control = new ComponentSettings(this); state.RunManuallyModified += RunModified; state.OnReset += (sender, arg) => { if (autosplitter != null) { autosplitter.lastsplit = -1; } }; state.OnStart += (sender, arg) => { if (autosplitter != null) { autosplitter.lastsplit = -1; autosplitter.lastsplitat = DateTime.UtcNow; } }; state.OnSkipSplit += (sender, arg) => { if (autosplitter != null) { autosplitter.lastsplitat = DateTime.UtcNow; } }; state.OnSplit += (sender, arg) => { if (autosplitter != null) { autosplitter.lastsplitat = DateTime.UtcNow; } }; RunModified(state, null); } void RunModified(object sender, EventArgs a) { if (state.Run.GameName == "La-Mulana Remake") { autosplitter = remake; } /*else if (state.Run.GameName == "La-Mulana Classic") * autosplitter = classic;*/ else { autosplitter = null; } if (autosplitter != null) { autosplitter.lastsplit = -1; } settings_control.SetSplits(state, remake); }
public void SetSplits(LiveSplitState state, SplitMatcher remakesplitter) { splitnames.Clear(); foreach (ISegment segment in state.Run) { Match m = split_regex.Match(segment.Name); if (!m.Success) { continue; } string splitname = m.Success ? m.Groups[2].Value.Normalize().ToLowerInvariant() : ""; if (!splitnames.Contains(splitname)) { splitnames.Add(splitname); } } SuspendLayout(); splitCondMenu.MenuItems.Clear(); AddSplitConds(splitCondMenu.MenuItems, remakesplitter.splitcats); var listsofsplits = new[] { new { panel = runMappingLayout, splits = splitnames.AsEnumerable() }, new { panel = otherMappingLayout, splits = remakesplitter.splits.Keys.Except(splitnames) } }; foreach (var y in listsofsplits) { y.panel.AutoScroll = false; // If I don't do this, the layout never shrinks. I don't even. y.panel.Controls.Clear(); y.panel.RowStyles.Clear(); if (y.panel == runMappingLayout) { int unmapped = splitnames.Except(remakesplitter.splits.Keys).Count(); if (unmapped > 0) { y.panel.Controls.Add(new Label { Text = String.Format("Warning: {0} unmapped splits", unmapped), Dock = DockStyle.Fill, TextAlign = System.Drawing.ContentAlignment.MiddleCenter }); y.panel.SetColumnSpan(y.panel.Controls[0], 2); y.panel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); } } foreach (string split in y.splits) { TextBox splitbox = new TextBox { Text = split, Dock = DockStyle.Fill, ReadOnly = true }; Button selector; selector = new Button { Text = remakesplitter.splits.ContainsKey(split) ? remakesplitter.displaynames[remakesplitter.splits[split]] : "Unmapped", Tag = split, Dock = DockStyle.Fill, TextAlign = System.Drawing.ContentAlignment.MiddleLeft, }; if (y.panel == runMappingLayout && !remakesplitter.splits.ContainsKey(split)) { selector.BackColor = System.Drawing.Color.PaleVioletRed; } selector.Click += (object sender, EventArgs evargs) => splitCondMenu.Show((Control)sender, new System.Drawing.Point(0, 0)); y.panel.Controls.Add(splitbox); y.panel.Controls.Add(selector); y.panel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); } y.panel.RowCount = y.panel.RowStyles.Count; y.panel.AutoScroll = true; } ResumeLayout(); }