comparison orpg/tools/aliaslib.py @ 18:97265586402b ornery-orc

Traipse 'OpenRPG' {090827-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: Update Manager is now in version 0.8. While not every button works, users can now browse the different revisions and their different changesets. The code has been refined some with feature from Core added to it. A Crash report is now created if the users software crashes. Update Manager has been moved to the Traipse Suite menu item, and a Debug Console as been added as well.
author sirebral
date Thu, 27 Aug 2009 01:04:43 -0500
parents 4385a7d0efd1
children baee049045be
comparison
equal deleted inserted replaced
17:265b987cce4f 18:97265586402b
27 # 27 #
28 28
29 __version__ = "$Id: aliaslib.py,v 1.20 2007/08/09 05:23:21 digitalxero Exp $" 29 __version__ = "$Id: aliaslib.py,v 1.20 2007/08/09 05:23:21 digitalxero Exp $"
30 30
31 from orpg.orpg_wx import * 31 from orpg.orpg_wx import *
32 from orpg.orpgCore import * 32 from orpg.orpgCore import component
33 from orpg.orpg_windows import createMaskedButton, orpgMultiCheckBoxDlg 33 from orpg.orpg_windows import createMaskedButton, orpgMultiCheckBoxDlg
34 from orpg.tools.rgbhex import RGBHex 34 from orpg.tools.rgbhex import RGBHex
35 import orpg.tools.orpg_log 35 from orpg.dirpath import dir_struct
36 import orpg.dirpath 36 from orpg.tools.validate import validate
37 import orpg.orpg_xml 37 from orpg.tools.orpg_settings import settings
38 import orpg.tools.validate 38 import re
39 import orpg.tools.orpg_settings
40 39
41 class AliasLib(wx.Frame): 40 class AliasLib(wx.Frame):
42 def __init__(self): 41 def __init__(self):
43 self.orpgframe = open_rpg.get_component('frame') 42 self.orpgframe = component.get('frame')
44 self.log = open_rpg.get_component('log')
45 self.log.log("Enter AliasLib", ORPG_DEBUG)
46 wx.Frame.__init__(self, None, wx.ID_ANY, title="Alias Lib") 43 wx.Frame.__init__(self, None, wx.ID_ANY, title="Alias Lib")
47 self.orpgframe.Freeze() 44 self.orpgframe.Freeze()
48 self.Freeze() 45 self.Freeze()
49 self.SetOwnBackgroundColour('#EFEFEF') 46 self.SetOwnBackgroundColour('#EFEFEF')
50 self.dir_struct = open_rpg.get_component('dir_struct') 47 self.filename = settings.get_setting('aliasfile') + '.alias'
51 self.settings = open_rpg.get_component('settings') 48 validate.config_file(self.filename, "default_alias.alias")
52 self.xml = open_rpg.get_component('xml')
53 self.validate = open_rpg.get_component('validate')
54 self.filename = self.settings.get_setting('aliasfile') + '.alias'
55 self.validate.config_file(self.filename, "default_alias.alias")
56 self.buildMenu() 49 self.buildMenu()
57 self.buildButtons() 50 self.buildButtons()
58 self.buildGUI() 51 self.buildGUI()
59 wx.CallAfter(self.InitSetup) 52 wx.CallAfter(self.InitSetup)
60 wx.CallAfter(self.loadFile) 53 wx.CallAfter(self.loadFile)
61 self.Thaw() 54 self.Thaw()
62 self.orpgframe.Thaw() 55 self.orpgframe.Thaw()
63 self.Bind(wx.EVT_CLOSE, self.OnMB_FileExit) 56 self.Bind(wx.EVT_CLOSE, self.OnMB_FileExit)
64 self.log.log("Exit AliasLib", ORPG_DEBUG)
65 57
66 def InitSetup(self): 58 def InitSetup(self):
67 self.chat = open_rpg.get_component('chat') 59 self.chat = component.get('chat')
68 self.gametree = open_rpg.get_component('tree') 60 self.gametree = component.get('tree')
69 self.map = open_rpg.get_component('map') 61 self.map = component.get('map')
70 self.session = open_rpg.get_component('session') 62 self.session = component.get('session')
71 63
72 def buildMenu(self): 64 def buildMenu(self):
73 self.log.log("Enter AliasLib->buildMenu(self)", ORPG_DEBUG)
74 filemenu = wx.Menu() 65 filemenu = wx.Menu()
75 item = wx.MenuItem(filemenu, wx.ID_ANY, "&New\tCtrl+N", "New ALias Lib") 66 item = wx.MenuItem(filemenu, wx.ID_ANY, "&New\tCtrl+N", "New ALias Lib")
76 self.Bind(wx.EVT_MENU, self.OnMB_FileNew, item) 67 self.Bind(wx.EVT_MENU, self.OnMB_FileNew, item)
77 filemenu.AppendItem(item) 68 filemenu.AppendItem(item)
78 item = wx.MenuItem(filemenu, wx.ID_ANY, "&Open\tCtrl+O", "Open Alias Lib") 69 item = wx.MenuItem(filemenu, wx.ID_ANY, "&Open\tCtrl+O", "Open Alias Lib")
127 menu.Append(filemenu, "&File") 118 menu.Append(filemenu, "&File")
128 menu.Append(aliasmenu, "&Alias") 119 menu.Append(aliasmenu, "&Alias")
129 menu.Append(filtermenu, "&Filter") 120 menu.Append(filtermenu, "&Filter")
130 menu.Append(transmitmenu, "&Transmit") 121 menu.Append(transmitmenu, "&Transmit")
131 self.SetMenuBar(menu) 122 self.SetMenuBar(menu)
132 self.log.log("Exit AliasLib->buildMenu(self)", ORPG_DEBUG)
133 123
134 def OnMB_FileNew(self, event): 124 def OnMB_FileNew(self, event):
135 self.log.log("Enter AliasLib->OnMB_FileNew(self, event)", ORPG_DEBUG)
136 oldfilename = self.filename 125 oldfilename = self.filename
137 dlg = wx.TextEntryDialog(self, "Please Name This Alias Lib", "New Alias Lib") 126 dlg = wx.TextEntryDialog(self, "Please Name This Alias Lib", "New Alias Lib")
138 if dlg.ShowModal() == wx.ID_OK: 127 if dlg.ShowModal() == wx.ID_OK:
139 self.filename = dlg.GetValue() + '.alias' 128 self.filename = dlg.GetValue() + '.alias'
140 dlg.Destroy() 129 dlg.Destroy()
141 if oldfilename != self.filename: 130 if oldfilename != self.filename:
142 self.OnMB_FileSave(None, oldfilename) 131 self.OnMB_FileSave(None, oldfilename)
143 self.aliasList = [] 132 self.aliasList = []
144 self.filterList = [] 133 self.filterList = []
145 self.OnMB_FileSave(None) 134 self.OnMB_FileSave(None)
146 self.settings.set_setting('aliasfile', self.filename[:-6]) 135 settings.set_setting('aliasfile', self.filename[:-6])
147 self.log.log("Exit AliasLib->OnMB_FileNew(self, event)", ORPG_DEBUG)
148 136
149 def OnMB_FileOpen(self, event): 137 def OnMB_FileOpen(self, event):
150 self.log.log("Enter AliasLib->OnMB_FileOpen(self, event)", ORPG_DEBUG)
151 oldfilename = self.filename 138 oldfilename = self.filename
152 dlg = wx.FileDialog(self, "Select an Alias Lib to Open", self.dir_struct["user"], wildcard="*.alias", style=wx.HIDE_READONLY|wx.OPEN) 139 dlg = wx.FileDialog(self, "Select an Alias Lib to Open",
140 dir_struct["user"], wildcard="*.alias",
141 style=wx.HIDE_READONLY|wx.OPEN)
153 if dlg.ShowModal() == wx.ID_OK: 142 if dlg.ShowModal() == wx.ID_OK:
154 self.filename = dlg.GetFilename() 143 self.filename = dlg.GetFilename()
155 dlg.Destroy() 144 dlg.Destroy()
156 if oldfilename != self.filename: 145 if oldfilename != self.filename:
157 self.OnMB_FileSave(None, oldfilename) 146 self.OnMB_FileSave(None, oldfilename)
158 self.loadFile() 147 self.loadFile()
159 self.settings.set_setting('aliasfile', self.filename[:-6]) 148 settings.set_setting('aliasfile', self.filename[:-6])
160 self.log.log("Exit AliasLib->OnMB_FileOpen(self, event)", ORPG_DEBUG)
161 149
162 def OnMB_FileSave(self, event, file=None): 150 def OnMB_FileSave(self, event, file=None):
163 self.log.log("Enter AliasLib->OnMB_FileSave(self, event)", ORPG_DEBUG)
164 idx = self.aliasIdx 151 idx = self.aliasIdx
165 if file == None: 152 if file == None:
166 file = self.filename 153 file = self.filename
167 xml = "<aliaslib>\n" 154 xml = "<aliaslib>\n"
168 for n in xrange(self.selectAliasWnd.GetItemCount()): 155 for n in xrange(self.selectAliasWnd.GetItemCount()):
180 xml += 'sub="' + self.MakeHTMLSafe(rule[1]) + '" ' 167 xml += 'sub="' + self.MakeHTMLSafe(rule[1]) + '" '
181 xml += "/>\n" 168 xml += "/>\n"
182 xml += "\t</filter>\n" 169 xml += "\t</filter>\n"
183 xml += "</aliaslib>" 170 xml += "</aliaslib>"
184 self.alias = idx 171 self.alias = idx
185 f = open(self.dir_struct["user"] + file, "w") 172 f = open(dir_struct["user"] + file, "w")
186 f.write(xml) 173 f.write(xml)
187 f.close() 174 f.close()
188 self.log.log("Exit AliasLib->OnMB_FileSave(self, event)", ORPG_DEBUG)
189 175
190 def OnMB_FileExportToTree(self, event): 176 def OnMB_FileExportToTree(self, event):
191 self.log.log("Enter AliasLib->OnMB_FileExportToTree(self, event)", ORPG_DEBUG) 177 #tree = component.get("tree")
192 #tree = open_rpg.get_component("tree") 178 xml = '<nodehandler class="voxchat_handler" '
193 xml = '<nodehandler class="voxchat_handler" icon="player" module="voxchat" name="' + self.filename[:-6] + '" use.filter="0" version="1.0">' + "\n" 179 xml += 'icon="player" '
180 xml += 'module="voxchat" '
181 xml += 'name="' + self.filename[:-6] + '" '
182 xml += 'use.filter="0" '
183 xml += 'version="1.0">' + '\n'
194 idx = self.aliasIdx 184 idx = self.aliasIdx
195 for n in xrange(self.selectAliasWnd.GetItemCount()): 185 for n in xrange(self.selectAliasWnd.GetItemCount()):
196 self.alias = n 186 self.alias = n
197 xml += "\t<voxchat.alias " 187 xml += "\t<voxchat.alias "
198 xml += 'name="' + self.MakeHTMLSafe(self.alias[0]) + '" ' 188 xml += 'name="' + self.MakeHTMLSafe(self.alias[0]) + '" '
208 xml += 'sub="' + self.MakeHTMLSafe(rule[1]) + '" ' 198 xml += 'sub="' + self.MakeHTMLSafe(rule[1]) + '" '
209 xml += "/>\n" 199 xml += "/>\n"
210 xml += "\t</voxchat.filter>\n" 200 xml += "\t</voxchat.filter>\n"
211 xml += "</nodehandler>" 201 xml += "</nodehandler>"
212 self.gametree.insert_xml(xml) 202 self.gametree.insert_xml(xml)
213 self.log.log("Exit AliasLib->OnMB_FileExportToTree(self, event)", ORPG_DEBUG)
214 203
215 def OnMB_FileExit(self, event): 204 def OnMB_FileExit(self, event):
216 self.log.log("Enter AliasLib->OnMB_FileExit(self, event)", ORPG_DEBUG)
217 self.OnMB_FileSave(0) 205 self.OnMB_FileSave(0)
218 self.Hide() 206 self.Hide()
219 top_frame = open_rpg.get_component('frame') 207 self.orpgframe.mainmenu.Check(self.orpgframe.mainmenu.FindMenuItem("Windows", "Alias Lib"), False)
220 top_frame.mainmenu.Check(top_frame.mainmenu.FindMenuItem("Windows", "Alias Lib"), False)
221 self.log.log("Exit AliasLib->OnMB_FileExit(self, event)", ORPG_DEBUG)
222 208
223 def OnMB_AliasNew(self, event): 209 def OnMB_AliasNew(self, event):
224 self.log.log("Enter AliasLib->OnMB_AliasNew(self, event)", ORPG_DEBUG)
225 self.NewEditAliasDialog("New") 210 self.NewEditAliasDialog("New")
226 self.log.log("Exit AliasLib->OnMB_AliasNew(self, event)", ORPG_DEBUG)
227 211
228 def OnMB_AliasAddTemporary(self, event): 212 def OnMB_AliasAddTemporary(self, event):
229 self.log.log("Enter AliasLib->OnMB_AliasAddTemporary(self, event)", ORPG_DEBUG)
230 minis = self.map.canvas.layers['miniatures'].miniatures 213 minis = self.map.canvas.layers['miniatures'].miniatures
231 for min in minis: 214 for min in minis:
232 name = min.label 215 name = min.label
233 if name not in self.aliasList: 216 if name not in self.aliasList:
234 i = self.selectAliasWnd.InsertStringItem(self.selectAliasWnd.GetItemCount(), name) 217 i = self.selectAliasWnd.InsertStringItem(self.selectAliasWnd.GetItemCount(), name)
235 self.selectAliasWnd.SetStringItem(i, 1, "Default") 218 self.selectAliasWnd.SetStringItem(i, 1, "Default")
236 self.selectAliasWnd.RefreshItem(i) 219 self.selectAliasWnd.RefreshItem(i)
237 self.RefreshAliases() 220 self.RefreshAliases()
238 self.log.log("Exit AliasLib->OnMB_AliasAddTemporary(self, event)", ORPG_DEBUG)
239 221
240 def OnMB_AliasEdit(self, event): 222 def OnMB_AliasEdit(self, event):
241 self.log.log("Enter AliasLib->OnMB_AliasEdit(self, event)", ORPG_DEBUG)
242 if self.aliasIdx != -1: 223 if self.aliasIdx != -1:
243 self.NewEditAliasDialog("Edit") 224 self.NewEditAliasDialog("Edit")
244 self.log.log("Exit AliasLib->OnMB_AliasEdit(self, event)", ORPG_DEBUG)
245 225
246 def NewEditAliasDialog(self, type): 226 def NewEditAliasDialog(self, type):
247 self.log.log("Enter AliasLib->NewEditAliasDialog(self, type)", ORPG_DEBUG)
248 dlg = wx.Dialog(self, wx.ID_ANY, type + " Alias", style=wx.DEFAULT_DIALOG_STYLE|wx.STAY_ON_TOP) 227 dlg = wx.Dialog(self, wx.ID_ANY, type + " Alias", style=wx.DEFAULT_DIALOG_STYLE|wx.STAY_ON_TOP)
249 txt = wx.TextCtrl(dlg, wx.ID_ANY) 228 txt = wx.TextCtrl(dlg, wx.ID_ANY)
250 if type == 'Edit': 229 if type == 'Edit':
251 txt.SetValue(self.alias[0]) 230 txt.SetValue(self.alias[0])
252 self.colorbtn = wx.Button(dlg, wx.ID_ANY, "Default Color") 231 self.colorbtn = wx.Button(dlg, wx.ID_ANY, "Default Color")
277 else: 256 else:
278 self.selectAliasWnd.SetStringItem(i, 1, RGBHex().hexstring(r, g, b)) 257 self.selectAliasWnd.SetStringItem(i, 1, RGBHex().hexstring(r, g, b))
279 self.selectAliasWnd.SetItemTextColour(i, RGBHex().hexstring(r, g, b)) 258 self.selectAliasWnd.SetItemTextColour(i, RGBHex().hexstring(r, g, b))
280 self.selectAliasWnd.RefreshItem(i) 259 self.selectAliasWnd.RefreshItem(i)
281 self.RefreshAliases() 260 self.RefreshAliases()
282 self.log.log("Exit AliasLib->NewEditAliasDialog(self, type)", ORPG_DEBUG)
283 261
284 def ChangeAliasColor(self, event): 262 def ChangeAliasColor(self, event):
285 self.log.log("Enter AliasLib->ChangeAliasColor(self, event)", ORPG_DEBUG)
286 color = RGBHex().do_hex_color_dlg(self) 263 color = RGBHex().do_hex_color_dlg(self)
287 self.colorbtn.SetLabel("Chat Color") 264 self.colorbtn.SetLabel("Chat Color")
288 self.colorbtn.SetForegroundColour(color) 265 self.colorbtn.SetForegroundColour(color)
289 self.log.log("Exit AliasLib->ChangeAliasColor(self, event)", ORPG_DEBUG)
290 266
291 def OnMB_AliasDelete(self, event): 267 def OnMB_AliasDelete(self, event):
292 self.log.log("Enter AliasLib->OnMB_AliasDelete(self, event)", ORPG_DEBUG)
293 if self.aliasIdx != -1: 268 if self.aliasIdx != -1:
294 self.selectAliasWnd.DeleteItem(self.aliasIdx) 269 self.selectAliasWnd.DeleteItem(self.aliasIdx)
295 self.RefreshAliases() 270 self.RefreshAliases()
296 self.log.log("Exit AliasLib->OnMB_AliasDelete(self, event)", ORPG_DEBUG)
297 271
298 def OnMB_FilterNew(self, event): 272 def OnMB_FilterNew(self, event):
299 self.log.log("Enter AliasLib->OnMB_FilterNew(self, event)", ORPG_DEBUG)
300 dlg = wx.TextEntryDialog(self, 'Filter Name: ', 'Please name this filter') 273 dlg = wx.TextEntryDialog(self, 'Filter Name: ', 'Please name this filter')
301 if dlg.ShowModal() != wx.ID_OK: 274 if dlg.ShowModal() != wx.ID_OK:
302 dlg.Destroy() 275 dlg.Destroy()
303 return 276 return
304 filterName = dlg.GetValue() 277 filterName = dlg.GetValue()
305 i = self.selectFilterWnd.InsertStringItem(self.selectFilterWnd.GetItemCount(), filterName) 278 i = self.selectFilterWnd.InsertStringItem(self.selectFilterWnd.GetItemCount(), filterName)
306 self.filter = i 279 self.filter = i
307 self.regExList.append([]) 280 self.regExList.append([])
308 self.OnMB_FilterEdit(None) 281 self.OnMB_FilterEdit(None)
309 self.log.log("Exit AliasLib->OnMB_FilterNew(self, event)", ORPG_DEBUG)
310 282
311 def OnMB_FilterEdit(self, event): 283 def OnMB_FilterEdit(self, event):
312 self.log.log("Enter AliasLib->OnMB_FilterEdit(self, event)", ORPG_DEBUG)
313 wnd = FilterEditWnd(self, self.filter, self.filterRegEx) 284 wnd = FilterEditWnd(self, self.filter, self.filterRegEx)
314 wnd.MakeModal(True) 285 wnd.MakeModal(True)
315 wnd.Show() 286 wnd.Show()
316 self.log.log("Exit AliasLib->OnMB_FilterEdit(self, event)", ORPG_DEBUG)
317 287
318 def OnMB_FilterDelete(self, event): 288 def OnMB_FilterDelete(self, event):
319 self.log.log("Enter AliasLib->OnMB_FilterDelete(self, event)", ORPG_DEBUG)
320 if self.filterIdx != -1: 289 if self.filterIdx != -1:
321 self.selectFilterWnd.DeleteItem(self.filterIdx) 290 self.selectFilterWnd.DeleteItem(self.filterIdx)
322 self.log.log("Exit AliasLib->OnMB_FilterDelete(self, event)", ORPG_DEBUG)
323 291
324 def OnMB_TransmitSend(self, event): 292 def OnMB_TransmitSend(self, event):
325 self.log.log("Enter AliasLib->OnMB_TransmitSend(self, event)", ORPG_DEBUG)
326 self.orpgframe.Freeze() 293 self.orpgframe.Freeze()
327 if self.alias[1] != 'Default': 294 if self.alias[1] != 'Default':
328 defaultcolor = self.settings.get_setting("mytextcolor") 295 defaultcolor = settings.get_setting("mytextcolor")
329 self.settings.set_setting("mytextcolor", self.alias[1]) 296 settings.set_setting("mytextcolor", self.alias[1])
330 self.chat.set_colors() 297 self.chat.set_colors()
331 line = self.textWnd.GetValue().replace("\n", "<br />") 298 line = self.textWnd.GetValue().replace("\n", "<br />")
332 if self.checkFilterText.IsChecked() and self.filter != self.chat.defaultFilterName: 299 if self.checkFilterText.IsChecked() and self.filter != self.chat.defaultFilterName:
333 for rule in self.filterRegEx: 300 for rule in self.filterRegEx: line = re.sub(rule[0], rule[1], line)
334 line = re.sub(rule[0], rule[1], line)
335 if len(line) > 1: 301 if len(line) > 1:
336 if len(line) > 1 and line[0] != "/": 302 if len(line) > 1 and line[0] != "/": self.chat.ParsePost(line, True, True)
337 self.chat.ParsePost(line, True, True) 303 else: self.chat.chat_cmds.docmd(line)
338 else:
339 self.chat.chat_cmds.docmd(line)
340 if self.alias[1] != 'Default': 304 if self.alias[1] != 'Default':
341 self.settings.set_setting("mytextcolor", defaultcolor) 305 settings.set_setting("mytextcolor", defaultcolor)
342 self.chat.set_colors() 306 self.chat.set_colors()
343 if self.checkClearText.IsChecked(): 307 if self.checkClearText.IsChecked():
344 self.textWnd.SetValue("") 308 self.textWnd.SetValue("")
345 top_frame.Thaw() 309 self.orpgframe.Thaw()
346 self.log.log("Exit AliasLib->OnMB_TransmitSend(self, event)", ORPG_DEBUG)
347 310
348 def OnMB_TransmitEmote(self, event): 311 def OnMB_TransmitEmote(self, event):
349 self.log.log("Enter AliasLib->OnMB_TransmitEmote(self, event)", ORPG_DEBUG)
350 self.orpgframe.Freeze() 312 self.orpgframe.Freeze()
351 line = self.textWnd.GetValue().replace("\n", "<br />") 313 line = self.textWnd.GetValue().replace("\n", "<br />")
352 if self.checkFilterText.IsChecked() and self.filter != self.chat.defaultFilterName: 314 if self.checkFilterText.IsChecked() and self.filter != self.chat.defaultFilterName:
353 for rule in self.filterRegEx: 315 for rule in self.filterRegEx: line = re.sub(rule[0], rule[1], line)
354 line = re.sub(rule[0], rule[1], line)
355 self.chat.emote_message(line) 316 self.chat.emote_message(line)
356 if self.checkClearText.IsChecked(): 317 if self.checkClearText.IsChecked():
357 self.textWnd.SetValue("") 318 self.textWnd.SetValue("")
358 top_frame.Thaw() 319 self.orpgframe.Thaw()
359 self.log.log("Exit AliasLib->OnMB_TransmitEmote(self, event)", ORPG_DEBUG)
360 320
361 def OnMB_TransmitWhisper(self, event): 321 def OnMB_TransmitWhisper(self, event):
362 self.log.log("Enter AliasLib->OnMB_TransmitWhisper(self, event)", ORPG_DEBUG)
363 self.orpgframe.Freeze() 322 self.orpgframe.Freeze()
364 players = self.session.get_players() 323 players = self.session.get_players()
365 if self.alias[1] != 'Default': 324 if self.alias[1] != 'Default':
366 defaultcolor = self.settings.get_setting("mytextcolor") 325 defaultcolor = settings.get_setting("mytextcolor")
367 self.settings.set_setting("mytextcolor", self.alias[1]) 326 settings.set_setting("mytextcolor", self.alias[1])
368 self.chat.set_colors() 327 self.chat.set_colors()
369 opts = [] 328 opts = []
370 myid = session.get_id() 329 myid = self.session.get_id()
371 for p in players: 330 for p in players:
372 if p[2] != myid: 331 if p[2] != myid: opts.append("(" + p[2] + ") " + self.chat.html_strip(p[0]))
373 opts.append("(" + p[2] + ") " + self.chat.html_strip(p[0]))
374 dlg = orpgMultiCheckBoxDlg(self, opts, "Select Players:", "Whisper To", []) 332 dlg = orpgMultiCheckBoxDlg(self, opts, "Select Players:", "Whisper To", [])
375 sendto = [] 333 sendto = []
376 if dlg.ShowModal() == wx.ID_OK: 334 if dlg.ShowModal() == wx.ID_OK:
377 selections = dlg.get_selections() 335 selections = dlg.get_selections()
378 for s in selections: 336 for s in selections: sendto.append(players[s][2])
379 sendto.append(players[s][2])
380 line = self.textWnd.GetValue().replace("\n", "<br />") 337 line = self.textWnd.GetValue().replace("\n", "<br />")
381 if self.checkFilterText.IsChecked() and self.filter != self.chat.defaultFilterName: 338 if self.checkFilterText.IsChecked() and self.filter != self.chat.defaultFilterName:
382 for rule in self.filterRegEx: 339 for rule in self.filterRegEx: line = re.sub(rule[0], rule[1], line)
383 line = re.sub(rule[0], rule[1], line) 340 if len(sendto): self.chat.whisper_to_players(line, sendto)
384 if len(sendto):
385 self.chat.whisper_to_players(line, sendto)
386 if self.alias[1] != 'Default': 341 if self.alias[1] != 'Default':
387 self.settings.set_setting("mytextcolor", defaultcolor) 342 settings.set_setting("mytextcolor", defaultcolor)
388 self.chat.set_colors() 343 self.chat.set_colors()
389 if self.checkClearText.IsChecked(): 344 if self.checkClearText.IsChecked(): self.textWnd.SetValue("")
390 self.textWnd.SetValue("") 345 self.orpgframe.Thaw()
391 top_frame.Thaw()
392 self.log.log("Exit AliasLib->OnMB_TransmitWhisper(self, event)", ORPG_DEBUG)
393 346
394 def OnMB_TransmitMacro(self, event): 347 def OnMB_TransmitMacro(self, event):
395 self.log.log("Enter AliasLib->OnMB_TransmitMacro(self, event)", ORPG_DEBUG)
396 self.orpgframe.Freeze() 348 self.orpgframe.Freeze()
397 if self.alias[1] != 'Default': 349 if self.alias[1] != 'Default':
398 defaultcolor = self.settings.get_setting("mytextcolor") 350 defaultcolor = settings.get_setting("mytextcolor")
399 self.settings.set_setting("mytextcolor", self.alias[1]) 351 settings.set_setting("mytextcolor", self.alias[1])
400 self.chat.set_colors() 352 self.chat.set_colors()
401 lines = self.textWnd.GetValue().split("\n") 353 lines = self.textWnd.GetValue().split("\n")
402 if self.checkFilterText.IsChecked() and self.filter != self.chat.defaultFilterName: 354 if self.checkFilterText.IsChecked() and self.filter != self.chat.defaultFilterName:
355 line = self.textWnd.GetValue().replace("\n", "<br />")
403 for rule in self.filterRegEx: 356 for rule in self.filterRegEx:
404 line = re.sub(rule[0], rule[1], line) 357 line = re.sub(rule[0], rule[1], line)
405 for line in lines: 358 for line in lines:
406 if len(line) > 1: 359 if len(line) > 1:
407 if line[0] != "/": 360 if line[0] != "/": self.chat.ParsePost(line, True, True)
408 self.chat.ParsePost(line, True, True) 361 else: self.chat.chat_cmds.docmd(line)
409 else:
410 self.chat.chat_cmds.docmd(line)
411 if self.alias[1] != 'Default': 362 if self.alias[1] != 'Default':
412 self.settings.set_setting("mytextcolor", defaultcolor) 363 settings.set_setting("mytextcolor", defaultcolor)
413 self.chat.set_colors() 364 self.chat.set_colors()
414 if self.checkClearText.IsChecked(): 365 if self.checkClearText.IsChecked(): self.textWnd.SetValue("")
415 self.textWnd.SetValue("") 366 self.orpgframe.Thaw()
416 top_frame.Thaw()
417 self.log.log("Exit AliasLib->OnMB_TransmitMacro(self, event)", ORPG_DEBUG)
418 367
419 def buildButtons(self): 368 def buildButtons(self):
420 self.log.log("Enter AliasLib->buildButtons(self)", ORPG_DEBUG)
421 self.topBtnSizer = wx.BoxSizer(wx.HORIZONTAL) 369 self.topBtnSizer = wx.BoxSizer(wx.HORIZONTAL)
422 self.middleBtnSizer = wx.BoxSizer(wx.HORIZONTAL) 370 self.middleBtnSizer = wx.BoxSizer(wx.HORIZONTAL)
423 self.bottomBtnSizer = wx.BoxSizer(wx.HORIZONTAL) 371 self.bottomBtnSizer = wx.BoxSizer(wx.HORIZONTAL)
424 self.addFromMapBtn = createMaskedButton(self, self.dir_struct["icon"] + 'install.gif', 'Add temporary aliases from map', wx.ID_ANY, "#C0C0C0") 372 self.addFromMapBtn = createMaskedButton(self, dir_struct["icon"] + 'install.gif',
425 self.newAliasBtn = createMaskedButton(self, self.dir_struct["icon"] + 'player.gif', 'Add a new Alias', wx.ID_ANY) 373 'Add temporary aliases from map', wx.ID_ANY, "#C0C0C0")
426 self.delAliasBtn = createMaskedButton(self, self.dir_struct["icon"] + 'noplayer.gif', 'Delete selected Alias', wx.ID_ANY) 374 self.newAliasBtn = createMaskedButton(self, dir_struct["icon"] + 'player.gif', 'Add a new Alias', wx.ID_ANY)
427 self.editAliasBtn = createMaskedButton(self, self.dir_struct["icon"] + 'note.gif', 'Edit selected Alias', wx.ID_ANY) 375 self.delAliasBtn = createMaskedButton(self, dir_struct["icon"] + 'noplayer.gif', 'Delete selected Alias', wx.ID_ANY)
376 self.editAliasBtn = createMaskedButton(self, dir_struct["icon"] + 'note.gif', 'Edit selected Alias', wx.ID_ANY)
428 self.Bind(wx.EVT_BUTTON, self.OnMB_AliasNew, self.newAliasBtn) 377 self.Bind(wx.EVT_BUTTON, self.OnMB_AliasNew, self.newAliasBtn)
429 self.Bind(wx.EVT_BUTTON, self.OnMB_AliasAddTemporary, self.addFromMapBtn) 378 self.Bind(wx.EVT_BUTTON, self.OnMB_AliasAddTemporary, self.addFromMapBtn)
430 self.Bind(wx.EVT_BUTTON, self.OnMB_AliasEdit, self.editAliasBtn) 379 self.Bind(wx.EVT_BUTTON, self.OnMB_AliasEdit, self.editAliasBtn)
431 self.Bind(wx.EVT_BUTTON, self.OnMB_AliasDelete, self.delAliasBtn) 380 self.Bind(wx.EVT_BUTTON, self.OnMB_AliasDelete, self.delAliasBtn)
432 self.newFilterBtn = createMaskedButton(self, self.dir_struct["icon"] + 'add_filter.gif', 'Add a new Filter', wx.ID_ANY, "#0000FF") 381 self.newFilterBtn = createMaskedButton(self, dir_struct["icon"] + 'add_filter.gif',
433 self.editFilterBtn = createMaskedButton(self, self.dir_struct["icon"] + 'edit_filter.gif', 'Edit selected Filter', wx.ID_ANY, "#FF0000") 382 'Add a new Filter', wx.ID_ANY, "#0000FF")
434 self.delFilterBtn = createMaskedButton(self, self.dir_struct["icon"] + 'delete_filter.gif', 'Delete selected Filter', wx.ID_ANY, "#0000FF") 383 self.editFilterBtn = createMaskedButton(self, dir_struct["icon"] + 'edit_filter.gif',
384 'Edit selected Filter', wx.ID_ANY, "#FF0000")
385 self.delFilterBtn = createMaskedButton(self, dir_struct["icon"] + 'delete_filter.gif',
386 'Delete selected Filter', wx.ID_ANY, "#0000FF")
435 self.Bind(wx.EVT_BUTTON, self.OnMB_FilterNew, self.newFilterBtn) 387 self.Bind(wx.EVT_BUTTON, self.OnMB_FilterNew, self.newFilterBtn)
436 self.Bind(wx.EVT_BUTTON, self.OnMB_FilterEdit, self.editFilterBtn) 388 self.Bind(wx.EVT_BUTTON, self.OnMB_FilterEdit, self.editFilterBtn)
437 self.Bind(wx.EVT_BUTTON, self.OnMB_FilterDelete, self.delFilterBtn) 389 self.Bind(wx.EVT_BUTTON, self.OnMB_FilterDelete, self.delFilterBtn)
438 self.textBoldBtn = createMaskedButton(self, self.dir_struct["icon"] + 'bold.gif', 'Bold', wx.ID_ANY, "#BDBDBD") 390 self.textBoldBtn = createMaskedButton(self, dir_struct["icon"] + 'bold.gif', 'Bold', wx.ID_ANY, "#BDBDBD")
439 self.textItalicBtn = createMaskedButton(self, self.dir_struct["icon"] + 'italic.gif', 'Italic', wx.ID_ANY, "#BDBDBD") 391 self.textItalicBtn = createMaskedButton(self, dir_struct["icon"] + 'italic.gif', 'Italic', wx.ID_ANY, "#BDBDBD")
440 self.textUnderlineBtn = createMaskedButton(self, self.dir_struct["icon"] + 'underlined.gif', 'Underline', wx.ID_ANY, "#BDBDBD") 392 self.textUnderlineBtn = createMaskedButton(self, dir_struct["icon"] + 'underlined.gif',
393 'Underline', wx.ID_ANY, "#BDBDBD")
441 self.textColorBtn = wx.Button(self, wx.ID_ANY, "Color") 394 self.textColorBtn = wx.Button(self, wx.ID_ANY, "Color")
442 self.textColorBtn.SetForegroundColour(wx.BLACK) 395 self.textColorBtn.SetForegroundColour(wx.BLACK)
443 self.exportBtn = createMaskedButton(self, self.dir_struct["icon"] + 'grid.gif', 'Export to Tree', wx.ID_ANY) 396 self.exportBtn = createMaskedButton(self, dir_struct["icon"] + 'grid.gif', 'Export to Tree', wx.ID_ANY)
444 self.Bind(wx.EVT_BUTTON, self.FormatText, self.textBoldBtn) 397 self.Bind(wx.EVT_BUTTON, self.FormatText, self.textBoldBtn)
445 self.Bind(wx.EVT_BUTTON, self.FormatText, self.textItalicBtn) 398 self.Bind(wx.EVT_BUTTON, self.FormatText, self.textItalicBtn)
446 self.Bind(wx.EVT_BUTTON, self.FormatText, self.textUnderlineBtn) 399 self.Bind(wx.EVT_BUTTON, self.FormatText, self.textUnderlineBtn)
447 self.Bind(wx.EVT_BUTTON, self.FormatText, self.textColorBtn) 400 self.Bind(wx.EVT_BUTTON, self.FormatText, self.textColorBtn)
448 self.Bind(wx.EVT_BUTTON, self.OnMB_FileExportToTree, self.exportBtn) 401 self.Bind(wx.EVT_BUTTON, self.OnMB_FileExportToTree, self.exportBtn)
476 self.bottomBtnSizer.Add(self.sayBtn, 0, wx.EXPAND) 429 self.bottomBtnSizer.Add(self.sayBtn, 0, wx.EXPAND)
477 self.bottomBtnSizer.Add(self.emoteBtn, 0, wx.EXPAND) 430 self.bottomBtnSizer.Add(self.emoteBtn, 0, wx.EXPAND)
478 self.bottomBtnSizer.Add(self.whisperBtn, 0, wx.EXPAND) 431 self.bottomBtnSizer.Add(self.whisperBtn, 0, wx.EXPAND)
479 self.bottomBtnSizer.Add(self.macroBtn, 0, wx.EXPAND) 432 self.bottomBtnSizer.Add(self.macroBtn, 0, wx.EXPAND)
480 self.bottomBtnSizer.Add(self.doneBtn, 0, wx.EXPAND|wx.ALIGN_RIGHT) 433 self.bottomBtnSizer.Add(self.doneBtn, 0, wx.EXPAND|wx.ALIGN_RIGHT)
481 self.log.log("Exit AliasLib->buildButtons(self)", ORPG_DEBUG)
482 434
483 def buildGUI(self): 435 def buildGUI(self):
484 self.log.log("Enter AliasLib->buildGUI(self)", ORPG_DEBUG)
485 self.sizer = wx.BoxSizer(wx.VERTICAL) 436 self.sizer = wx.BoxSizer(wx.VERTICAL)
486 rightwnd = wx.SplitterWindow(self, wx.ID_ANY, style=wx.SP_LIVE_UPDATE|wx.SP_NO_XP_THEME|wx.SP_3DSASH) 437 rightwnd = wx.SplitterWindow(self, wx.ID_ANY, style=wx.SP_LIVE_UPDATE|wx.SP_NO_XP_THEME|wx.SP_3DSASH)
487 leftwnd = wx.SplitterWindow(rightwnd, wx.ID_ANY, style=wx.SP_LIVE_UPDATE|wx.SP_NO_XP_THEME|wx.SP_3DSASH) 438 leftwnd = wx.SplitterWindow(rightwnd, wx.ID_ANY, style=wx.SP_LIVE_UPDATE|wx.SP_NO_XP_THEME|wx.SP_3DSASH)
488 self.selectAliasWnd = wx.ListCtrl(leftwnd, wx.ID_ANY, style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES) 439 self.selectAliasWnd = wx.ListCtrl(leftwnd, wx.ID_ANY, style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES)
489 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.NewAliasSelection, self.selectAliasWnd) 440 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.NewAliasSelection, self.selectAliasWnd)
493 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.NewFilterSelection, self.selectFilterWnd) 444 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.NewFilterSelection, self.selectFilterWnd)
494 self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.NoFilterSelection, self.selectFilterWnd) 445 self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.NoFilterSelection, self.selectFilterWnd)
495 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnMB_FilterEdit, self.selectFilterWnd) 446 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnMB_FilterEdit, self.selectFilterWnd)
496 self.textWnd = wx.TextCtrl(rightwnd, wx.ID_ANY, style=wx.TE_MULTILINE|wx.TE_BESTWRAP) 447 self.textWnd = wx.TextCtrl(rightwnd, wx.ID_ANY, style=wx.TE_MULTILINE|wx.TE_BESTWRAP)
497 leftwnd.SplitHorizontally(self.selectAliasWnd, self.selectFilterWnd) 448 leftwnd.SplitHorizontally(self.selectAliasWnd, self.selectFilterWnd)
449 leftwnd.SetMinimumPaneSize(75)
498 rightwnd.SplitVertically(leftwnd, self.textWnd) 450 rightwnd.SplitVertically(leftwnd, self.textWnd)
451 rightwnd.SetMinimumPaneSize(200)
499 self.sizer.Add(self.topBtnSizer, 0, wx.EXPAND) 452 self.sizer.Add(self.topBtnSizer, 0, wx.EXPAND)
500 self.sizer.Add(rightwnd, 1, wx.EXPAND) 453 self.sizer.Add(rightwnd, 1, wx.EXPAND)
501 self.sizer.Add(self.middleBtnSizer, 0, wx.EXPAND) 454 self.sizer.Add(self.middleBtnSizer, 0, wx.EXPAND)
502 self.sizer.Add(self.bottomBtnSizer, 0, wx.EXPAND) 455 self.sizer.Add(self.bottomBtnSizer, 0, wx.EXPAND)
503 self.SetSizer(self.sizer) 456 self.SetSizer(self.sizer)
504 self.SetAutoLayout(True) 457 self.SetAutoLayout(True)
505 self.Fit() 458 self.Fit()
506 self.log.log("Exit AliasLib->buildGUI(self)", ORPG_DEBUG)
507 459
508 def loadFile(self): 460 def loadFile(self):
509 self.log.log("Enter AliasLib->loadFile(self)", ORPG_DEBUG) 461 f = open(dir_struct["user"] + self.filename, "r")
510 f = open(self.dir_struct["user"] + self.filename, "r")
511 data = f.read() 462 data = f.read()
512 f.close() 463 f.close()
513 self.alias = -1 464 self.alias = -1
514 self.filter = -1 465 self.filter = -1
515 xml_dom = self.xml.parseXml(data) 466 xml_dom = component.get('xml').parseXml(data)
516 del data 467 del data
517 aliases = xml_dom.getElementsByTagName("alias") 468 aliases = xml_dom.getElementsByTagName("alias")
518 alist = [] 469 alist = []
519 for alias in aliases: 470 for alias in aliases:
520 if alias.hasAttribute("color"): 471 if alias.hasAttribute("color"): color = alias.getAttribute("color")
521 color = alias.getAttribute("color") 472 else: color = 'Default'
522 else:
523 color = 'Default'
524 aname = self.MakeSafeHTML(alias.getAttribute("name")) 473 aname = self.MakeSafeHTML(alias.getAttribute("name"))
525 alist.append([aname, color]) 474 alist.append([aname, color])
526 alist.sort() 475 alist.sort()
527 self.aliasList = alist 476 self.aliasList = alist
528 filters = xml_dom.getElementsByTagName("filter") 477 filters = xml_dom.getElementsByTagName("filter")
530 self.regExList = [] 479 self.regExList = []
531 for filter in filters: 480 for filter in filters:
532 flist.append(filter.getAttribute("name")) 481 flist.append(filter.getAttribute("name"))
533 rules = filter.getElementsByTagName("rule") 482 rules = filter.getElementsByTagName("rule")
534 sub = [] 483 sub = []
535 for rule in rules: 484 for rule in rules: sub.append([self.MakeSafeHTML(rule.getAttribute("match")),
536 sub.append([self.MakeSafeHTML(rule.getAttribute("match")), self.MakeSafeHTML(rule.getAttribute("sub"))]) 485 self.MakeSafeHTML(rule.getAttribute("sub"))])
537 self.regExList.append(sub) 486 self.regExList.append(sub)
538 self.filterList = flist 487 self.filterList = flist
539 xml_dom.unlink() 488 xml_dom.unlink()
540 self.alias = -1 489 self.alias = -1
541 self.filter = -1 490 self.filter = -1
542 self.log.log("Exit AliasLib->loadFile(self)", ORPG_DEBUG)
543 491
544 def MakeSafeHTML(self, str): 492 def MakeSafeHTML(self, str):
545 return str.replace("&amp;", "&").replace("&lt;", "<").replace("&quot;", '"').replace("&gt;", ">").replace("&#39;", "'") 493 return str.replace("&amp;", "&").replace("&lt;", "<").replace("&quot;", '"').replace("&gt;", ">").replace("&#39;", "'")
546 def MakeHTMLSafe(self, str): 494 def MakeHTMLSafe(self, str):
547 return str.replace("&", "&amp;").replace("<", "&lt;").replace('"', "&quot;").replace(">", "&gt;").replace("'", "&#39;") 495 return str.replace("&", "&amp;").replace("<", "&lt;").replace('"', "&quot;").replace(">", "&gt;").replace("'", "&#39;")
548 def ImportFromTree(self, xml_dom): 496 def ImportFromTree(self, xml_dom):
549 self.log.log("Enter AliasLib->ImportFromTree(self, xml_dom)", ORPG_DEBUG)
550 oldfilename = self.filename 497 oldfilename = self.filename
551 if xml_dom.getAttribute('name') == 'Alias Library': 498 if xml_dom.getAttribute('name') == 'Alias Library':
552 dlg = wx.TextEntryDialog(self, "Please Name This Alias Lib", "New Alias Lib") 499 dlg = wx.TextEntryDialog(self, "Please Name This Alias Lib", "New Alias Lib")
553 if dlg.ShowModal() == wx.ID_OK: 500 if dlg.ShowModal() == wx.ID_OK:
554 self.filename = dlg.GetValue() + '.alias' 501 self.filename = dlg.GetValue() + '.alias'
555 dlg.Destroy() 502 dlg.Destroy()
556 else: 503 else:
557 dlg.Destroy() 504 dlg.Destroy()
558 return 505 return
559 else: 506 else: self.filename = xml_dom.getAttribute('name') + '.alias'
560 self.filename = xml_dom.getAttribute('name') + '.alias' 507 settings.set_setting('aliasfile', self.filename[:-6])
561 self.settings.set_setting('aliasfile', self.filename[:-6]) 508 if oldfilename != self.filename: self.OnMB_FileSave(None, oldfilename)
562 if oldfilename != self.filename: 509 f = open(dir_struct["user"] + self.filename, "w")
563 self.OnMB_FileSave(None, oldfilename)
564 f = open(self.dir_struct["user"] + self.filename, "w")
565 f.write(xml_dom.toxml().replace('nodehandler', 'aliaslib').replace('voxchat.', '')) 510 f.write(xml_dom.toxml().replace('nodehandler', 'aliaslib').replace('voxchat.', ''))
566 f.close() 511 f.close()
567 wx.CallAfter(self.loadFile) 512 wx.CallAfter(self.loadFile)
568 self.log.log("Exit AliasLib->ImportFromTree(self, xml_dom)", ORPG_DEBUG)
569 513
570 def NewAliasSelection(self, event): 514 def NewAliasSelection(self, event):
571 self.log.log("Enter AliasLib->NewAliasSelection(self, event)", ORPG_DEBUG)
572 self.alias = event.GetIndex() 515 self.alias = event.GetIndex()
573 wx.CallAfter(self.chat.aliasList.SetStringSelection, self.alias[0]) 516 wx.CallAfter(self.chat.aliasList.SetStringSelection, self.alias[0])
574 self.log.log("Exit AliasLib->NewAliasSelection(self, event)", ORPG_DEBUG)
575 517
576 def NoAliasSelection(self, event): 518 def NoAliasSelection(self, event):
577 self.log.log("Enter AliasLib->NoAliasSelection(self, event)", ORPG_DEBUG)
578 self.aliasIdx = -1 519 self.aliasIdx = -1
579 wx.CallAfter(self.chat.aliasList.SetStringSelection, self.alias[0]) 520 wx.CallAfter(self.chat.aliasList.SetStringSelection, self.alias[0])
580 self.log.log("Exit AliasLib->NoAliasSelection(self, event)", ORPG_DEBUG)
581 521
582 def GetSelectedAlias(self): 522 def GetSelectedAlias(self):
583 self.log.log("Enter AliasLib->GetSelectedAlias(self)", ORPG_DEBUG)
584 self.InitSetup() 523 self.InitSetup()
585 if self.aliasIdx != -1: 524 if self.aliasIdx != -1:
586 self.log.log("Exit AliasLib->GetSelectedAlias(self) return " + str(self.aliasIdx), ORPG_DEBUG) 525 return [self.selectAliasWnd.GetItem(self.aliasIdx, 0).GetText(),
587 return [self.selectAliasWnd.GetItem(self.aliasIdx, 0).GetText(), self.selectAliasWnd.GetItem(self.aliasIdx, 1).GetText()] 526 self.selectAliasWnd.GetItem(self.aliasIdx, 1).GetText()]
588 self.log.log("Exit AliasLib->GetSelectedAlias(self) return " + str(self.aliasIdx), ORPG_DEBUG)
589 return [self.chat.defaultAliasName, "Default"] 527 return [self.chat.defaultAliasName, "Default"]
590 528
591 def SetSelectedAlias(self, alias): 529 def SetSelectedAlias(self, alias):
592 self.log.log("Enter AliasLib->SetSelectedAlias(self, aliasIdx)", ORPG_DEBUG)
593 found = False 530 found = False
594 if isinstance(alias, (int, long)): 531 if isinstance(alias, (int, long)):
595 self.aliasIdx = alias 532 self.aliasIdx = alias
596 found = True 533 found = True
597 else: 534 else:
599 if self.selectAliasWnd.GetItem(n, 0).GetText() == alias: 536 if self.selectAliasWnd.GetItem(n, 0).GetText() == alias:
600 self.aliasIdx = n 537 self.aliasIdx = n
601 found = True 538 found = True
602 if not found: 539 if not found:
603 self.aliasIdx = -1 540 self.aliasIdx = -1
604 self.log.log("Exit AliasLib->SetSelectedAlias(self, aliasIdx)", ORPG_DEBUG)
605 541
606 def GetAliasList(self): 542 def GetAliasList(self):
607 self.log.log("Enter AliasLib->GetAliasList(self)", ORPG_DEBUG)
608 alist = [] 543 alist = []
609 for n in xrange(0, self.selectAliasWnd.GetItemCount()): 544 for n in xrange(0, self.selectAliasWnd.GetItemCount()):
610 self.alias = n 545 self.alias = n
611 alist.append(self.alias[0]) 546 alist.append(self.alias[0])
612 self.log.log("Exit AliasLib->GetAliasList(self)", ORPG_DEBUG)
613 alist.sort() 547 alist.sort()
614 alist.insert(0, self.chat.defaultAliasName) 548 alist.insert(0, self.chat.defaultAliasName)
615 return alist 549 return alist
616 550
617 def SetAliasList(self, alist): 551 def SetAliasList(self, alist):
618 self.log.log("Enter AliasLib->SetAliasList(self, list)", ORPG_DEBUG)
619 self.selectAliasWnd.ClearAll() 552 self.selectAliasWnd.ClearAll()
620 self.selectAliasWnd.InsertColumn(0, "Alias") 553 self.selectAliasWnd.InsertColumn(0, "Alias")
621 self.selectAliasWnd.InsertColumn(1, "Chat Color") 554 self.selectAliasWnd.InsertColumn(1, "Chat Color")
622 for item in alist: 555 for item in alist:
623 i = self.selectAliasWnd.InsertStringItem(self.selectAliasWnd.GetItemCount(), item[0]) 556 i = self.selectAliasWnd.InsertStringItem(self.selectAliasWnd.GetItemCount(), item[0])
624 self.selectAliasWnd.SetStringItem(i, 1, item[1]) 557 self.selectAliasWnd.SetStringItem(i, 1, item[1])
625 if item[1] != 'Default': 558 if item[1] != 'Default': self.selectAliasWnd.SetItemTextColour(i, item[1])
626 self.selectAliasWnd.SetItemTextColour(i, item[1])
627 self.selectAliasWnd.RefreshItem(i) 559 self.selectAliasWnd.RefreshItem(i)
628 self.aliasIdx = -1 560 self.aliasIdx = -1
629 self.RefreshAliases() 561 self.RefreshAliases()
630 self.log.log("Exit AliasLib->SetAliasList(self, list)", ORPG_DEBUG)
631 562
632 def GetAliasColor(self): 563 def GetAliasColor(self):
633 self.log.log("Enter/Exit AliasLib->GetAliasColor(self) return " + self.alias[1], ORPG_DEBUG)
634 return self.alias[1] 564 return self.alias[1]
635 565
636 def RefreshAliases(self): 566 def RefreshAliases(self):
637 self.orpgframe.Freeze() 567 self.orpgframe.Freeze()
638 self.Freeze() 568 self.Freeze()
641 l2 = len(self.filterList) 571 l2 = len(self.filterList)
642 if self.chat != None: 572 if self.chat != None:
643 tmp = self.chat.aliasList.GetStringSelection() 573 tmp = self.chat.aliasList.GetStringSelection()
644 self.alias = tmp 574 self.alias = tmp
645 aidx = self.aliasIdx+1 575 aidx = self.aliasIdx+1
646 if len(self.aliasList) <= aidx: 576 if len(self.aliasList) <= aidx: aidx = 0
647 aidx = 0
648 self.chat.aliasList.Clear() 577 self.chat.aliasList.Clear()
649 for n in xrange(l1): 578 for n in xrange(l1): self.chat.aliasList.Insert(self.aliasList[n], n)
650 self.chat.aliasList.Insert(self.aliasList[n], n)
651 self.chat.aliasList.SetStringSelection(self.aliasList[aidx]) 579 self.chat.aliasList.SetStringSelection(self.aliasList[aidx])
652 fidx = self.chat.filterList.GetSelection() 580 fidx = self.chat.filterList.GetSelection()
653 if len(self.filterList) <= fidx: 581 if len(self.filterList) <= fidx: fidx = 0
654 fidx = 0
655 self.chat.filterList.Clear() 582 self.chat.filterList.Clear()
656 for n in xrange(l2): 583 for n in xrange(l2):
657 self.chat.filterList.Insert(self.filterList[n], n) 584 self.chat.filterList.Insert(self.filterList[n], n)
658 self.chat.filterList.SetStringSelection(self.filterList[fidx]) 585 self.chat.filterList.SetStringSelection(self.filterList[fidx])
659 if self.chat.parent.GMChatPanel != None: 586 if self.chat.parent.GMChatPanel != None:
660 aidx = self.chat.parent.GMChatPanel.aliasList.GetSelection() 587 aidx = self.chat.parent.GMChatPanel.aliasList.GetSelection()
661 if len(self.aliasList) <- aidx: 588 if len(self.aliasList) <- aidx: aidx = 0
662 aidx = 0
663 self.chat.parent.GMChatPanel.aliasList.Clear() 589 self.chat.parent.GMChatPanel.aliasList.Clear()
664 for n in xrange(l1): 590 for n in xrange(l1):
665 self.chat.parent.GMChatPanel.aliasList.Insert(self.aliasList[n], n) 591 self.chat.parent.GMChatPanel.aliasList.Insert(self.aliasList[n], n)
666 self.chat.parent.GMChatPanel.aliasList.SetStringSelection(self.aliasList[aidx]) 592 self.chat.parent.GMChatPanel.aliasList.SetStringSelection(self.aliasList[aidx])
667 fidx = self.chat.parent.GMChatPanel.filterList.GetSelection() 593 fidx = self.chat.parent.GMChatPanel.filterList.GetSelection()
697 tab.filterList.Insert(self.filterList[n], n) 623 tab.filterList.Insert(self.filterList[n], n)
698 tab.filterList.SetStringSelection(self.filterList[fidx]) 624 tab.filterList.SetStringSelection(self.filterList[fidx])
699 625
700 for tab in self.chat.parent.null_tabs: 626 for tab in self.chat.parent.null_tabs:
701 aidx = tab.aliasList.GetSelection() 627 aidx = tab.aliasList.GetSelection()
702 if len(self.aliasList) <= aidx: 628 if len(self.aliasList) <= aidx: aidx = 0
703 aidx = 0
704 tab.aliasList.Clear() 629 tab.aliasList.Clear()
705 for n in xrange(l1): 630 for n in xrange(l1):
706 tab.aliasList.Insert(self.aliasList[n], n) 631 tab.aliasList.Insert(self.aliasList[n], n)
707 tab.aliasList.SetStringSelection(self.aliasList[aidx]) 632 tab.aliasList.SetStringSelection(self.aliasList[aidx])
708 fidx = tab.filterList.GetSelection() 633 fidx = tab.filterList.GetSelection()
712 tab.filterList.SetStringSelection(self.filterList[fidx]) 637 tab.filterList.SetStringSelection(self.filterList[fidx])
713 self.Thaw() 638 self.Thaw()
714 wx.CallAfter(self.orpgframe.Thaw) 639 wx.CallAfter(self.orpgframe.Thaw)
715 640
716 def SetAliasColor(self, color): 641 def SetAliasColor(self, color):
717 self.log.log("Enter AliasLib->SetAliasColor(self, color)", ORPG_DEBUG)
718 if self.aliasIdx != -1: 642 if self.aliasIdx != -1:
719 self.selectAliasWnd.SetStringItem(self.aliasIdx, 1, color) 643 self.selectAliasWnd.SetStringItem(self.aliasIdx, 1, color)
720 self.selectAliasWnd.SetItemTextColour(self.aliasIdx, color) 644 self.selectAliasWnd.SetItemTextColour(self.aliasIdx, color)
721 self.log.log("Exit AliasLib->SetAliasColor(self, color)", ORPG_DEBUG)
722 645
723 def FilterTextChecked(self, event): 646 def FilterTextChecked(self, event):
724 if self.checkFilterText.IsChecked(): 647 if self.checkFilterText.IsChecked():
725 self.chat.filterList.SetStringSelection(self.filter) 648 self.chat.filterList.SetStringSelection(self.filter)
726 else: 649 else: self.chat.filterList.SetStringSelection(self.chat.defaultFilterName)
727 self.chat.filterList.SetStringSelection(self.chat.defaultFilterName)
728 650
729 def NewFilterSelection(self, event): 651 def NewFilterSelection(self, event):
730 self.log.log("Enter AliasLib->NewFilterSelection(self, event)", ORPG_DEBUG)
731 self.filter = event.GetIndex() 652 self.filter = event.GetIndex()
732 if self.checkFilterText.IsChecked(): 653 if self.checkFilterText.IsChecked(): wx.CallAfter(self.chat.filterList.SetStringSelection, self.filter)
733 wx.CallAfter(self.chat.filterList.SetStringSelection, self.filter)
734 self.log.log("Exit AliasLib->NewFilterSelection(self, event)", ORPG_DEBUG)
735 654
736 def NoFilterSelection(self, event): 655 def NoFilterSelection(self, event):
737 self.log.log("Enter AliasLib->NoFilterSelection(self, event)", ORPG_DEBUG)
738 self.filter = -1 656 self.filter = -1
739 wx.CallAfter(self.chat.filterList.SetStringSelection, self.filter) 657 wx.CallAfter(self.chat.filterList.SetStringSelection, self.filter)
740 self.log.log("Exit AliasLib->NoFilterSelection(self, event)", ORPG_DEBUG)
741 658
742 def GetSelectedFilter(self): 659 def GetSelectedFilter(self):
743 self.log.log("Enter AliasLib->GetSelectedFilter(self)", ORPG_DEBUG) 660 if self.filterIdx != -1: return self.selectFilterWnd.GetItem(self.filterIdx, 0).GetText()
744 if self.filterIdx != -1:
745 self.log.log("Exit AliasLib->GetSelectedFilter(self) return " + str(self.filterIdx), ORPG_DEBUG)
746 return self.selectFilterWnd.GetItem(self.filterIdx, 0).GetText()
747 self.log.log("Exit AliasLib->GetSelectedFilter(self) return " + str(self.filterIdx), ORPG_DEBUG)
748 return self.chat.defaultFilterName 661 return self.chat.defaultFilterName
749 662
750 def SetSelectedFilter(self, idx): 663 def SetSelectedFilter(self, idx):
751 self.log.log("Enter AliasLib->SetSelectedFilter(self, filter)", ORPG_DEBUG)
752 self.filterIdx = idx 664 self.filterIdx = idx
753 self.log.log("Exit AliasLib->SetSelectedFilter(self, filter)", ORPG_DEBUG)
754 665
755 def GetFilterList(self): 666 def GetFilterList(self):
756 self.log.log("Enter AliasLib->GetFilterList(self)", ORPG_DEBUG)
757 list = [] 667 list = []
758 for n in xrange(-1, self.selectFilterWnd.GetItemCount()): 668 for n in xrange(-1, self.selectFilterWnd.GetItemCount()):
759 self.filter = n 669 self.filter = n
760 list.append(self.filter) 670 list.append(self.filter)
761 self.log.log("Exit AliasLib->GetFilterList(self)", ORPG_DEBUG)
762 return list 671 return list
763 672
764 def SetFilterList(self, list): 673 def SetFilterList(self, list):
765 self.log.log("Enter AliasLib->SetFilterList(self, list)", ORPG_DEBUG)
766 self.selectFilterWnd.ClearAll() 674 self.selectFilterWnd.ClearAll()
767 self.selectFilterWnd.InsertColumn(0, "Filter Name") 675 self.selectFilterWnd.InsertColumn(0, "Filter Name")
768 for item in list: 676 for item in list:
769 i = self.selectFilterWnd.InsertStringItem(self.selectFilterWnd.GetItemCount(), item) 677 i = self.selectFilterWnd.InsertStringItem(self.selectFilterWnd.GetItemCount(), item)
770 self.selectFilterWnd.RefreshItem(i) 678 self.selectFilterWnd.RefreshItem(i)
771 self.selectFilterWnd.SetColumnWidth(0, wx.LIST_AUTOSIZE) 679 self.selectFilterWnd.SetColumnWidth(0, wx.LIST_AUTOSIZE)
772 self.filter = -1 680 self.filter = -1
773 self.RefreshAliases() 681 self.RefreshAliases()
774 self.log.log("Exit AliasLib->SetFilterList(self, list)", ORPG_DEBUG)
775 682
776 def GetFilterRegEx(self): 683 def GetFilterRegEx(self):
777 if self.filterIdx == -1: 684 if self.filterIdx == -1: return []
778 return []
779 return self.regExList[self.filterIdx] 685 return self.regExList[self.filterIdx]
780 686
781 def SetFilterRegEx(self, list): 687 def SetFilterRegEx(self, list):
782 self.regExList[self.filterIdx] = list 688 self.regExList[self.filterIdx] = list
783 689
785 #self.textColorBtn = wx.Button(self, wx.ID_ANY, "Color") 691 #self.textColorBtn = wx.Button(self, wx.ID_ANY, "Color")
786 #self.textColorBtn.SetForegroundColour(wx.BLACK) 692 #self.textColorBtn.SetForegroundColour(wx.BLACK)
787 id = event.GetId() 693 id = event.GetId()
788 txt = self.textWnd.GetValue() 694 txt = self.textWnd.GetValue()
789 (beg, end) = self.textWnd.GetSelection() 695 (beg, end) = self.textWnd.GetSelection()
790 if beg != end: 696 if beg != end: sel_txt = txt[beg:end]
791 sel_txt = txt[beg:end] 697 else: sel_txt = txt
792 else: 698 if id == self.textBoldBtn.GetId(): sel_txt = "<b>" + sel_txt + "</b>"
793 sel_txt = txt 699 elif id == self.textItalicBtn.GetId(): sel_txt = "<i>" + sel_txt + "</i>"
794 if id == self.textBoldBtn.GetId(): 700 elif id == self.textUnderlineBtn.GetId(): sel_txt = "<u>" + sel_txt + "</u>"
795 sel_txt = "<b>" + sel_txt + "</b>"
796 elif id == self.textItalicBtn.GetId():
797 sel_txt = "<i>" + sel_txt + "</i>"
798 elif id == self.textUnderlineBtn.GetId():
799 sel_txt = "<u>" + sel_txt + "</u>"
800 elif id == self.textColorBtn.GetId(): 701 elif id == self.textColorBtn.GetId():
801 dlg = wx.ColourDialog(self) 702 dlg = wx.ColourDialog(self)
802 if not dlg.ShowModal() == wx.ID_OK: 703 if not dlg.ShowModal() == wx.ID_OK:
803 dlg.Destroy() 704 dlg.Destroy()
804 return 705 return
805 color = dlg.GetColourData().GetColour() 706 color = dlg.GetColourData().GetColour()
806 color = RGBHex().hexstring(color[0], color[1], color[2]) 707 color = RGBHex().hexstring(color[0], color[1], color[2])
807 dlg.Destroy() 708 dlg.Destroy()
808 sel_txt = '<font color="' + color + '">' + sel_txt + '</font>' 709 sel_txt = '<font color="' + color + '">' + sel_txt + '</font>'
809 if beg != end: 710 if beg != end: txt = txt[:beg] + sel_txt + txt[end:]
810 txt = txt[:beg] + sel_txt + txt[end:] 711 else: txt = sel_txt
811 else:
812 txt = sel_txt
813 self.textWnd.SetValue(txt) 712 self.textWnd.SetValue(txt)
814 self.textWnd.SetInsertionPointEnd() 713 self.textWnd.SetInsertionPointEnd()
815 self.textWnd.SetFocus() 714 self.textWnd.SetFocus()
816 715
817 #Properties 716 #Properties
818 alias = property(GetSelectedAlias, SetSelectedAlias) 717 alias = property(GetSelectedAlias, SetSelectedAlias)
819 aliasList = property(GetAliasList, SetAliasList) 718 aliasList = property(GetAliasList, SetAliasList)
820 aliasColor = property(GetAliasColor, SetAliasColor) 719 aliasColor = property(GetAliasColor, SetAliasColor)
821
822 filter = property(GetSelectedFilter, SetSelectedFilter) 720 filter = property(GetSelectedFilter, SetSelectedFilter)
823 filterList = property(GetFilterList, SetFilterList) 721 filterList = property(GetFilterList, SetFilterList)
824 filterRegEx = property(GetFilterRegEx, SetFilterRegEx) 722 filterRegEx = property(GetFilterRegEx, SetFilterRegEx)
825 723
826 724
827
828 class FilterEditWnd(wx.Frame): 725 class FilterEditWnd(wx.Frame):
829 def __init__(self, parent, filterName, filterList): 726 def __init__(self, parent, filterName, filterList):
830 wx.Frame.__init__(self, parent, wx.ID_ANY, "Edit Filter: " + filterName) 727 wx.Frame.__init__(self, parent, wx.ID_ANY, "Edit Filter: " + filterName)
831
832 self.filterList = filterList 728 self.filterList = filterList
833 self.parent = parent 729 self.parent = parent
834
835 self.Freeze() 730 self.Freeze()
836 self.buildGUI() 731 self.buildGUI()
837 self.fillList() 732 self.fillList()
838 self.Layout() 733 self.Layout()
839 self.grid.Select(0) 734 self.grid.Select(0)
840 self.Thaw() 735 self.Thaw()
841
842 self.Bind(wx.EVT_CLOSE, self.OnExit) 736 self.Bind(wx.EVT_CLOSE, self.OnExit)
843 737
844 def buildGUI(self): 738 def buildGUI(self):
845 bsizer = wx.BoxSizer(wx.VERTICAL) 739 bsizer = wx.BoxSizer(wx.VERTICAL)
846 self.panel = wx.Panel(self, wx.ID_ANY) 740 self.panel = wx.Panel(self, wx.ID_ANY)
847 bsizer.Add(self.panel, 1, wx.EXPAND) 741 bsizer.Add(self.panel, 1, wx.EXPAND)
848 self.SetSizer(bsizer) 742 self.SetSizer(bsizer)
849 self.SetAutoLayout(True) 743 self.SetAutoLayout(True)
850
851 self.grid = wx.ListCtrl(self.panel, wx.ID_ANY, style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES) 744 self.grid = wx.ListCtrl(self.panel, wx.ID_ANY, style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES)
852 self.grid.InsertColumn(0, "Replace") 745 self.grid.InsertColumn(0, "Replace")
853 self.grid.InsertColumn(1, "With") 746 self.grid.InsertColumn(1, "With")
854 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.selectRule, self.grid) 747 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.selectRule, self.grid)
855 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.RuleEdit, self.grid) 748 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.RuleEdit, self.grid)
856
857 self.addBtn = wx.Button(self.panel, wx.ID_ANY, 'Add') 749 self.addBtn = wx.Button(self.panel, wx.ID_ANY, 'Add')
858 self.editBtn = wx.Button(self.panel, wx.ID_ANY, 'Edit') 750 self.editBtn = wx.Button(self.panel, wx.ID_ANY, 'Edit')
859 self.deleteBtn = wx.Button(self.panel, wx.ID_ANY, 'Delete') 751 self.deleteBtn = wx.Button(self.panel, wx.ID_ANY, 'Delete')
860 self.okBtn = wx.Button(self.panel, wx.ID_OK, 'Done') 752 self.okBtn = wx.Button(self.panel, wx.ID_OK, 'Done')
861
862 self.Bind(wx.EVT_BUTTON, self.RuleAdd, self.addBtn) 753 self.Bind(wx.EVT_BUTTON, self.RuleAdd, self.addBtn)
863 self.Bind(wx.EVT_BUTTON, self.RuleEdit, self.editBtn) 754 self.Bind(wx.EVT_BUTTON, self.RuleEdit, self.editBtn)
864 self.Bind(wx.EVT_BUTTON, self.RuleDelete, self.deleteBtn) 755 self.Bind(wx.EVT_BUTTON, self.RuleDelete, self.deleteBtn)
865 self.Bind(wx.EVT_BUTTON, self.OnDone, self.okBtn) 756 self.Bind(wx.EVT_BUTTON, self.OnDone, self.okBtn)
866
867 btsizer = wx.BoxSizer(wx.VERTICAL) 757 btsizer = wx.BoxSizer(wx.VERTICAL)
868 btsizer.Add(self.addBtn, 0, wx.EXPAND) 758 btsizer.Add(self.addBtn, 0, wx.EXPAND)
869 btsizer.Add(self.editBtn, 0, wx.EXPAND) 759 btsizer.Add(self.editBtn, 0, wx.EXPAND)
870 btsizer.Add(self.deleteBtn, 0, wx.EXPAND) 760 btsizer.Add(self.deleteBtn, 0, wx.EXPAND)
871 btsizer.Add(self.okBtn, 0, wx.EXPAND) 761 btsizer.Add(self.okBtn, 0, wx.EXPAND)
872
873 sizer = wx.GridBagSizer(5,5) 762 sizer = wx.GridBagSizer(5,5)
874
875 sizer.Add(self.grid, (0,0), flag=wx.EXPAND) 763 sizer.Add(self.grid, (0,0), flag=wx.EXPAND)
876 sizer.Add(btsizer, (0,1), flag=wx.EXPAND) 764 sizer.Add(btsizer, (0,1), flag=wx.EXPAND)
877
878 sizer.AddGrowableCol(0) 765 sizer.AddGrowableCol(0)
879 sizer.AddGrowableRow(0) 766 sizer.AddGrowableRow(0)
880 sizer.SetEmptyCellSize((0,0)) 767 sizer.SetEmptyCellSize((0,0))
881
882 self.panel.SetSizer(sizer) 768 self.panel.SetSizer(sizer)
883 self.panel.SetAutoLayout(True) 769 self.panel.SetAutoLayout(True)
884 770
885 def fillList(self): 771 def fillList(self):
886 for rule in self.filterList: 772 for rule in self.filterList:
887 i = self.grid.InsertStringItem(self.grid.GetItemCount(), rule[0]) 773 i = self.grid.InsertStringItem(self.grid.GetItemCount(), rule[0])
888 self.grid.SetStringItem(i, 1, rule[1]) 774 self.grid.SetStringItem(i, 1, rule[1])
889
890 self.grid.SetColumnWidth(0, wx.LIST_AUTOSIZE) 775 self.grid.SetColumnWidth(0, wx.LIST_AUTOSIZE)
891 self.grid.SetColumnWidth(1, wx.LIST_AUTOSIZE) 776 self.grid.SetColumnWidth(1, wx.LIST_AUTOSIZE)
892 777
893 def selectRule(self, event): 778 def selectRule(self, event):
894 self.currentIdx = event.GetIndex() 779 self.currentIdx = event.GetIndex()
895 self.Freeze() 780 self.Freeze()
896 for i in xrange(0, self.grid.GetItemCount()): 781 for i in xrange(0, self.grid.GetItemCount()):
897 self.grid.SetItemBackgroundColour(i, (255,255,255)) 782 self.grid.SetItemBackgroundColour(i, (255,255,255))
898
899 self.grid.SetItemBackgroundColour(self.currentIdx, (0,255,0)) 783 self.grid.SetItemBackgroundColour(self.currentIdx, (0,255,0))
900 self.grid.SetItemState(self.currentIdx, 0, wx.LIST_STATE_SELECTED) 784 self.grid.SetItemState(self.currentIdx, 0, wx.LIST_STATE_SELECTED)
901 self.grid.EnsureVisible(self.currentIdx) 785 self.grid.EnsureVisible(self.currentIdx)
902 self.Thaw() 786 self.Thaw()
903 787
910 sizer.Add(wx.StaticText(dlg, wx.ID_ANY, 'With: '), 0, wx.EXPAND) 794 sizer.Add(wx.StaticText(dlg, wx.ID_ANY, 'With: '), 0, wx.EXPAND)
911 withtxt = wx.TextCtrl(dlg, wx.ID_ANY) 795 withtxt = wx.TextCtrl(dlg, wx.ID_ANY)
912 sizer.Add(withtxt, 0, wx.EXPAND) 796 sizer.Add(withtxt, 0, wx.EXPAND)
913 sizer.Add(wx.Button(dlg, wx.ID_OK, 'Ok'), 0, wx.EXPAND) 797 sizer.Add(wx.Button(dlg, wx.ID_OK, 'Ok'), 0, wx.EXPAND)
914 sizer.Add(wx.Button(dlg, wx.ID_CANCEL, 'Cancel'), 0, wx.EXPAND) 798 sizer.Add(wx.Button(dlg, wx.ID_CANCEL, 'Cancel'), 0, wx.EXPAND)
915
916 dlg.SetSizer(sizer) 799 dlg.SetSizer(sizer)
917 dlg.SetAutoLayout(True) 800 dlg.SetAutoLayout(True)
918 dlg.Fit() 801 dlg.Fit()
919
920 rpltxt.SetValue(self.grid.GetItem(self.currentIdx, 0).GetText()) 802 rpltxt.SetValue(self.grid.GetItem(self.currentIdx, 0).GetText())
921 withtxt.SetValue(self.grid.GetItem(self.currentIdx, 1).GetText()) 803 withtxt.SetValue(self.grid.GetItem(self.currentIdx, 1).GetText())
922
923 if dlg.ShowModal() != wx.ID_OK: 804 if dlg.ShowModal() != wx.ID_OK:
924 dlg.Destroy() 805 dlg.Destroy()
925 return 806 return
926
927 self.grid.SetStringItem(self.currentIdx, 0, rpltxt.GetValue()) 807 self.grid.SetStringItem(self.currentIdx, 0, rpltxt.GetValue())
928 self.grid.SetStringItem(self.currentIdx, 1, withtxt.GetValue()) 808 self.grid.SetStringItem(self.currentIdx, 1, withtxt.GetValue())
929 self.grid.RefreshItem(self.currentIdx) 809 self.grid.RefreshItem(self.currentIdx)
930 self.grid.SetColumnWidth(0, wx.LIST_AUTOSIZE) 810 self.grid.SetColumnWidth(0, wx.LIST_AUTOSIZE)
931 self.grid.SetColumnWidth(1, wx.LIST_AUTOSIZE) 811 self.grid.SetColumnWidth(1, wx.LIST_AUTOSIZE)
932
933 dlg.Destroy() 812 dlg.Destroy()
934 813
935 def RuleAdd(self, event): 814 def RuleAdd(self, event):
936 i = self.grid.InsertStringItem(self.grid.GetItemCount(), '') 815 i = self.grid.InsertStringItem(self.grid.GetItemCount(), '')
937 self.grid.SetStringItem(i, 1, '') 816 self.grid.SetStringItem(i, 1, '')
942 self.grid.DeleteItem(self.currentIdx) 821 self.grid.DeleteItem(self.currentIdx)
943 self.grid.Select(0) 822 self.grid.Select(0)
944 823
945 def OnExit(self, event): 824 def OnExit(self, event):
946 self.MakeModal(False) 825 self.MakeModal(False)
947
948 list = [] 826 list = []
949 for i in xrange(0, self.grid.GetItemCount()): 827 for i in xrange(0, self.grid.GetItemCount()):
950 list.append([self.grid.GetItem(i, 0).GetText(), self.grid.GetItem(i, 1).GetText()]) 828 list.append([self.grid.GetItem(i, 0).GetText(), self.grid.GetItem(i, 1).GetText()])
951
952 self.parent.filterRegEx = list 829 self.parent.filterRegEx = list
953 event.Skip() 830 event.Skip()
954 831
955 def OnDone(self, event): 832 def OnDone(self, event):
956 self.Close() 833 self.Close()