Beispiel #1
0
		public static FileInfo GetTasProjSaveFileFromUser(string currentFile)
		{
			var sfd = new SaveFileDialog();
			if (!string.IsNullOrWhiteSpace(currentFile))
			{
				sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
				sfd.InitialDirectory = Path.GetDirectoryName(currentFile);
			}
			else if (!(Global.Emulator is NullEmulator))
			{
				sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
				sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
			}
			else
			{
				sfd.FileName = "NULL";
				sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
			}

			sfd.Filter = "Tas Project Files (*.tasproj)|*.tasproj|All Files|*.*";
			sfd.RestoreDirectory = true;
			var result = sfd.ShowHawkDialog();
			if (result != DialogResult.OK)
			{
				return null;
			}

			return new FileInfo(sfd.FileName);
		}
Beispiel #2
0
		public static FileInfo SaveFileDialog(string currentFile, string path, string fileType, string fileExt)
		{
			if (!Directory.Exists(path))
			{
				Directory.CreateDirectory(path);
			}

			var sfd = new SaveFileDialog
			{
				FileName = !string.IsNullOrWhiteSpace(currentFile)
					? Path.GetFileName(currentFile)
					: PathManager.FilesystemSafeName(Global.Game) + "." + fileExt,
				InitialDirectory = path,
				Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt),
				RestoreDirectory = true,
			};

			var result = sfd.ShowHawkDialog();
			if (result != DialogResult.OK)
			{
				return null;
			}

			return new FileInfo(sfd.FileName);
		}
Beispiel #3
0
        private void BrowseBtn_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog
            {
                InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null),
                DefaultExt = "." + Global.MovieSession.Movie.PreferredExtension,
                FileName = RecordBox.Text,
                OverwritePrompt = false,
                Filter = "Movie Files (*." + Global.MovieSession.Movie.PreferredExtension + ")|*." + Global.MovieSession.Movie.PreferredExtension + "|All Files|*.*"
            };

            var result = sfd.ShowHawkDialog();
            if (result == DialogResult.OK
                && !string.IsNullOrWhiteSpace(sfd.FileName))
            {
                RecordBox.Text = sfd.FileName;
            }
        }
Beispiel #4
0
		public void Screenshot()
		{
			var sfd = new SaveFileDialog
				{
					FileName = PathManager.FilesystemSafeName(Global.Game) + "-Nametables",
					InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Screenshots"].Path, "NES"),
					Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*",
					RestoreDirectory = true
				};

			var result = sfd.ShowHawkDialog();
			if (result != DialogResult.OK)
			{
				return;
			}

			var file = new FileInfo(sfd.FileName);
			using (Bitmap b = new Bitmap(Width, Height))
			{
				Rectangle rect = new Rectangle(new Point(0, 0), Size);
				DrawToBitmap(b, rect);

				ImageFormat i;
				string extension = file.Extension.ToUpper();
				switch (extension)
				{
					default:
					case ".PNG":
						i = ImageFormat.Png;
						break;
					case ".BMP":
						i = ImageFormat.Bmp;
						break;
				}

				b.Save(file.FullName, i);
			}
		}
Beispiel #5
0
		private void NewScriptMenuItem_Click(object sender, EventArgs e)
		{
			var sfd = new SaveFileDialog
			{
				InitialDirectory = !string.IsNullOrWhiteSpace(_luaList.Filename) ?
					Path.GetDirectoryName(_luaList.Filename) :
					PathManager.MakeAbsolutePath(Global.Config.PathEntries.LuaPathFragment, null),
				DefaultExt = ".lua",
				FileName = !string.IsNullOrWhiteSpace(_luaList.Filename) ?
					Path.GetFileNameWithoutExtension(_luaList.Filename) :
					Path.GetFileNameWithoutExtension(Global.Game.Name),
				OverwritePrompt = true,
				Filter = "Lua Scripts (*.lua)|*.lua|All Files (*.*)|*.*"
			};

			var result = sfd.ShowHawkDialog();
			if (result == DialogResult.OK
				&& !string.IsNullOrWhiteSpace(sfd.FileName))
			{
				string defaultTemplate = "while true do\n\temu.frameadvance();\nend";
				File.WriteAllText(sfd.FileName, defaultTemplate);
				_luaList.Add(new LuaFile(Path.GetFileNameWithoutExtension(sfd.FileName), sfd.FileName));
				UpdateDialog();
				System.Diagnostics.Process.Start(sfd.FileName);
			}
		}
