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