/// <summary> /// Loads settings from the given XML node. /// </summary> public void LoadSettings(XmlNode node) { XmlElement splitsElement = node["Splits"]; XmlNodeList splitNodes = splitsElement.GetElementsByTagName("Split"); Split[] splits = new Split[splitNodes.Count]; for (int i = 0; i < splitNodes.Count; i++) { XmlNode splitElement = splitNodes[i]; SplitTypes type = (SplitTypes)Enum.Parse(typeof(SplitTypes), splitElement.Attributes[0].InnerText); string data = splitElement.Attributes[1].InnerText; splits[i] = new Split(type, data); } DisplayEnabled = bool.Parse(node["DisplayEnabled"].InnerText); var matchElement = node["MatchFileTime"]; // This null check protects again versioning differences (since the option to match file time was added // roughly two years after the original autosplitter release). if (matchElement != null) { MatchFileTime = bool.Parse(matchElement.InnerText); } settingsControl.DeathCheckbox = DisplayEnabled; settingsControl.FileTimeCheckbox = MatchFileTime; // Setting splits on the collection control also updates the split collection. collectionControl.SetSplits(splits); }
/// <summary> /// Parses the given string data based on split type. /// </summary> private object ParseData(SplitTypes type, string data) { switch (type) { case SplitTypes.BodyPart: return(ParseEnum <BodyParts>(data)); case SplitTypes.CartridgeCount: case SplitTypes.TumorCount: case SplitTypes.FutureCompletion: return(int.Parse(data)); case SplitTypes.CartridgeCompletion: return(ParseEnum <Cartridges>(data)); case SplitTypes.Level: string[] tokens = data.Split(','); int x = int.Parse(tokens[0]); int y = int.Parse(tokens[1]); return(new Point(x, y)); case SplitTypes.WorldEvent: return(ParseEnum <WorldEvents>(data)); case SplitTypes.Zone: return(ParseEnum <Zones>(data)); } return(null); }
public Split(SplitTypes type, int[] data) { Type = type; Data = data; // A split is considered valid if all dropdowns have valid values (or the split is manual/quitout). Note // that disabled dropdowns have their index stored as int.MaxValue rather than -1 (in order to keep the // simple rule that -1 always means unfinished). IsFinished = type == SplitTypes.Manual || type == SplitTypes.Quitout || (data != null && data.All(d => d >= 0)); }
/// <summary> /// Parses split data based on the given data. /// </summary> private object ParseData(SplitTypes splitType) { int dataIndex = splitDataComboBox.SelectedIndex; if (IsEnumeratedType(splitType) && dataIndex == -1) { return(null); } switch (splitType) { case SplitTypes.BodyPart: return((BodyParts)dataIndex); case SplitTypes.CartridgeCompletion: return((Cartridges)dataIndex); case SplitTypes.CartridgeCount: case SplitTypes.TumorCount: int result; if (int.TryParse(dataCountTextbox.Text, out result)) { return(result); } return(null); case SplitTypes.FutureCompletion: return(dataIndex); case SplitTypes.Level: int x; int y; if (int.TryParse(xTextbox.Text, out x) && int.TryParse(yTextbox.Text, out y)) { return(new Point(x, y)); } return(null); case SplitTypes.WorldEvent: return((WorldEvents)dataIndex); case SplitTypes.Zone: return((Zones)dataIndex); } return(null); }
/// <summary> /// Runs indexer /// </summary> private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { IsIndexingInProgress = true; UpdateCanStartIndexing(); IndexerConfiguration.SplitterSetting splitterSetting = new IndexerConfiguration.SplitterSetting() { UseDefaultSplitterOfType = ApplyBestSuffixSplit ? SplitterType.Advance : (ApplyCamelCaseSplit ? SplitterType.CamelCase : SplitterType.None), }; IndexerConfiguration.DictionarySetting dictionarySetting = new IndexerConfiguration.DictionarySetting() { DefaultDictionaryRemoveEnglishStopWord = RemoveEnglishStopWords, DefaultDictionaryRemoveProgrammingStopWord = RemoveProgrammingStopWords }; IndexerConfiguration.TextCorrectorSetting textCorrectorSetting = new IndexerConfiguration. TextCorrectorSetting() { UseDefaultSpellChecker = ApplySpellCheck }; ExtractType extractType = 0; SplitTypes.Where(x => x.IsSelected).ToList().ForEach(x => extractType |= x.Value); IndexerConfiguration.TextExtractorSetting textExtractorSetting = new IndexerConfiguration. TextExtractorSetting() { ExtractType = extractType }; IStemmer stemmer = ApplyLemmatizer ? _stanfordLemmatizer : null; IndexerConfiguration.StemmerSetting stemmerSetting = new IndexerConfiguration.StemmerSetting() { CustomStemmer = stemmer, UseDefaultPorterStemmer = ApplyStemmer }; List <IndexerFile> selectedFiles = SelectedFiles.ToList(); IndexerConfiguration indexerConfiguration = IndexerConfiguration.GetIndexerConfiguration(splitterSetting, dictionarySetting, textExtractorSetting, textCorrectorSetting, stemmerSetting, selectedFiles, this); Indexer indexer = new Indexer(indexerConfiguration); e.Result = indexer.Execute(); }
/// <summary> /// Saves settings in an XML node. /// </summary> public XmlNode SaveSettings(XmlDocument document) { XmlElement settingsElement = document.CreateElement("Settings"); XmlElement splitsElement = document.CreateElement("Splits"); foreach (Split split in splitCollection.Splits) { SplitTypes type = split.Type; string data; if (type == SplitTypes.Level) { Point point = (Point)split.Data; data = point.X + "," + point.Y; } else { data = split.Data.ToString(); } XmlAttribute splitType = document.CreateAttribute("Type"); splitType.InnerText = type.ToString(); XmlAttribute splitData = document.CreateAttribute("Data"); splitData.InnerText = data; XmlElement splitElement = document.CreateElement("Split"); splitElement.Attributes.Append(splitType); splitElement.Attributes.Append(splitData); splitsElement.AppendChild(splitElement); } XmlElement displayElement = document.CreateElement("DisplayEnabled"); displayElement.InnerText = DisplayEnabled.ToString(); XmlElement fileTimeElement = document.CreateElement("MatchFileTime"); fileTimeElement.InnerText = MatchFileTime.ToString(); settingsElement.AppendChild(displayElement); settingsElement.AppendChild(fileTimeElement); settingsElement.AppendChild(splitsElement); return(settingsElement); }
public void Refresh(Split split) { SplitTypes type = split.Type; if (type == SplitTypes.Unassigned) { return; } splitTypeComboBox.SelectedIndex = (int)type; var controls = splitDetailsPanel.Controls; // If a valid split type was selected, the data array is guaranteed to exist (although it might still have // -1 values). int[] data = split.Data; for (int i = 0; i < controls.Count; i++) { Control control = controls[i]; if (control is TextBox textbox) { int value = data[i]; textbox.Text = value != -1 ? value.ToString() : ""; continue; } var dropdown = (ComboBox)control; int index = data[i]; dropdown.SelectedIndex = dropdown.Enabled ? index : (index == int.MaxValue ? -1 : index); } // For non-manual splits, the finished state will already have been refreshed (as dropdowns are set). // Quitouts are also finished by default (since they use no additional controls). if (type == SplitTypes.Manual || type == SplitTypes.Quitout) { RefreshFinished(true); } }
static public void split(GameObject ball, Vector2 touchPosition, List <GameObject> ballsCreated) { SplitTypes version = ball.GetComponent <Mover>().splitType; switch (version) { case SplitTypes.Half: splitHalf(ball, ballsCreated); break; case SplitTypes.Quarter: splitQuarters(ball, ballsCreated); break; case SplitTypes.Reverse: reverseDirection(ball, ballsCreated); break; } }
public SoulsSplitControl(SoulsSplitCollectionControl parent, int index) { this.parent = parent; Index = index; previousSplitType = SplitTypes.Unassigned; InitializeComponent(); functionMap = new Dictionary <SplitTypes, Func <Control[]> >() { { SplitTypes.Bonfire, GetBonfireControls }, { SplitTypes.Boss, GetBossControls }, { SplitTypes.Covenant, GetCovenantControls }, { SplitTypes.Event, GetEventControls }, { SplitTypes.Flag, GetFlagControls }, { SplitTypes.Item, GetItemControls }, { SplitTypes.Quitout, GetQuitoutControls }, { SplitTypes.Zone, GetZoneControls } }; }
/// <summary> /// Constructs the class. The string data is parsed based on split type. /// </summary> public Split(SplitTypes type, string data) { Type = type; Data = ParseData(type, data); }
/// <summary> /// Constructs the class. /// </summary> public Split(SplitTypes type, object data) { Type = type; Data = data; }
private Control GetDetails(SplitTypes type) { switch (type) { case SplitTypes.Egg: var dropdown = new ComboBox(); dropdown.Items.AddRange(Enum.GetNames(typeof(Eggs))); return(dropdown); case SplitTypes.Feather: var textbox = new TextBox { Height = 21, TextAlign = HorizontalAlignment.Center }; // See https://stackoverflow.com/q/463299/7281613 (these events are also copied from the Dark Souls // autosplitter). textbox.KeyPress += (sender, args) => { char c = args.KeyChar; // See http://www.asciitable.com/ as well. The idea here is to accept all control keys (such as // Ctrl + V) while still excluding letters and punctuation. if (c >= '!' && c <= '~' && !char.IsDigit(args.KeyChar)) { args.Handled = true; } }; textbox.KeyDown += (sender, args) => { // Pressing escape removes focus from the textbox. if (args.KeyCode == Keys.Escape) { ParentForm.Controls[0].Focus(); } }; textbox.TextChanged += (sender, args) => { string text = textbox.Text; if (text.Length == 0 || int.TryParse(text, out _)) { return; } // It's possible to paste a non-integer into the textbox. If the above check fails, all non- // digits are stripped from the pasted value. var builder = new StringBuilder(); foreach (char c in text) { if (char.IsDigit(c)) { builder.Append(c); } } // This actually causes the TextChanged event to be triggered again, but the function returns // immediately due to the checks above. textbox.Text = builder.ToString(); }; textbox.Enter += (sender, args) => { // See https://stackoverflow.com/a/6857301/7281613. This causes all text to be selected after // the click is processed. BeginInvoke((Action)textbox.SelectAll); }; return(textbox); } return(null); }
/// <summary> /// Checks whether the given split type is an enumerated type. /// </summary> private bool IsEnumeratedType(SplitTypes type) { return(type == SplitTypes.BodyPart || type == SplitTypes.CartridgeCompletion || type == SplitTypes.FutureCompletion || type == SplitTypes.WorldEvent || type == SplitTypes.Zone); }
/// <summary> /// Constructs the class with split type and data given directly. /// </summary> public SplitControl(SplitCollectionControl parent, int index, SplitTypes splitType, object splitData) : this(parent, index) { SplitType = splitType; SplitData = splitData; }
private void OnSplitTypeChange(SplitTypes splitType) { bool previouslyFinished = IsFinished; Control[] controls = splitType != SplitTypes.Manual ? functionMap[splitType]() : null; ControlCollection panelControls = splitDetailsPanel.Controls; panelControls.Clear(); if (controls != null) { for (int i = 0; i < controls.Length; i++) { var control = controls[i]; if (i > 0) { control.Location = new Point(controls[i - 1].Bounds.Right + ControlSpacing, 0); } panelControls.Add(control); } } // Item splits require two lines. if (splitType == SplitTypes.Item) { Height = Height * 2 - ItemSplitCorrection; splitDetailsPanel.Height = splitDetailsPanel.Height * 2 + ControlSpacing; Control[] secondaryControls = GetItemSecondaryControls(); int y = controls[0].Bounds.Bottom + ControlSpacing; for (int i = 0; i < secondaryControls.Length; i++) { Control control = secondaryControls[i]; Point point = new Point(0, y); if (i > 0) { point.X = secondaryControls[i - 1].Bounds.Right + ControlSpacing; } control.Location = point; panelControls.Add(control); LinkItemLines(controls, secondaryControls); } // Changing an existing split to an item split can cause later splits to be shifted down. if (Index < parent.SplitCount - 1) { parent.ShiftSplits(Index + 1); } } else if (previousSplitType == SplitTypes.Item) { Height = (Height + ItemSplitCorrection) / 2; splitDetailsPanel.Height = (splitDetailsPanel.Height - ControlSpacing) / 2; parent.ShiftSplits(Index + 1); } if (previouslyFinished) { // Changing the split type always adds new, empty controls, which means the new split is unfinished by // default (unless it's manual). if (splitType != SplitTypes.Manual) { parent.UnfinishedCount++; IsFinished = false; } } else if (splitType == SplitTypes.Manual || splitType == SplitTypes.Quitout) { parent.UnfinishedCount--; IsFinished = true; } previousSplitType = splitType; }
/// <summary> /// Updates start indexing button /// </summary> public void UpdateCanStartIndexing() { CanStartIndexing = !IsIndexingInProgress && SplitTypes.Any(x => x.IsSelected) && SelectedFiles.Any(); }
public Split(SplitTypes type, int data) { Type = type; Data = data; }