private void AddPlayerImages()
        {
            var contentHolder = this.FindControl <StackPanel>("PlayerSelectorPanel");

            foreach (var playerSave in saveFile.GetPlayerSaves())
            {
                var player = playerSave.Player;
                var img    = new Image
                {
                    Width  = 120,
                    Height = 120,
                    Source = LoadPlayerPhoto(playerSave.Index),
                    Cursor = new Cursor(StandardCursorType.Hand)
                };
                var button = new Button
                {
                    Background      = Brushes.Transparent,
                    BorderThickness = new Thickness(0),
                    Content         = img
                };
                button.Click += (o, e) => LoadPlayer(player);
                ToolTip.SetTip(img, playerSave.Player.Name);
                contentHolder.Children.Add(button);
            }
        }
Exemple #2
0
        private void AddPlayerImages()
        {
            var contentHolder = this.FindControl <StackPanel>("PlayerSelectorPanel");

            foreach (var playerSave in saveFile.GetPlayerSaves())
            {
                var img = new Image
                {
                    Width  = 120,
                    Height = 120,
                    Source = LoadPlayerPhoto(playerSave.Index)
                };
                contentHolder.Children.Add(img);
            }
        }
Exemple #3
0
        private async void OpenFileButton_Click(object o, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filters = new List <FileDialogFilter>
                {
                    new FileDialogFilter
                    {
                        Name       = "New Horizons Save File",
                        Extensions = new List <string>
                        {
                            "dat"
                        }
                    },
                    new FileDialogFilter
                    {
                        Name       = "All Files",
                        Extensions = new List <string>
                        {
                            "*"
                        }
                    }
                }
            };

            var files = await openFileDialog.ShowAsync(this);

            if (files.Length > 0)
            {
                // Determine whether they selected the header file or the main file
                var    file = files[0];
                string headerPath;
                string filePath;
                if (file.EndsWith("Header.dat"))
                {
                    headerPath = file;
                    filePath   = Path.Combine(Path.GetDirectoryName(file), $"{Path.GetFileNameWithoutExtension(file).Replace("Header", "")}.dat");
                }
                else
                {
                    filePath   = file;
                    headerPath = Path.Combine(Path.GetDirectoryName(file), $"{Path.GetFileNameWithoutExtension(file)}Header.dat");
                }

                if (File.Exists(headerPath) && File.Exists(filePath))
                {
                    saveFile = new MainSaveFile(headerPath, filePath);
                    if (saveFile.Loaded)
                    {
                        (o as Button).IsVisible = false;
                        this.FindControl <TabControl>("EditorTabControl").IsVisible = true;
                        this.FindControl <Grid>("BottomBar").IsVisible = true;
                        AddPlayerImages();
                        LoadPlayer(saveFile.GetPlayerSaves()[0].Player);
                        LoadVillagers();
                    }
                    else
                    {
                        saveFile = null;
                    }
                }
            }
        }
        private async void OpenFileButton_Click(object o, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filters = new List <FileDialogFilter>
                {
                    new FileDialogFilter
                    {
                        Name       = "New Horizons Save File",
                        Extensions = new List <string>
                        {
                            "dat"
                        }
                    },
                    new FileDialogFilter
                    {
                        Name       = "All Files",
                        Extensions = new List <string>
                        {
                            "*"
                        }
                    }
                }
            };

            var files = await openFileDialog.ShowAsync(this);

            if (files.Length > 0)
            {
                // Determine whether they selected the header file or the main file
                var    file = files[0];
                string headerPath;
                string filePath;
                if (file.EndsWith("Header.dat"))
                {
                    headerPath = file;
                    filePath   = Path.Combine(Path.GetDirectoryName(file), $"{Path.GetFileNameWithoutExtension(file).Replace("Header", "")}.dat");
                }
                else
                {
                    filePath   = file;
                    headerPath = Path.Combine(Path.GetDirectoryName(file), $"{Path.GetFileNameWithoutExtension(file)}Header.dat");
                }

                if (File.Exists(headerPath) && File.Exists(filePath))
                {
                    saveFile = new MainSaveFile(headerPath, filePath);
                    if (saveFile.Loaded)
                    {
                        villagerDatabase = VillagerDatabaseLoader.LoadVillagerDatabase((uint)saveFile.GetRevision());
                        LoadVillagerComboBoxItems();
                        (o as Button).IsVisible = false;
                        this.FindControl <TabControl>("EditorTabControl").IsVisible = true;
                        this.FindControl <Grid>("BottomBar").IsVisible    = true;
                        this.FindControl <TextBlock>("SaveInfoText").Text = $"Save File for Version {saveFile.GetRevisionString()} Loaded";
                        AddPlayerImages();
                        LoadPlayer(saveFile.GetPlayerSaves()[0].Player);
                        LoadVillagers();
                        LoadVillager(saveFile.Villagers[0]);

                        // Load Item List
                        itemDatabase = ItemDatabaseLoader.LoadItemDatabase((uint)saveFile.GetRevision());
                        var itemsBox = this.FindControl <ComboBox>("ItemSelectBox");
                        itemsBox.Items = itemDatabase.Values;

                        // Set up connections
                        SetupUniversalConnections();
                        SetupPlayerTabConnections();
                        SetupVillagerTabConnections();

                        SetItem(Item.NO_ITEM);
                    }
                    else
                    {
                        saveFile = null;
                    }
                }
            }
        }