comparison orpg/main.py @ 161:a766e1cbcb7c alpha

Traipse Alpha 'OpenRPG' {091128-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 (Keeping up with Beta) New Features: Added Bookmarks 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 New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. *Whiteboard from Core not showing* default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories
author sirebral
date Sat, 28 Nov 2009 01:25:20 -0600
parents 06f10429eedc
children 5c9a118476b2
comparison
equal deleted inserted replaced
159:033887bb8a86 161:a766e1cbcb7c
96 "on_player_event":self.on_player_event, 96 "on_player_event":self.on_player_event,
97 "on_status_event":self.on_status_event, 97 "on_status_event":self.on_status_event,
98 "on_password_signal":self.on_password_signal, 98 "on_password_signal":self.on_password_signal,
99 "orpgFrame":self} 99 "orpgFrame":self}
100 self.session = orpg.networking.mplay_client.mplay_client(settings.get("player"), call_backs) 100 self.session = orpg.networking.mplay_client.mplay_client(settings.get("player"), call_backs)
101 component.add("session", self.session)
101 self.poll_timer = wx.Timer(self, wx.NewId()) 102 self.poll_timer = wx.Timer(self, wx.NewId())
102 self.Bind(wx.EVT_TIMER, self.session.poll, self.poll_timer) 103 self.Bind(wx.EVT_TIMER, self.session.poll, self.poll_timer)
103 self.poll_timer.Start(100) 104 self.poll_timer.Start(100)
104 self.ping_timer = wx.Timer(self, wx.NewId()) 105 self.ping_timer = wx.Timer(self, wx.NewId())
105 self.Bind(wx.EVT_TIMER, self.session.update, self.ping_timer) 106 self.Bind(wx.EVT_TIMER, self.session.update, self.ping_timer)
108 self.DiceManager = DiceManager(settings.get("dieroller")) 109 self.DiceManager = DiceManager(settings.get("dieroller"))
109 component.add('DiceManager', self.DiceManager) 110 component.add('DiceManager', self.DiceManager)
110 111
111 #create password manager --SD 8/03 112 #create password manager --SD 8/03
112 self.password_manager = component.get('password_manager') 113 self.password_manager = component.get('password_manager')
113 component.add("session", self.session) 114
115 # build frame windows
114 component.add('frame', self) 116 component.add('frame', self)
115
116 # build frame windows
117 self.build_menu() 117 self.build_menu()
118 self.build_gui() 118 self.build_gui()
119 self.build_hotkeys() 119 self.build_hotkeys()
120
121 logger.debug("GUI Built") 120 logger.debug("GUI Built")
122 component.add("chat",self.chat)
123 component.add("map",self.map)
124 component.add("alias", self.aliaslib)
125
126 logger.debug("openrpg components all added") 121 logger.debug("openrpg components all added")
127 self.tree.load_tree(settings.get("gametree")) 122 self.tree.load_tree(settings.get("gametree"))
128 logger.debug("Tree Loaded") 123 logger.debug("Tree Loaded")
129 self.players.size_cols() 124 self.players.size_cols()
130 125
136 131
137 tipotday_start = settings.get('tipotday_start') 132 tipotday_start = settings.get('tipotday_start')
138 try: tipotday_start = int(tipotday_start) 133 try: tipotday_start = int(tipotday_start)
139 except TypeError: tipotday_start = 0 134 except TypeError: tipotday_start = 0
140 135
141
142 self.TipOfTheDay = wx.CreateFileTipProvider(dir_struct['data']+'tips.txt', tipotday_start) 136 self.TipOfTheDay = wx.CreateFileTipProvider(dir_struct['data']+'tips.txt', tipotday_start)
143
144 #Load Update Manager 137 #Load Update Manager
145 component.add('updatemana', self.updateMana) 138 component.add('updatemana', self.updateMana)
146 logger.debug("update manager reloaded") 139 logger.debug("update manager reloaded")
147 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) 140 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
148 141
161 """Some Actions need to be done after the main frame is drawn""" 154 """Some Actions need to be done after the main frame is drawn"""
162 self.players.size_cols() 155 self.players.size_cols()
163 try: 156 try:
164 if settings.get('tipotday_enabled').lower() != '0': self.ShowTipOfTheDay() 157 if settings.get('tipotday_enabled').lower() != '0': self.ShowTipOfTheDay()
165 except: self.add_setting('Tip of the Day') 158 except: self.add_setting('Tip of the Day')
166
167 159
168 def add_setting(self, setting): 160 def add_setting(self, setting):
169 if setting == 'Tip of the Day': 161 if setting == 'Tip of the Day':
170 settings.add_tab('General', 'Tip of the Day', 'grid') 162 settings.add_tab('General', 'Tip of the Day', 'grid')
171 settings.add('Tip of the Day', 'tipotday_start', '0', 'int', 'Current Tip of the Day') 163 settings.add('Tip of the Day', 'tipotday_start', '0', 'int', 'Current Tip of the Day')
202 elif type == "admin": self.password_manager.ClearPassword("admin", int(id)) 194 elif type == "admin": self.password_manager.ClearPassword("admin", int(id))
203 elif type == "room": self.password_manager.ClearPassword("room", int(id)) 195 elif type == "room": self.password_manager.ClearPassword("room", int(id))
204 else: pass 196 else: pass
205 except: traceback.print_exc() 197 except: traceback.print_exc()
206 198
207
208 def build_menu(self): 199 def build_menu(self):
209 menu = \ 200 menu = \
210 [[ 201 [[
211 ['&OpenRPG'], 202 ['&OpenRPG'],
212 [' &Settings\tCtrl-S'], 203 [' &Settings\tCtrl-S'],
581 else: 572 else:
582 self.mainmenu.SetMenuState("ToolsMapBar", True) 573 self.mainmenu.SetMenuState("ToolsMapBar", True)
583 self._mgr.GetPane("Map Tool Bar").Show() 574 self._mgr.GetPane("Map Tool Bar").Show()
584 self._mgr.Update() 575 self._mgr.Update()
585 576
586 #Help Menu #Needs a custom Dialog because it is ugly on Windows
587 def OnMB_HelpAbout(self): 577 def OnMB_HelpAbout(self):
588 if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide() 578 if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide()
589 else: self.AboutORPG.Show() 579 else: self.AboutORPG.Show()
590 580
591 def OnMB_HelpOnlineUserGuide(self): 581 def OnMB_HelpOnlineUserGuide(self):
730 self._mgr.AddPane(self.gs, wndinfo) 720 self._mgr.AddPane(self.gs, wndinfo)
731 logger.debug("Game Server Window Created") 721 logger.debug("Game Server Window Created")
732 722
733 #Create the Alias Lib Window 723 #Create the Alias Lib Window
734 self.aliaslib = orpg.tools.aliaslib.AliasLib() 724 self.aliaslib = orpg.tools.aliaslib.AliasLib()
725 component.add("alias", self.aliaslib)
735 self.aliaslib.Hide() 726 self.aliaslib.Hide()
736 logger.debug("Alias Window Created") 727 logger.debug("Alias Window Created")
737 menuid = wx.NewId() 728 menuid = wx.NewId()
738 self.windowsmenu.Append(menuid, "Alias Lib", kind=wx.ITEM_CHECK) 729 self.windowsmenu.Append(menuid, "Alias Lib", kind=wx.ITEM_CHECK)
739 self.windowsmenu.Check(menuid, False) 730 self.windowsmenu.Check(menuid, False)
745 if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose) 736 if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose)
746 else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose) 737 else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose)
747 logger.debug("AUI Bindings Done") 738 logger.debug("AUI Bindings Done")
748 739
749 #Load the layout if one exists 740 #Load the layout if one exists
750 layout = xml_dom.find("DockLayout") 741 try:
751 self._mgr.LoadPerspective(layout.text) 742 layout = xml_dom.find("DockLayout")
752 logger.debug("Perspective Loaded") 743 self._mgr.LoadPerspective(layout.text)
744 logger.debug("Perspective Loaded")
745 except: pass
753 self._mgr.GetPane("Browse Server Window").Hide() 746 self._mgr.GetPane("Browse Server Window").Hide()
754 self._mgr.Update() 747 self._mgr.Update()
755 self.Maximize(maximized) 748 self.Maximize(maximized)
756 logger.debug("GUI is all created") 749 logger.debug("GUI is all created")
757 self.Thaw() 750 self.Thaw()
783 776
784 if name == "tab": temp_wnd = self.do_tab_window(xml_dom, parent_wnd) 777 if name == "tab": temp_wnd = self.do_tab_window(xml_dom, parent_wnd)
785 elif name == "map": 778 elif name == "map":
786 temp_wnd = orpg.mapper.map.map_wnd(parent_wnd, -1) 779 temp_wnd = orpg.mapper.map.map_wnd(parent_wnd, -1)
787 self.map = temp_wnd 780 self.map = temp_wnd
781 component.add("map",self.map)
782
788 elif name == "tree": 783 elif name == "tree":
789 temp_wnd = orpg.gametree.gametree.game_tree(parent_wnd, -1) 784 temp_wnd = orpg.gametree.gametree.game_tree(parent_wnd, -1)
790 self.tree = temp_wnd 785 self.tree = temp_wnd
791 if settings.get('ColorTree') == '1': 786 if settings.get('ColorTree') == '1':
792 self.tree.SetBackgroundColour(settings.get('bgcolor')) 787 self.tree.SetBackgroundColour(settings.get('bgcolor'))
797 792
798 elif name == "chat": 793 elif name == "chat":
799 temp_wnd = orpg.chat.chatwnd.chat_notebook(parent_wnd, wx.DefaultSize) 794 temp_wnd = orpg.chat.chatwnd.chat_notebook(parent_wnd, wx.DefaultSize)
800 self.chattabs = temp_wnd 795 self.chattabs = temp_wnd
801 self.chat = temp_wnd.MainChatPanel 796 self.chat = temp_wnd.MainChatPanel
797 component.add("chat",self.chat)
802 798
803 elif name == "player": 799 elif name == "player":
804 temp_wnd = orpg.player_list.player_list(parent_wnd) 800 temp_wnd = orpg.player_list.player_list(parent_wnd)
805 self.players = temp_wnd 801 self.players = temp_wnd
806 if settings.get('ColorTree') == '1': 802 if settings.get('ColorTree') == '1':
838 wndinfo.Position(int(pos)) 834 wndinfo.Position(int(pos))
839 wndinfo.Show() 835 wndinfo.Show()
840 self._mgr.AddPane(temp_wnd, wndinfo) 836 self._mgr.AddPane(temp_wnd, wndinfo)
841 return temp_wnd 837 return temp_wnd
842 838
843
844 def onPaneClose(self, evt): 839 def onPaneClose(self, evt):
845 pane = evt.GetPane() 840 pane = evt.GetPane()
846 #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration. 841 #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration.
847 #Adding ID also fixed docking. Go figure. 842 #Adding ID also fixed docking. Go figure.
848 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False) 843 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False)
853 for wndid, wname in self.mainwindows.iteritems(): 848 for wndid, wname in self.mainwindows.iteritems():
854 if pane.name == wname: self.windowsmenu.Check(wndid, False); break 849 if pane.name == wname: self.windowsmenu.Check(wndid, False); break
855 evt.Skip() 850 evt.Skip()
856 self._mgr.Update() 851 self._mgr.Update()
857 852
858
859 def saveLayout(self): 853 def saveLayout(self):
860 filename = dir_struct["user"] + "layout.xml" 854 filename = dir_struct["user"] + "layout.xml"
861 layout = parse(filename) 855 layout = parse(filename)
862 xml_dom = layout.getroot() 856 xml_dom = layout.getroot()
863 (x_size,y_size) = self.GetClientSize() 857 (x_size,y_size) = self.GetClientSize()
867 xml_dom.set("height", str(y_size)) 861 xml_dom.set("height", str(y_size))
868 xml_dom.set("width", str(x_size)) 862 xml_dom.set("width", str(x_size))
869 xml_dom.set("posx", str(x_pos)) 863 xml_dom.set("posx", str(x_pos))
870 xml_dom.set("posy", str(y_pos)) 864 xml_dom.set("posy", str(y_pos))
871 xml_dom.set("maximized", str(max)) 865 xml_dom.set("maximized", str(max))
872 try: 866 try: xml_dom.find("DockLayout").text = str(self._mgr.SavePerspective())
873 xml_dom.find("DockLayout").text = str(self._mgr.SavePerspective())
874 except: 867 except:
875 elem = Element('DockLayout') 868 elem = Element('DockLayout')
876 elem.set("DO_NO_EDIT","True") 869 elem.set("DO_NO_EDIT","True")
877 elem.text = str(self._mgr.SavePerspective()) 870 elem.text = str(self._mgr.SavePerspective())
878 xml_dom.append(elem) 871 xml_dom.append(elem)
879
880 layout.write(filename) 872 layout.write(filename)
881 873
882 def build_hotkeys(self): 874 def build_hotkeys(self):
883 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys()) 875 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys())
884 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys()) 876 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys())