annotate plugins/bcg/tok_dialogs.py @ 119:9314d63c0941 alpha

Traipse Alpha 'OpenRPG' {091029-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: Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images! Changes made to the map for increased portability. SnowDog has changes planned in Core, though. Added an initial push to the BCG. Not much to see, just shows off how it is re-writing Main code. Fix to remote admin commands Minor fix to texted based server, works in /System/ folder Some Core changes to gametree to correctly disply Pretty Print, thanks David! Fix to Splitter Nodes not being created. Added images to Plugin Control panel for Autostart feature Fix to massive amounts of images loading; from Core fix to gsclient so with_statement imports Added 'boot' command to remote admin Prep work in Pass tool for remote admin rankings and different passwords, ei, Server, Admin, Moderator, etc. Remote Admin Commands more organized, more prep work. Added Confirmation window for sent nodes. Minor changes to allow for portability to an OpenSUSE linux OS (hopefully without breaking) {091028} 00: Made changes to gametree to start working with Element Tree, mostly from Core Minor changes to Map to start working with Element Tree, from Core Preliminary changes to map efficiency, from FlexiRPG Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Changes to main.py to start working with Element Tree {091029} 00: Changes made to server to start working with Element Tree. Changes made to Meta Server Lib. Prepping test work for a multi meta network page. Minor bug fixed with mini to gametree Zoom Mouse plugin added. Known Issue: Disconnecting causes an server side error. XML data is not being passed correctly.
author sirebral
date Thu, 29 Oct 2009 20:35:28 -0500
parents 2f2bebe9c77f
children
rev   line source
105
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
2 #
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
3 # openrpg-dev@lists.sourceforge.net
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
4 #
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
6 # it under the terms of the GNU General Public License as published by
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
8 # (at your option) any later version.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
9 #
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
13 # GNU General Public License for more details.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
14 #
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
16 # along with this program; if not, write to the Free Software
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
18 # --
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
19 #
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
20 # File: mapper/min_dialogs.py
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
21 # Author: Chris Davis
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
22 # Maintainer:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
23 # Version:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
24 # $Id: min_dialogs.py,v 1.27 2006/11/13 02:23:16 digitalxero Exp $
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
25 #
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
26 # Description: This file contains some of the basic definitions for the chat
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
27 # utilities in the orpg project.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
28
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
29 ##-----------------------------
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
30 ## token List Panel
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
31 ##-----------------------------
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
32
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
33 from tokens import *
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
34
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
35 class min_list_panel(wx.Dialog):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
36
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
37 def __init__(self, parent,layers, log, pos =(-1,-1)):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
38 wx.Dialog.__init__(self, parent,-1, log,pos = (-1,-1), size = (785,175), style=wx.RESIZE_BORDER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
39 listID = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
40 self.parent = parent
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
41 self.min = layers['tokens'].tokens
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
42 self.grid = layers['grid']
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
43 self.layers = layers
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
44 self.listID = listID
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
45 list_sizer = wx.BoxSizer(wx.VERTICAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
46 self.list_sizer = list_sizer
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
47 listctrl = wx.ListCtrl(self, listID, style=wx.LC_REPORT | wx.SUNKEN_BORDER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
48 self.listctrl = listctrl
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
49 self.Centre(wx.BOTH)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
50 self.log = log
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
51 self.list_sizer.Add(self.listctrl,1,wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
52 self.listctrl.InsertColumn(0,"POS ")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
53 self.listctrl.InsertColumn(0,"LOCKED")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
54 self.listctrl.InsertColumn(0,"HEADING")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
55 self.listctrl.InsertColumn(0,"FACING")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
56 self.listctrl.InsertColumn(0,"LABEL")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
57 self.listctrl.InsertColumn(0,"PATH")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
58 self.listctrl.SetColumnWidth(1, wx.LIST_AUTOSIZE_USEHEADER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
59 self.listctrl.SetColumnWidth(2, wx.LIST_AUTOSIZE_USEHEADER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
60 self.listctrl.SetColumnWidth(3, wx.LIST_AUTOSIZE_USEHEADER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
61 self.listctrl.SetColumnWidth(4, wx.LIST_AUTOSIZE_USEHEADER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
62 self.listctrl.SetColumnWidth(5, wx.LIST_AUTOSIZE_USEHEADER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
63 self.list_sizer.Add(wx.Button(self, wx.ID_OK, "DONE"),0,wx.ALIGN_CENTER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
64 self.refresh()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
65 self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
66 self.listctrl.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick, id=listID)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
67 self.listctrl.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
68 self.listctrl.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
69 self.SetSizer(self.list_sizer)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
70 self.SetAutoLayout(True)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
71 self.Fit()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
72
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
73 def OnRightClick(self,event):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
74 if self.listctrl.GetSelectedItemCount() > 0:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
75 menu = wx.Menu()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
76 lPopupID1 = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
77 lPopupID2 = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
78 lPopupID3 = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
79 menu.Append(lPopupID1, "&Edit")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
80 menu.Append(lPopupID2, "&Delete")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
81 menu.Append(lPopupID3, "To &Gametree")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
82 self.Bind(wx.EVT_MENU, self.onEdit, id=lPopupID1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
83 self.Bind(wx.EVT_MENU, self.onDelete, id=lPopupID2)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
84 self.Bind(wx.EVT_MENU, self.onToGametree, id=lPopupID3)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
85 self.PopupMenu(menu, cmpPoint(self.x, self.y))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
86 menu.Destroy()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
87 event.Skip()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
88
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
89 def refresh(self):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
90 self.SetMinSize((600,175));
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
91 for m in self.min:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
92 self.listctrl.InsertStringItem(self.min.index(m),self.min[self.min.index(m)].path)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
93 self.listctrl.SetStringItem(self.min.index(m),1,self.min[self.min.index(m)].label)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
94 self.listctrl.SetStringItem(self.min.index(m),2,`self.min[self.min.index(m)].heading`)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
95 #self.listctrl.SetStringItem(self.min.index(m),3,`self.min[self.min.index(m)].face`)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
96 self.listctrl.SetStringItem(self.min.index(m),4,`self.min[self.min.index(m)].locked`)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
97 self.listctrl.SetStringItem(self.min.index(m),5,`self.min[self.min.index(m)].pos`)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
98 oldcolumnwidth = self.listctrl.GetColumnWidth(0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
99 self.listctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
100 if oldcolumnwidth < self.listctrl.GetColumnWidth(0): self.listctrl.SetColumnWidth(0, wx.LIST_AUTOSIZE)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
101 else: self.listctrl.SetColumnWidth(0, oldcolumnwidth)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
102 self.list_sizer=self.list_sizer
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
103
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
104 def onEdit(self,event):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
105 min_list = []
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
106 min_index = []
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
107 loop_count = 0
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
108 item =-1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
109 while True:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
110 loop_count += 1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
111 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
112 if item == -1: break
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
113 min_list.append(self.min[item])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
114 min_index.append(item-loop_count+1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
115 if len(min_list) > 0: dlg = min_list_edit_dialog(self.parent,min_index, min_list,self.layers)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
116 if dlg.ShowModal() == wx.ID_OK: pass
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
117 self.listctrl.DeleteAllItems()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
118 self.refresh()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
119 event.Skip()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
120
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
121 def onDelete(self,event):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
122 loop_count = 0
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
123 item = -1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
124 while True:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
125 loop_count += 1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
126 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
127 if item == -1: break
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
128 self.layers["tokens"].del_token(self.min[item-loop_count+1])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
129 self.listctrl.DeleteAllItems()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
130 self.refresh()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
131 event.Skip()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
132
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
133 def onToGametree(self,event):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
134 min_list = []
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
135 min_index = []
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
136 loop_count = 0
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
137 item =-1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
138 while True:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
139 loop_count += 1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
140 item = self.listctrl.GetNextItem(item,wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
141 if item == -1: break
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
142 min_list.append(self.min[item])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
143 min_index.append(item-loop_count+1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
144 if len(min_list) > 0:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
145 for sel_rmin in min_list:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
146 #############
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
147 min_xml = sel_rmin.toxml(action="new")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
148 node_begin = "<nodehandler module='map_token_nodehandler' class='map_token_handler' name='"
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
149
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
150 if sel_rmin.label: node_begin += sel_rmin.label + "'"
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
151 else: node_begin += "Unnamed token'"
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
152
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
153 node_begin += ">"
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
154 gametree = component.get('tree')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
155 node_xml = node_begin + min_xml + '</nodehandler>'
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
156 print "Sending this XML to insert_xml:" + node_xml
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
157 gametree.insert_xml(node_xml)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
158 #############
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
159 self.listctrl.DeleteAllItems()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
160 self.refresh()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
161 event.Skip()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
162
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
163 def OnRightDown(self,event):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
164 self.x = event.GetX()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
165 self.y = event.GetY()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
166 event.Skip()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
167
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
168 def on_ok(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
169 self.EndModal(wx.ID_OK)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
170
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
171 class min_list_edit_dialog(wx.Dialog):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
172 def __init__(self,parent,min_index, min_list, layers):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
173 wx.Dialog.__init__(self,parent,-1,"token List",wx.DefaultPosition,wx.Size(600,530))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
174 self.layers = layers
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
175 grid = layers['grid']
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
176 min = layers['tokens']
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
177 self.min_list = min_list
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
178 self.min_index = min_index
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
179 self.min = min
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
180 sizer1 = wx.BoxSizer(wx.VERTICAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
181 sizer = wx.BoxSizer(wx.HORIZONTAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
182 self.grid = grid
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
183 editor = min_list_edit_panel(self, min_index, min_list,layers)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
184 sizer1.Add(editor, 1, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
185 sizer.Add(wx.Button(self, wx.ID_OK, "OK"), 1, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
186 sizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
187 sizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
188 sizer.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
189 sizer1.Add(sizer, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
190 self.editor = editor
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
191 self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
192 self.SetSizer(sizer1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
193 self.SetAutoLayout(True)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
194 self.Fit()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
195
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
196 def on_revert(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
197 pass
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
198
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
199 def on_ok(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
200 self.editor.on_ok(self.layers)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
201 self.EndModal(wx.ID_OK)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
202
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
203 class min_list_edit_panel(wx.Panel):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
204 def __init__(self, parent, min_index, min_list,layers):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
205 LABEL_COMBO = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
206 PATH_COMBO = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
207 POS_COMB = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
208 MIN_POS = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
209 POS_SPIN = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
210 self.grid = layers['grid']
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
211 self.min = layers['tokens'].tokens
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
212 self.min_list = min_list
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
213 self.min_index = min_index
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
214 self.layers = layers
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
215 wx.Panel.__init__(self, parent, -1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
216 self.min=min
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
217 listsizer = wx.StaticBoxSizer(wx.StaticBox(self,-1,"Token list properties"), wx.VERTICAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
218 labelsizer = wx.BoxSizer(wx.HORIZONTAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
219 self.labelcheck = wx.CheckBox(self,-1,"Serialize")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
220 labelsizer.Add(wx.StaticText(self, -1, "Label: "), 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
221 labelsizer.Add(self.labelcheck,wx.ALIGN_RIGHT,wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
222 listsizer.Add(labelsizer,0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
223 self.labelcombo = wx.ComboBox(self, LABEL_COMBO,"no change",style=wx.CB_DROPDOWN)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
224 listsizer.Add(self.labelcombo,0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
225 self.pathcombo = wx.ComboBox(self, PATH_COMBO, "no change",style=wx.CB_DROPDOWN)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
226 self.positioncombo = wx.ComboBox(self, POS_COMB, "no change", choices=["no change"], style=wx.CB_READONLY)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
227 #self.positioncombo.SetValue(`min_list[0].pos`)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
228 self.labelcombo.Append("no change")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
229 self.pathcombo.Append("no change")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
230 for m in min_list:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
231 self.labelcombo.Append(min_list[min_list.index(m)].label)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
232 self.pathcombo.Append(min_list[min_list.index(m)].path)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
233 self.positioncombo.Append(`min_list[min_list.index(m)].pos`)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
234 listsizer.Add(wx.StaticText(self, -1, "Path:"), 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
235 listsizer.Add(self.pathcombo, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
236 listsizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
237 self.heading = wx.RadioBox(self, MIN_HEADING, "Heading",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
238 choices=["None","N","NE","E","SE","S","SW","W","NW","no change"], majorDimension=5, style=wx.RA_SPECIFY_COLS)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
239 self.heading.SetSelection( 9 )
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
240 listsizer.Add( self.heading, 0, wx.EXPAND )
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
241 listsizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
242
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
243 ## Remove
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
244 #self.face = wx.RadioBox(self, MIN_FACE, "Facing",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
245 # choices=["None","N","NE","E","SE","S","SW","W","NW","no change"], majorDimension=5, style=wx.RA_SPECIFY_COLS)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
246 #self.face.SetSelection(9)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
247 #listsizer.Add(self.face, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
248
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
249 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
250 ###Group together locked, Hide, and snap radioboxes in group2 box
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
251 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
252 group2 = wx.BoxSizer(wx.HORIZONTAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
253 self.locked = wx.RadioBox(self, MIN_LOCK, "Lock",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
254 choices=["Don't lock","Lock","no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
255 self.locked.SetSelection(2)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
256 self.hide = wx.RadioBox(self, MIN_HIDE, "Hide",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
257 choices=["Don't hide", "Hide", "no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
258 self.hide.SetSelection(2)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
259 self.snap = wx.RadioBox(self,MIN_ALIGN,"Snap",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
260 choices=["Center","Top left","no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
261 self.snap.SetSelection(2)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
262 group2.Add(self.locked, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
263 group2.Add(wx.Size(10,0))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
264 group2.Add(self.hide, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
265 group2.Add(wx.Size(10,0))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
266 group2.Add(self.snap, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
267 group2.Add(wx.Size(10,0))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
268 listsizer.Add(group2,0,0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
269 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
270 ###Group together the postion radiobox and the and its selection elements
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
271 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
272 xpos = int(min_list[0].pos[0])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
273 #xpos = int(`min_list[0].pos`[1:`min_list[0].pos`.index(',')])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
274 ypos = int(min_list[0].pos[1])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
275 #ypos = int(`min_list[0].pos`[`min_list[0].pos`.rfind(',')+1:len(`min_list[0].pos`)-1])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
276 self.scx = wx.SpinCtrl(self, POS_SPIN, "", (-1,-1), wx.Size(75,25))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
277 self.scx.SetRange(0,self.grid.return_grid()[0])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
278 self.scx.SetValue(xpos)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
279 self.scy = wx.SpinCtrl(self, POS_SPIN, "", (-1,-1), wx.Size(75,25))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
280 self.scy.SetRange(0,self.grid.return_grid()[1])
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
281 self.scy.SetValue(1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
282 self.scy.SetValue(ypos)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
283 positionbox = wx.BoxSizer(wx.HORIZONTAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
284 self.poschoice = wx.RadioBox(self,MIN_POS,"Position",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
285 choices=["Manual", "Existing", "no change"],majorDimension=1,style=wx.RA_SPECIFY_COLS)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
286 self.poschoice.SetSelection(2)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
287 positionbox.Add(self.poschoice,0,0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
288 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
289 ### group together choices under position choice boxsizer
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
290 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
291 poschoicebox = wx.BoxSizer(wx.VERTICAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
292 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
293 ### spinbox contains the x and y spinctrls
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
294 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
295 spinbox = wx.BoxSizer(wx.HORIZONTAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
296 group2.Add(positionbox,0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
297 xpos = wx.StaticText(self, -1,"XPOS: ")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
298 spinbox.Add(xpos,0, 0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
299 spinbox.Add(self.scx, 0, 0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
300 ypos = wx.StaticText(self, -1,"YPOS: ")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
301 spinbox.Add(ypos,0, 0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
302 spinbox.Add(self.scy, 0, 0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
303 poschoicebox.Add(wx.Size(0,15))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
304 poschoicebox.Add(spinbox,0,0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
305 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
306 ### kludge is just a way to horizontaly position text. .Add doesn't seem to work.
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
307 ###
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
308 kluge = wx.BoxSizer(wx.HORIZONTAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
309 klugetext = wx.StaticText(self, -1, " ")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
310 kluge.Add(klugetext,0,0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
311 kluge.Add(self.positioncombo,0,0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
312 poschoicebox.Add(wx.Size(0,1))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
313 poschoicebox.Add(kluge,0,0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
314 positionbox.Add(poschoicebox,0,0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
315 listsizer.Add(positionbox,0, 0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
316 self.listsizer = listsizer
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
317 #self.outline = wx.StaticBox(self,-1,"token list properties")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
318 #listsizer.Add(self.outline,0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
319 self.SetSizer(listsizer)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
320 self.SetAutoLayout(True)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
321 self.Fit()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
322 self.Bind(wx.EVT_SPINCTRL, self.on_spin, id=POS_SPIN)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
323 self.Bind(wx.EVT_TEXT, self.on_combo_box, id=POS_COMB)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
324 #self.Bind(wx.EVT_SIZE, self.on_size)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
325 self.Bind(wx.EVT_TEXT, self.on_text, id=MIN_LABEL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
326 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_HEADING)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
327 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_FACE)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
328
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
329 def on_ok(self,min):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
330 self.min = min
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
331 for m in self.min_list:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
332 if self.hide.GetSelection() !=2: m.hide = self.hide.GetSelection()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
333 if self.heading.GetSelection() !=9: m.heading = self.heading.GetSelection()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
334 #if self.face.GetSelection() !=9: m.face = self.face.GetSelection()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
335 if self.locked.GetSelection() !=2: m.locked = self.locked.GetSelection()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
336 if self.snap.GetSelection() !=2: m.snap_to_align = self.snap.GetSelection()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
337 if self.labelcombo.GetValue() != "no change":
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
338 m.label = self.labelcombo.GetValue()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
339 if self.labelcheck.GetValue(): m.label += " " + `self.layers['tokens'].next_serial()`
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
340 if self.pathcombo.GetValue() != "no change":
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
341 path = self.pathcombo.GetValue()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
342 image = self.evaluate(path)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
343 if str(image[1]) != '-1':
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
344 m.path = image[0]
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
345 m.bmp = image[1]
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
346 else:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
347 image[-1] = -1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
348 while image[1] == -1:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
349 image = 0
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
350 self.dlg = wx.TextEntryDialog(self,
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
351 'You entered an invalid URL for the image path. Please Enter a valid URL or cancel to leave the old url unchanged')
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
352 if self.dlg.ShowModal() == wx.ID_OK:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
353 path = self.dlg.GetValue()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
354 image = self.evaluate(path)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
355 if image[1] != -1:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
356 m.path = image[0]
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
357 m.bmp = image[1]
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
358 self.dlg.Destroy()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
359 else: break
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
360 if self.poschoice.GetSelection() !=2:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
361 if self.poschoice.GetSelection() == 0: m.pos = cmpPoint(self.scx.GetValue(),self.scy.GetValue())
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
362 else:
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
363 pos = self.positioncombo.GetValue()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
364 m.pos = cmpPoint(int(`pos`[2:`pos`.index(",")]),int(`pos`[`pos`.rfind(',')+1:len(`pos`)-2]))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
365 self.layers["tokens"].canvas.send_map_data()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
366
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
367 def evaluate(self, ckpath):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
368 path = []
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
369 if ckpath[:7] != "http://": ckpath = "http://" + ckpath
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
370 path = self.check_path(ckpath)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
371 return [ckpath, path]
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
372
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
373 def check_path(self, path):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
374 if ImageHandler.Cache.has_key(path): return ImageHandler.Cache[path]
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
375 img = ImageHandler.directLoad(path)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
376 if img is None: return -1
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
377 return img
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
378
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
379 def on_text(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
380 id=evt.GetId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
381
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
382 def on_spin(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
383 self.poschoice.SetSelection(0)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
384
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
385 def on_combo_box(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
386 self.poschoice.SetSelection(1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
387
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
388 def on_radio_box(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
389 id=evt.GetId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
390 index = evt.GetInt()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
391
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
392 def on_size(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
393 s = self.GetClientSizeTuple()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
394 self.listsizer.SetDimension(20,20,s[0]-40,s[1]-40)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
395 self.outline.SetDimensions(5,5,s[0]-10,s[1]-10)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
396
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
397 ##-----------------------------
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
398 ## token Prop Panel
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
399 ##-----------------------------
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
400
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
401 MIN_LABEL = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
402 MIN_HEADING = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
403 MIN_FACE = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
404 MIN_HIDE = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
405 MIN_LOCK = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
406 MIN_ALIGN = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
407 wxID_MIN_WIDTH = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
408 wxID_MIN_HEIGHT = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
409 wxID_MIN_SCALING = wx.NewId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
410
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
411 class min_edit_panel(wx.Panel):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
412 def __init__(self, parent, min):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
413 wx.Panel.__init__(self, parent, -1)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
414 self.min = min
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
415 sizer = wx.StaticBoxSizer(wx.StaticBox(self,-1,"token"), wx.VERTICAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
416 sizerSize = wx.BoxSizer(wx.HORIZONTAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
417 hSizer = wx.BoxSizer(wx.HORIZONTAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
418 self.label = wx.TextCtrl(self, MIN_LABEL, min.label)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
419 sizer.Add(wx.StaticText(self, -1, "Label:"), 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
420 sizer.Add(self.label, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
421 sizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
422 self.heading = wx.RadioBox(self, MIN_HEADING, "Heading",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
423 choices=["None","N","NE",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
424 "E","SE","S",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
425 "SW","W","NW"],majorDimension=5,style=wx.RA_SPECIFY_COLS)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
426 self.heading.SetSelection(min.heading)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
427 #self.face = wx.RadioBox(self, MIN_FACE, "Facing",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
428 # choices=["None","N","NE",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
429 # "E","SE","S",
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
430 # "SW","W","NW"],majorDimension=5,style=wx.RA_SPECIFY_COLS)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
431 #self.face.SetSelection(min.face)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
432 self.locked = wx.CheckBox(self, MIN_LOCK, " Lock")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
433 self.locked.SetValue(min.locked)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
434 self.hide = wx.CheckBox(self, MIN_HIDE, " Hide")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
435 self.hide.SetValue(min.hide)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
436 sizer.Add(self.heading, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
437 sizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
438 #sizer.Add(self.face, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
439 sizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
440 #
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
441 #image resizing
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
442 #
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
443 self.min_width_old_value = str(self.min.bmp.GetWidth())
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
444 self.min_width = wx.TextCtrl(self, wxID_MIN_WIDTH, self.min_width_old_value)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
445 sizerSize.Add(wx.StaticText(self, -1, "Width: "), 0, wx.ALIGN_CENTER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
446 sizerSize.Add(self.min_width, 1, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
447 sizerSize.Add(wx.Size(20, 25))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
448
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
449 #TODO:keep in mind that self.min is a local copy???
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
450 self.min_height_old_value = str(self.min.bmp.GetHeight())
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
451 self.min_height = wx.TextCtrl(self, wxID_MIN_HEIGHT, self.min_height_old_value)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
452 sizerSize.Add(wx.StaticText(self, -1, "Height: "),0,wx.ALIGN_CENTER)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
453 sizerSize.Add(self.min_height, 1, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
454 self.min_scaling = wx.CheckBox(self, wxID_MIN_SCALING, "Lock scaling")
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
455 self.min_scaling.SetValue(True)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
456 sizerSize.Add(self.min_scaling, 1, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
457 sizer.Add(sizerSize, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
458 sizer.Add(wx.Size(10, 10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
459
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
460 # Now, add the last items on in their own sizer
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
461 hSizer.Add(self.locked, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
462 hSizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
463 hSizer.Add(self.hide, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
464
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
465 # Add the hSizer to the main sizer
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
466 sizer.Add( hSizer )
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
467 self.sizer = sizer
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
468 self.SetSizer(self.sizer)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
469 self.SetAutoLayout(True)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
470 self.Fit()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
471
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
472 #self.Bind(wx.EVT_SIZE, self.on_size)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
473 self.Bind(wx.EVT_TEXT, self.on_text, id=MIN_LABEL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
474 self.Bind(wx.EVT_TEXT, self.on_scaling, id=wxID_MIN_WIDTH)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
475 self.Bind(wx.EVT_TEXT, self.on_scaling, id=wxID_MIN_HEIGHT)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
476 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_HEADING)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
477 #self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=MIN_FACE)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
478
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
479 def on_scaling(self, evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
480 if self.min_scaling.GetValue() == False: return
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
481 elif self.min_width.GetValue() and wxID_MIN_WIDTH == evt.GetId() and self.min_width.GetInsertionPoint():
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
482 self.min_height.SetValue(str(int((float(self.min_width.GetValue()) / float(self.min_width_old_value)) * float(self.min_height_old_value))) )
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
483 elif self.min_height.GetValue() and wxID_MIN_HEIGHT == evt.GetId() and self.min_height.GetInsertionPoint():
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
484 self.min_width.SetValue(str(int((float(self.min_height.GetValue()) / float(self.min_height_old_value)) * float(self.min_width_old_value))) )
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
485
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
486 def update_min(self):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
487 self.min.set_min_props(self.heading.GetSelection(),
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
488 #self.face.GetSelection(),
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
489 self.label.GetValue(),
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
490 self.locked.GetValue(),
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
491 self.hide.GetValue(),
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
492 self.min_width.GetValue(),
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
493 self.min_height.GetValue())
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
494
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
495 def on_radio_box(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
496 id = evt.GetId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
497 index = evt.GetInt()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
498
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
499 def on_text(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
500 id = evt.GetId()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
501
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
502 def on_size(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
503 s = self.GetClientSizeTuple()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
504 self.sizer.SetDimension(20,20,s[0]-40,s[1]-40)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
505 self.outline.SetDimensions(5,5,s[0]-10,s[1]-10)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
506
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
507 class min_edit_dialog(wx.Dialog):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
508 def __init__(self,parent,min):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
509 #520,265
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
510 wx.Dialog.__init__(self,parent,-1,"token",wx.DefaultPosition,wx.Size(520,350))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
511 (w,h) = self.GetClientSizeTuple()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
512 mastersizer = wx.BoxSizer(wx.VERTICAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
513 editor = min_edit_panel(self,min)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
514 #editor.SetDimensions(0,0,w,h-25)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
515 self.editor = editor
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
516 mastersizer.Add(editor, 1, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
517 mastersizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
518 sizer = wx.BoxSizer(wx.HORIZONTAL)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
519 sizer.Add(wx.Button(self, wx.ID_OK, "OK"), 1, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
520 sizer.Add(wx.Size(10,10))
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
521 sizer.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
522 #sizer.SetDimension(0,h-25,w,25)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
523 mastersizer.Add(sizer, 0, wx.EXPAND)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
524 self.SetSizer(mastersizer)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
525 self.SetAutoLayout(True)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
526 self.Fit()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
527 self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK)
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
528
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
529 def on_ok(self,evt):
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
530 self.editor.update_min()
2f2bebe9c77f Traipse Alpha 'OpenRPG' {091006-03}
sirebral
parents:
diff changeset
531 self.EndModal(wx.ID_OK)