public static void Compile() { if (IDEProject.inst().Settings.CompilerPath == null || IDEProject.inst().Settings.CompilerPath.Trim().Length == 0) { if (ModernDialog.ShowMessage("You need to set a compile file in settings", "No princess here", System.Windows.MessageBoxButton.OKCancel) == MessageBoxResult.OK) { IDESettingsDlg dlg = new IDESettingsDlg(); dlg.ShowDialog(); } return; } IDEProject.inst().CompilerOutput = ""; IDEProject.inst().CompileErrors.Clear(); PluginLib.ICompilerService comp = null; if (IDEProject.inst().Settings.Compiler != null && IDEProject.inst().Settings.Compiler.Length > 0) { comp = PluginManager.inst().Compilers.FirstOrDefault(c => c.Name.Equals(IDEProject.inst().Settings.Compiler)); if (comp == null) { ModernDialog.ShowMessage(String.Format("Unable to find compiler: \"{0}\"", IDEProject.inst().Settings.Compiler), "Error", MessageBoxButton.OK); return; } } else { comp = PluginManager.inst().Compilers.FirstOrDefault(); if (comp == null) { ModernDialog.ShowMessage("No compiler plugins are installed", "Error", MessageBoxButton.OK); return; } } Parago.Windows.ProgressDialogResult result = Parago.Windows.ProgressDialog.Execute(null, "Compiling...", (a, b) => { comp.CompileFile(IDEProject.inst().Settings.CompilerPath, IDEProject.inst(), ErrorHandler.inst()); MainWindow.inst().Dispatcher.Invoke(delegate() { if (IDEProject.inst().CompileErrors.Count != 0) { Dlg.CompErrDlg dlg = new Dlg.CompErrDlg(); dlg.ShowDialog(); } if (IDEProject.inst().CompileErrors.Count == 0) { foreach (PluginLib.ICompilerService c in PluginManager.inst().Compilers) { c.PostCompile(IDEProject.inst().Settings.CompilerPath, IDEProject.inst().Settings.SourceTree, ErrorHandler.inst()); } Dlg.CompSuccessDlg dlg = new Dlg.CompSuccessDlg(); dlg.ShowDialog(); } }); }); }
private void LoadFile_Click(object sender, RoutedEventArgs e) { bool MoveAndExtract(string filePath) { string newTargetFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/tmp/sourceFiles/"; Directory.CreateDirectory(newTargetFolder); File.Copy(filePath, newTargetFolder + Path.GetFileName(filePath), true); var process = new Process { StartInfo = new ProcessStartInfo { FileName = "py", Arguments = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/Scripts/SARC/SARCExtract.py " + newTargetFolder + Path.GetFileName(filePath), WindowStyle = ProcessWindowStyle.Hidden } }; process.Start(); process.WaitForExit(); string extractedFolderName = newTargetFolder + Path.GetFileNameWithoutExtension(filePath) + "/"; DirectoryInfo dirInfo = new DirectoryInfo(extractedFolderName); if (!dirInfo.Exists) { throw new Exception("Failed to extact; check the stdout and stderr output of the process variable"); } return(dirInfo.Exists); } // open and extract SZS OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Yoshi Fruit Cart package file (Ysi_Cmn.pack)|Ysi_Cmn.pack"; if (openFileDialog.ShowDialog() != true) { // no file selected return; } Parago.Windows.ProgressDialogResult result = Parago.Windows.ProgressDialog.Execute(this, "Loading data...", (progress) => { Parago.Windows.ProgressDialog.Report(progress, 40, "Extracting game package file..."); if (!MoveAndExtract(openFileDialog.FileName)) { throw new System.Exception(); } Parago.Windows.ProgressDialog.Report(progress, 80, "Extracting scene file..."); if (!MoveAndExtract(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/tmp/sourceFiles/Ysi_Cmn/Common/Scene/Ysi.szs")) { throw new System.Exception(); } Parago.Windows.ProgressDialog.Report(progress, 90, "Populating GameDataContainer..."); gameDataContainer = new NintendoLand.DataFormats.GameDataContainer(Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tmp", "sourceFiles", "Ysi" )); Parago.Windows.ProgressDialog.Report(progress, 95, "Populating dropdown..."); Application.Current.Dispatcher.Invoke(new Action(() => { foreach (string map in gameDataContainer.MapsAvailable) { ComboBoxItem item = new ComboBoxItem(); item.Name = Path.GetFileNameWithoutExtension(map); int levelIndex = int.Parse(Path.GetFileNameWithoutExtension(map).Replace("MapData", "")); if (levelIndex == 99) { item.Content = "Tutorial stage"; } else if (levelIndex > 49) { item.Content = "Gate " + (levelIndex + 1) + " (UNUSED)"; } else { item.Content = "Gate " + (levelIndex + 1); } LevelSelector.Items.Add(item); } LevelSelector.IsEnabled = true; LevelSelector.SelectedIndex = 1; })); }); }