Beispiel #6
0
		private FileInfo GetSaveFileFromUser()
		{
			var sfd = new SaveFileDialog();
			if (!string.IsNullOrWhiteSpace(_luaList.Filename))
			{
				sfd.FileName = Path.GetFileNameWithoutExtension(_luaList.Filename);
				sfd.InitialDirectory = Path.GetDirectoryName(_luaList.Filename);
			}
			else if (Global.Game != null)
			{
				sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
				sfd.InitialDirectory = PathManager.GetLuaPath();
			}
			else
			{
				sfd.FileName = "NULL";
				sfd.InitialDirectory = PathManager.GetLuaPath();
			}

			sfd.Filter = "Lua Session Files (*.luases)|*.luases|All Files|*.*";
			sfd.RestoreDirectory = true;
			var result = sfd.ShowHawkDialog();
			if (result != DialogResult.OK)
			{
				return null;
			}

			return new FileInfo(sfd.FileName);
		}
Beispiel #7
0
        public static bool SaveMacroAs(MovieZone macro)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            // Create directory?
            bool create = false;
            if (!Directory.Exists(SuggestedFolder()))
            {
                Directory.CreateDirectory(SuggestedFolder());
                create = true;
            }
            dialog.InitialDirectory = SuggestedFolder();
            dialog.FileName = macro.Name;
            dialog.Filter = "Movie Macros (*.bk2m)|*.bk2m|All Files|*.*";

            DialogResult result = dialog.ShowHawkDialog();
            if (result != DialogResult.OK)
            {
                if (create)
                    Directory.Delete(dialog.InitialDirectory);
                return false;
            }

            macro.Save(dialog.FileName);
            Global.Config.RecentMacros.Add(dialog.FileName);

            return true;
        }
Beispiel #8
0
		private static string GetSaveFileFromUser()
		{
			var sfd = new SaveFileDialog
			{
				Filter = "Text (*.txt)|*.txt|All Files|*.*",
				RestoreDirectory = true
			};

			if (Global.Emulator is NullEmulator)
			{
				sfd.FileName = "MemoryDump";
				sfd.InitialDirectory = PathManager.GetBasePathAbsolute();
			}
			else
			{
				sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
				sfd.InitialDirectory = Path.GetDirectoryName(PathManager.MakeAbsolutePath(Global.Config.RecentRoms.MostRecent, null));
			}

			var result = sfd.ShowHawkDialog();

			return result == DialogResult.OK ? sfd.FileName : string.Empty;
		}
Beispiel #9
0
		private void ScreenshotAsMenuItem_Click(object sender, EventArgs e)
		{
			var path = String.Format(PathManager.ScreenshotPrefix(Global.Game) + ".{0:yyyy-MM-dd HH.mm.ss}.png", DateTime.Now);

			var sfd = new SaveFileDialog
			{
				InitialDirectory = Path.GetDirectoryName(path),
				FileName = Path.GetFileName(path),
				Filter = "PNG File (*.png)|*.png"
			};

			var result = sfd.ShowHawkDialog();
			if (result == DialogResult.OK)
			{
				TakeScreenshot(sfd.FileName);
			}
		}
Beispiel #10
0
		private string GetBinarySaveFileFromUser()
		{
			var sfd = new SaveFileDialog
			{
				Filter = GetSaveFileFilter(),
				RestoreDirectory = true,
				InitialDirectory = RomDirectory
			};

			if (_domain.Name == "File on Disk")
			{
				sfd.FileName = RomName;
			}
			else
			{
				sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
			}

			var result = sfd.ShowHawkDialog();

			return result == DialogResult.OK ? sfd.FileName : string.Empty;
		}
