public void GLControl_Load(object sender, EventArgs e) { ControllerEditor = new ControllerEditor(glControl.ClientSize, new Input(glControl)); ControllerEditor.ScenePlayEvent += ControllerEditor_ScenePlayed; ControllerEditor.ScenePauseEvent += ControllerEditor_ScenePaused; ControllerEditor.SceneStopEvent += ControllerEditor_SceneStopped; ControllerEditor.Update += ControllerEditor_Update; ControllerFiles = new ControllerFiles(this, ControllerEditor, filesRecent); UpdateTransformLabels(null); PortalDepth.ValueChanged += IntegerUpDown_ValueChanged; PortalDepth.Value = 40; SetPortalRendering(true); ToolPanel.Initialize(ControllerEditor); PropertiesEditor.Initialize(ControllerEditor); Time.Initialize(ControllerEditor); Slider_ValueChanged( null, new RoutedPropertyChangedEventArgs<double>(ControllerEditor.physicsStepSize, ControllerEditor.physicsStepSize) ); //Start the drawing loop last to make sure all listeners are in place. _loop = new GLLoop(glControl, ControllerEditor); _loop.Run(60); }
public void Initialize(ControllerEditor controllerEditor) { _controllerEditor = controllerEditor; _controllerEditor.TimeChanged += Update; _controllerEditor.ScenePlayEvent += _controllerEditor_ScenePlayEvent; _controllerEditor.SceneStopEvent += _controllerEditor_SceneStopEvent; }
public ToolDefault(ControllerEditor controller) : base(controller) { string filepath = Path.Combine(Directory.GetCurrentDirectory(), "editor assets", "models", "coordinateArrows.obj"); ModelLoader loader = new ModelLoader(); translationModel = loader.LoadObj(filepath); translationModel.Transform.Position = new Vector3(0, 0, 5); }
public void Initialize(ControllerEditor controller) { _controller = controller; _controller.SceneModified += _controller_SceneModified; _controller.LevelChanged += (ControllerEditor control, string filepath) => { control.selection.SelectionChanged += Selection_SelectionChanged; }; SetSelected(null); }
public ToolButton(ControllerEditor controller, Tool tool, BitmapImage image) { InitializeComponent(); _tool = tool; _controller = controller; if (image != null) { Button.Content = new System.Windows.Controls.Image { Source = image, VerticalAlignment = VerticalAlignment.Center }; } Button.Click += Button_Click; }
public ControllerFiles(MainWindow controller, ControllerEditor controllerEditor, System.Windows.Controls.MenuItem recentFiles) { ControllerWPF = controller; ControllerEditor = controllerEditor; ControllerEditor.LevelLoaded += ControllerEditor_LevelLoaded; ControllerEditor.LevelSaved += ControllerEditor_LevelSaved; ControllerEditor.LevelCreated += ControllerEditor_LevelCreated; _saveFileDialog = new SaveFileDialog(); _loadFileDialog = new OpenFileDialog(); _saveFileDialog.FileOk += _saveFileDialog_FileOk; _loadFileDialog.FileOk += _loadFileDialog_FileOk; _saveFileDialog.Filter = Serializer.fileExtensionName + " (*." + Serializer.fileExtension + ")|*." + Serializer.fileExtension + "|TXT|*.txt"; _loadFileDialog.Filter = Serializer.fileExtensionName + " (*." + Serializer.fileExtension + ")|*." + Serializer.fileExtension + "|TXT|*.txt"; //TODO: Figure out how to add callback for user pressing the cancel button in file dialog window. FilepathCurrent = null; Loading = false; RecentFiles = new RecentFilesList(recentFiles, this); }
/// <summary> /// Adds tool buttons. Intended to be called once. /// </summary> /// <param name="controller"></param> public void Initialize(ControllerEditor controller) { Debug.Assert(controller != null); controller.ToolChanged += ControllerEditor_ToolChanged; string AssetsDirectory = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "editor assets"); var arguments = new[] { new { tool = (Tool)new ToolAddEntity(controller), image = new BitmapImage(new Uri(System.IO.Path.Combine(AssetsDirectory, "icons", "entityIcon.png"))) }, new { tool = (Tool)new ToolAddPortal(controller), image = new BitmapImage(new Uri(System.IO.Path.Combine(AssetsDirectory, "icons", "portalIcon.png"))) }, new { tool = (Tool)new ToolPortalLinker(controller), image = new BitmapImage(new Uri(System.IO.Path.Combine(AssetsDirectory, "icons", "polygonLinkerIcon.png"))) }, new { tool = (Tool)new ToolAddActor(controller), image = new BitmapImage(new Uri(System.IO.Path.Combine(AssetsDirectory, "icons", "entityIcon.png"))) }, new { tool = (Tool)new ToolAddWall(controller), image = new BitmapImage(new Uri(System.IO.Path.Combine(AssetsDirectory, "icons", "polygonIcon.png"))) }, new { tool = (Tool)new ToolAddPlayer(controller), image = new BitmapImage(new Uri(System.IO.Path.Combine(AssetsDirectory, "icons", "polygonIcon.png"))) } }; for (int i = 0; i < arguments.Length; i++) { AddButton(controller, arguments[i].tool, arguments[i].image); } }
public ToolAddPortal(ControllerEditor controller) : base(controller) { }
public Tool(ControllerEditor controller) { Enabled = false; Controller = controller; }
private void ControllerEditor_Update(ControllerEditor controller) { Invoke(() => { Vector2 mousePos = ControllerEditor.GetMouseWorld(); MouseCoordinates.Content = mousePos.X.ToString("0.00") + ", " + mousePos.Y.ToString("0.00"); int fps = (int)Math.Round(_loop.UpdatesPerSecond * (double)_loop.MillisecondsPerStep / _loop.GetAverage()); FrameRate.Content = "FPS " + fps.ToString() + "/" + _loop.UpdatesPerSecond.ToString(); var selection = ControllerEditor.selection.GetAll(); if (selection.Count > 0) { UpdateTransformLabels(selection[0]); PropertiesEditor.SetSelected(selection[0]); } else { UpdateTransformLabels(null); PropertiesEditor.SetSelected(null); } }); }
private void _controllerEditor_ScenePlayEvent(ControllerEditor controller) { MainWindow.Invoke(() => { TimeValue.IsEnabled = false; _update(controller.GetTime()); }); }
private void ControllerEditor_LevelCreated(ControllerEditor controller, string filepath) { MainWindow.Invoke(() => { }); }
public ToolAddWall(ControllerEditor controller) : base(controller) { }
private void ControllerEditor_ToolChanged(ControllerEditor controller, Tool tool) { MainWindow.Invoke(() => { if (ButtonMap.ContainsKey(tool)) { ButtonMap[tool].Button.IsChecked = true; } else { foreach (ToolButton button in ButtonMap.Values) { button.Button.IsChecked = false; } } }); }
private void AddButton(ControllerEditor controller, Tool tool, BitmapImage buttonImage) { ToolButton button = new ToolButton(controller, tool, buttonImage); ToolGrid.Children.Add(button); ButtonMap.Add(tool, button); }
private void Update(ControllerEditor controllerEditor, double time) { MainWindow.Invoke(() => { _update(time); }); }
private void ControllerEditor_LevelSaved(ControllerEditor controller, string filepath) { MainWindow.Invoke(() => { Debug.Assert(filepath != null); Debug.Assert(filepath != ""); RecentFiles.AddFilepath(filepath); ControllerWPF.Status.Content = "Saved"; FilepathCurrent = filepath; }); }
public ToolAddActor(ControllerEditor controller) : base(controller) { }
private void ControllerEditor_SceneStopped(ControllerEditor controller) { Invoke(() => { toolStart.IsEnabled = true; toolPause.IsEnabled = false; toolStop.IsEnabled = false; menuRunStart.IsEnabled = true; menuRunPause.IsEnabled = false; menuRunStop.IsEnabled = false; Status.Content = "Stopped"; }); }