annotate orpg/gametree/nodehandlers/forms.py @ 183:0d9b746b5751 beta

Traipse Beta 'OpenRPG' {100115-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Fri, 15 Jan 2010 23:01:42 -0600
parents 3b6888bb53b5
children dcae32e219f1
rev   line source
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
3 # openrpg-dev@lists.sourceforge.net
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
4 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
5 # This program is free software; you can redistribute it and/or modify
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
6 # it under the terms of the GNU General Public License as published by
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
8 # (at your option) any later version.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
9 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
10 # This program is distributed in the hope that it will be useful,
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
13 # GNU General Public License for more details.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
14 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
15 # You should have received a copy of the GNU General Public License
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
16 # along with this program; if not, write to the Free Software
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
18 # --
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
19 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
20 # File: forms.py
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
21 # Author: Chris Davis
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
22 # Maintainer:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
23 # Version:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
24 # $Id: forms.py,v 1.53 2007/04/21 23:00:51 digitalxero Exp $
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
25 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
26 # Description: The file contains code for the form based nodehanlers
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
27 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
28
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
29 __version__ = "$Id: forms.py,v 1.53 2007/04/21 23:00:51 digitalxero Exp $"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
30
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
31 from containers import *
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
32 import orpg.minidom as minidom
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
33 from orpg.orpg_xml import xml
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
34 from wx.lib.scrolledpanel import ScrolledPanel
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
35 from orpg.tools.settings import settings
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
36
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
37 def bool2int(b):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
38 #in wxPython 2.5+, evt.Checked() returns True or False instead of 1.0 or 0.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
39 #by running the results of that through this function, we convert it.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
40 #if it was an int already, nothing changes. The difference between 1.0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
41 #and 1, i.e. between ints and floats, is potentially dangerous when we
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
42 #use str() on it, but it seems to work fine right now.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
43 if b: return 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
44 else: return 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
45
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
46 #################################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
47 ## form container
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
48 #################################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
49
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
50 class form_handler(container_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
51 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
52 <nodehandler name='?' module='forms' class='form_handler' >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
53 <form width='100' height='100' />
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
54 </nodehandler>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
55 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
56 def __init__(self,xml,tree_node):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
57 container_handler.__init__(self, xml, tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
58
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
59 def load_children(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
60 self.atts = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
61 for child_xml in self.xml:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
62 if child_xml.tag == "form": self.xml.remove(child_xml)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
63 elif child_xml: self.tree.load_xml(child_xml, self.mytree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
64 if not self.xml.get('width'): self.xml.set('width', '400')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
65 if not self.xml.get('height'): self.xml.set('height', '600')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
66
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
67 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
68 return form_edit_panel(parent,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
69
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
70 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
71 return form_panel(parent,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
72
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
73 def on_drop(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
74 # make sure its a contorl node
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
75 container_handler.on_drop(self,evt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
76
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
77 class form_panel(ScrolledPanel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
78 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
79 ScrolledPanel.__init__(self, parent, wx.ID_ANY, style=wx.NO_BORDER|wx.VSCROLL|wx.HSCROLL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
80 self.height = int(handler.xml.get("height"))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
81 self.width = int(handler.xml.get("width"))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
82 self.SetSize((0,0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
83 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
84 self.parent = parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
85 self.main_sizer = wx.BoxSizer(wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
86 handler.tree.traverse(handler.mytree_node, self.create_child_wnd, None, False)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
87 self.SetSizer(self.main_sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
88 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
89 self.SetupScrolling()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
90 parent.SetSize(self.GetSize())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
91 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
92
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
93 def SetSize(self, xy):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
94 (x, y) = self.GetSize()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
95 (nx, ny) = xy
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
96 if x < nx:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
97 x = nx+10
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
98 y += ny+11
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
99 ScrolledPanel.SetSize(self, (x, y))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
100
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
101 def create_child_wnd(self, treenode, evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
102 node = self.handler.tree.GetPyData(treenode)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
103 panel = node.get_use_panel(self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
104 size = node.get_size_constraint()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
105 if panel:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
106 self.main_sizer.Add(panel, size, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
107 self.main_sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
108
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
109 F_HEIGHT = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
110 F_WIDTH = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
111 class form_edit_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
112 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
113 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
114 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
115 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Form Properties"), wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
116 wh_sizer = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
117 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')),
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
118 F_HEIGHT : wx.TextCtrl(self, F_HEIGHT, handler.xml.get('height')),
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
119 F_WIDTH : wx.TextCtrl(self, F_WIDTH, handler.xml.get('width'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
120 }
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
121
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
122 wh_sizer.Add(wx.StaticText(self, -1, "Width:"), 0, wx.ALIGN_CENTER)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
123 wh_sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
124 wh_sizer.Add(self.text[F_WIDTH], 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
125 wh_sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
126 wh_sizer.Add(wx.StaticText(self, -1, "Height:"), 0, wx.ALIGN_CENTER)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
127 wh_sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
128 wh_sizer.Add(self.text[F_HEIGHT], 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
129
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
130 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
131 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
132 sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
133 sizer.Add(wh_sizer,0,wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
134
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
135 self.SetSizer(sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
136 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
137 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
138 parent.SetSize(self.GetBestSize())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
139
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
140 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
141 self.Bind(wx.EVT_TEXT, self.on_text, id=F_HEIGHT)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
142 self.Bind(wx.EVT_TEXT, self.on_text, id=F_WIDTH)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
143
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
144 def on_text(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
145 id = evt.GetId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
146 txt = self.text[id].GetValue()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
147 if not len(txt): return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
148 if id == P_TITLE:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
149 self.handler.xml.set('name',txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
150 self.handler.rename(txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
151 elif id == F_HEIGHT or id == F_WIDTH:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
152 try: int(txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
153 except: return 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
154 if id == F_HEIGHT: self.handler.xml.set("height",txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
155 elif id == F_WIDTH: self.handler.xml.set("width",txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
157 ##########################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
158 ## control handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
159 ##########################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
160 class control_handler(node_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
161 """ A nodehandler for form controls.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
162 <nodehandler name='?' module='forms' class='control_handler' />
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
163 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
164 def __init__(self, xml, tree_node):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
165 node_handler.__init__(self, xml, tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
166
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
167 def get_size_constraint(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
168 return 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
169
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
170 ##########################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
171 ## textctrl handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
172 ##########################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
173 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
174 # Updated by Snowdog (April 2003)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
175 # Now includes Raw Send Mode (like the chat macro uses)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
176 # and an option to remove the title from text when sent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
177 # to the chat in the normal non-chat macro mode.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
178 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
179 class textctrl_handler(node_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
180 """ <nodehandler class="textctrl_handler" module="form" name="">
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
181 <text multiline='0' send_button='0' raw_mode='0' hide_title='0'>Text In Node</text>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
182 </nodehandler>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
183 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
184 def __init__(self,xml,tree_node):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
185 node_handler.__init__(self,xml,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
186 self.text_elem = self.xml.find('text')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
187 if self.text_elem.get("send_button") == "": self.text_elem.set("send_button","0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
188 if self.text_elem.get("raw_mode") == "": self.text_elem.set("raw_mode","0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
189 if self.text_elem.get("hide_title") == "": self.text_elem.set("hide_title","0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
190
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
191 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
192 return textctrl_edit_panel(parent,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
193
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
194 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
195 return text_panel(parent,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
196
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
197 def get_size_constraint(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
198 return int(self.text_elem.get("multiline",0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
199
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
200 def is_multi_line(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
201 return int(self.text_elem.get("multiline",0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
202
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
203 def is_raw_send(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
204 return int(self.text_elem.get("raw_mode",0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
205
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
206 def is_hide_title(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
207 return int(self.text_elem.get("hide_title",0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
208
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
209 def has_send_button(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
210 return int(self.text_elem.get("send_button",0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
211
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
212 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
213 txt = self.get_value()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
214 txt = string.replace(txt,'\n',"<br />")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
215 if not self.is_hide_title(): txt = "<b>"+self.xml.get("name")+":</b> "+txt
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
216 return txt
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
217
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
218 def get_value(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
219 return self.text_elem.text
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
220
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
221 def set_value(self, new_value):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
222 self.text_elem.text = str(new_value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
223
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
224 FORM_TEXT_CTRL = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
225 FORM_SEND_BUTTON = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
226
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
227 class text_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
228 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
229 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
230 self.chat = handler.chat
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
231 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
232 if handler.is_multi_line():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
233 text_style = wx.TE_MULTILINE
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
234 sizer_style = wx.EXPAND
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
235 sizer = wx.BoxSizer(wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
236 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
237 sizer_style = wx.ALIGN_CENTER
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
238 text_style = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
239 sizer = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
240
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
241 txt = handler.get_value()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
242 if txt == None: txt = ''
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
243 self.text = wx.TextCtrl(self, FORM_TEXT_CTRL, txt, style=text_style)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
244 sizer.Add(wx.StaticText(self, -1, handler.xml.get('name')+": "), 0, sizer_style)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
245 sizer.Add(wx.Size(5,0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
246 sizer.Add(self.text, 1, sizer_style)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
247
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
248 if handler.has_send_button(): sizer.Add(wx.Button(self, FORM_SEND_BUTTON, "Send"), 0, sizer_style)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
249
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
250 self.sizer = sizer
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
251 self.SetSizer(sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
252 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
253
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
254 parent.SetSize(self.GetBestSize())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
255 self.Bind(wx.EVT_TEXT, self.on_text, id=FORM_TEXT_CTRL)
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 92
diff changeset
256 self.Bind(wx.EVT_BUTTON, self.on_send, id=FORM_SEND_BUTTON)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 92
diff changeset
257
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 92
diff changeset
258 def on_text(self, evt):
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
259 txt = self.text.GetValue()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
260 #txt = strip_text(txt) ##Does not seem to exist.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
261 self.handler.text_elem.text = txt
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
262
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
263 def on_send(self, evt):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 92
diff changeset
264 txt = self.text.GetValue()
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 92
diff changeset
265 txt = self.chat.ParseMap(txt, self.handler.xml)
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
266 txt = self.chat.ParseParent(txt, self.handler.xml.get('map'))
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
267 if not self.handler.is_raw_send():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
268 self.chat.ParsePost(self.handler.tohtml(), True, True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
269 return 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
270 actionlist = txt.split("\n")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
271 for line in actionlist:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
272 if(line != ""):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
273 if line[0] != "/": ## it's not a slash command
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
274 self.chat.ParsePost(line, True, True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
275 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
276 action = line
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
277 self.chat.chat_cmds.docmd(action)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
278 return 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
279
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
280 F_MULTI = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
281 F_SEND_BUTTON = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
282 F_RAW_SEND = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
283 F_HIDE_TITLE = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
284 F_TEXT = wx.NewId()
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
285 T_BUT_REF = wx.NewId()
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
286
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
287 class textctrl_edit_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
288 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
289 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
290 self.handler = handler
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
291 self.parent = parent
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
292 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Text Properties"), wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
293
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
294 self.title = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
295 self.multi = wx.CheckBox(self, F_MULTI, " Multi-Line")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
296 self.multi.SetValue(handler.is_multi_line())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
297 self.raw_send = wx.CheckBox(self, F_RAW_SEND, " Send as Macro")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
298 self.raw_send.SetValue(handler.is_raw_send())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
299 self.hide_title = wx.CheckBox(self, F_HIDE_TITLE, " Hide Title")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
300 self.hide_title.SetValue(handler.is_hide_title())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
301 self.send_button = wx.CheckBox(self, F_SEND_BUTTON, " Send Button")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
302 self.send_button.SetValue(handler.has_send_button())
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
303 button_ref = wx.Button(self, T_BUT_REF, "Reference")
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
304
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
305 sizer.Add(wx.StaticText(self, P_TITLE, "Title:"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
306 sizer.Add(self.title, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
307 sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
308 sizer.Add(self.multi, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
309 sizer.Add(self.raw_send, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
310 sizer.Add(self.hide_title, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
311 sizer.Add(self.send_button, 0 , wx.EXPAND)
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
312 sizer.Add(button_ref, 0)
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
313 sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
314 if handler.is_multi_line():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
315 sizer_style = wx.EXPAND
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
316 text_style = wx.TE_MULTILINE
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
317 multi = 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
318 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
319 sizer_style=wx.EXPAND
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
320 text_style = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
321 multi = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
322 self.text = wx.TextCtrl(self, F_TEXT, handler.get_value(),style=text_style)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
323 sizer.Add(wx.Size(5,0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
324 sizer.Add(self.text, multi, sizer_style)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
325 self.SetSizer(sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
326 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
327
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
328 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
329 self.Bind(wx.EVT_TEXT, self.on_text, id=F_TEXT)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
330 self.Bind(wx.EVT_CHECKBOX, self.on_button, id=F_MULTI)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
331 self.Bind(wx.EVT_CHECKBOX, self.on_raw_button, id=F_RAW_SEND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
332 self.Bind(wx.EVT_CHECKBOX, self.on_hide_button, id=F_HIDE_TITLE)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
333 self.Bind(wx.EVT_CHECKBOX, self.on_send_button, id=F_SEND_BUTTON)
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
334 self.Bind(wx.EVT_BUTTON, self.on_reference, id=T_BUT_REF)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
335 self.parent.Bind(wx.EVT_CLOSE, self.tree_failsafe)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
336
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
337 ## EZ_Tree Core TaS - Prof.Ebral ##
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
338 def on_reference(self, evt, car=None):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
339 self.do_tree = wx.Frame(self, -1, 'EZ Tree')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
340 self.ez_tree = orpg.gametree.gametree
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
341 self.temp_wnd = self.ez_tree.game_tree(self.do_tree, self.ez_tree.EZ_REF)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
342 self.temp_wnd.Bind(wx.EVT_LEFT_DCLICK, self.on_ldclick)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
343 component.get('tree_fs').save_tree(settings.get("gametree"))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
344 self.temp_wnd.load_tree(settings.get("gametree"))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
345 self.do_tree.Show()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
346
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
347 def tree_failsafe(self, evt):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
348 self.parent.Destroy()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
349 component.add('tree', component.get('tree_fs')) ## Backup
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
350
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
351 def get_grid_ref(self, obj, complete):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
352 self.temp_wnd.Freeze()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
353 self.grid_ref = complete
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
354 self.mini_grid = wx.Frame(self, -1, 'EZ Tree Mini Grid')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
355 self.temp_grid = obj.get_use_panel(self.mini_grid)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
356 self.temp_grid.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.on_grid_ldclick)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
357 self.mini_grid.Show()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
358
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
359 def on_grid_ldclick(self, evt):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
360 complete = self.grid_ref
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
361 row = str(evt.GetRow()+1)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
362 col = str(evt.GetCol()+1)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
363 complete = complete[:len(complete)-2] + '::'+'('+row+','+col+')'+complete[len(complete)-2:]
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
364 self.text.AppendText(complete); self.on_text(evt)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
365 self.mini_grid.Destroy()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
366
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
367 def on_ldclick(self, evt):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
368 self.rename_flag = 0
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
369 pt = evt.GetPosition()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
370 (item, flag) = self.temp_wnd.HitTest(pt)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
371 if item.IsOk():
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
372 obj = self.temp_wnd.GetPyData(item)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
373 self.temp_wnd.SelectItem(item)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
374 start = self.handler.xml.get('map').split('::')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
375 end = obj.xml.get('map').split('::')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
376 if obj.xml.get('class') not in ['rpg_grid_handler', 'textctrl_handler']: do = 'None'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
377 elif end[0] == '' or start[0] != end[0]: do = 'Root'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
378 elif start == end: do = 'Child'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
379 elif start != end: do = 'Parent'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
380 if do == 'Root':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
381 complete = "!@"
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
382 for e in end:
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
383 if e != '': complete += e +'::'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
384 complete = complete + obj.xml.get('name') + '@!'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
385 elif do == 'Parent':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
386 while start[0] == end[0]:
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
387 del end[0], start[0]
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
388 if len(start) == 0 or len(end) == 0: break
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
389 complete = "!#"
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
390 for e in end: complete += e +'::'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
391 complete = complete + obj.xml.get('name') + '#!'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
392 elif do == 'Child':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
393 while start[0] == end[0]:
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
394 del end[0], start[0]
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
395 if len(start) == 0 or len(end) == 0: break
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
396 complete = "!!"
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
397 for e in end: complete += e +'::'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
398 complete = complete + obj.xml.get('name') + '!!'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
399 if do != 'None':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
400 if obj.xml.get('class') == 'rpg_grid_handler':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
401 self.get_grid_ref(obj, complete)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
402 else: self.text.AppendText(complete); self.on_text(evt)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
403 self.do_tree.Destroy()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
404 if do == 'None':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
405 wx.MessageBox('Invalid Reference', 'Error')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
406 ##### #####
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
407
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
408 def on_text(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
409 id = evt.GetId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
410 if id == P_TITLE:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
411 txt = self.title.GetValue()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
412 if not len(txt): return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
413 self.handler.xml.set('name',txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
414 self.handler.rename(txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
415 if id == F_TEXT:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
416 txt = self.text.GetValue()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
417 #txt = strip_text(txt) ##Does not seem to exist.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
418 self.handler.text_elem.text = txt
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
419
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
420 def on_button(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
421 self.handler.text_elem.set("multiline",str(bool2int(evt.Checked())))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
422
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
423 def on_raw_button(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
424 self.handler.text_elem.set("raw_mode",str(bool2int(evt.Checked())))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
425
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
426 def on_hide_button(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
427 self.handler.text_elem.set("hide_title",str(bool2int(evt.Checked())))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
428
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
429 def on_send_button(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
430 self.handler.text_elem.set("send_button",str(bool2int(evt.Checked())))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
431
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
432
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
433 #######################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
434 ## listbox handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
435 #######################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
436 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
437 # Updated by Snowdog (April 2003)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
438 # Now includesan option to remove the title from
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
439 # text when sent to the chat.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
440 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
441 L_DROP = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
442 L_LIST = 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
443 L_RADIO = 2
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
444 L_CHECK = 3
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
445 L_ROLLER = 4
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
446
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
447 class listbox_handler(node_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
448 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
449 <nodehandler class="listbox_handler" module="forms" name="">
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
450 <list type="1" send_button='0' hide_title='0'>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
451 <option value="" selected="" >Option Text I</option>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
452 <option value="" selected="" >Option Text II</option>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
453 </list>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
454 </nodehandler>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
455 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
456 def __init__(self,xml,tree_node):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
457 node_handler.__init__(self,xml,tree_node)
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
458 self.list_reload()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
459 #print xml
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
460 #print self.tree.GetItemParent(tree_node)
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
461 if self.list.get("send_button") == "": self.list.set("send_button","0")
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
462 if self.list.get("hide_title") == "": self.list.set("hide_title","0")
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
463 if self.list.get("raw_mode") == "": self.list.set("raw_mode","0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
464
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
465 def list_reload(self):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
466 self.list = self.xml.find('list')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
467 self.options = self.list.findall('option')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
468 self.captions = []
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
469 for opt in self.options:
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
470 if opt.get('caption') == None: opt.set('caption', '')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
471 self.captions.append(opt.get('caption'))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
472
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
473 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
474 return listbox_edit_panel(parent,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
475
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
476 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
477 return listbox_panel(parent,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
478
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
479 def get_type(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
480 return int(self.list.get("type"))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
481
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
482 def set_type(self,type):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
483 self.list.set("type",str(type))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
484
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
485 def is_hide_title(self):
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
486 return int(self.list.get("hide_title", 0))
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
487
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
488 def is_raw_send(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
489 return int(self.list.get("raw_mode",0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
490
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
491 # single selection methods
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
492 def get_selected_node(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
493 for opt in self.options:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
494 if opt.get("selected") == "1": return opt
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
495 return None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
496
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
497 def get_selected_index(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
498 i = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
499 for opt in self.options:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
500 if opt.get("selected") == "1": return i
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
501 i += 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
502 return 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
503
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
504 def get_selected_text(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
505 node = self.get_selected_node()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
506 if node: return node.text
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
507 else: return ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
508
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
509 # mult selection methods
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
510 def get_selections(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
511 opts = []
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
512 for opt in self.options:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
513 if opt.get("selected") == "1": opts.append(opt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
514 return opts
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
515
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
516 def get_selections_text(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
517 opts = []
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
518 for opt in self.options:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
519 if opt.get("selected") == "1": opts.append(opt.text)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
520 return opts
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
521
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
522 def get_selections_index(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
523 opts = []
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
524 i = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
525 for opt in self.options:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
526 if opt.get("selected") == "1": opts.append(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
527 i += 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
528 return opts
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
529
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
530 # setting selection method
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
531 def set_selected_node(self,index,selected=1):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
532 if self.get_type() != L_CHECK: self.clear_selections()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
533 self.options[index].set("selected", str(bool2int(selected)))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
534
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
535 def clear_selections(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
536 for opt in self.options: opt.set("selected","0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
537
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
538 # misc methods
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
539 def get_options(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
540 opts = []
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
541 for opt in self.options: opts.append(opt.text)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
542 return opts
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
543
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
544 def get_captions(self):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
545 captions = []
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
546 for opt in self.options: captions.append(opt.get("caption"))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
547 self.captions = captions
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
548 return captions
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
549
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
550 def get_option(self, index):
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
551 return self.options[index].text
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
552
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
553 def get_caption(self, index):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
554 captions = self.get_captions()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
555 return captions[index] or ''
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
556
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
557 def add_option(self, caption, value):
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
558 elem = Element('option')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
559 elem.set("value","0")
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
560 elem.set('caption', caption)
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
561 elem.set("selected","0")
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
562 elem.text = value
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
563 self.list.append(elem)
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
564 self.list_reload()
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
565
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
566 def remove_option(self,index):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
567 self.list.remove(self.options[index])
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
568 self.list_reload()
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
569
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
570 def edit_option(self, index, value):
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
571 self.options[index].text = value
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
572
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
573 def edit_caption(self, index, value):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
574 self.options[index].set('caption', value)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
575 self.captions[index] = value
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
576
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
577 def has_send_button(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
578 if self.list.get("send_button") == '0': return False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
579 else: return True
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
580
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
581 def get_size_constraint(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
582 if self.get_type() == L_DROP: return 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
583 else: return 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
584
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
585 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
586 opts = self.get_selections_text()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
587 text = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
588 if not self.is_hide_title(): text = "<b>"+self.xml.get("name")+":</b> "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
589 comma = ", "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
590 text += comma.join(opts)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
591 return text
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
592
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
593 def get_value(self):
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
594 return "\n".join(self.get_selections_text())
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
595
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
596 def on_send_to_chat(self, evt):
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
597 txt = self.get_selected_text()
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
598 txt = self.chat.ParseMap(txt, self.xml)
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
599 txt = self.chat.ParseParent(txt, self.xml.get('map'))
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
600 if not self.is_raw_send():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
601 self.chat.ParsePost(self.tohtml(), True, True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
602 return 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
603 actionlist = self.get_selections_text()
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
604 for line in actionlist:
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
605 line = self.chat.ParseMap(line, self.xml)
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
606 line = self.chat.ParseParent(line, self.xml.get('map'))
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
607 if(line != ""):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
608 if line[0] != "/": ## it's not a slash command
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
609 self.chat.ParsePost(line, True, True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
610 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
611 action = line
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
612 self.chat.chat_cmds.docmd(action)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
613 return 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
614
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
615
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
616 F_LIST = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
617 F_SEND = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
618
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
619
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
620 class listbox_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
621 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
622 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
623 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
624 self.chat = handler.chat
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
625 opts = []
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
626 values = handler.get_options()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
627 captions = handler.get_captions()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
628 for value in values:
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
629 if captions[values.index(value)] != '': opts.append(captions[values.index(value)])
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
630 else: opts.append(value)
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
631 cur_opt = handler.get_selected_text()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
632 type = handler.get_type()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
633 label = handler.xml.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
634
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
635 if type == L_DROP:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
636 self.list = wx.ComboBox(self, F_LIST, cur_opt, choices=opts, style=wx.CB_READONLY)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
637 if self.list.GetSize()[0] > 200:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
638 self.list.Destroy()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
639 self.list = wx.ComboBox(self, F_LIST, cur_opt, size=(200, -1), choices=opts, style=wx.CB_READONLY)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
640 elif type == L_LIST: self.list = wx.ListBox(self,F_LIST,choices=opts)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
641 elif type == L_RADIO: self.list = wx.RadioBox(self,F_LIST,label,choices=opts,majorDimension=3)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
642 elif type == L_CHECK:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
643 self.list = wx.CheckListBox(self,F_LIST,choices=opts)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
644 self.set_checks()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
645
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
646 for i in handler.get_selections_text():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
647 if type == L_DROP: self.list.SetValue( i )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
648 else: self.list.SetStringSelection( i )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
649 if type == L_DROP: sizer = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
650 else: sizer = wx.BoxSizer(wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
651
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
652 if type != L_RADIO:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
653 sizer.Add(wx.StaticText(self, -1, label+": "), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
654 sizer.Add(wx.Size(5,0))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
655 sizer.Add(self.list, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
656 if handler.has_send_button():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
657 sizer.Add(wx.Button(self, F_SEND, "Send"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
658 self.Bind(wx.EVT_BUTTON, self.handler.on_send_to_chat, id=F_SEND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
659 self.sizer = sizer
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
660 self.SetSizer(sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
661 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
662 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
663 parent.SetSize(self.GetBestSize())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
664
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
665 if type == L_DROP: self.Bind(wx.EVT_COMBOBOX, self.on_change, id=F_LIST)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
666 elif type == L_LIST: self.Bind(wx.EVT_LISTBOX, self.on_change, id=F_LIST)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
667 elif type == L_RADIO: self.Bind(wx.EVT_RADIOBOX, self.on_change, id=F_LIST)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
668 elif type == L_CHECK:self.Bind(wx.EVT_CHECKLISTBOX, self.on_check, id=F_LIST)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
669 self.type = type
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
670
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
671 def on_change(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
672 self.handler.set_selected_node(self.list.GetSelection())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
673
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
674 def on_check(self,evt):
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
675 for i in xrange(self.list.GetCount()): self.handler.set_selected_node(i, bool2int(self.list.IsChecked(i)))
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
676
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
677 def set_checks(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
678 for i in self.handler.get_selections_index(): self.list.Check(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
679
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
680
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
681 BUT_ADD = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
682 BUT_REM = wx.NewId()
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
683 BUT_REF = wx.NewId()
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
684 BUT_EDIT = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
685 F_TYPE = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
686 F_NO_TITLE = wx.NewId()
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
687 LIST_CTRL = wx.NewId()
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
688
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
689 class listbox_edit_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
690 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
691 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
692 self.handler = handler
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
693 self.parent = parent
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
694 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "List Box Properties"), wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
695
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
696 self.text = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
697 self.listbox = wx.ListCtrl(self, LIST_CTRL, style=wx.LC_REPORT)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
698 self.listbox.InsertColumn(0, 'Caption')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
699 self.listbox.InsertColumn(1, 'Value')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
700 self.listbox.SetColumnWidth(0, 75)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
701 self.listbox.SetColumnWidth(1, 300)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
702 self.reload_options()
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
703
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
704 opts = ['Drop Down', 'List Box', 'Radio Box', 'Check List']
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
705 self.type_radios = wx.RadioBox(self,F_TYPE,"List Type",choices=opts)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
706 self.type_radios.SetSelection(handler.get_type())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
707
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
708 self.send_button = wx.CheckBox(self, F_SEND_BUTTON, " Send Button")
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
709 self.send_button.SetValue(handler.has_send_button())
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
710
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
711 self.raw_send = wx.CheckBox(self, F_RAW_SEND, " Send as Macro")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
712 self.raw_send.SetValue(handler.is_raw_send())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
713
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
714 self.hide_title = wx.CheckBox(self, F_NO_TITLE, " Hide Title")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
715 self.hide_title.SetValue(handler.is_hide_title())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
716
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
717 but_sizer = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
718 but_sizer.Add(wx.Button(self, BUT_ADD, "Add"), 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
719 but_sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
720 but_sizer.Add(wx.Button(self, BUT_EDIT, "Edit"), 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
721 but_sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
722 but_sizer.Add(wx.Button(self, BUT_REM, "Remove"), 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
723
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
724 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
725 sizer.Add(self.text, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
726 sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
727 sizer.Add(self.type_radios, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
728 sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
729 sizer.Add(self.send_button, 0 , wx.EXPAND)
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
730 sizer.Add(self.hide_title, 0, wx.EXPAND)
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
731 sizer.Add(self.raw_send, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
732 sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
733 sizer.Add(wx.StaticText(self, -1, "Options:"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
734 sizer.Add(self.listbox,1,wx.EXPAND);
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
735 sizer.Add(but_sizer,0,wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
736
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
737 self.SetSizer(sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
738 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
739 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
740 parent.SetSize(self.GetBestSize())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
741
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
742 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
743 self.Bind(wx.EVT_BUTTON, self.on_edit, id=BUT_EDIT)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
744 self.Bind(wx.EVT_BUTTON, self.on_remove, id=BUT_REM)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
745 self.Bind(wx.EVT_BUTTON, self.on_add, id=BUT_ADD)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
746 self.Bind(wx.EVT_RADIOBOX, self.on_type, id=F_TYPE)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
747 self.Bind(wx.EVT_CHECKBOX, self.on_hide_button, id=F_NO_TITLE)
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
748 self.Bind(wx.EVT_CHECKBOX, self.on_send_button, id=F_SEND_BUTTON)
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
749 self.Bind(wx.EVT_CHECKBOX, self.on_raw_button, id=F_RAW_SEND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
750
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
751 def on_type(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
752 self.handler.set_type(evt.GetInt())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
753
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
754 def on_add(self,evt):
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
755 self.dlg = wx.Frame(self, -1, 'Text', size=(300,150))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
756 edit_panel = wx.Panel(self.dlg, -1)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
757 sizer = wx.GridBagSizer(1, 2)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
758 edit_panel.SetSizer(sizer)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
759 caption_text = wx.StaticText(edit_panel, -1, 'Caption')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
760 self.caption_entry = wx.TextCtrl(edit_panel, -1, '')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
761 value_text = wx.StaticText(edit_panel, -1, 'Value')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
762 self.value_entry = wx.TextCtrl(edit_panel, -1, '')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
763 button_ok = wx.Button(edit_panel, wx.ID_OK)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
764 button_cancel = wx.Button(edit_panel, wx.ID_CANCEL)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
765 button_ref = wx.Button(edit_panel, BUT_REF, "Reference")
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
766 sizer.Add(caption_text, (0,0))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
767 sizer.Add(self.caption_entry, (0,1), span=(1,3), flag=wx.EXPAND)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
768 sizer.Add(value_text, (1,0))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
769 sizer.Add(self.value_entry, (1,1), span=(1,3), flag=wx.EXPAND)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
770 sizer.Add(button_ok, (3,0))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
771 sizer.Add(button_cancel, (3,1))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
772 sizer.Add(button_ref, (3,2), flag=wx.EXPAND)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
773 self.Bind(wx.EVT_BUTTON, self.on_reference, id=BUT_REF)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
774 self.Bind(wx.EVT_BUTTON, self.on_add_option, id=wx.ID_OK)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
775 self.Bind(wx.EVT_BUTTON, self.on_edit_cancel, id=wx.ID_CANCEL)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
776 self.dlg.Show()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
777
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
778 def on_add_option(self, evt):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
779 self.handler.add_option(self.caption_entry.GetValue(), self.value_entry.GetValue())
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
780 self.reload_options()
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
781 self.dlg.Destroy()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
782 component.add('tree', component.get('tree_fs')) ## Backup
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
783 return
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
784
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
785 ## EZ_Tree Core TaS - Prof.Ebral ##
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
786 def on_reference(self, evt, car=None):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
787 self.do_tree = wx.Frame(self, -1, 'EZ Tree')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
788 self.ez_tree = orpg.gametree.gametree
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
789 self.temp_wnd = self.ez_tree.game_tree(self.do_tree, self.ez_tree.EZ_REF)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
790 self.temp_wnd.Bind(wx.EVT_LEFT_DCLICK, self.on_ldclick)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
791 component.get('tree_fs').save_tree(settings.get("gametree"))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
792 self.temp_wnd.load_tree(settings.get("gametree"))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
793 self.do_tree.Show()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
794
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
795 def get_grid_ref(self, obj, complete):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
796 self.temp_wnd.Freeze()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
797 self.grid_ref = complete
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
798 self.mini_grid = wx.Frame(self, -1, 'EZ Tree Grid')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
799 self.temp_grid = obj.get_use_panel(self.mini_grid)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
800 self.temp_grid.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.on_grid_ldclick)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
801 self.mini_grid.Show()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
802
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
803 def on_grid_ldclick(self, evt):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
804 complete = self.grid_ref
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
805 row = str(evt.GetRow()+1)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
806 col = str(evt.GetCol()+1)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
807 complete = complete[:len(complete)-2] + '::'+'('+row+','+col+')'+complete[len(complete)-2:]
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
808 self.value_entry.AppendText(complete)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
809 self.mini_grid.Destroy()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
810
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
811 def on_ldclick(self, evt):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
812 self.rename_flag = 0
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
813 pt = evt.GetPosition()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
814 (item, flag) = self.temp_wnd.HitTest(pt)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
815 if item.IsOk():
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
816 obj = self.temp_wnd.GetPyData(item)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
817 self.temp_wnd.SelectItem(item)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
818 start = self.handler.xml.get('map').split('::')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
819 end = obj.xml.get('map').split('::')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
820 if obj.xml.get('class') not in ['rpg_grid_handler', 'textctrl_handler']: do = 'None'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
821 elif end[0] == '' or start[0] != end[0]: do = 'Root'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
822 elif start == end: do = 'Child'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
823 elif start != end: do = 'Parent'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
824 if do == 'Root':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
825 complete = "!@"
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
826 for e in end:
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
827 if e != '': complete += e +'::'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
828 complete = complete + obj.xml.get('name') + '@!'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
829 elif do == 'Parent':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
830 while start[0] == end[0]:
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
831 del end[0], start[0]
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
832 if len(start) == 0 or len(end) == 0: break
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
833 complete = "!#"
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
834 for e in end: complete += e +'::'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
835 complete = complete + obj.xml.get('name') + '#!'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
836 elif do == 'Child':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
837 while start[0] == end[0]:
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
838 del end[0], start[0]
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
839 if len(start) == 0 or len(end) == 0: break
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
840 complete = "!!"
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
841 for e in end: complete += e +'::'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
842 complete = complete + obj.xml.get('name') + '!!'
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
843 if do != 'None':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
844 if obj.xml.get('class') == 'rpg_grid_handler':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
845 self.get_grid_ref(obj, complete)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
846 else: self.value_entry.AppendText(complete); self.reload_options()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
847 self.do_tree.Destroy()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
848 if do == 'None':
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
849 wx.MessageBox('Invalid Reference', 'Error')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
850 ##### #####
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
851
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
852 def on_edit_ok(self, evt):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
853 self.handler.edit_caption(self.index, self.caption_entry.GetValue())
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
854 self.handler.edit_option(self.index, self.value_entry.GetValue())
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
855 self.reload_options()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
856 self.dlg.Destroy()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
857 component.add('tree', component.get('tree_fs')) ## Backup
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
858 return
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
859
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
860 def on_edit_cancel(self, evt):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
861 self.dlg.Destroy()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
862 component.add('tree', component.get('tree_fs')) ## Backup
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
863 return
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
864
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
865 def on_remove(self,evt):
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
866 index = self.listbox.GetFocusedItem()
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
867 if index >= 0:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
868 self.handler.remove_option(index)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
869 self.reload_options()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
870
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
871 def on_edit(self,evt):
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
872 self.index = self.listbox.GetFocusedItem()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
873 if self.index >= 0:
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
874 self.dlg = wx.Frame(self, -1, 'Text', size=(300,150))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
875 edit_panel = wx.Panel(self.dlg, -1)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
876 sizer = wx.GridBagSizer(1, 2)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
877 edit_panel.SetSizer(sizer)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
878 caption_text = wx.StaticText(edit_panel, -1, 'Caption')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
879 self.caption_entry = wx.TextCtrl(edit_panel, -1, self.handler.get_caption(self.index))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
880 value_text = wx.StaticText(edit_panel, -1, 'Value')
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
881 self.value_entry = wx.TextCtrl(edit_panel, -1, self.handler.get_option(self.index))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
882 button_ok = wx.Button(edit_panel, wx.ID_OK)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
883 button_cancel = wx.Button(edit_panel, wx.ID_CANCEL)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
884 button_ref = wx.Button(edit_panel, BUT_REF, "Reference")
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
885 sizer.Add(caption_text, (0,0))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
886 sizer.Add(self.caption_entry, (0,1), span=(1,3), flag=wx.EXPAND)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
887 sizer.Add(value_text, (1,0))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
888 sizer.Add(self.value_entry, (1,1), span=(1,3), flag=wx.EXPAND)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
889 sizer.Add(button_ok, (3,0))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
890 sizer.Add(button_cancel, (3,1))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
891 sizer.Add(button_ref, (3,2), flag=wx.EXPAND)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
892 self.Bind(wx.EVT_BUTTON, self.on_reference, id=BUT_REF)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
893 self.Bind(wx.EVT_BUTTON, self.on_edit_ok, id=wx.ID_OK)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
894 self.Bind(wx.EVT_BUTTON, self.on_edit_cancel, id=wx.ID_CANCEL)
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
895 self.dlg.Show()
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
896
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
897 def reload_options(self):
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
898 self.listbox.DeleteAllItems()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
899 values = self.handler.get_options()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
900 captions = self.handler.get_captions()
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
901 for index in range(len(values)):
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 156
diff changeset
902 self.listbox.Append((captions[index], values[index]))
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
903
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
904 def on_text(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
905 id = evt.GetId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
906 txt = self.text.GetValue()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
907 if not len(txt): return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
908 if id == P_TITLE:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
909 self.handler.xml.set('name',txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
910 self.handler.rename(txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
911
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
912 def on_send_button(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
913 self.handler.list.set("send_button", str( bool2int(evt.Checked()) ))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
914
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
915 def on_hide_button(self,evt):
142
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
916 self.handler.list.set("hide_title", str( bool2int(evt.Checked()) ))
2345c12d93a7 Traipse Beta 'OpenRPG' {091123-01}
sirebral
parents: 135
diff changeset
917
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
918 def on_raw_button(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
919 self.handler.list.set("raw_mode",str(bool2int(evt.Checked())))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
920
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
921
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
922 ###############################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
923 ## link image handlers
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
924 ###############################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
925
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
926 class link_handler(node_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
927 """ A nodehandler for URLs. Will open URL in a wxHTMLFrame
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
928 <nodehandler name='?' module='forms' class='link_handler' >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
929 <link href='http//??.??' />
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
930 </nodehandler >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
931 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
932 def __init__(self,xml,tree_node):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
933 node_handler.__init__(self,xml,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
934 self.link = self.xml[0]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
935
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
936 def on_use(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
937 href = self.link.get("href")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
938 wb = webbrowser.get()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
939 wb.open(href)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
940
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
941 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
942 return link_edit_panel(parent,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
943
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
944 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
945 return link_panel(parent,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
946
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
947 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
948 href = self.link.get("href")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
949 title = self.xml.get("name")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
950 return "<a href='"+href+"' >"+title+"</a>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
951
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
952 class link_panel(wx.StaticText):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
953 def __init__(self,parent,handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
954 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
955 label = handler.xml.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
956 wx.StaticText.__init__(self,parent,-1,label)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
957 self.SetForegroundColour(wx.BLUE)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
958 self.Bind(wx.EVT_LEFT_DOWN, self.handler.on_use)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
959
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
960 P_URL = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
961
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
962 class link_edit_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
963 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
964 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
965 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
966 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Link Properties"), wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
967
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
968 self.text = {}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
969 self.text[P_TITLE] = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
970 self.text[P_URL] = wx.TextCtrl(self, P_URL, handler.link.get('href'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
971
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
972 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
973 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
974 sizer.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
975 sizer.Add(wx.StaticText(self, -1, "URL:"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
976 sizer.Add(self.text[P_URL], 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
977 self.SetSizer(sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
978 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
979 self.Bind(wx.EVT_TEXT, self.on_text, id=P_URL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
980
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
981 def on_text(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
982 id = evt.GetId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
983 txt = self.text[id].GetValue()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
984 if not len(txt): return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
985 if id == P_TITLE:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
986 self.handler.xml.set('name',txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
987 self.handler.rename(txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
988 elif id == P_URL: self.handler.link.set('href',txt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
989
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
990 ##########################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
991 ## webimg node handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
992 ##########################
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
993 class webimg_handler(node_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
994 """ A nodehandler for URLs. Will open URL in a wxHTMLFrame
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
995 <nodehandler name='?' module='forms' class='webimg_handler' >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
996 <link href='http//??.??' />
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
997 </nodehandler >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
998 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
999 def __init__(self,xml,tree_node):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1000 node_handler.__init__(self,xml,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1001 self.link = self.xml[0]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1003 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1004 return link_edit_panel(parent,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1005
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1006 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1007 img = img_helper().load_url(self.link.get("href"))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1008 if not img is None: return wx.StaticBitmap(parent,-1,img,size= wx.Size(img.GetWidth(),img.GetHeight()))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1009 return wx.EmptyBitmap(1, 1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1010
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1011 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1012 href = self.link.get("href")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1013 title = self.xml.get("name")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1014 return "<img src='"+href+"' alt="+title+" >"