private void FileSelectorButton_Click(object sender, RoutedEventArgs e)
        {
            // Set up the directory picker
            var ofd = new CommonOpenFileDialog();

            ofd.Title                     = "Choose Directory";
            ofd.IsFolderPicker            = true;
            ofd.AddToMostRecentlyUsedList = false;
            ofd.AllowNonFileSystemItems   = false;
            ofd.EnsureFileExists          = true;
            ofd.EnsurePathExists          = true;
            ofd.EnsureReadOnly            = false;
            ofd.EnsureValidNames          = true;
            ofd.Multiselect               = false;
            ofd.ShowPlacesList            = true;

            var window = Application.Current.Windows.OfType <Window>().SingleOrDefault(w => w.IsActive);

            if (ofd.ShowDialog(window) == CommonFileDialogResult.Ok)
            {
                FileReference reference = new FileReference
                {
                    FilePath = ofd.FileName
                };

                WSettingsManager.GetSettings().SetProperty(FieldName, reference);
                FileName = ofd.FileName;
            }
        }
예제 #2
0
        public void ExportToDae()
        {
            if (m_CollisionMesh == null)
            {
                MessageBox.Show("You must select a room before you can export its collision.", "No collision mesh selected");
                return;
            }

            var sfd = new CommonSaveFileDialog()
            {
                Title                        = "Export DAE",
                DefaultExtension             = "dae",
                AlwaysAppendDefaultExtension = true,
            };

            sfd.Filters.Add(new CommonFileDialogFilter("Collada", ".dae"));
            if (WSettingsManager.GetSettings().LastCollisionDaePath.FilePath != "")
            {
                sfd.InitialDirectory = WSettingsManager.GetSettings().LastCollisionDaePath.FilePath;
            }

            if (sfd.ShowDialog() == CommonFileDialogResult.Ok)
            {
                m_CollisionMesh.ToDAEFile(sfd.FileName);

                WSettingsManager.GetSettings().LastCollisionDaePath.FilePath = Path.GetDirectoryName(sfd.FileName);
                WSettingsManager.SaveSettings();
            }
        }
예제 #3
0
        public void ImportFromDae()
        {
            if (m_CollisionMesh == null)
            {
                MessageBox.Show("You must select a room before you can import collision for it.", "No collision mesh selected");
                return;
            }

            var ofd = new CommonOpenFileDialog()
            {
                Title            = "Import DAE",
                DefaultExtension = "dae",
            };

            ofd.Filters.Add(new CommonFileDialogFilter("Collada", ".dae"));
            if (WSettingsManager.GetSettings().LastCollisionDaePath.FilePath != "")
            {
                ofd.InitialDirectory = WSettingsManager.GetSettings().LastCollisionDaePath.FilePath;
            }

            if (ofd.ShowDialog() == CommonFileDialogResult.Ok)
            {
                WRoom currRoom = World.Map.FocusedScene as WRoom;
                m_CollisionMesh.FromDAEFile(ofd.FileName, currRoom.RoomIndex);

                m_CollisionTree.ItemsSource = new ObservableCollection <CollisionGroupNode>()
                {
                    ActiveCollisionMesh.RootNode
                };

                WSettingsManager.GetSettings().LastCollisionDaePath.FilePath = Path.GetDirectoryName(ofd.FileName);
                WSettingsManager.SaveSettings();
            }
        }
예제 #4
0
        private void OnRequestSaveSongInputDataAs()
        {
            var sfd = new CommonSaveFileDialog()
            {
                Title                        = "Save DOL Copy",
                DefaultExtension             = "dol",
                AlwaysAppendDefaultExtension = true,
            };

            sfd.Filters.Add(new CommonFileDialogFilter("DOL files", ".dol"));

            if (sfd.ShowDialog() == CommonFileDialogResult.Ok)
            {
                File.Copy(Path.Combine(WSettingsManager.GetSettings().RootDirectoryPath, "sys", "main.dol"), sfd.FileName);

                using (FileStream stream = new FileStream(sfd.FileName, FileMode.Open, FileAccess.Write))
                {
                    EndianBinaryWriter writer = new EndianBinaryWriter(stream, Endian.Big);
                    writer.BaseStream.Seek(SONGS_OFFSET, SeekOrigin.Begin);

                    for (int i = 0; i < NUM_SONGS; i++)
                    {
                        Songs[i].Write(writer);
                    }
                }

                m_IsDataDirty = false;
                OnPropertyChanged("WindowTitle");
            }
        }
        private void OnUserCancelSettings()
        {
            CloseOptionsMenuWindow();

            // Kind of a hack to reset the state of the settings to
            // before the user opened the window.
            WSettingsManager.LoadSettings();
        }
