public VariableEditorPicker(AutoSplitEnv env, Variable variable = null) { InitializeComponent(); _env = env; EditedVariable = variable?.Clone(_env); var dictionary = env.VariableTypes.Keys .Except(env.HiddenVariables) .Where(t => env.VariableTypes[t] != null) .ToDictionary(t => { var tName = t.Name; if (tName.Contains("`")) { tName = tName.Remove(tName.IndexOf("`")); } return(tName); }); cbVarTypes.DataSource = new BindingSource(dictionary.OrderBy(p => p.Key), null); cbVarTypes.DisplayMember = "Key"; cbVarTypes.ValueMember = "Value"; cbVarTypes.SelectedValueChanged += cbVarTypes_SelectedValueChanged; cbVarTypes.SelectedItem = dictionary.First(p => p.Value == env.DefaultVariableType); }
public static Variable FromXml(XmlElement elem, AutoSplitEnv env) { var typeStr = elem.GetAttribute("type"); var type = DeserializeType(typeStr, env); return((Variable)Activator.CreateInstance(type, elem)); }
static Type DeserializeType(string str, AutoSplitEnv env) { str = RemoveNamespace(str); var genericTypeStr = str; Type[] genericParams = null; if (str.IndexOf('`') != -1) { var startIndex = str.IndexOf("[[") + 2; var endIndex = str.LastIndexOf("]]") - 1; var paramsStr = str.Substring(startIndex, endIndex - startIndex); genericParams = paramsStr.Split(new string[] { "],[" }, StringSplitOptions.RemoveEmptyEntries) .Select(s => Type.GetType(s)).ToArray(); genericTypeStr = str.Substring(0, str.IndexOf("[[")); } var type = env.VariableTypes.Keys.FirstOrDefault(t => t.Name == genericTypeStr); if (genericParams != null) { type = type.MakeGenericType(genericParams); } return(type); }
public AutoSplitEditor(AutoSplitEnv env, AutoSplit source = null) { InitializeComponent(); MaximumSize = new Size(Size.Width, Screen.AllScreens.Max(s => s.WorkingArea.Height)); btnAdd.Text = btnRemove.Text = string.Empty; btnAdd.BackgroundImage = Resources.Add; btnRemove.BackgroundImage = Resources.Remove; foreach (var btn in tlpListBtn.Controls.OfType <Button>()) { btn.FlatAppearance.MouseOverBackColor = Color.LightGray; btn.FlatAppearance.MouseDownBackColor = SystemColors.ControlLight; } lstVariables.Height = 0; //hack to fix the control not filling its parent properly _env = env; EditedAutoSplit = source?.Clone(_env) ?? new AutoSplit(); txtName.DataBindings.Add("Text", EditedAutoSplit, "Name"); RefreshEvents(); cbEvent.DataBindings.Add("SelectedItem", EditedAutoSplit, "Event"); lstVariables.Format += (s, e) => e.Value = $"{((Variable)e.ListItem).ToString(_env)}"; lstVariables.DataSource = new BindingList <Variable>(EditedAutoSplit.Variables); lstVariables.SelectedIndex = -1; #if DEBUG label2.Visible = cbEvent.Visible = true; #endif }
public static AutoSplit ShowEditor(AutoSplitEnv env, AutoSplit source = null) { using (var form = new AutoSplitEditor(env, source)) { return(form.ShowDialog() != DialogResult.Cancel ? form.EditedAutoSplit : source); } }
public static Variable ShowEditor(AutoSplitEnv env) { using (var form = new VariableEditorPicker(env)) { return(form.ShowDialog() != DialogResult.Cancel ? form.EditedVariable : null); } }
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(); }
public static Variable ShowEditor(AutoSplitEnv env, Type type, Variable source = null) { using (var form = new VariableEditor(env, type, source)) { if (form.ShowDialog() != DialogResult.Cancel) { return(form.EditedVariable); } } return(source); }
public static IEnumerable <Variable> VariablesFromXml(XmlElement elem, AutoSplitEnv env) { var vars = new List <Variable>(); foreach (XmlElement child in elem.ChildNodes) { vars.Add(FromXml(child, env)); } return(vars); }
public LoadScreenEditor(AutoSplitEnv env, LoadScreen source) : base(env, source) { InitializeComponent(); if (source != null) { locationStart.Value = source.StartLocation; locationEnd.Value = source.EndLocation; locationStart.ValueEquals = source.EqualsStartLocation; locationEnd.ValueEquals = source.EqualsEndLocation; } }
public static Variable[] Clone(this IEnumerable <Variable> vars, AutoSplitEnv env) { var source = vars.ToArray(); var clone = new Variable[source.Length]; for (int i = 0; i < source.Length; i++) { clone[i] = source[i].Clone(env); } return(clone); }
public ActionEditor(AutoSplitEnv env, Action source) : base(env, source) { InitializeComponent(); var events = env.Events.Select(e => GameEvent.GetOriginal(env.GameEventTypes, e) ?? e) .Where(e => e != GameEvent.Always && !e.Hidden) .OrderBy(e => e) .ToList(); Value = (Action)source?.Clone(env) ?? new Action(events.Min()); cbEvent.DataSource = events; cbEvent.DataBindings.Add("SelectedItem", Value, nameof(Value.Value)); }
public LocationValueEditor(AutoSplitEnv env, LocationValue source = null) : base(env, source) { InitializeComponent(); _env = env; cbAddresses.Text = "Location"; if (source != null) { locationValueControl1.Value = source.Value; locationValueControl1.ValueEquals = source.ValueEquals; chkOnChange.Checked = source.OnValueChanged; } }
public MemoryValueEditor(AutoSplitEnv env, MemoryValue source = null) : base(env, source) { InitializeComponent(); _env = env; cbAddresses.DataSource = _env.Addresses.Where(w => IsSupportedMemoryWatcher(w)).OrderBy(w => w.Name).ToList(); cbAddresses.SelectionChangeCommitted += (s, e) => ChangeAddress((MemoryWatcher)cbAddresses.SelectedItem); if (source != null) { var addr = _env.Addresses.FirstOrDefault(m => m.Name == source.MemoryWatcherName); if (addr != null) { cbAddresses.SelectedItem = addr; } else { MessageBox.Show($"The address \"{source.MemoryWatcherName}\" does not exist.\nPlease choose another one.", "Address not found", MessageBoxButtons.OK, MessageBoxIcon.Error); } } ChangeAddress((MemoryWatcher)cbAddresses.SelectedItem); if (source != null) { if (cbValue.DropDownStyle == ComboBoxStyle.DropDownList) { cbValue.SelectedItem = source.Value; } else { var value = source.Value as IFormattable; cbValue.Text = value.ToString(null, CultureInfo.InvariantCulture); } cbComparison.SelectedItem = source.Comparison; chkOnChange.Checked = source.OnValueChanged; if (source is StringValue) { var stringValue = (StringValue)source; chkIgnoreCase.Checked = stringValue.IgnoreCase; chkContains.Checked = stringValue.IsContained; } } }
public static AutoSplitList ShowEditor(AutoSplitEnv env, AutoSplitList list = null) { using (var form = new AutoSplitListEditor(env, list)) { if (form.ShowDialog() != DialogResult.Cancel) { if (list == null) { return(form.EditedList); } list.Clear(); list.AddRange(form.EditedList); } return(list); } }
public VariableEditor(AutoSplitEnv env, Type varType, Variable source) { InitializeComponent(); _env = env; EditedVariable = source?.Clone(env); var typeName = varType.Name.IndexOf("`") != -1 ? varType.Name.Remove(varType.Name.IndexOf("`")) : varType.Name; Text = typeName + " Editor"; _editor = (VariableControl)Activator.CreateInstance(_env.GetEditor(varType), env, source); _editor.Dock = DockStyle.Fill; _editor.Margin = new Padding(_editor.Margin.Left, _editor.Margin.Top, _editor.Margin.Right, 0); _editor.TabIndex = 0; tlpMain.Controls.Add(_editor); tlpMain.SetRow(_editor, 0); tlpMain.SetColumn(_editor, 0); }
public AutoSplitListEditor(AutoSplitEnv env, AutoSplitList list = null) { InitializeComponent(); FormClosing += (s, e) => { if (e.CloseReason != CloseReason.None) { DialogResult = DialogResult.OK; } }; _env = env; EditedList = list?.Clone(env) ?? new AutoSplitList(); dgvList.AutoGenerateColumns = false; dgvList.DataBindingComplete += DgvList_DataBindingComplete; dgvList.CellMouseDown += DgvList_CellMouseDown; dgvList.DataSource = new BindingList <AutoSplit>(EditedList); _cmsSplitRow = new ContextMenuStrip(); _cmsSplitRow.Items.Add("Edit...", null, (s, e) => EditSelectedRow()); _cmsSplitRow.Items.Add("-"); _cmsSplitRow.Items.Add("Move up", null, (s, e) => DgvList_SelectRow(DgvList_MoveRow(dgvList.SelectedRows[0], -1))); _cmsSplitRow.Items.Add("Move down", null, (s, e) => DgvList_SelectRow(DgvList_MoveRow(dgvList.SelectedRows[0], 1))); _cmsSplitRow.Items.Add("-"); _cmsSplitRow.Items.Add("Remove", null, (s, e) => DgvList_RemoveSelectedRow()); btnEdit.Click += (s, e) => EditSelectedRow(); btnMoveUp.Click += (s, e) => DgvList_SelectRow(DgvList_MoveRow(dgvList.SelectedRows[0], -1)); btnMoveDown.Click += (s, e) => DgvList_SelectRow(DgvList_MoveRow(dgvList.SelectedRows[0], 1)); btnRemove.Click += (s, e) => DgvList_RemoveSelectedRow(); _cmsAddFromPreset = new ContextMenuStrip(); PopulateAddFromPresetCM(_env.Presets); btnAddFromPreset.Click += BtnAddFromPreset_Click; }
public static Variable ShowEditor(AutoSplitEnv env, Variable source) => ShowEditor(env, source.GetType(), source);
public VariableControl(AutoSplitEnv env, Variable source) { Value = source?.Clone(env); }
public virtual string ToString(AutoSplitEnv env) => ToString();
/// <summary> /// Returns a deep copy of the current <see cref="Variable"/>. /// </summary> public virtual Variable Clone(AutoSplitEnv env) => FromXml(ToXml(new XmlDocument()), env);
public override string ToString(AutoSplitEnv env) => $"{nameof(Action)} -> {GameEvent.GetOriginal(env.GameEventTypes, Value)?.Name ?? Value.InternalValue.ToString()}";