static private ShowOutputMessage ( string message ) : void | ||
message | string | |
return | void |
private void Window_ContentRendered(object sender, EventArgs e) { if (ScriptsBuilder.ReloadScripts()) { // Sucess: this.progresslbl.Content = "Loading..."; System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); timer.Interval = 5; timer.Tick += timer_Tick; timer.Enabled = true; Result = true; } else { progressBar.Value = 80; this.progresslbl.Content = "Failure!"; Result = false; EditorCommands.ShowOutputMessage("Error while compiling the scripts"); ErrorDataGrid.Visibility = Visibility.Visible; ErrorDataGrid.ItemsSource = ScriptsBuilder.Logger.Errors; } }
// Attemps to load Gibbo's default layout public static void LoadGibbsoDefaultLayout() { EditorCommands.ShowOutputMessage("Attempting to load Gibbo's default layout"); if (LoadLayout("Default")) { EditorCommands.ShowOutputMessage("Gibbo's default layout has been loaded successfully"); } else { EditorCommands.ShowOutputMessage("Gibbo's saved layout load attempt has failed"); } }
public TutorialWindow(string xmlPath, string rootPath, string title) { InitializeComponent(); this.title = title; Title = title; if (!ReadTutorial(xmlPath)) { EditorCommands.ShowOutputMessage("Error loading tutorial"); this.Close(); } this.rootPath = rootPath; RenderPage(0); }
/// <summary> /// Loads a saved project /// </summary> internal static bool LoadProject() { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Open project"; ofd.Filter = @"(*.gibbo)|*.gibbo"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { LoadProject(ofd.FileName); EditorCommands.AddToProjectHistory(ofd.FileName); } EditorCommands.ShowOutputMessage("Project loaded with success"); return(false); }
/// <summary> /// Saves the current project using a different thread /// </summary> internal static void SaveProject() { if (SceneManager.GameProject != null) { // Save project in a different thread Thread saveThread = new Thread(() => { SceneManager.GameProject.Save(); if (UserPreferences.Instance != null) { GibboHelper.SerializeObject(SceneManager.GameProject.ProjectPath + "\\_userPrefs.pgb", UserPreferences.Instance); } }); EditorCommands.ShowOutputMessage("Project Saved"); saveThread.Start(); } }
private bool RenderList() { string tutorialsPath = AppDomain.CurrentDomain.BaseDirectory + @"\Tutorials"; if (!Directory.Exists(tutorialsPath)) { EditorCommands.ShowOutputMessage("Tutorials folder not found"); return(false); } DirectoryInfo directory = new DirectoryInfo(tutorialsPath); if (!getTutorials(directory)) { EditorCommands.ShowOutputMessage("Error loading tutorials"); return(false); } foreach (FileInfo file in tutorialFiles) { string xmlFullPath = file.FullName; XDocument doc = XDocument.Load(xmlFullPath); string category = doc.Element("Tutorial").Element("Info").Element("Category").Value; if (!tutorialsSections.ContainsKey(category)) { tutorialsSections.Add(category, new TutorialsCategoryContainer(category)); DockPanel.SetDock(tutorialsSections[category], Dock.Top); this.ContainersDockPanel.Children.Add(tutorialsSections[category]); } if (!(tutorialsSections[category] as TutorialsCategoryContainer).AddTutorialPreview(xmlFullPath, file.DirectoryName)) { return(false); } } return(true); }
// Attemps to create a new Layout public static bool CreateNewLayout(string layoutName) { if (layoutName.Trim().Equals(string.Empty)) { return(false); } EditorCommands.ShowOutputMessage("Attempting to create a new layout"); if (layoutName.Equals("Default")) { EditorCommands.ShowOutputMessage("Cannot override Gibbo's Default Layout"); return(false); } if (RemoveLayout(layoutName)) { EditorCommands.ShowOutputMessage("Attempting to replace layout"); } try { EditorCommands.ShowOutputMessage("Attempting to save the layout"); var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(DockManager); using (var stream = new StreamWriter(layoutPath + layoutName + LayoutExtension)) serializer.Serialize(stream); EditorCommands.ShowOutputMessage("Layout saved successfully"); } catch (Exception) { EditorCommands.ShowOutputMessage("Layout saving attempt has failed"); return(false); } Properties.Settings.Default.Layout = layoutName; return(true); }
internal static void RenderPicture(ref Image picture, string path, int maxWidth, int maxHeight) { if (!File.Exists(path)) { EditorCommands.ShowOutputMessage("Error loading Images"); return; } BitmapImage image = new BitmapImage(); image.BeginInit(); // AppDomain.CurrentDomain.BaseDirectory + @"\Tutorials\FirstSteps\Pictures\" image.UriSource = new Uri(path, UriKind.Absolute); image.CacheOption = BitmapCacheOption.OnLoad; image.EndInit(); if (image.Width < maxWidth && image.Height < maxHeight) { picture.Width = image.Width; picture.Height = image.Height; } else { double ratioX = (double)maxWidth / (double)image.Width; double ratioY = (double)maxHeight / (double)image.Height; // use whichever multiplier is smaller double ratio = ratioX < ratioY ? ratioX : ratioY; // now we can get the new height and width int newWidth = Convert.ToInt32(image.Width * ratio); int newHeight = Convert.ToInt32(image.Height * ratio); picture.Width = newWidth; picture.Height = newHeight; } picture.Source = image; }
public static bool RemoveLayout(string layoutName) { EditorCommands.ShowOutputMessage("Attempting to remove layout"); if (layoutName.Equals("Default")) { EditorCommands.ShowOutputMessage("Cannot remove Gibbo's Default Layout"); return(false); } if (LayoutExists(layoutName)) { try { System.IO.File.Delete(layoutPath + layoutName + layoutExtension); if (Properties.Settings.Default.Layout == layoutName) { Properties.Settings.Default.Layout = string.Empty; } } catch { EditorCommands.ShowOutputMessage("Attempt to remove layout has failed"); return(false); } } return(true); }
internal static bool LoadProject(string filename) { try { if (File.Exists(filename)) { SceneManager.GameProject = GibboProject.Load(filename); //File.Copy("Farseer Engine MonoGame OpenGL.dll", SceneManager.GameProject.ProjectPath + "\\Farseer Engine MonoGame OpenGL.dll", true); File.Copy("Gibbo.Library.dll", SceneManager.GameProject.ProjectPath + "\\Gibbo.Library.dll", true); File.Copy("Project Templates\\Gibbo.Library.xml", SceneManager.GameProject.ProjectPath + "\\Gibbo.Library.xml", true); File.Copy("Project Templates\\Gibbo.Engine.Windows.exe", SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe", true); GibboHelper.CopyDirectory("Project Templates\\libs", SceneManager.GameProject.ProjectPath + "", true); File.Copy("MonoGame.Framework.dll", SceneManager.GameProject.ProjectPath + "\\MonoGame.Framework.dll", true); File.Copy("OpenTK.dll", SceneManager.GameProject.ProjectPath + "\\OpenTK.dll", true); // load user settings: if (!File.Exists(SceneManager.GameProject.ProjectPath + "\\_userPrefs.pgb")) { UserPreferences.Instance = new UserPreferences(); GibboHelper.SerializeObject(SceneManager.GameProject.ProjectPath + "\\_userPrefs.pgb", UserPreferences.Instance); } else { UserPreferences.Instance = GibboHelper.DeserializeObject(SceneManager.GameProject.ProjectPath + "\\_userPrefs.pgb") as Model.UserPreferences; } SceneManager.ActiveScene = null; EditorHandler.SelectedGameObjects.Clear(); EditorHandler.ChangeSelectedObjects(); EditorHandler.SceneTreeView.CreateView(); EditorHandler.ProjectTreeView.CreateView(); CompilerWindow cf = new CompilerWindow(); cf.ShowDialog(); bool success = cf.Result; Reload(); if (success) { LoadLastScene(); EditorCommands.ShowOutputMessage("Project loaded with success"); //kryptonNavigator1.SelectedIndex = 1; } else { EditorCommands.ShowOutputMessage("Project loaded with script errors"); } EditorHandler.Settings = new IniFile(SceneManager.GameProject.ProjectPath + "\\settings.ini"); return(true); } } catch (Exception ex) { MessageBox.Show("Invalid File\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(false); }