comparison orpg/mapper/map_handler.py @ 0:4385a7d0efd1 grumpy-goblin

Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author sirebral
date Tue, 14 Jul 2009 16:41:58 -0500
parents
children 0b8b7e3ed78d
comparison
equal deleted inserted replaced
-1:000000000000 0:4385a7d0efd1
1 #
2 # openrpg-dev@lists.sourceforge.net
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 # --
18 #
19 # File: orpg/mapper/map_handler.py
20 # Author: OpenRPG Team
21 # Maintainer:
22 # Version:
23 # $Id: map_handler.py,v 1.14 2007/04/03 00:14:35 digitalxero Exp $
24 #
25 # Description: map layer handler
26 #
27 __version__ = "$Id: map_handler.py,v 1.14 2007/04/03 00:14:35 digitalxero Exp $"
28
29 from base_handler import *
30
31 class map_handler(base_layer_handler):
32 def __init__(self, parent, id, canvas):
33 base_layer_handler.__init__(self, parent, id, canvas)
34
35 def build_ctrls(self):
36 base_layer_handler.build_ctrls(self)
37 self.width = wx.TextCtrl(self, wx.ID_ANY, size=(75,25))
38 self.height = wx.TextCtrl(self, wx.ID_ANY, size=(75,25))
39 self.apply_button = wx.Button(self, wx.ID_OK, "Apply", style=wx.BU_EXACTFIT)
40 self.load_default = wx.Button(self, wx.ID_ANY, "Default Map", style=wx.BU_EXACTFIT)
41 self.sizer.Prepend(wx.Size(20,25),1)
42 self.sizer.Prepend(self.load_default, 0, wx.EXPAND)
43 self.sizer.Prepend(wx.Size(20,25))
44 self.sizer.Prepend(self.apply_button, 0, wx.EXPAND)
45 self.sizer.Prepend(wx.Size(20,25))
46 self.sizer.Prepend(self.height, 0, wx.EXPAND)
47 self.sizer.Prepend(wx.StaticText(self, -1, "Height: "),0,wx.ALIGN_CENTER)
48 self.sizer.Prepend(wx.Size(10,25))
49 self.sizer.Prepend(self.width, 0, wx.EXPAND)
50 self.sizer.Prepend(wx.StaticText(self, -1, "Width: "),0,wx.ALIGN_CENTER)
51 self.sizer.Prepend(wx.Size(10,25))
52 self.Bind(wx.EVT_BUTTON, self.on_apply, self.apply_button)
53 self.Bind(wx.EVT_BUTTON, self.on_load_default, self.load_default)
54 self.update_info()
55
56 def update_info(self):
57 size = self.canvas.get_size()
58 self.width.SetValue(str(size[0]))
59 self.height.SetValue(str(size[1]))
60
61 def build_menu(self,label = "Grid"):
62 base_layer_handler.build_menu(self,label)
63
64 def on_load_default(self, evt):
65 self.map_frame.load_default()
66
67 def on_apply(self, evt):
68 session=self.canvas.frame.session
69 if (session.my_role() != session.ROLE_GM):
70 open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature")
71 return
72 try:
73 size = (int(self.width.GetValue()),int(self.height.GetValue()))
74 except:
75 wx.MessageBox("Invalide Map Size!","Map Properties")
76 return
77 self.canvas.set_size(size)
78 self.update_info()
79 self.canvas.send_map_data()
80 self.canvas.Refresh()