Beispiel #11
0
        private void BrowseBtn_Click(object sender, EventArgs e)
        {
            string filename = string.Empty;
            string initialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MultiDiskBundlesFragment, "Global_NULL");

            if (!Global.Game.IsNullInstance)
            {
                filename = NameBox.Text;
                if (string.IsNullOrWhiteSpace(filename))
                {
                    filename = Path.ChangeExtension(PathManager.FilesystemSafeName(Global.Game), ".xml");
                }

                initialDirectory = Path.GetDirectoryName(filename);
            }

            var sfd = new SaveFileDialog
            {
                FileName = filename,
                InitialDirectory = initialDirectory,
                Filter = "xml (*.xml)|*.xml|All Files|*.*"
            };

            var result = sfd.ShowHawkDialog();
            if (result != DialogResult.Cancel)
            {
                NameBox.Text = sfd.FileName;
            }
        }
Beispiel #12
0
		public static FileInfo GetCdlSaveFileFromUser(string currentFile)
		{
			var sfd = new SaveFileDialog
			{
				Filter = "Code Data Logger Files (*.cdl)|*.cdl|All Files|*.*",
				InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null),
				RestoreDirectory = true
			};

			if (!string.IsNullOrWhiteSpace(currentFile))
			{
				sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
			}

			var result = sfd.ShowHawkDialog();
			if (result != DialogResult.OK)
			{
				return null;
			}

			return new FileInfo(sfd.FileName);
		}
Beispiel #13
0
		public static FileInfo GetCheatSaveFileFromUser(string currentFile)
		{
			var sfd = new SaveFileDialog();
			if (!string.IsNullOrWhiteSpace(currentFile))
			{
				sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
			}
			else if (!(Global.Emulator is NullEmulator))
			{
				sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
			}

			sfd.InitialDirectory = PathManager.GetCheatsPath(Global.Game);
			sfd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
			sfd.RestoreDirectory = true;
			var result = sfd.ShowHawkDialog();
			if (result != DialogResult.OK)
			{
				return null;
			}

			return new FileInfo(sfd.FileName);
		}
Beispiel #14
0
		private string GetBinarySaveFileFromUser()
		{
			var sfd = new SaveFileDialog
			{
				Filter = GetSaveFileFilter(),
				RestoreDirectory = true
			};

			if (Global.Emulator is NullEmulator)
			{
				sfd.FileName = "MemoryDump";
				sfd.InitialDirectory = PathManager.GetBasePathAbsolute();
			}
			else
			{
				if (_domain.Name == "File on Disk")
				{
					sfd.FileName = Path.GetFileName(Global.Config.RecentRoms.MostRecent);
				}
				else
				{
					sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
				}

				sfd.InitialDirectory = Path.GetDirectoryName(PathManager.MakeAbsolutePath(Global.Config.RecentRoms.MostRecent, null));
			}

			var result = sfd.ShowHawkDialog();

			return result == DialogResult.OK ? sfd.FileName : string.Empty;
		}
Beispiel #15
0
        private void SaveStateAs()
        {
            if (!Global.Emulator.HasSavestates())
            {
                return;
            }

            var path = PathManager.GetSaveStatePath(Global.Game);

            var file = new FileInfo(path);
            if (file.Directory != null && file.Directory.Exists == false)
            {
                file.Directory.Create();
            }

            var sfd = new SaveFileDialog
            {
                AddExtension = true,
                DefaultExt = "State",
                Filter = "Save States (*.State)|*.State|All Files|*.*",
                InitialDirectory = path,
                FileName = PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave0.State"
            };

            var result = sfd.ShowHawkDialog();
            if (result == DialogResult.OK)
            {
                SaveState(sfd.FileName, sfd.FileName, false);
            }
        }
