Пример #1
0
        /// <summary>
        /// <para>Loads an animation frame from the currently loaded animation.</para>
        /// <para>Make sure to set the animation using <see cref="Setup"/> and only selecting frames from the current loaded animation.</para>
        /// </summary>
        /// <param name="frame">Refence to the frame to load into the viewer</param>
        public void LoadFrame(Animation.AnimationEntry.Frame frame)
        {
            LoadedFrame = frame;
            var path = Path.Combine(FilePath, LoadedAnimation.SpriteSheets[frame.SpriteSheet]);

            if (File.Exists(path))
            {
                GIF.Load(path);
            }
            else
            {
                var messagebox = new HedgeMessageBox("Failed to load sprite sheet!",
                                                     "The sprite sheet for the loaded sprite\ncould not be found.");
                messagebox.AddButton("Select sprite sheet file", () =>
                {
                    var ofd    = new OpenFileDialog();
                    ofd.Filter = "Graphics Interchange Format|*.gif";
                    if (ofd.ShowDialog() == true)
                    {
                        GIF.Load(ofd.FileName);
                    }
                    messagebox.Close();
                });
                messagebox.AddButton("Cancel", () => { messagebox.Close(); });
                messagebox.Show();
            }
        }
        private void Button_Ignore_Click(object sender, RoutedEventArgs e)
        {
            var messagebox = new HedgeMessageBox("Save Current Palette?",
                                                 "Do you want to try save your current palette\n" +
                                                 "as a backup before contining/exiting?\n\n" +
                                                 "This will not work if ManiaPal crashed while saving!");

            messagebox.AddButton("Save Palette", () =>
            {
                try
                {
                    var MP = MainWindow.Instance;
                    if (MP.LoadedFileType != null)
                    {
                        MP.LoadedFileType.filePath += ".bak";
                        MP.LoadedFileType.Write(MP.LoadedFileType.filePath, MP.Palettes, MP.CurrentPaletteSet);
                        return;
                    }
                }
                catch
                {
                    MessageBox.Show("Failed");
                }
                messagebox.Close();
            });
            messagebox.AddButton("Don't Save", () => { messagebox.Close(); });
            messagebox.ShowDialog();
            Close();
        }
Пример #3
0
        private void UI_SaveFile_Click(object sender, RoutedEventArgs e)
        {
            if (LoadedFileType != null)
            {
                LoadedFileType.Write(LoadedFileType.filePath, Palettes, CurrentPaletteSet);
                return;
            }

            var messagebox = new HedgeMessageBox("Save Warning!", "No File was loaded prior to saving!\n" +
                                                 "ManiaPal is currently unable to save to any\nMania formats without it being loaded prior to saving.");

            messagebox.AddButton("Save Palette as Adobe Colour Table", () =>
            {
                var fileType = FileTypes.FirstOrDefault(t => t.GetFileTypeName() == "Adobe Colour Table");
                var sfd      = new SaveFileDialog();
                sfd.Filter   = fileType.GetSupportedFileFilters();
                if (sfd.ShowDialog() == true)
                {
                    fileType.Write(sfd.FileName, Palettes, CurrentPaletteSet);
                }
                messagebox.Close();
            });
            messagebox.AddButton("Don't Save", () => { messagebox.Close(); });
            messagebox.Show();
        }
Пример #4
0
        private void UI_SelectAnimationPath_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.Filter = "Sonic Mania Animation|*.bin";
            if (ofd.ShowDialog() == true)
            {
                UI_FilePathTextBox.Text = ofd.FileName;
                try
                {
                    // Prepare the viewer
                    SpriteView.Setup(ofd.FileName);
                }
                catch
                {
                    // Clear viewer if failed
                    SpriteView.Setup(null);
                    // Display error
                    var messageBox = new HedgeMessageBox("Failed to load animation!",
                                                         "ManiaPal failed to parse the selected file.\nMake sure you have selected the correct file.");
                    messageBox.AddButton("OK", () => { messageBox.Close(); });
                    messageBox.ShowDialog();
                    return;
                }
                // Clean and fill the animation list
                UI_Animation.Items.Clear();
                foreach (var animation in SpriteView.LoadedAnimation.Animations)
                {
                    UI_Animation.Items.Add(animation);
                }

                FrameID    = 0;
                FrameIDMax = 0;
                Update();
                // Load the first animation
                if (UI_Animation.Items.Count != 0)
                {
                    UI_Animation.SelectedIndex = 0;
                }
            }
        }