Mercurial > traipse_dev
comparison orpg/tools/aliaslib.py @ 195:b633f4c64aae alpha
Traipse Alpha 'OpenRPG' {100219-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 (Patch-2)
New Features:
New Namespace method with two new syntaxes
Fixes:
Fix to Server GUI startup errors
Fix to Server GUI Rooms tab updating
Fix to Chat and Settings if non existant die roller is picked
Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated
Fix to Alias Lib's Export to Tree, Open, Save features
Fix to alias node, now works properly
Fix to Splitter node, minor GUI cleanup
author | sirebral |
---|---|
date | Sat, 24 Apr 2010 08:37:20 -0500 |
parents | f38df4bf9715 |
children |
comparison
equal
deleted
inserted
replaced
182:4b2884f29a72 | 195:b633f4c64aae |
---|---|
19 # | 19 # |
20 # File: aliaslib.py | 20 # File: aliaslib.py |
21 # Author: Dj Gilcrease | 21 # Author: Dj Gilcrease |
22 # Maintainer: | 22 # Maintainer: |
23 # Version: | 23 # Version: |
24 # $Id: aliaslib.py,v 1.20 2007/08/09 05:23:21 digitalxero Exp $ | 24 # $Id: aliaslib.py,v Traipse 'Ornery-Orc' prof.ebral Exp $ |
25 # | 25 # |
26 # Description: nodehandler for alias. | 26 # Description: nodehandler for alias. |
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 Traipse 'Ornery-Orc' prof.ebral Exp $" |
30 | 30 |
31 from orpg.orpg_wx import * | 31 from orpg.orpg_wx import * |
32 from orpg.orpgCore import component | 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 from orpg.dirpath import dir_struct | 35 from orpg.dirpath import dir_struct |
36 from orpg.tools.validate import validate | 36 from orpg.tools.validate import validate |
37 from orpg.tools.orpg_settings import settings | 37 from orpg.tools.orpg_settings import settings |
38 from xml.etree.ElementTree import tostring, parse | |
38 import re | 39 import re |
39 | 40 |
40 class AliasLib(wx.Frame): | 41 class AliasLib(wx.Frame): |
41 def __init__(self): | 42 def __init__(self): |
42 self.orpgframe = component.get('frame') | 43 self.orpgframe = component.get('frame') |
172 f = open(dir_struct["user"] + file, "w") | 173 f = open(dir_struct["user"] + file, "w") |
173 f.write(xml) | 174 f.write(xml) |
174 f.close() | 175 f.close() |
175 | 176 |
176 def OnMB_FileExportToTree(self, event): | 177 def OnMB_FileExportToTree(self, event): |
177 #tree = component.get("tree") | |
178 xml = '<nodehandler class="voxchat_handler" ' | 178 xml = '<nodehandler class="voxchat_handler" ' |
179 xml += 'icon="player" ' | 179 xml += 'icon="player" ' |
180 xml += 'module="voxchat" ' | 180 xml += 'module="voxchat" ' |
181 xml += 'name="' + self.filename[:-6] + '" ' | 181 xml += 'name="' + self.filename[:-6] + '" ' |
182 xml += 'use.filter="0" ' | 182 xml += 'use.filter="0" ' |
457 self.SetSizer(self.sizer) | 457 self.SetSizer(self.sizer) |
458 self.SetAutoLayout(True) | 458 self.SetAutoLayout(True) |
459 self.Fit() | 459 self.Fit() |
460 | 460 |
461 def loadFile(self): | 461 def loadFile(self): |
462 f = open(dir_struct["user"] + self.filename, "r") | 462 data = parse(dir_struct["user"] + self.filename) |
463 data = f.read() | 463 xml_dom = data.getroot() |
464 f.close() | 464 aliases = xml_dom.findall("alias") |
465 self.alias = -1 | |
466 self.filter = -1 | |
467 xml_dom = component.get('xml').parseXml(data) | |
468 del data | |
469 aliases = xml_dom.getElementsByTagName("alias") | |
470 alist = [] | 465 alist = [] |
471 for alias in aliases: | 466 for alias in aliases: |
472 if alias.hasAttribute("color"): color = alias.getAttribute("color") | 467 if alias.get("color"): color = alias.get("color") |
473 else: color = 'Default' | 468 else: color = 'Default' |
474 aname = self.MakeSafeHTML(alias.getAttribute("name")) | 469 aname = self.MakeSafeHTML(alias.get("name")) |
475 alist.append([aname, color]) | 470 alist.append([aname, color]) |
476 alist.sort() | 471 alist.sort() |
477 self.aliasList = alist | 472 self.aliasList = alist |
478 filters = xml_dom.getElementsByTagName("filter") | 473 filters = xml_dom.findall("filter") |
479 flist = [] | 474 flist = [] |
480 self.regExList = [] | 475 self.regExList = [] |
481 for filter in filters: | 476 for filter in filters: |
482 flist.append(filter.getAttribute("name")) | 477 flist.append(filter.get("name")) |
483 rules = filter.getElementsByTagName("rule") | 478 rules = filter.findall("rule") |
484 sub = [] | 479 sub = [] |
485 for rule in rules: sub.append([self.MakeSafeHTML(rule.getAttribute("match")), | 480 for rule in rules: sub.append([self.MakeSafeHTML(rule.get("match")), |
486 self.MakeSafeHTML(rule.getAttribute("sub"))]) | 481 self.MakeSafeHTML(rule.get("sub"))]) |
487 self.regExList.append(sub) | 482 self.regExList.append(sub) |
488 self.filterList = flist | 483 self.filterList = flist |
489 xml_dom.unlink() | 484 self.alias = 0 |
490 self.alias = -1 | 485 self.filter = 0 |
491 self.filter = -1 | |
492 | 486 |
493 def MakeSafeHTML(self, str): | 487 def MakeSafeHTML(self, str): |
494 return str.replace("&", "&").replace("<", "<").replace(""", '"').replace(">", ">").replace("'", "'") | 488 return str.replace("&", "&").replace("<", "<").replace(""", '"').replace(">", ">").replace("'", "'") |
495 def MakeHTMLSafe(self, str): | 489 def MakeHTMLSafe(self, str): |
496 return str.replace("&", "&").replace("<", "<").replace('"', """).replace(">", ">").replace("'", "'") | 490 return str.replace("&", "&").replace("<", "<").replace('"', """).replace(">", ">").replace("'", "'") |
497 def ImportFromTree(self, xml_dom): | 491 def ImportFromTree(self, xml_dom): |
498 oldfilename = self.filename | 492 oldfilename = self.filename |
499 if xml_dom.getAttribute('name') == 'Alias Library': | 493 if xml_dom.get('name') == 'Alias Library': |
500 dlg = wx.TextEntryDialog(self, "Please Name This Alias Lib", "New Alias Lib") | 494 dlg = wx.TextEntryDialog(self, "Please Name This Alias Lib", "New Alias Lib") |
501 if dlg.ShowModal() == wx.ID_OK: | 495 if dlg.ShowModal() == wx.ID_OK: |
502 self.filename = dlg.GetValue() + '.alias' | 496 self.filename = dlg.GetValue() + '.alias' |
503 dlg.Destroy() | 497 dlg.Destroy() |
504 else: | 498 else: |
505 dlg.Destroy() | 499 dlg.Destroy() |
506 return | 500 return |
507 else: self.filename = xml_dom.getAttribute('name') + '.alias' | 501 else: self.filename = xml_dom.get('name') + '.alias' |
508 settings.set_setting('aliasfile', self.filename[:-6]) | 502 settings.set_setting('aliasfile', self.filename[:-6]) |
509 if oldfilename != self.filename: self.OnMB_FileSave(None, oldfilename) | 503 if oldfilename != self.filename: self.OnMB_FileSave(None, oldfilename) |
510 f = open(dir_struct["user"] + self.filename, "w") | 504 f = open(dir_struct["user"] + self.filename, "w") |
511 f.write(xml_dom.toxml().replace('nodehandler', 'aliaslib').replace('voxchat.', '')) | 505 f.write(tostring(xml_dom).replace('nodehandler', 'aliaslib').replace('voxchat.', '')) |
512 f.close() | 506 f.close() |
513 wx.CallAfter(self.loadFile) | 507 wx.CallAfter(self.loadFile) |
514 | 508 |
515 def NewAliasSelection(self, event): | 509 def NewAliasSelection(self, event): |
516 self.alias = event.GetIndex() | 510 self.alias = event.GetIndex() |
687 | 681 |
688 def SetFilterRegEx(self, list): | 682 def SetFilterRegEx(self, list): |
689 self.regExList[self.filterIdx] = list | 683 self.regExList[self.filterIdx] = list |
690 | 684 |
691 def FormatText(self, event): | 685 def FormatText(self, event): |
692 #self.textColorBtn = wx.Button(self, wx.ID_ANY, "Color") | |
693 #self.textColorBtn.SetForegroundColour(wx.BLACK) | |
694 id = event.GetId() | 686 id = event.GetId() |
695 txt = self.textWnd.GetValue() | 687 txt = self.textWnd.GetValue() |
696 (beg, end) = self.textWnd.GetSelection() | 688 (beg, end) = self.textWnd.GetSelection() |
697 if beg != end: sel_txt = txt[beg:end] | 689 if beg != end: sel_txt = txt[beg:end] |
698 else: sel_txt = txt | 690 else: sel_txt = txt |