Beispiel #16
0
        /// <summary>
        /// start AV recording
        /// </summary>
        private void _RecordAv(string videowritername, string filename, bool unattended)
        {
            if (_currAviWriter != null)
            {
                return;
            }

            // select IVideoWriter to use
            IVideoWriter aw = null;

            if (unattended)
            {
                aw = VideoWriterInventory.GetVideoWriter(videowritername);

            }
            else
            {
                aw = VideoWriterChooserForm.DoVideoWriterChoserDlg(VideoWriterInventory.GetAllWriters(), this,
                    out _avwriterResizew, out _avwriterResizeh, out _avwriterpad, out _dumpaudiosync);
            }

            if (aw == null)
            {
                GlobalWin.OSD.AddMessage(
                    unattended ? string.Format("Couldn't start video writer \"{0}\"", videowritername) : "A/V capture canceled.");

                return;
            }

            try
            {
                if (_dumpaudiosync)
                {
                    aw = new VideoStretcher(aw);
                }
                else
                {
                    aw = new AudioStretcher(aw);
                }

                aw.SetMovieParameters(Global.Emulator.CoreComm.VsyncNum, Global.Emulator.CoreComm.VsyncDen);
                if (_avwriterResizew > 0 && _avwriterResizeh > 0)
                {
                    aw.SetVideoParameters(_avwriterResizew, _avwriterResizeh);
                }
                else
                {
                    aw.SetVideoParameters(Global.Emulator.VideoProvider().BufferWidth, Global.Emulator.VideoProvider().BufferHeight);
                }

                aw.SetAudioParameters(44100, 2, 16);

                // select codec token
                // do this before save dialog because ffmpeg won't know what extension it wants until it's been configured
                if (unattended)
                {
                    aw.SetDefaultVideoCodecToken();
                }
                else
                {
                    var token = aw.AcquireVideoCodecToken(this);
                    if (token == null)
                    {
                        GlobalWin.OSD.AddMessage("A/V capture canceled.");
                        aw.Dispose();
                        return;
                    }

                    aw.SetVideoCodecToken(token);
                }

                // select file to save to
                if (unattended)
                {
                    aw.OpenFile(filename);
                }
                else
                {
                    string ext = aw.DesiredExtension();
                    string pathForOpenFile;

                    //handle directories first
                    if (ext == "<directory>")
                    {
                        var fbd = new FolderBrowserEx();
                        if (fbd.ShowDialog() == DialogResult.Cancel)
                        {
                            aw.Dispose();
                            return;
                        }
                        pathForOpenFile = fbd.SelectedPath;
                    }
                    else
                    {
                        var sfd = new SaveFileDialog();
                        if (Global.Game != null)
                        {
                            sfd.FileName = PathManager.FilesystemSafeName(Global.Game) + "." + ext; //dont use Path.ChangeExtension, it might wreck game names with dots in them
                            sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AvPathFragment, null);
                        }
                        else
                        {
                            sfd.FileName = "NULL";
                            sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AvPathFragment, null);
                        }

                        sfd.Filter = string.Format("{0} (*.{0})|*.{0}|All Files|*.*", ext);

                        var result = sfd.ShowHawkDialog();
                        if (result == DialogResult.Cancel)
                        {
                            aw.Dispose();
                            return;
                        }

                        pathForOpenFile = sfd.FileName;
                    }

                    aw.OpenFile(pathForOpenFile);
                }

                // commit the avi writing last, in case there were any errors earlier
                _currAviWriter = aw;
                GlobalWin.OSD.AddMessage("A/V capture started");
                AVIStatusLabel.Image = Properties.Resources.AVI;
                AVIStatusLabel.ToolTipText = "A/V capture in progress";
                AVIStatusLabel.Visible = true;
            }
            catch
            {
                GlobalWin.OSD.AddMessage("A/V capture failed!");
                aw.Dispose();
                throw;
            }

            if (_dumpaudiosync)
            {
                Global.Emulator.EndAsyncSound();
            }
            else
            {
                _aviSoundInput = !Global.Emulator.StartAsyncSound()
                    ? new MetaspuAsync(Global.Emulator.SyncSoundProvider, ESynchMethod.ESynchMethod_V)
                    : Global.Emulator.SoundProvider;
            }
            _dumpProxy = new MetaspuSoundProvider(ESynchMethod.ESynchMethod_V);
            RewireSound();
        }
		private void SaveConfigAsMenuItem_Click(object sender, EventArgs e)
		{
			var path = PathManager.DefaultIniPath;
			var sfd = new SaveFileDialog
			{
				InitialDirectory = Path.GetDirectoryName(path),
				FileName = Path.GetFileName(path),
				Filter = "Config File (*.ini)|*.ini"
			};

			var result = sfd.ShowHawkDialog();
			if (result == DialogResult.OK)
			{
				SaveConfig(sfd.FileName);
				GlobalWin.OSD.AddMessage("Copied settings");
			}
		}
