Mercurial > fife-parpg
comparison tools/object_editor.py @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | |
children | 81641655bc38 |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
1 #!/usr/bin/python | |
2 import sys, os, wx | |
3 import wx.grid as gridlib | |
4 | |
5 class AttributedClass(object): | |
6 def __init__(self): | |
7 self.custom_attrs = {} | |
8 | |
9 class Object(AttributedClass): | |
10 def __init__(self): | |
11 self.actions = [] | |
12 self.blocking = False | |
13 self.parent = None | |
14 self.filename = '' | |
15 | |
16 class Action(AttributedClass): | |
17 def __init__(self): | |
18 self.animations = {} | |
19 | |
20 class Animation(object): | |
21 def __init__(self): | |
22 self.frames = [] | |
23 self.actionframe = -1 | |
24 self.filename = '' | |
25 | |
26 class Image(object): | |
27 def __init__(self): | |
28 self.delay = 0 | |
29 self.x_offset = 0 | |
30 self.y_offset = 0 | |
31 self.filename = '' | |
32 | |
33 class FifeObjectEditor(wx.Frame): | |
34 def __init__(self, parent, id, title): | |
35 wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(700, 500)) | |
36 self.CreateStatusBar() | |
37 | |
38 self.SetMenuBar(self.createMenus()) | |
39 | |
40 splitter = wx.SplitterWindow(self, -1) | |
41 | |
42 self.tree = wx.TreeCtrl(splitter, 1, wx.DefaultPosition, (-1,-1)) | |
43 root = self.tree.AddRoot('New Project') | |
44 | |
45 self.notebook = wx.Notebook(splitter, -1) | |
46 self.projectPropertyPanel = self.createProjectPropertyPanel(self.notebook) | |
47 self.objectPropertyPanel = self.createObjectPropertyPanel(self.notebook) | |
48 self.actionPropertyPanel = self.createActionPropertyPanel(self.notebook) | |
49 self.animationPropertyPanel = self.createAnimationPropertyPanel(self.notebook) | |
50 self.imagePropertyPanel = self.createImagePropertyPanel(self.notebook) | |
51 self.customAttrPanel = self.createCustomAttrPanel(self.notebook) | |
52 self.notebook.AddPage(self.projectPropertyPanel, 'Settings') | |
53 self.notebook.AddPage(self.customAttrPanel, 'Custom Attributes') | |
54 | |
55 splitter.SplitVertically(self.tree, self.notebook, 250) | |
56 | |
57 self.Centre() | |
58 | |
59 def createMenus(self): | |
60 menuBar = wx.MenuBar() | |
61 file = wx.Menu() | |
62 edit = wx.Menu() | |
63 help = wx.Menu() | |
64 | |
65 file.Append(110, '&Open Project', 'Loads project file') | |
66 file.Append(111, '&Save Project', 'Saves project file') | |
67 file.Append(112, 'Save Project &As...', 'Saves project file with given filename') | |
68 file.AppendSeparator() | |
69 file.Append(110, '&Open Object', 'Loads object file') | |
70 file.Append(111, '&Save Object', 'Saves object file') | |
71 file.Append(112, 'Save Object &As...', 'Saves object file with given filename') | |
72 file.AppendSeparator() | |
73 file.Append(113, 'O&pen Animation', 'Loads animation file') | |
74 file.Append(114, 'Sa&ve Animation', 'Saves animation file') | |
75 file.Append(115, 'Save Animation As...', 'Saves animation file with given filename') | |
76 | |
77 edit.Append(130, '&Create New Object', 'Creates a new object') | |
78 edit.Append(131, '&Delete Object', 'Deletes selected object') | |
79 edit.AppendSeparator() | |
80 edit.Append(132, 'C&reate New Action', 'Creates new action') | |
81 edit.Append(133, 'D&elete Action', 'Deletes selected action') | |
82 edit.AppendSeparator() | |
83 edit.Append(134, 'Cr&eate New Animation', 'Creates new animation') | |
84 edit.Append(135, 'De&lete Animation', 'Deletes selected animation') | |
85 edit.AppendSeparator() | |
86 edit.Append(136, 'Add Frames', 'Adds frames into animation') | |
87 edit.Append(137, 'Delete Frames', 'Deletes selected frames from animation') | |
88 | |
89 help.Append(150, '&About', 'About the FIFE Object Editor') | |
90 | |
91 menuBar.Append(file, "&File") | |
92 menuBar.Append(edit, "&Edit") | |
93 menuBar.Append(help, "&Help") | |
94 return menuBar | |
95 | |
96 def createProjectPropertyPanel(self, notebook): | |
97 panel = wx.Panel(notebook, -1) | |
98 vbox = wx.BoxSizer(wx.VERTICAL) | |
99 | |
100 hbox = wx.BoxSizer(wx.HORIZONTAL) | |
101 hbox.Add(wx.StaticText(panel, -1, 'Project Name', size=(150, -1))) | |
102 panel.projectName = wx.TextCtrl(panel, -1, '') | |
103 hbox.Add(panel.projectName, wx.EXPAND) | |
104 vbox.Add(hbox, 0, wx.EXPAND | wx.ALL, 4) | |
105 | |
106 hbox = wx.BoxSizer(wx.HORIZONTAL) | |
107 hbox.Add(wx.StaticText(panel, -1, 'Author', size=(150, -1))) | |
108 panel.projectAuthor = wx.TextCtrl(panel, -1, '') | |
109 hbox.Add(panel.projectAuthor, wx.EXPAND) | |
110 vbox.Add(hbox, 0, wx.EXPAND | wx.ALL, 4) | |
111 | |
112 panel.SetSizer(vbox) | |
113 return panel | |
114 | |
115 def createObjectPropertyPanel(self, notebook): | |
116 panel = wx.Panel(notebook, -1) | |
117 return panel | |
118 | |
119 def createActionPropertyPanel(self, notebook): | |
120 panel = wx.Panel(notebook, -1) | |
121 return panel | |
122 | |
123 def createAnimationPropertyPanel(self, notebook): | |
124 panel = wx.Panel(notebook, -1) | |
125 return panel | |
126 | |
127 def createImagePropertyPanel(self, notebook): | |
128 panel = wx.Panel(notebook, -1) | |
129 return panel | |
130 | |
131 def createCustomAttrPanel(self, notebook): | |
132 panel = wx.Panel(notebook, -1) | |
133 vbox = wx.BoxSizer(wx.VERTICAL) | |
134 grid = gridlib.Grid(notebook, -1) | |
135 grid.CreateGrid(100, 2) | |
136 panel.grid = grid | |
137 vbox.Add(panel.grid, 0, wx.EXPAND | wx.ALL, 4) | |
138 panel.SetSizer(vbox) | |
139 return panel | |
140 | |
141 | |
142 class FifeObjectEditorApp(wx.App): | |
143 def OnInit(self): | |
144 myframe = FifeObjectEditor(None, -1, "FIFE Object Editor") | |
145 myframe.Show(True) | |
146 return True | |
147 | |
148 if __name__ == '__main__': | |
149 app = FifeObjectEditorApp(0) | |
150 app.MainLoop() |