Exemple #1
0
 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;
         }
     }
 }
Exemple #2
0
        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);
                            }
                        }
                    }
                }
            }
        }