Beispiel #18
0
		private string GetSaveFileFromUser()
		{
			var sfd = new SaveFileDialog
			{
				Filter = "Text (*.txt)|*.txt|All Files|*.*",
				RestoreDirectory = true,
				InitialDirectory = RomDirectory
			};

			if (_domain.Name == "File on Disk")
			{
				sfd.FileName = Path.GetFileNameWithoutExtension(RomName) + ".txt";
			}
			else
			{
				sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
			}

			var result = sfd.ShowHawkDialog();

			return result == DialogResult.OK ? sfd.FileName : string.Empty;
		}
Beispiel #19
0
		public void SaveFile()
		{
			string path = PathManager.MakeAbsolutePath(
						Global.Config.PathEntries[Global.Emulator.SystemId, "Screenshots"].Path,
						Global.Emulator.SystemId);

			var di = new DirectoryInfo(path);

			if (!di.Exists)
			{
				di.Create();
			}

			var sfd = new SaveFileDialog
			{
				FileName = PathManager.FilesystemSafeName(Global.Game) + "-Palettes",
				InitialDirectory = path,
				Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*",
				RestoreDirectory = true
			};

			var result = sfd.ShowHawkDialog();
			if (result != DialogResult.OK)
			{
				return;
			}

			var file = new FileInfo(sfd.FileName);
			var b = this.bmp;

			ImageFormat i;
			string extension = file.Extension.ToUpper();

			switch (extension)
			{
				default:
				case ".PNG":
					i = ImageFormat.Png;
					break;
				case ".BMP":
					i = ImageFormat.Bmp;
					break;
			}

			b.Save(file.FullName, i);
		}
Beispiel #20
0
        private FileInfo GetFileFromUser()
        {
            var sfd = new SaveFileDialog();
            if (_logFile == null)
            {
                sfd.FileName = PathManager.FilesystemSafeName(Global.Game) + ".log";
                sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null);
            }
            else if (!string.IsNullOrWhiteSpace(_logFile.FullName))
            {
                sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
                sfd.InitialDirectory = Path.GetDirectoryName(_logFile.FullName);
            }
            else
            {
                sfd.FileName = Path.GetFileNameWithoutExtension(_logFile.FullName);
                sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null);
            }

            sfd.Filter = "Log Files (*.log)|*.log|Text Files (*.txt)|*.txt|All Files|*.*";
            sfd.RestoreDirectory = true;
            var result = sfd.ShowHawkDialog();
            if (result == DialogResult.OK)
            {
                return new FileInfo(sfd.FileName);
            }
            else
            {
                return null;
            }
        }
Beispiel #21
0
		private void BrowseBtn_Click(object sender, EventArgs e)
		{			
			string movieFolderPath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
			
			// Create movie folder if it doesn't already exist
			try
			{
				if (!Directory.Exists(movieFolderPath))
				{
					Directory.CreateDirectory(movieFolderPath);
				}
			}
			catch (Exception movieDirException)
			{
				if (movieDirException is IOException ||
						movieDirException is UnauthorizedAccessException ||
						movieDirException is PathTooLongException
					)
				{
					//TO DO : Pass error to user?
				}
				else throw;
			}
			
			var sfd = new SaveFileDialog
			{
				InitialDirectory = movieFolderPath,
				DefaultExt = "." + Global.MovieSession.Movie.PreferredExtension,
				FileName = RecordBox.Text,
				OverwritePrompt = false,
				Filter = "Movie Files (*." + Global.MovieSession.Movie.PreferredExtension + ")|*." + Global.MovieSession.Movie.PreferredExtension + "|All Files|*.*"
			};

			var result = sfd.ShowHawkDialog();
			if (result == DialogResult.OK
				&& !string.IsNullOrWhiteSpace(sfd.FileName))
			{
				RecordBox.Text = sfd.FileName;
			}
		}