Mercurial > traipse_dev
annotate orpg/networking/gsclient.py @ 248:1df5912db00c beta tip
Traipse Beta 'OpenRPG' {101205-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 (Closed)
New Features:
New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order
New to Server GUI, can now clear log
New Earthdawn Dieroller
New IronClaw roller, sheet, and image
New ShapeShifter PC Sheet
Updates:
Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence.
Update to Browser Server window. Display rooms with ' " & cleaner
Update to Server. Handles ' " & cleaner
Update to Dieroller. Cleaner, more effecient expression system
Update to Hidden Die plugin, allows for non standard dice rolls
Update to location.py, allows for more portable references when starting Traipse
Update to the Features node
Fixes:
Fix to InterParse that was causing an Infernal Loop with Namespace Internal
Fix to XML data, removed old Minidom and switched to Element Tree
Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread
Fix to Server, removing wxPython dependencies where not needed
Fix to metaservers.xml file not being created
Fix to Single and Double quotes in Whiteboard text
Fix to Background images not showing when using the Image Server
Fix to Duplicate chat names appearing
Fix to Server GUI's logging output
Fix to FNB.COLORFUL_TABS bug
Fix to Gametree for XSLT Sheets
Fix to Gametree for locating gametree files
Fix to Send to Chat from Gametree
Fix to Gametree, renaming and remapping operates correctly
Fix to aliaslib, prevents error caused when SafeHTML is sent None
author | sirebral |
---|---|
date | Sun, 05 Dec 2010 10:53:30 -0600 |
parents | 42f4809ad8a8 |
children |
rev | line source |
---|---|
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
1 # Copyright (C) 2000-2001 The OpenRPG Project |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
2 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
3 # openrpg-dev@lists.sourceforge.net |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
4 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
5 # This program is free software; you can redistribute it and/or modify |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
6 # it under the terms of the GNU General Public License as published by |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
7 # the Free Software Foundation; either version 2 of the License, or |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
8 # (at your option) any later version. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
9 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
10 # This program is distributed in the hope that it will be useful, |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
13 # GNU General Public License for more details. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
14 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
15 # You should have received a copy of the GNU General Public License |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
16 # along with this program; if not, write to the Free Software |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
18 # -- |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
19 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
20 # File: gsclient.py |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
21 # Author: Chris Davis |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
22 # Maintainer: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
23 # Version: |
184 | 24 # $Id: gsclient.py,v Traipse 'Ornery-Orc' prof.ebral Exp $ |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
25 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
26 # Description: The file contains code for the game server browser |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
27 # |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
28 |
135 | 29 from __future__ import with_statement |
184 | 30 __version__ = "$Id: gsclient.py,v Traipse 'Ornery-Orc' prof.ebral Exp $" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
31 |
135 | 32 import meta_server_lib |
33 import orpg.tools.rgbhex | |
34 import traceback | |
35 | |
100 | 36 from orpg.dirpath import dir_struct |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
37 from orpg.orpg_windows import * |
135 | 38 from orpg.tools.validate import validate |
39 from orpg.orpgCore import component | |
71
449a8900f9ac
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents:
66
diff
changeset
|
40 from orpg.tools.orpg_settings import settings |
135 | 41 from orpg.tools.orpg_log import debug |
42 | |
43 from xml.etree.ElementTree import ElementTree, Element | |
44 from xml.etree.ElementTree import fromstring, tostring | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
45 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
46 gs_host = 1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
47 gs_join = 2 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
48 # constants |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
49 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
50 class server_instance: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
51 def __init__(self, id, name="[Unknown]", users="0", address="127.0.0.1", port="9557"): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
52 self.id = id |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
53 self.name = name |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
54 self.user = users |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
55 self.addy = address |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
56 self.port = port |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
57 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
58 def server_instance_compare(x,y): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
59 """compares server insances for list sort""" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
60 DEV_SERVER = "OpenRPG DEV" |
135 | 61 xname = x.name |
62 xuser = int(x.user) | |
63 yname = y.name | |
64 yuser = int(y.user) | |
65 | |
66 who_name = cmp(yname, xname) | |
67 who_user = cmp(yuser, xuser) | |
68 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
69 if x.name.startswith(DEV_SERVER): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
70 if y.name.startswith(DEV_SERVER): |
135 | 71 if not who_name: return who_user |
72 else: return who_name | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
73 else: return -1 |
135 | 74 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
75 elif y.name.startswith(DEV_SERVER): return 1 |
135 | 76 elif not who_user: return who_name |
77 else: return who_user | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
78 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
79 def roomCmp(room1, room2): |
135 | 80 if int(room1) > int(room2): return 1 |
81 elif int(room1) < int(room2): return -1 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
82 return 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
83 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
84 class game_server_panel(wx.Panel): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
85 def __init__(self,parent): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
86 wx.Panel.__init__(self, parent, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
87 self.parent = parent |
135 | 88 self.password_manager = component.get('password_manager') |
66 | 89 self.frame = component.get('frame') |
90 self.session = component.get('session') | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
91 self.serverNameSet = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
92 self.last_motd = "" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
93 self.buttons = {} |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
94 self.texts = {} |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
95 self.svrList = [] |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
96 self.build_ctrls() |
135 | 97 self.bookmarks() |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
98 self.refresh_server_list() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
99 self.refresh_room_list() |
135 | 100 self.build_bookmark_menu() |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
101 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
102 def build_ctrls(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
103 ## Section Sizers (with frame edges and text captions) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
104 self.box_sizers = {} |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
105 self.box_sizers["server"] = wx.StaticBox(self, -1, "Server") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
106 self.box_sizers["window"] = wx.StaticBox(self, -1, "Exit" ) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
107 self.box_sizers["room"] = wx.StaticBox(self, -1, "Rooms") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
108 self.box_sizers["c_room"] = wx.StaticBox(self, -1, "Create Room") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
109 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
110 ## Layout Sizers |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
111 self.sizers = {} |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
112 self.sizers["main"] = wx.GridBagSizer(hgap=1, vgap=1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
113 self.sizers["server"] = wx.StaticBoxSizer(self.box_sizers["server"], wx.VERTICAL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
114 self.sizers["rooms"] = wx.StaticBoxSizer(self.box_sizers["room"], wx.VERTICAL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
115 self.sizers["close"] = wx.StaticBoxSizer(self.box_sizers["window"], wx.HORIZONTAL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
116 self.sizers["c_room"] = wx.StaticBoxSizer(self.box_sizers["c_room"], wx.VERTICAL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
117 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
118 #Build Server Sizer |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
119 adder = wx.StaticText(self, -1, "Address:") |
135 | 120 self.texts["address"] = wx.TextCtrl(self, wx.ID_ANY) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
121 servers = wx.StaticText(self, -1, "Servers:") |
135 | 122 self.server_list = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_REPORT | wx.SUNKEN_BORDER ) |
123 self.server_list.InsertColumn(0, '', wx.LIST_FORMAT_LEFT, 0) | |
124 self.server_list.InsertColumn(1, "Players", wx.LIST_FORMAT_LEFT, 0) | |
125 self.server_list.InsertColumn(2, "Name", wx.LIST_FORMAT_LEFT, 0) | |
126 self.buttons['gs_connect'] = wx.Button(self, wx.ID_ANY, "Connect") | |
127 self.buttons['gs_refresh'] = wx.Button(self, wx.ID_ANY, "Refresh") | |
128 self.buttons['gs_disconnect'] = wx.Button(self, wx.ID_ANY, "Disconnect") | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
129 self.sizers["svrbtns"] = wx.BoxSizer(wx.HORIZONTAL) |
135 | 130 self.sizers["svrbtns"].Add(self.buttons['gs_connect'], 0, wx.EXPAND) |
131 self.sizers["svrbtns"].Add(self.buttons['gs_refresh'], 0, wx.EXPAND) | |
132 self.sizers["svrbtns"].Add(self.buttons['gs_disconnect'], 0, wx.EXPAND) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
133 self.sizers["server"].Add(adder, 0, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
134 self.sizers["server"].Add(self.texts["address"], 0, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
135 self.sizers["server"].Add(servers, 0, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
136 self.sizers["server"].Add(self.server_list, 1, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
137 self.sizers["server"].Add(self.sizers["svrbtns"], 0, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
138 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
139 #Build Rooms Sizer |
135 | 140 self.room_list = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_REPORT | wx.SUNKEN_BORDER) |
100 | 141 self.room_list.InsertColumn(0,"Game", wx.LIST_FORMAT_LEFT,-1) |
142 self.room_list.InsertColumn(1,"Players", wx.LIST_FORMAT_LEFT,-1) | |
143 self.room_list.InsertColumn(2,"PW", wx.LIST_FORMAT_LEFT,-1) | |
135 | 144 self.buttons['gs_join_room'] = wx.Button(self, wx.ID_ANY, "Join Room") |
145 self.buttons['gs_join_lobby'] = wx.Button(self, wx.ID_ANY, "Lobby") | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
146 self.sizers["roombtns"] = wx.BoxSizer(wx.HORIZONTAL) |
135 | 147 self.sizers["roombtns"].Add(self.buttons['gs_join_room'], 0, wx.EXPAND) |
148 self.sizers["roombtns"].Add(self.buttons['gs_join_lobby'], 0, wx.EXPAND) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
149 self.sizers["rooms"].Add(self.room_list, 1, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
150 self.sizers["rooms"].Add(self.sizers["roombtns"], 0, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
151 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
152 #Build Close Sizer |
135 | 153 self.buttons['close_orpg'] = wx.Button(self, wx.ID_ANY,"Exit OpenRPG") |
154 self.buttons['gs_close'] = wx.Button(self, wx.ID_ANY,"Close Window") | |
155 self.sizers["close"].Add(self.buttons['close_orpg'], 1, wx.ALIGN_CENTER_VERTICAL) | |
156 self.sizers["close"].Add(self.buttons['gs_close'], 1, wx.ALIGN_CENTER_VERTICAL) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
157 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
158 #Build Create Room Sizer |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
159 rname = wx.StaticText(self,-1, "Room Name:") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
160 self.texts["room_name"] = wx.TextCtrl(self, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
161 rpass = wx.StaticText(self,-1, "Password:") |
135 | 162 self.buttons['gs_pwd'] = wx.CheckBox(self, wx.ID_ANY, "") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
163 self.texts["room_pwd"] = wx.TextCtrl(self, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
164 self.texts["room_pwd"].Enable(0) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
165 pwsizer = wx.BoxSizer(wx.HORIZONTAL) |
135 | 166 pwsizer.Add(self.buttons['gs_pwd'],0,0) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
167 pwsizer.Add(self.texts["room_pwd"], 1, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
168 apass = wx.StaticText(self,-1, "Admin Password:") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
169 self.texts["room_boot_pwd"] = wx.TextCtrl(self, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
170 minver = wx.StaticText(self,-1, "Minimum Version:") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
171 self.texts["room_min_version"] = wx.TextCtrl(self, -1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
172 self.sizers["c_room_layout"] = wx.FlexGridSizer(rows=8, cols=2, hgap=1, vgap=1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
173 self.sizers["c_room_layout"].Add(rname, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
174 self.sizers["c_room_layout"].Add(self.texts["room_name"], 0, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
175 self.sizers["c_room_layout"].Add(rpass, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
176 self.sizers["c_room_layout"].Add(pwsizer, 0, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
177 self.sizers["c_room_layout"].Add(apass, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
178 self.sizers["c_room_layout"].Add(self.texts["room_boot_pwd"], 0, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
179 self.sizers["c_room_layout"].Add(minver, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
180 self.sizers["c_room_layout"].Add(self.texts["room_min_version"], 0, wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
181 self.sizers["c_room_layout"].AddGrowableCol(1) |
135 | 182 self.buttons['gs_create_room'] = wx.Button(self, wx.ID_ANY, "Create Room") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
183 self.sizers["c_room"].Add(self.sizers["c_room_layout"], 1, wx.EXPAND) |
135 | 184 self.sizers["c_room"].Add(self.buttons['gs_create_room'], 0, wx.EXPAND) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
185 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
186 #Build Main Sizer |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
187 self.sizers["main"].Add(self.sizers["server"], (0,0), span=(2,1), flag=wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
188 self.sizers["main"].Add(self.sizers["rooms"], (0,1), flag=wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
189 self.sizers["main"].Add(self.sizers["close"], (2,0), flag=wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
190 self.sizers["main"].Add(self.sizers["c_room"], (1,1), span=(2,1), flag=wx.EXPAND) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
191 self.sizers["main"].AddGrowableCol(0) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
192 self.sizers["main"].AddGrowableCol(1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
193 self.sizers["main"].AddGrowableRow(0) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
194 self.SetSizer(self.sizers["main"]) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
195 self.SetAutoLayout(True) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
196 self.Fit() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
197 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
198 ## Event Handlers |
135 | 199 self.Bind(wx.EVT_BUTTON, self.gs_connect, self.buttons['gs_connect']) |
200 self.Bind(wx.EVT_BUTTON, self.gs_disconnect, self.buttons['gs_disconnect']) | |
201 self.Bind(wx.EVT_BUTTON, self.gs_create_room, self.buttons['gs_create_room']) | |
202 self.Bind(wx.EVT_BUTTON, self.gs_join, self.buttons['gs_join_room']) | |
203 self.Bind(wx.EVT_BUTTON, self.gs_join_lobby, self.buttons['gs_join_lobby']) | |
204 self.Bind(wx.EVT_BUTTON, self.gs_server_refresh, self.buttons['gs_refresh']) | |
205 self.Bind(wx.EVT_BUTTON, self.gs_close, self.buttons['gs_close']) | |
206 self.Bind(wx.EVT_BUTTON, self.close_orpg, self.buttons['close_orpg']) | |
207 self.Bind(wx.EVT_CHECKBOX, self.gs_pwd, self.buttons['gs_pwd']) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
208 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
209 # Added double click handlers 5/05 -- Snowdog |
135 | 210 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_server_dbclick, self.server_list) |
211 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_room_dbclick, self.room_list) | |
212 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_room_select, self.room_list) | |
213 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_server_select, self.server_list) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
214 self.texts['address'].Bind(wx.EVT_SET_FOCUS, self.on_text) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
215 self.set_connected(self.session.is_connected()) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
216 self.cur_room_index = -1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
217 self.cur_server_index = -1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
218 self.rmList = {} |
135 | 219 |
220 # Create Book Mark Image List | |
221 self.server_list.Bind(wx.EVT_LEFT_DOWN, self.on_hit) | |
222 self._imageList = wx.ImageList( 16, 16, False ) | |
223 img = wx.Image(dir_struct["icon"]+"add.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() | |
224 self._imageList.Add( img ) | |
225 img = wx.Image(dir_struct["icon"]+"star.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() | |
226 self._imageList.Add( img ) | |
227 self.server_list.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL ) | |
228 | |
229 def bookmarks(self): | |
230 validate.config_file('server_bookmarks.xml', | |
231 'default_server_bookmarks.xml') | |
232 self.bookmarks = ElementTree() | |
233 self.bookmarks.parse(dir_struct['user'] + 'server_bookmarks.xml') | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
234 |
135 | 235 def build_bookmark_menu(self): |
236 gsm = self.frame.mainmenu.GetMenu( | |
237 self.frame.mainmenu.FindMenu('Game Server')) | |
238 self.bookmarks_menu = wx.Menu() | |
239 x = 0 | |
240 for server in self.bookmarks.findall('server'): | |
241 for svr in self.svrList: | |
242 address = svr.addy | |
243 if server.get('address') == address: self.server_list.SetItemImage(x, 1) | |
244 x += 1 | |
245 item = wx.MenuItem(self.bookmarks_menu, wx.ID_ANY, | |
246 server.get('name'), server.get('name')) | |
247 open_rpg.get_component('frame').Bind(wx.EVT_MENU, | |
248 self.on_bookmarks_menu, item) | |
249 self.bookmarks_menu.AppendItem(item) | |
250 gsm.AppendSubMenu(self.bookmarks_menu, "Bookmarks") | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
251 |
135 | 252 def on_bookmarks_menu(self, evt): |
253 id = evt.GetId() | |
254 menu = self.bookmarks_menu.FindItemById(id) | |
255 for server in self.bookmarks.findall('server'): | |
256 if server.get('name') == menu.GetLabel(): | |
257 address = server.get('address') | |
258 self.cur_server_index = 999 | |
259 self.name = server.get('name') | |
140 | 260 self.texts["address"].SetValue(address) |
135 | 261 if self.session.is_connected(): |
262 if self.session.host_server == address : return | |
263 else: self.frame.kill_mplay_session() | |
264 self.do_connect(address) | |
265 break | |
266 | |
267 def bookmark(self, item, flag): | |
268 name = self.svrList[item].name | |
269 address = self.svrList[item].addy | |
270 port = self.svrList[item].port | |
271 self.server_list.SetItemImage(item, 1) | |
272 for server in self.bookmarks.findall('server'): | |
273 if server.get('name') == name: | |
274 self.bookmarks_menu.Remove( | |
275 self.bookmarks_menu.FindItem(server.get('name'))) | |
276 self.bookmarks.getroot().remove(server) | |
277 self.server_list.SetItemImage(item, 0) | |
278 break | |
279 else: | |
280 server = Element('server') | |
281 server.set('name', name) | |
282 server.set('address', address + ':' + port) | |
283 self.bookmarks.getroot().append(server) | |
284 item = wx.MenuItem(self.bookmarks_menu, wx.ID_ANY, name, name) | |
285 open_rpg.get_component('frame').Bind(wx.EVT_MENU, | |
286 self.on_bookmarks_menu, item) | |
287 self.bookmarks_menu.AppendItem(item) | |
288 self.save_bookmarks() | |
289 | |
290 def save_bookmarks(self): | |
291 with open(dir_struct['user'] + 'server_bookmarks.xml', 'w') as f: | |
292 self.bookmarks.write(f) | |
293 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
294 def on_server_dbclick(self, evt=None): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
295 #make sure address is updated just in case list select wasn't done |
135 | 296 try: self.on_select(evt) |
297 except: pass | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
298 address = self.texts["address"].GetValue() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
299 if self.session.is_connected(): |
184 | 300 if self.session.host_server == address : return |
301 else: self.frame.kill_mplay_session() | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
302 self.do_connect(address) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
303 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
304 def on_room_dbclick(self, evt=None): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
305 #make sure address is updated just in case list select wasn't done |
135 | 306 try: self.on_select(evt) |
307 except: pass | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
308 group_id = str(self.room_list.GetItemData(self.cur_room_index)) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
309 if self.NoGroups: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
310 self.NoGroups = False |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
311 self.session.group_id = group_id |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
312 self.on_server_dbclick() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
313 return |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
314 if self.cur_room_index >= 0: |
135 | 315 if self.cur_room_index != 0: self.set_lobbybutton(1); |
316 else: self.set_lobbybutton(0); | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
317 group = self.session.get_group_info(group_id) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
318 pwd = "" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
319 if (group[2] == "True") or (group[2] == "1"): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
320 pwd = self.password_manager.GetPassword("room", group_id) |
135 | 321 else: pwd = "" |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
322 self.session.send_join_group(group_id, pwd) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
323 |
135 | 324 def on_room_select(self,evt): |
325 self.cur_room_index = evt.m_itemIndex | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
326 |
135 | 327 def on_hit(self, evt): |
328 pos = wx.Point( evt.GetX(), evt.GetY() ) | |
329 (item, flag) = self.server_list.HitTest( pos ) | |
330 ## Item == list[server], flag == (32 = 0 colum, 128 = else) ## | |
331 if flag == 32: self.bookmark(item, flag) | |
332 evt.Skip() | |
333 | |
334 def on_server_select(self,evt): | |
335 self.cur_server_index = evt.m_itemIndex | |
336 self.name = self.svrList[self.cur_server_index].name | |
337 address = self.svrList[self.cur_server_index].addy | |
338 port = self.svrList[self.cur_server_index].port | |
339 self.texts["address"].SetValue(address + ":" + str(port)) | |
340 self.refresh_room_list() | |
341 | |
342 def on_text(self, evt): | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
343 id = evt.GetId() |
135 | 344 if (id == self.texts["address"].GetValue()) and (self.cur_server_index >= 0): |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
345 self.cur_server_index = -1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
346 evt.Skip() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
347 |
135 | 348 def add_room(self, data): |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
349 i = self.room_list.GetItemCount() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
350 if (data[2]=="1") or (data[2]=="True"): pwd="yes" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
351 else: pwd="no" |
236 | 352 name = data[1].replace('&', "&") |
237 | 353 name = name.replace('"', '"').replace(''', "'").replace("<", '<').replace(">", '>') |
236 | 354 self.room_list.InsertStringItem(i, name) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
355 self.room_list.SetStringItem(i,1,data[3]) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
356 self.room_list.SetStringItem(i,2,pwd) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
357 self.room_list.SetItemData(i,int(data[0])) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
358 self.refresh_room_list() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
359 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
360 def del_room(self, data): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
361 i = self.room_list.FindItemData(-1, int(data[0])) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
362 self.room_list.DeleteItem(i) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
363 self.refresh_room_list() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
364 |
135 | 365 def update_room(self, data): |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
366 i = self.room_list.FindItemData(-1,int(data[0])) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
367 if data[2]=="1" : pwd="yes" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
368 else: pwd="no" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
369 self.room_list.SetStringItem(i,0,data[1]) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
370 self.room_list.SetStringItem(i,1,data[3]) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
371 self.room_list.SetStringItem(i,2,pwd) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
372 self.refresh_room_list() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
373 |
135 | 374 def set_cur_room_text(self, name): |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
375 pass |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
376 #self.texts["cur_room"].SetLabel(name) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
377 #self.sizers["room"].Layout() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
378 |
135 | 379 def set_lobbybutton(self, allow): |
380 self.buttons['gs_join_lobby'].Enable(allow) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
381 |
135 | 382 def set_connected(self, connected): |
383 self.buttons['gs_connect'].Enable(not connected) | |
384 self.buttons['gs_disconnect'].Enable(connected) | |
385 self.buttons['gs_join_room'].Enable(connected) | |
386 self.buttons['gs_create_room'].Enable(connected) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
387 if not connected: |
135 | 388 self.buttons['gs_join_lobby'].Enable(connected) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
389 self.room_list.DeleteAllItems() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
390 self.set_cur_room_text("Not Connected!") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
391 self.cur_room_index = -1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
392 self.frame.status.set_connect_status("Not Connected") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
393 else: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
394 self.frame.status.set_connect_status(self.name) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
395 self.set_cur_room_text("Lobby") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
396 |
135 | 397 def gs_connect(self, evt): |
398 address = self.texts['address'].GetValue() | |
399 try: dummy = self.name | |
400 except: self.name = `address` | |
401 self.do_connect(address) | |
402 | |
403 def gs_disconnect(self, evt): | |
404 self.frame.kill_mplay_session() | |
405 | |
406 def gs_create_room(self, evt): | |
407 self.do_create_group() | |
408 | |
409 def gs_join(self, evt): | |
410 self.do_join_group() | |
411 | |
412 def gs_join_lobby(self, evt): | |
413 self.do_join_lobby() | |
414 | |
415 def gs_server_refresh(self, evt): | |
416 self.refresh_server_list() | |
417 | |
418 def gs_pwd(self, evt): | |
419 self.texts['room_pwd'].Enable(evt.Checked()) | |
420 | |
421 def close_orpg(self, evt): | |
422 dlg = wx.MessageDialog(self, 'Quit OpenRPG?', "OpenRPG", wx.YES_NO) | |
423 if dlg.ShowModal() == wx.ID_YES: | |
424 dlg.Destroy() | |
425 self.frame.kill_mplay_session() | |
426 self.frame.closed_confirmed() | |
427 | |
428 def gs_close(self, evt): | |
429 self.parent.OnMB_GameServerBrowseServers() | |
430 | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
431 def refresh_room_list(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
432 self.room_list.DeleteAllItems() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
433 address = self.texts["address"].GetValue() |
135 | 434 try: cadder = self.session.host_server |
435 except: cadder = '' | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
436 if self.rmList.has_key(address) and len(self.rmList[address]) > 0 and cadder != address: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
437 groups = self.rmList[address] |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
438 self.NoGroups = True |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
439 else: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
440 self.NoGroups = False |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
441 groups = self.session.get_groups() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
442 for g in groups: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
443 i = self.room_list.GetItemCount() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
444 if (g[2]=="True") or (g[2]=="1") : pwd="yes" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
445 else: pwd="no" |
236 | 446 name = g[1].replace('&', "&") |
237 | 447 name = name.replace('"', '"').replace(''', "'").replace("<", '<').replace(">", '>') |
236 | 448 self.room_list.InsertStringItem(i, name) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
449 self.room_list.SetStringItem(i, 1, g[3]) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
450 self.room_list.SetStringItem(i, 2, pwd) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
451 self.room_list.SetItemData(i, int(g[0])) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
452 if self.room_list.GetItemCount() > 0: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
453 self.colorize_group_list(groups) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
454 self.room_list.SortItems(roomCmp) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
455 wx.CallAfter(self.autosizeRooms) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
456 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
457 def autosizeRooms(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
458 self.room_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) |
100 | 459 if self.room_list.GetColumnWidth(0) < 70: self.room_list.SetColumnWidth(0, 70) |
460 if self.room_list.GetColumnWidth(1) < 70: self.room_list.SetColumnWidth(1, 70) | |
461 if self.room_list.GetColumnWidth(2) < 50: self.room_list.SetColumnWidth(2, 50) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
462 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
463 def refresh_server_list(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
464 try: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
465 self.svrList = [] |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
466 self.server_list.DeleteAllItems() |
135 | 467 etreeEl = meta_server_lib.get_server_list(["2"]); |
468 node_list = etreeEl.findall('server') | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
469 hex = orpg.tools.rgbhex.RGBHex() |
135 | 470 color1 = settings.get("RoomColor_Active") |
471 color2 = settings.get("RoomColor_Locked") | |
472 color3 = settings.get("RoomColor_Empty") | |
473 color4 = settings.get("RoomColor_Lobby") | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
474 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
475 if len(node_list): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
476 length = len(node_list) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
477 part = 0 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
478 partLength = 1.0/length |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
479 for n in node_list: |
135 | 480 self.svrList.append(server_instance(n.get('id'), n.get('name'), |
481 n.get('num_users'), n.get('address'), | |
482 n.get('port'))) | |
483 address = n.get('address') + ':' + n.get('port') | |
484 self.rmList[address] = [] | |
485 rooms = n.findall('room') | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
486 |
135 | 487 for room in rooms: |
236 | 488 name = room.get('name').replace('&', "&") |
237 | 489 name = name.replace('"', '"').replace(''', "'").replace("<", '<').replace(">", '>') |
236 | 490 self.rmList[address].append((room.get("id"), name, |
135 | 491 room.get("pwd"), room.get("num_users"))) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
492 self.svrList.sort(server_instance_compare) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
493 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
494 for n in self.svrList: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
495 i = self.server_list.GetItemCount() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
496 name = n.name |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
497 players = n.user |
135 | 498 self.server_list.InsertImageStringItem(i, '', 0) |
499 for server in self.bookmarks.findall('server'): | |
500 if server.get('name') == name: self.server_list.SetItemImage(i, 1) | |
501 self.server_list.SetStringItem(i,1,players) | |
502 self.server_list.SetStringItem(i,2,name) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
503 r,g,b = hex.rgb_tuple(color1) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
504 svrcolor = wx.Colour(red=r,green=g,blue=b) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
505 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
506 if players == "0": |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
507 r,g,b = hex.rgb_tuple(color3) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
508 svrcolor = wx.Colour(red=r,green=g,blue=b) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
509 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
510 if n.name.startswith("OpenRPG DEV"): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
511 r,g,b = hex.rgb_tuple(color2) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
512 svrcolor = wx.Colour(red=r,green=g,blue=b) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
513 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
514 item = self.server_list.GetItem(i) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
515 item.SetTextColour(svrcolor) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
516 self.server_list.SetItem(item) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
517 part += partLength |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
518 self.servers = node_list |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
519 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
520 # No server is currently selected!!! Versus the broken and random 0! |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
521 self.cur_server_index = -1 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
522 self.server_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
523 self.server_list.SetColumnWidth(1, wx.LIST_AUTOSIZE) |
135 | 524 if self.server_list.GetColumnWidth(1) < 70: self.server_list.SetColumnWidth(1, 70) |
525 self.server_list.SetColumnWidth(2, wx.LIST_AUTOSIZE) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
526 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
527 if self.serverNameSet == 0: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
528 self.texts["address"].SetValue("127.0.0.1:6774") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
529 self.serverNameSet = 1 |
135 | 530 else: pass |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
531 except Exception, e: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
532 print "Server List not available." |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
533 traceback.print_exc() |
184 | 534 |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
535 def failed_connection(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
536 if(self.cur_server_index >= 0): |
135 | 537 server_index = self.servers[self.cur_server_index] |
538 if(meta_server_lib.post_failed_connection(server_index.get('id'), | |
539 meta=server_index.get('meta'), address=server_index.get('address'), | |
540 port=server_index.get('port'))): | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
541 self.refresh_server_list() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
542 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
543 def do_connect(self, address): |
66 | 544 chat = component.get('chat') |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
545 chat.InfoPost("Locating server at " + address + "...") |
135 | 546 if self.session.connect(address): self.frame.start_timer() |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
547 else: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
548 chat.SystemPost("Failed to connect to game server...") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
549 self.failed_connection() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
550 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
551 def do_join_lobby(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
552 self.cur_room_index = 0 |
135 | 553 self.session.send_join_group("0", "") |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
554 self.set_lobbybutton(0); |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
555 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
556 def do_join_group(self): |
135 | 557 if self.cur_room_index >= 0: |
558 if self.cur_room_index != 0: self.set_lobbybutton(1); | |
559 else: self.set_lobbybutton(0); | |
560 group_id = str(self.room_list.GetItemData(self.cur_room_index)) | |
561 group = self.session.get_group_info(group_id) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
562 pwd = "" |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
563 if (group[2] == "True") or (group[2] == "1"): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
564 pwd = self.password_manager.GetPassword("room", group_id) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
565 #dlg = wx.TextEntryDialog(self,"Password?","Join Private Room") |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
566 #if dlg.ShowModal() == wx.ID_OK: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
567 # pwd = dlg.GetValue() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
568 #dlg.Destroy() |
135 | 569 else: pwd = "" |
570 if pwd != None: #pwd == None means the user clicked "Cancel" | |
571 self.session.send_join_group(group_id, pwd) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
572 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
573 def do_create_group(self): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
574 name = self.texts["room_name"].GetValue() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
575 boot_pwd = self.texts["room_boot_pwd"].GetValue() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
576 minversion = self.texts["room_min_version"].GetValue() |
236 | 577 |
135 | 578 if self.buttons['gs_pwd'].GetValue(): pwd = self.texts["room_pwd"].GetValue() |
579 else: pwd = "" | |
580 if name == "": wx.MessageBox("Invalid Name","Error"); | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
581 else: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
582 msg = "%s is creating room \'%s.\'" % (self.session.name, name) |
135 | 583 self.session.send(msg) |
584 self.session.send_create_group(name, pwd, boot_pwd, minversion) | |
184 | 585 self.set_lobbybutton(1); |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
586 |
135 | 587 def on_size(self, evt): |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
588 pass |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
589 |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
590 def colorize_group_list(self, groups): |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
591 try: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
592 hex = orpg.tools.rgbhex.RGBHex() |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
593 for gr in groups: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
594 item_list_location = self.room_list.FindItemData(-1,int(gr[0])) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
595 if item_list_location != -1: |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
596 item = self.room_list.GetItem(item_list_location) |
135 | 597 if gr[0] == "0": r,g,b = hex.rgb_tuple(settings.get("RoomColor_Lobby")) |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
598 elif gr[3] <> "0": |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
599 if gr[2] == "True" or gr[2] == "1": |
135 | 600 r,g,b = hex.rgb_tuple(settings.get("RoomColor_Locked")) |
601 else: r,g,b = hex.rgb_tuple(settings.get("RoomColor_Active")) | |
602 else: r,g,b = hex.rgb_tuple(settings.get("RoomColor_Empty")) | |
0
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
603 color = wx.Colour(red=r,green=g,blue=b) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
604 item.SetTextColour(color) |
4385a7d0efd1
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff
changeset
|
605 self.room_list.SetItem(item) |
135 | 606 except: traceback.print_exc() |