예제 #6
0
 private void OnRequestApplyPlaybackPatch()
 {
     if (MessageBox.Show("This will apply a patch to the *.dol file displayed in thie editor's title bar that permanently removes song playback when conducting Wind Waker songs.\n\nAre you sure you want to continue?", "Apply Patch?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
     {
         Patch songPlaybackPatch = JsonConvert.DeserializeObject <Patch>(File.ReadAllText(@"resources\patches\disable_song_playback.json"));
         songPlaybackPatch.Apply(WSettingsManager.GetSettings().RootDirectoryPath);
     }
 }
예제 #7
0
        private void LoadSongData()
        {
            const string NameFile = "resources/WindWakerSongNames.txt";

            string[] SongNames;

            Songs = new WindWakerSong[NUM_SONGS];

            // Try to load names from file if the file exists
            if (File.Exists(NameFile))
            {
                SongNames = File.ReadAllLines("resources/WindWakerSongNames.txt");
            }
            // Otherwise generate generic names!
            else
            {
                SongNames = new string[NUM_SONGS];

                for (int i = 0; i < NUM_SONGS; i++)
                {
                    SongNames[i] = $"Song { i }";
                }
            }

            using (FileStream stream = new FileStream(Path.Combine(WSettingsManager.GetSettings().RootDirectoryPath, "sys", "main.dol"), FileMode.Open, FileAccess.Read))
            {
                EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big);
                reader.BaseStream.Seek(SONGS_OFFSET, SeekOrigin.Begin);

                for (int i = 0; i < NUM_SONGS; i++)
                {
                    Songs[i] = new WindWakerSong(reader);

                    // Grab name from the list we loaded/generated earlier
                    if (SongNames.Length > i)
                    {
                        Songs[i].Name = SongNames[i];
                    }
                    // If there aren't enough names in the list we read from file, default to a generic name!
                    else
                    {
                        Songs[i].Name = $"Song { i }";
                    }
                }
            }

            CurrentSong = Songs[0];
        }
예제 #8
0
        private void OnRequestSaveSongInputData()
        {
            using (FileStream stream = new FileStream(Path.Combine(WSettingsManager.GetSettings().RootDirectoryPath, "sys", "main.dol"), FileMode.Open, FileAccess.Write))
            {
                EndianBinaryWriter writer = new EndianBinaryWriter(stream, Endian.Big);
                writer.BaseStream.Seek(SONGS_OFFSET, SeekOrigin.Begin);

                for (int i = 0; i < NUM_SONGS; i++)
                {
                    Songs[i].Write(writer);
                }
            }

            m_IsDataDirty = false;
            OnPropertyChanged("WindowTitle");
        }
예제 #9
0
        private void OnRequestOpenEnemyDropEditor()
        {
            if (m_MinitorWindow != null)
            {
                m_MinitorWindow.Show();
                m_MinitorWindow.Focus();
                return;
            }

            WindowTitle = "Enemy Item Drop Editor - " + Path.Combine(WSettingsManager.GetSettings().RootDirectoryPath, "files", "res", "ActorDat", "ActorDat.bin");

            m_MinitorWindow             = new EnemyDropMinitorWindow();
            m_MinitorWindow.DataContext = this;
            m_MinitorWindow.Closing    += M_MinitorWindow_Closing;

            m_MinitorWindow.Show();
        }
예제 #10
0
        private void FileSelectorButton_Click(object sender, RoutedEventArgs e)
        {
            // Set up the file/directory picker
            CommonFileDialog fd;

            if (IsFileSaver)
            {
                fd = new CommonSaveFileDialog();
                if (FileExtension != null)
                {
                    CommonSaveFileDialog sfd = fd as CommonSaveFileDialog;
                    sfd.DefaultExtension             = FileExtension;
                    sfd.AlwaysAppendDefaultExtension = true;
                    sfd.Filters.Add(new CommonFileDialogFilter(FileExtension, "." + FileExtension));
                }
            }
            else
            {
                fd = new CommonOpenFileDialog();
                CommonOpenFileDialog ofd = fd as CommonOpenFileDialog;
                ofd.IsFolderPicker          = !IsFilePicker;
                ofd.AllowNonFileSystemItems = false;
                ofd.Multiselect             = false;
            }
            fd.Title = IsFilePicker ? "Choose File" : "Choose Directory";
            fd.AddToMostRecentlyUsedList = false;
            fd.EnsureFileExists          = true;
            fd.EnsurePathExists          = true;
            fd.EnsureReadOnly            = false;
            fd.EnsureValidNames          = true;
            fd.ShowPlacesList            = true;

            var window = Application.Current.Windows.OfType <Window>().SingleOrDefault(w => w.IsActive);

            if (fd.ShowDialog(window) == CommonFileDialogResult.Ok)
            {
                FileReference reference = new FileReference
                {
                    FilePath = fd.FileName
                };

                WSettingsManager.GetSettings().SetProperty(FieldName, reference);
                FileName = fd.FileName;
            }
        }
예제 #11
0
        private void OnRequestOpenInputEditor()
        {
            if (m_MinitorWindow != null)
            {
                m_MinitorWindow.Show();
                m_MinitorWindow.Focus();
                return;
            }

            WindowTitle = "Song Input Editor - " + Path.Combine(WSettingsManager.GetSettings().RootDirectoryPath, "sys", "main.dol");

            m_MinitorWindow             = new InputMinitorWindow();
            m_MinitorWindow.DataContext = this;
            m_MinitorWindow.Closing    += M_MinitorWindow_Closing;

            LoadSongData();

            m_MinitorWindow.Show();
            m_MinitorWindow.NoteCountCombo.SelectionChanged += OnCurrentSongNoteCountChanged;
        }
예제 #12
0
        private bool TryLoadMessageArchive()
        {
            string bmgres_path = Path.Combine(WSettingsManager.GetSettings().RootDirectoryPath, "files", "res", "Msg", "bmgres.arc");

            if (!File.Exists(bmgres_path))
            {
                return(false);
            }

            m_MessageArchive = ArchiveUtilities.LoadArchive(bmgres_path);

            VirtualFilesystemFile text_bank = m_MessageArchive.GetFileAtPath("zel_00.bmg");

            using (MemoryStream strm = new MemoryStream(text_bank.Data))
            {
                EndianBinaryReader reader = new EndianBinaryReader(strm, Endian.Big);
                LoadMessageData(reader);
            }

            return(true);
        }
예제 #13
0
        public void OnRequestOpenTextEditor()
        {
            if (m_MinitorWindow != null && m_MinitorWindow.IsVisible == true)
            {
                m_MinitorWindow.Focus();
                return;
            }

            if (Messages == null)
            {
                if (!TryLoadMessageArchive())
                {
                    MessageBox.Show($"The file " +
                                    $"\"{ Path.Combine(WSettingsManager.GetSettings().RootDirectoryPath, "files", "res", "Msg", "bmgres.arc") }\" " +
                                    $"could not be found. The text editor cannot be opened.\n\n" +
                                    $"Please check that the Root Directory in your settings includes this file.",
                                    "Archive Not Found", MessageBoxButton.OK, MessageBoxImage.Error);

                    return;
                }
            }

            WindowTitle = "Text Editor - " + Path.Combine(WSettingsManager.GetSettings().RootDirectoryPath, "files", "res", "Msg", "bmgres.arc");

            m_MinitorWindow             = new TextMinitorWindow();
            m_MinitorWindow.DataContext = this;
            m_DetailsModel = (WDetailsViewViewModel)m_MinitorWindow.DetailsPanel.DataContext;

            m_RendererViewModel = new TextboxRendererViewModel();

            SelectedMessage = Messages[0];
            m_MinitorWindow.Show();

            CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(m_MinitorWindow.TextListView.ItemsSource);

            view.Filter = FilterMessages;

            SearchFilter = "";
        }
예제 #14
0
        private void OnRequestSaveOtherFormatMessageData()
        {
            var sfd = new CommonSaveFileDialog()
            {
                Title                        = "Export Script Archive",
                DefaultExtension             = "txt",
                AlwaysAppendDefaultExtension = true,
            };

            sfd.Filters.Add(new CommonFileDialogFilter("Archives", "txt"));
            if (WSettingsManager.GetSettings().LastScriptArchivePath.FilePath != "")
            {
                sfd.InitialDirectory = WSettingsManager.GetSettings().LastScriptArchivePath.FilePath;
            }

            if (sfd.ShowDialog() == CommonFileDialogResult.Ok)
            {
                SaveMessageOther(sfd.FileName);

                WSettingsManager.GetSettings().LastScriptArchivePath.FilePath = Path.GetDirectoryName(sfd.FileName);
                WSettingsManager.SaveSettings();
            }
        }
        private void OnUserAcceptSettings()
        {
            WSettingsManager.SaveSettings();

            CloseOptionsMenuWindow();
        }
 public OptionsMenuViewModel()
 {
     Settings = WSettingsManager.GetSettings();
 }
예제 #17
0
 private void OnRequestSaveMessageData()
 {
     SaveMessageArchive(Path.Combine(WSettingsManager.GetSettings().RootDirectoryPath, "files", "res", "Msg", "bmgres.arc"));
 }