Mercurial > traipse_dev
comparison orpg/networking/gsclient.py @ 104:15e32ec131cb alpha
Traipse Alpha 'OpenRPG' {091006-02}
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:
00:
Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images!
01:
Forgot the default_server_bookmarks.xml; added.
02:
Bookmarks working with no errors now! Sweet!
author | sirebral |
---|---|
date | Tue, 06 Oct 2009 06:22:23 -0500 |
parents | 905fa5b06d53 |
children | ded1e7a25f8d |
comparison
equal
deleted
inserted
replaced
103:6127549aed8b | 104:15e32ec131cb |
---|---|
98 self.last_motd = "" | 98 self.last_motd = "" |
99 self.buttons = {} | 99 self.buttons = {} |
100 self.texts = {} | 100 self.texts = {} |
101 self.svrList = [] | 101 self.svrList = [] |
102 self.build_ctrls() | 102 self.build_ctrls() |
103 self.bookmarks() | |
103 self.refresh_server_list() | 104 self.refresh_server_list() |
104 self.refresh_room_list() | 105 self.refresh_room_list() |
105 self.build_bookmarks() ## Not yet implemented | 106 self.build_bookmark_menu() ## Not yet implemented |
106 #self.refresh_server_list() | 107 #self.refresh_server_list() |
107 #self.refresh_room_list() | 108 #self.refresh_room_list() |
108 | 109 |
109 def build_ctrls(self): | 110 def build_ctrls(self): |
110 ## Section Sizers (with frame edges and text captions) | 111 ## Section Sizers (with frame edges and text captions) |
230 img = wx.Image(dir_struct["icon"]+"add.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() | 231 img = wx.Image(dir_struct["icon"]+"add.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() |
231 self._imageList.Add( img ) | 232 self._imageList.Add( img ) |
232 img = wx.Image(dir_struct["icon"]+"star.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() | 233 img = wx.Image(dir_struct["icon"]+"star.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() |
233 self._imageList.Add( img ) | 234 self._imageList.Add( img ) |
234 self.server_list.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL ) | 235 self.server_list.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL ) |
235 | 236 |
236 def build_bookmarks(self): | 237 def bookmarks(self): |
237 gsm = self.frame.mainmenu.GetMenu( | |
238 self.frame.mainmenu.FindMenu('Game Server')) | |
239 self.bookmarks_menu = wx.Menu() | |
240 validate.config_file('server_bookmarks.xml', | 238 validate.config_file('server_bookmarks.xml', |
241 'default_server_bookmarks.xml') | 239 'default_server_bookmarks.xml') |
242 self.bookmarks = ElementTree() | 240 self.bookmarks = ElementTree() |
243 self.bookmarks.parse(dir_struct['user'] + 'server_bookmarks.xml') | 241 self.bookmarks.parse(dir_struct['user'] + 'server_bookmarks.xml') |
242 | |
243 def build_bookmark_menu(self): | |
244 gsm = self.frame.mainmenu.GetMenu( | |
245 self.frame.mainmenu.FindMenu('Game Server')) | |
246 self.bookmarks_menu = wx.Menu() | |
244 x = 0 | 247 x = 0 |
245 for server in self.bookmarks.findall('server'): | 248 for server in self.bookmarks.findall('server'): |
246 for svr in self.svrList: | 249 for svr in self.svrList: |
247 name = svr.name | 250 name = svr.name |
248 if server.get('name') == name: self.server_list.SetItemImage(x, 1) | 251 if server.get('name') == name: self.server_list.SetItemImage(x, 1) |
257 | 260 |
258 def on_bookmarks_menu(self, evt): | 261 def on_bookmarks_menu(self, evt): |
259 id = evt.GetId() | 262 id = evt.GetId() |
260 menu = self.bookmarks_menu.FindItemById(id) | 263 menu = self.bookmarks_menu.FindItemById(id) |
261 for server in self.bookmarks.findall('server'): | 264 for server in self.bookmarks.findall('server'): |
262 if server.name == menu.GetLabel(): | 265 if server.get('name') == menu.GetLabel(): |
263 address = server.addy | 266 address = server.get('address') |
264 self.cur_server_index = 999 | 267 self.cur_server_index = 999 |
265 self.name = server.name | 268 self.name = server.get('name') |
266 if self.session.is_connected(): | 269 if self.session.is_connected(): |
267 if self.session.host_server == address : return | 270 if self.session.host_server == address : return |
268 else: self.frame.kill_mplay_session() | 271 else: self.frame.kill_mplay_session() |
269 self.do_connect(address) | 272 self.do_connect(address) |
270 break | 273 break |
520 for n in self.svrList: | 523 for n in self.svrList: |
521 i = self.server_list.GetItemCount() | 524 i = self.server_list.GetItemCount() |
522 name = n.name | 525 name = n.name |
523 players = n.user | 526 players = n.user |
524 self.server_list.InsertImageStringItem(i, '', 0) | 527 self.server_list.InsertImageStringItem(i, '', 0) |
528 for server in self.bookmarks.findall('server'): | |
529 if server.get('name') == name: self.server_list.SetItemImage(i, 1) | |
525 self.server_list.SetStringItem(i,1,players) | 530 self.server_list.SetStringItem(i,1,players) |
526 self.server_list.SetStringItem(i,2,name) | 531 self.server_list.SetStringItem(i,2,name) |
527 r,g,b = hex.rgb_tuple(color1) | 532 r,g,b = hex.rgb_tuple(color1) |
528 svrcolor = wx.Colour(red=r,green=g,blue=b) | 533 svrcolor = wx.Colour(red=r,green=g,blue=b) |
529 | 534 |
560 except: | 565 except: |
561 pass | 566 pass |
562 except Exception, e: | 567 except Exception, e: |
563 print "Server List not available." | 568 print "Server List not available." |
564 traceback.print_exc() | 569 traceback.print_exc() |
565 x = 0 | 570 |
566 try: ### Alpha ### | |
567 for server in self.bookmarks.findall('server'): | |
568 for svr in self.svrList: | |
569 name = svr.name | |
570 if server.get('name') == name: self.server_list.SetItemImage(x, 1) | |
571 x += 1 | |
572 except: pass | |
573 | 571 |
574 def failed_connection(self): | 572 def failed_connection(self): |
575 if(self.cur_server_index >= 0): | 573 if(self.cur_server_index >= 0): |
576 id = self.servers[self.cur_server_index].getAttribute('id') | 574 id = self.servers[self.cur_server_index].getAttribute('id') |
577 meta = self.servers[self.cur_server_index].getAttribute('meta') | 575 meta = self.servers[self.cur_server_index].getAttribute('meta') |