comparison orpg/main.py @ 133:37d26a98883f alpha

Traipse Alpha 'OpenRPG' {091010-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 (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana **Pretty important update that can help remove thousands of dead children from your gametree. **Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! **New Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!! Dead Node Children, now that's a O O -v-v- Happy Halloween!
author sirebral
date Tue, 10 Nov 2009 12:11:13 -0600
parents e7f990be5075
children 82c47d583493
comparison
equal deleted inserted replaced
132:fe4dc5817d5e 133:37d26a98883f
33 from orpg.orpgCore import * 33 from orpg.orpgCore import *
34 from orpg_version import * 34 from orpg_version import *
35 from orpg.orpg_windows import * 35 from orpg.orpg_windows import *
36 36
37 import wx.py 37 import wx.py
38 #from orpg import minidom 38
39 import orpg.player_list 39 import orpg.player_list
40 import orpg.tools.pluginui as pluginUI 40 import orpg.tools.pluginui as pluginUI
41 import orpg.tools.aliaslib 41 import orpg.tools.aliaslib
42 import orpg.tools.toolBars 42 import orpg.tools.toolBars
43 import orpg.tools.orpg_sound 43 import orpg.tools.orpg_sound
53 import upmana.updatemana 53 import upmana.updatemana
54 import upmana.manifest as manifest 54 import upmana.manifest as manifest
55 55
56 from orpg.dirpath import dir_struct 56 from orpg.dirpath import dir_struct
57 from orpg.dieroller.utils import DiceManager 57 from orpg.dieroller.utils import DiceManager
58 from orpg.tools.orpg_settings import settings 58 from orpg.tools.settings import settings
59 from orpg.tools.validate import validate 59 from orpg.tools.validate import validate
60 from orpg.tools.passtool import PassTool 60 from orpg.tools.passtool import PassTool
61 from orpg.tools.orpg_log import logger, crash, debug 61 from orpg.tools.orpg_log import logger, crash, debug
62 from orpg.tools.metamenus import MenuBarEx 62 from orpg.tools.metamenus import MenuBarEx
63 63
64 from xml.etree.ElementTree import ElementTree, Element, parse 64 from xml.etree.ElementTree import ElementTree, Element, parse
65 from xml.etree.ElementTree import fromstring, tostring 65 from xml.etree.ElementTree import fromstring, tostring
66 ## Element Tree usage will require users to convert to and from string data quite often until users of older versions update.
67 ## This is a problem that users of older versions will need to cross as it is both Core and Traipse that will make the change.
68 ## Older versions have a problem with correct XML.
66 from orpg.orpg_xml import xml #to be replaced by etree 69 from orpg.orpg_xml import xml #to be replaced by etree
67 70
68 71
69 #################################### 72 ####################################
70 ## Main Frame 73 ## Main Frame
235 238
236 self.mainmenu = MenuBarEx(self, menu) 239 self.mainmenu = MenuBarEx(self, menu)
237 if settings.get('Heartbeat') == '1': 240 if settings.get('Heartbeat') == '1':
238 self.mainmenu.SetMenuState("GameServerServerHeartbeat", True) 241 self.mainmenu.SetMenuState("GameServerServerHeartbeat", True)
239 242
243 self.mainmenu.SetMenuState('ToolsPasswordManager', True if settings.get('PWMannager') == 'On' else False)
240 tabtheme = settings.get('TabTheme') #This change is stable. TaS. 244 tabtheme = settings.get('TabTheme') #This change is stable. TaS.
241 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') 245 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
242 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') 246 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw')
243 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua') 247 self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua')
244 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw') 248 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw')
262 266
263 # Traipse Suite of Additions. 267 # Traipse Suite of Additions.
264 self.traipseSuite = wx.Menu() 268 self.traipseSuite = wx.Menu()
265 self.mainmenu.Insert(5, self.traipseSuite, "&Traipse Suite") 269 self.mainmenu.Insert(5, self.traipseSuite, "&Traipse Suite")
266 270
267 #Update Manager 271 #Update Manager
268 mana = wx.MenuItem(self.traipseSuite, wx.ID_ANY, "Update Manager", "Update Manager") 272 mana = wx.MenuItem(self.traipseSuite, wx.ID_ANY, "Update Manager", "Update Manager")
269 self.Bind(wx.EVT_MENU, self.OnMB_UpdateManagerPanel, mana) 273 self.Bind(wx.EVT_MENU, self.OnMB_UpdateManagerPanel, mana)
270 self.traipseSuite.AppendItem(mana) 274 self.traipseSuite.AppendItem(mana)
271 275
272 self.debugConsole = wx.MenuItem(self.traipseSuite, -1, "Debug Console", "Debug Console") 276 self.debugConsole = wx.MenuItem(self.traipseSuite, -1, "Debug Console", "Debug Console")
740 if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose) 744 if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose)
741 else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose) 745 else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose)
742 logger.debug("AUI Bindings Done") 746 logger.debug("AUI Bindings Done")
743 747
744 #Load the layout if one exists 748 #Load the layout if one exists
745 layout = xml_dom.findall("DockLayout") 749 layout = xml_dom.find("DockLayout")
746 try: 750 try:
747 textnode = xml.safe_get_text_node(layout[0]) 751 self._mgr.LoadPerspective(layout.text)
748 self._mgr.LoadPerspective(textnode.text)
749 except: pass 752 except: pass
750 logger.debug("Perspective Loaded") 753 logger.debug("Perspective Loaded")
751 self._mgr.GetPane("Browse Server Window").Hide() 754 self._mgr.GetPane("Browse Server Window").Hide()
752 self._mgr.Update() 755 self._mgr.Update()
753 self.Maximize(maximized) 756 self.Maximize(maximized)
864 self._mgr.Update() 867 self._mgr.Update()
865 868
866 869
867 def saveLayout(self): 870 def saveLayout(self):
868 filename = dir_struct["user"] + "layout.xml" 871 filename = dir_struct["user"] + "layout.xml"
869 layout = parse(dir_struct["user"] + "layout.xml") 872 layout = parse(filename)
870 xml_dom = layout.getroot() 873 xml_dom = layout.getroot()
871 (x_size,y_size) = self.GetClientSize() 874 (x_size,y_size) = self.GetClientSize()
872 (x_pos,y_pos) = self.GetPositionTuple() 875 (x_pos,y_pos) = self.GetPositionTuple()
873 if self.IsMaximized(): max = 1 876 if self.IsMaximized(): max = 1
874 else: max = 0 877 else: max = 0
875 xml_dom.set("height", str(y_size)) 878 xml_dom.set("height", str(y_size))
876 xml_dom.set("width", str(x_size)) 879 xml_dom.set("width", str(x_size))
877 xml_dom.set("posx", str(x_pos)) 880 xml_dom.set("posx", str(x_pos))
878 xml_dom.set("posy", str(y_pos)) 881 xml_dom.set("posy", str(y_pos))
879 xml_dom.set("maximized", str(max)) 882 xml_dom.set("maximized", str(max))
880 layout = xml_dom.findall("DockLayout")
881 try: 883 try:
882 layout[0].text = str(self._mgr.SavePerspective()) 884 xml_dom.find("DockLayout").text = str(self._mgr.SavePerspective())
883 except: 885 except:
884 elem = Element('DockLayout') 886 elem = Element('DockLayout')
885 elem.set("DO_NO_EDIT","True") 887 elem.set("DO_NO_EDIT","True")
886 elem.text = str(self._mgr.SavePerspective()) 888 elem.text = str(self._mgr.SavePerspective())
887 xml_dom.append(elem) 889 xml_dom.append(elem)
890
891 layout.write(filename)
892 """
888 temp_file = open(filename, "w") 893 temp_file = open(filename, "w")
889 temp_file.write(tostring(xml_dom)) 894 temp_file.write(tostring(xml_dom))
890 temp_file.close() 895 temp_file.close()"""
891 896
892 897
893 def build_hotkeys(self): 898 def build_hotkeys(self):
894 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys()) 899 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys())
895 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys()) 900 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys())
954 for m in ignore_id: 959 for m in ignore_id:
955 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return 960 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return
956 961
957 # ok we are not ignoring this message 962 # ok we are not ignoring this message
958 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below 963 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below
964
959 ### Alpha ### 965 ### Alpha ###
960 etreeEl = Element('msg') 966 etreeEl = Element('msg')
961 try: etreeEl.append(fromstring(data)) 967 try: etreeEl.append(fromstring(data))
962 except: etreeEl.text = data 968 except: etreeEl.text = data
963 ### Remove after Element Tree is integrated further ### 969 ### Remove after Element Tree is integrated further ###
964 if player: 970 if player: display_name = self.chat.chat_display_name(player)
965 display_name = self.chat.chat_display_name(player) 971 else: display_name = "Server Administrator"
966 else: 972
967 display_name = "Server Administrator" 973 if etreeEl.text: self.chat.Post(etreeEl.text)
968
969 if etreeEl.text:
970 self.chat.Post(etreeEl.text)
971 974
972 for child in etreeEl.getchildren(): 975 for child in etreeEl.getchildren():
973 if child.tag == 'tree': 976 if child.tag == 'tree':
974 ### Alpha ### Allows users to decide if they want the node or not. 977 ### Alpha ### Allows users to decide if they want the node or not.
975 dlg = wx.MessageDialog(None, display_name + 'is trying to send you a tree node. Accept?', 'Question', 978 dlg = wx.MessageDialog(None, display_name + ' is trying to send you a tree node. Accept?', 'Question',
976 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) 979 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
977 if dlg.ShowModal() == wx.ID_YES: 980 if dlg.ShowModal() == wx.ID_YES:
978 dlg.Destroy() 981 dlg.Destroy()
979 self.tree.on_receive_data(data, player) 982 debug(child)
983 self.tree.on_receive_data(tostring(child)) #Removed player object because it was unused.
980 self.chat.InfoPost(display_name + " has sent you a tree node...") 984 self.chat.InfoPost(display_name + " has sent you a tree node...")
981 ### Core ### to be milked in later.
982 #TODO: Fix game tree to accepts elements
983 #self.tree.on_receive_data(child, player)
984 #self.chat.InfoPost(display_name + " has sent you a tree node...")
985
986 elif child.tag == 'map': 985 elif child.tag == 'map':
987 ### Core ### Adapted from, remove tostring later
988 #TODO: Fix map to accepts elements 986 #TODO: Fix map to accepts elements
989 self.map.new_data(tostring(child)) 987 self.map.new_data(tostring(child))
990
991 elif child.tag == 'chat': 988 elif child.tag == 'chat':
992 msg = orpg.chat.chat_msg.chat_msg(data) 989 msg = orpg.chat.chat_msg.chat_msg(tostring(child))
993 self.chat.post_incoming_msg(msg, player) 990 self.chat.post_incoming_msg(msg, player)
994 ### Core ### to be milked in later
995 #msg = orpg.chat.chat_msg.chat_msg()
996 #msg.takedom(child)
997 #self.chat.post_incoming_msg(msg, player)
998
999
1000 991
1001 def on_mplay_event(self, evt): 992 def on_mplay_event(self, evt):
1002 id = evt.get_id() 993 id = evt.get_id()
1003 if id == orpg.networking.mplay_client.MPLAY_CONNECTED: 994 if id == orpg.networking.mplay_client.MPLAY_CONNECTED:
1004 self.chat.InfoPost("Game connected!") 995 self.chat.InfoPost("Game connected!")