Mercurial > fife-parpg
view tools/object_editor.py @ 697:ecaa4d98f05f tip
Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
* Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring.
* GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass.
* The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class.
* The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged.
* Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Sat, 18 Jun 2011 00:28:40 -1000 |
parents | 81641655bc38 |
children |
line wrap: on
line source
#!/usr/bin/env python # -*- coding: utf-8 -*- # #################################################################### # Copyright (C) 2005-2009 by the FIFE team # http://www.fifengine.de # This file is part of FIFE. # # FIFE is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # #################################################################### import sys, os, wx import wx.grid as gridlib class AttributedClass(object): def __init__(self): self.custom_attrs = {} class Object(AttributedClass): def __init__(self): self.actions = [] self.blocking = False self.parent = None self.filename = '' class Action(AttributedClass): def __init__(self): self.animations = {} class Animation(object): def __init__(self): self.frames = [] self.actionframe = -1 self.filename = '' class Image(object): def __init__(self): self.delay = 0 self.x_offset = 0 self.y_offset = 0 self.filename = '' class FifeObjectEditor(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(700, 500)) self.CreateStatusBar() self.SetMenuBar(self.createMenus()) splitter = wx.SplitterWindow(self, -1) self.tree = wx.TreeCtrl(splitter, 1, wx.DefaultPosition, (-1,-1)) root = self.tree.AddRoot('New Project') self.notebook = wx.Notebook(splitter, -1) self.projectPropertyPanel = self.createProjectPropertyPanel(self.notebook) self.objectPropertyPanel = self.createObjectPropertyPanel(self.notebook) self.actionPropertyPanel = self.createActionPropertyPanel(self.notebook) self.animationPropertyPanel = self.createAnimationPropertyPanel(self.notebook) self.imagePropertyPanel = self.createImagePropertyPanel(self.notebook) self.customAttrPanel = self.createCustomAttrPanel(self.notebook) self.notebook.AddPage(self.projectPropertyPanel, 'Settings') self.notebook.AddPage(self.customAttrPanel, 'Custom Attributes') splitter.SplitVertically(self.tree, self.notebook, 250) self.Centre() def createMenus(self): menuBar = wx.MenuBar() file = wx.Menu() edit = wx.Menu() help = wx.Menu() file.Append(110, '&Open Project', 'Loads project file') file.Append(111, '&Save Project', 'Saves project file') file.Append(112, 'Save Project &As...', 'Saves project file with given filename') file.AppendSeparator() file.Append(110, '&Open Object', 'Loads object file') file.Append(111, '&Save Object', 'Saves object file') file.Append(112, 'Save Object &As...', 'Saves object file with given filename') file.AppendSeparator() file.Append(113, 'O&pen Animation', 'Loads animation file') file.Append(114, 'Sa&ve Animation', 'Saves animation file') file.Append(115, 'Save Animation As...', 'Saves animation file with given filename') edit.Append(130, '&Create New Object', 'Creates a new object') edit.Append(131, '&Delete Object', 'Deletes selected object') edit.AppendSeparator() edit.Append(132, 'C&reate New Action', 'Creates new action') edit.Append(133, 'D&elete Action', 'Deletes selected action') edit.AppendSeparator() edit.Append(134, 'Cr&eate New Animation', 'Creates new animation') edit.Append(135, 'De&lete Animation', 'Deletes selected animation') edit.AppendSeparator() edit.Append(136, 'Add Frames', 'Adds frames into animation') edit.Append(137, 'Delete Frames', 'Deletes selected frames from animation') help.Append(150, '&About', 'About the FIFE Object Editor') menuBar.Append(file, "&File") menuBar.Append(edit, "&Edit") menuBar.Append(help, "&Help") return menuBar def createProjectPropertyPanel(self, notebook): panel = wx.Panel(notebook, -1) vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(wx.StaticText(panel, -1, 'Project Name', size=(150, -1))) panel.projectName = wx.TextCtrl(panel, -1, '') hbox.Add(panel.projectName, wx.EXPAND) vbox.Add(hbox, 0, wx.EXPAND | wx.ALL, 4) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(wx.StaticText(panel, -1, 'Author', size=(150, -1))) panel.projectAuthor = wx.TextCtrl(panel, -1, '') hbox.Add(panel.projectAuthor, wx.EXPAND) vbox.Add(hbox, 0, wx.EXPAND | wx.ALL, 4) panel.SetSizer(vbox) return panel def createObjectPropertyPanel(self, notebook): panel = wx.Panel(notebook, -1) return panel def createActionPropertyPanel(self, notebook): panel = wx.Panel(notebook, -1) return panel def createAnimationPropertyPanel(self, notebook): panel = wx.Panel(notebook, -1) return panel def createImagePropertyPanel(self, notebook): panel = wx.Panel(notebook, -1) return panel def createCustomAttrPanel(self, notebook): panel = wx.Panel(notebook, -1) vbox = wx.BoxSizer(wx.VERTICAL) grid = gridlib.Grid(notebook, -1) grid.CreateGrid(100, 2) panel.grid = grid vbox.Add(panel.grid, 0, wx.EXPAND | wx.ALL, 4) panel.SetSizer(vbox) return panel class FifeObjectEditorApp(wx.App): def OnInit(self): myframe = FifeObjectEditor(None, -1, "FIFE Object Editor") myframe.Show(True) return True if __name__ == '__main__': app = FifeObjectEditorApp(0) app.MainLoop()