private void TrackItem(string itemName, WorldGrid world) { foreach (ContentControl item in ItemPool.Children) { if (item.Name == itemName && item.IsVisible) { if (world.Handle_Report(item as Item, this, data)) { world.Add_Item(item as Item, this); App.logger.Record(item.Name + " tracked"); } break; } } }
public void HandleItemReturn() { Data data = MainWindow.data; if (Parent != ((MainWindow)Application.Current.MainWindow).ItemPool) { WorldGrid parent = this.Parent as WorldGrid; ((WorldGrid)Parent).Handle_WorldGrid(this, false); ((MainWindow)Application.Current.MainWindow).ItemPool.Children.Add(this); ((MainWindow)Application.Current.MainWindow).DecrementCollected(); MouseDown -= Item_Return; if (data.dragDrop) { MouseDoubleClick -= Item_Click; MouseDoubleClick += Item_Click; MouseMove -= Item_MouseMove; MouseMove += Item_MouseMove; } else { MouseDown -= Item_MouseDown; MouseDown += Item_MouseDown; MouseUp -= Item_MouseUp; MouseUp += Item_MouseUp; } MouseEnter -= Report_Hover; UpdateFound(this.Name, parent.Name.Remove(parent.Name.Length - 4, 4), false); } }
private void LoadProgress(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.DefaultExt = ".txt"; openFileDialog.Filter = "txt files (*.txt)|*.txt"; openFileDialog.FileName = "kh2fm-tracker-save"; openFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory; if (openFileDialog.ShowDialog() == true) { Stream file = openFileDialog.OpenFile(); StreamReader reader = new StreamReader(file); // reset tracker OnReset(null, null); // set settings string settings = reader.ReadLine(); LoadSettings(settings.Substring(10)); // set hint state data.hintsLoaded = bool.Parse(reader.ReadLine()); if (data.hintsLoaded) { string attempts = reader.ReadLine(); attempts = attempts.Substring(13); string[] attemptsArray = attempts.Split('-'); for (int i = 0; i < attemptsArray.Length; ++i) { data.reportAttempts[i] = int.Parse(attemptsArray[i]); } string line1 = reader.ReadLine(); data.hintFileText[0] = line1; string[] reportvalues = line1.Split('.'); string line2 = reader.ReadLine(); data.hintFileText[1] = line2; line2 = line2.TrimEnd('.'); string[] reportorder = line2.Split('.'); for (int i = 0; i < reportorder.Length; ++i) { data.reportLocations.Add(data.codes.FindCode(reportorder[i])); string[] temp = reportvalues[i].Split(','); data.reportInformation.Add(new Tuple <string, int>(data.codes.FindCode(temp[0]), int.Parse(temp[1]) - 32)); } } // set hint values string[] hintValues = reader.ReadLine().Substring(12).Split(' '); for (int i = 0; i < hintValues.Length; ++i) { SetReportValue(data.Hints[i], int.Parse(hintValues[i])); } // add items to worlds while (reader.EndOfStream == false) { string world = reader.ReadLine(); string worldName = world.Substring(0, world.IndexOf(':')); string items = world.Substring(world.IndexOf(':') + 1).Trim(); if (items != string.Empty) { foreach (string item in items.Split(' ')) { WorldGrid grid = FindName(worldName + "Grid") as WorldGrid; Item importantCheck = FindName(item) as Item; if (grid.Handle_Report(importantCheck, this, data)) { grid.Add_Item(importantCheck, this); } } } } } }