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; } }
private void ProjectsListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (ProjectsListBox.SelectedItem != null) { string path = (string)(ProjectsListBox.SelectedItem as ListBoxItem).Tag; EditorCommands.AddToProjectHistory(path); StartEditor(path); } }
private void SettingsBtn_MouseUp(object sender, MouseButtonEventArgs e) { if (MessageBox.Show("Are you sure you want to delete this component?", "Warning!", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { ObjectComponent oc = this.PropertyGrid.SelectedObject as ObjectComponent; oc.Transform.GameObject.RemoveComponent(oc); this.Visibility = System.Windows.Visibility.Collapsed; EditorCommands.CheckPropertyGridConsistency(); } }
// 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"); } }
private void newProjectBtn_Click(object sender, RoutedEventArgs e) { NewProjectWindow np = new NewProjectWindow(); np.ShowDialog(); // A project was created? if (np.DialogResult.Value) { EditorCommands.AddToProjectHistory(np.ProjectPath); StartEditor(np.ProjectPath); } }
private void browseBtn_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Open project"; ofd.Filter = @"(*.gibbo)|*.gibbo"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { EditorCommands.AddToProjectHistory(ofd.FileName); StartEditor(ofd.FileName); } }
private void loadBtn_Click(object sender, RoutedEventArgs e) { if (ProjectsListBox.SelectedItem != null) { string path = (string)((ProjectsListBox.SelectedItem as ListBoxItem).Tag); EditorCommands.AddToProjectHistory(path); StartEditor(path); } else { System.Windows.MessageBox.Show("No project selected!\nPlease select from the list, browser or create a new project..", "Ups", MessageBoxButton.OK, MessageBoxImage.Error); } }
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> /// Changes the property grid and property label to the selected objects /// </summary> public static void ChangeSelectedObjects() { EditorHandler.TilesetMenuItems.IsEnabled = false; if (SelectedGameObjects != null) { if (SelectedGameObjects.Count == 1) { ChangeSelectedObject(SelectedGameObjects[0]); if (SelectedGameObjects[0] is Tileset) { EditorHandler.TilesetBrushControl.ChangeSelectionSize((SelectedGameObjects[0] as Tileset).TileWidth, (SelectedGameObjects[0] as Tileset).TileHeight); EditorHandler.TilesetBrushControl.ChangeImageSource((SelectedGameObjects[0] as Tileset).ImageName); SceneManager.ActiveTileset = (Tileset)SelectedGameObjects[0]; EditorHandler.TilesetMenuItems.IsEnabled = true; } else { SceneManager.ActiveTileset = null; } EditorCommands.CreatePropertyGridView(); } else if (SelectedGameObjects.Count == 0) { SceneManager.ActiveTileset = null; if (EditorHandler.SceneTreeView.SelectedItem != null) { (EditorHandler.SceneTreeView.SelectedItem as DragDropTreeViewItem).IsSelected = false; } EditorCommands.CreatePropertyGridView(); } else { EditorCommands.CreatePropertyGridView(); } if (EditorHandler.TilesetBrushControl != null) { EditorHandler.TilesetBrushControl.InvalidateVisual(); } } }
void newItem_Click(object sender, RoutedEventArgs e) { GibboMenuItem _sender = (GibboMenuItem)sender; foreach (var ti in TreeViewExtension.GetSelectedTreeViewItems(treeView)) { ObjectComponent component = (ObjectComponent)Activator.CreateInstance((Type)_sender.Tag, new object[] { /* params here */ }); GameObject gameObject = (GameObject)ti.Tag; if (!gameObject.AddComponent(component)) { MessageBox.Show("The component was not added to " + gameObject.Name + ", the requirements are not met", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { EditorCommands.CreatePropertyGridView(); } } }
/// <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 void Compile() { this.Dispatcher.Invoke((Action)(() => { if (!ScriptsBuilder.ReloadScripts()) { ErrorDataGrid.ItemsSource = ScriptsBuilder.Logger.Errors; if (ErrorDataGrid.Items.Count > 0) { ErrorsExpander.IsExpanded = true; } } else { ErrorDataGrid.ItemsSource = null; EditorCommands.CreatePropertyGridView(); } })); }
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); }