private void OnFormClosed(object sender, FormClosedEventArgs e) { if (Game != null) { Canvas.Release(); Sprite.Dispose(); Entity.Dispose(); Win.Dispose(); Game.Dispose(); Game = null; } }
private void OnFormClosed(object sender, FormClosedEventArgs e) { if(Game!=null) { Canvas.Release(); Sprite.Dispose(); Entity.Dispose(); Win.Dispose(); Game.Dispose(); Game = null; } }
private void button1_Click(object sender, EventArgs e) { if (Game == null) { Game = new WAdGame(); Canvas.Create(Game, @"F:\Program Files\WME DevKit\projects\wme_demo\wme_demo.wpr", @"c:\test.log"); Sprite = new WSprite(Game); Sprite.LoadFromFile(@"actors\molly\rr\walk.sprite"); Entity = new WAdEntity(Game); Entity.LoadFromFile(@"entities\oldguy\oldguy.entity"); Win = new WUIWindow(Game); Win.LoadFromFile(@"interface\system\mainmenu.window"); Game.Windows.Add(Win); Game.FocusedWindow = Win; } }
private void button1_Click(object sender, EventArgs e) { if(Game==null) { Game = new WAdGame(); Canvas.Create(Game, @"F:\Program Files\WME DevKit\projects\wme_demo\wme_demo.wpr", @"c:\test.log"); Sprite = new WSprite(Game); Sprite.LoadFromFile(@"actors\molly\rr\walk.sprite"); Entity = new WAdEntity(Game); Entity.LoadFromFile(@"entities\oldguy\oldguy.entity"); Win = new WUIWindow(Game); Win.LoadFromFile(@"interface\system\mainmenu.window"); Game.Windows.Add(Win); Game.FocusedWindow = Win; } }
////////////////////////////////////////////////////////////////////////// private bool InitEngine(string DefinitionFile, WmeCanvas Canvas) { try { DisposeNatives(); string ProjectFile = GetProjectFile(DefinitionFile, ParentForm); if (ProjectFile != null) { string LogFile = Path.Combine(Path.GetDirectoryName(ProjectFile), "WindowEdit.log"); Game = new WAdGame(); Game.ForceScripts = true; Game.DoNotExpandStrings = true; Game.EditorMode = true; if (!Canvas.Create(Game, ProjectFile, LogFile)) { DisposeNatives(); return false; } _Canvas = Canvas; _Canvas.PaintContent += new WmeCanvas.PaintContentDelegate(OnPaintContent); _Canvas.MouseMove += new MouseEventHandler(OnMouseMove); _Canvas.MouseDown += new MouseEventHandler(OnMouseDown); _Canvas.MouseUp += new MouseEventHandler(OnMouseUp); _Canvas.KeyDown += new KeyEventHandler(OnKeyDown); Application.Idle += new EventHandler(OnAppIdle); return true; } return false; } catch(Exception e) { MessageBox.Show("Error initializing game engine:\n\n" + e.Message, Form.ActiveForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } }
////////////////////////////////////////////////////////////////////////// private void DisposeNatives() { if(_Canvas != null) { _Canvas.PaintContent -= new WmeCanvas.PaintContentDelegate(OnPaintContent); _Canvas.MouseMove -= new MouseEventHandler(OnMouseMove); _Canvas.MouseDown -= new MouseEventHandler(OnMouseDown); _Canvas.MouseUp -= new MouseEventHandler(OnMouseUp); _Canvas.KeyDown -= new KeyEventHandler(OnKeyDown); _Canvas.Release(); _Canvas.Invalidate(); _Canvas = null; } if(LayoutTree != null) { LayoutTree.SelectionsChanged -= new EventHandler(OnSelectionChanged); LayoutTree.ItemDrag -= new ItemDragEventHandler(TreeItemDrag); LayoutTree.DragEnter -= new DragEventHandler(TreeDragEnter); LayoutTree.DragOver -= new DragEventHandler(TreeDragOver); LayoutTree.DragLeave -= new EventHandler(TreeDragLeave); LayoutTree.DragDrop -= new DragEventHandler(TreeDragDrop); LayoutTree.KeyUp -= new KeyEventHandler(TreeKeyUp); LayoutTree.Nodes.Clear(); LayoutTree.SelectedNodes.Clear(); } Application.Idle -= new EventHandler(OnAppIdle); if (_PropGrid != null) { _PropGrid.SelectedGridItemChanged -= new SelectedGridItemChangedEventHandler(OnPropertySelected); _PropGrid.SelectedObject = null; } RectResizer = null; if (Window != null) { Window.Dispose(); Window = null; } if (InvBox != null) { InvBox.Dispose(); InvBox = null; } if (RespBox != null) { RespBox.Dispose(); RespBox = null; } if (Game != null) { Game.Dispose(); Game = null; } }