diff orpg/tools/orpg_settings.py @ 164:d263c8ff4d7c beta

Traipse Beta 'OpenRPG' {091202-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 (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 Added 7th Sea die roller method; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Includes support for Mythos roller. 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. default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and no reactive settings when Ok is pressed.
author sirebral
date Wed, 02 Dec 2009 21:21:34 -0600
parents dcf4fbe09b70
children b7206781c254
line wrap: on
line diff
--- a/orpg/tools/orpg_settings.py	Sat Nov 28 01:25:58 2009 -0600
+++ b/orpg/tools/orpg_settings.py	Wed Dec 02 21:21:34 2009 -0600
@@ -131,73 +131,31 @@
             self.settings.set_setting(self.changes[i][0], self.changes[i][1])
             top_frame = component.get('frame')
 
-            if self.changes[i][0] == 'defaultfontsize' or self.changes[i][0] == 'defaultfont':
-                self.chat.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'), 
-                                                        self.settings.get_setting('defaultfontsize'))
-                self.chat.InfoPost("Font is now " + 
-                                    self.settings.get_setting('defaultfont') + " point size " + 
-                                    self.settings.get_setting('defaultfontsize'))
-                self.chat.chatwnd.scroll_down()
-
-            if self.changes[i][0] == 'bgcolor' or self.changes[i][0] == 'textcolor':
-                self.chat.chatwnd.SetPage(self.chat.ResetPage())
-                self.chat.chatwnd.scroll_down()
-                if self.settings.get_setting('ColorTree') == '1':
-                    top_frame.tree.SetBackgroundColour(self.settings.get_setting('bgcolor'))
-                    top_frame.tree.SetForegroundColour(self.settings.get_setting('textcolor'))
-                    top_frame.tree.Refresh()
-                    top_frame.players.SetBackgroundColour(self.settings.get_setting('bgcolor'))
-                    top_frame.players.SetForegroundColour(self.settings.get_setting('textcolor'))
-                    top_frame.players.Refresh()
-                else:
-                    top_frame.tree.SetBackgroundColour('white')
-                    top_frame.tree.SetForegroundColour('black')
-                    top_frame.tree.Refresh()
-                    top_frame.players.SetBackgroundColour('white')
-                    top_frame.players.SetForegroundColour('black')
-                    top_frame.players.Refresh()
+            ## Settings are now reactive and organized ##
+            ok = {'IdleStatusAlias': self.chat.chat_cmds.on_status,
+                'dieroller': self.dieroller_ok,
+                'defaultfontsize': self.font_ok,
+                'defaultfont': self.font_ok,
+                'bgcolor': self.text_ok,
+                'textcolor': self.text_ok,
+                'ColorTree': self.colortree_ok,
+                'player': self.session.set_name,
+                'TabBackgroundGradient': self.tab_gradient_ok}
 
-            if self.changes[i][0] == 'ColorTree':
-                if self.changes[i][1] == '1':
-                    top_frame.tree.SetBackgroundColour(self.settings.get_setting('bgcolor'))
-                    top_frame.tree.SetForegroundColour(self.settings.get_setting('textcolor'))
-                    top_frame.tree.Refresh()
-                    top_frame.players.SetBackgroundColour(self.settings.get_setting('bgcolor'))
-                    top_frame.players.SetForegroundColour(self.settings.get_setting('textcolor'))
-                    top_frame.players.Refresh()
-                else:
-                    top_frame.tree.SetBackgroundColour('white')
-                    top_frame.tree.SetForegroundColour('black')
-                    top_frame.tree.Refresh()
-                    top_frame.players.SetBackgroundColour('white')
-                    top_frame.players.SetForegroundColour('black')
-                    top_frame.players.Refresh()
+            if self.changes[i][0] in ok.keys(): ok[self.changes[i][0]](self.changes[i][1])
 
-            if self.changes[i][0] == 'GMWhisperTab' and self.changes[i][1] == '1': self.chat.parent.create_gm_tab()
-            self.toggleToolBars(self.chat, self.changes[i])
-            try: self.toggleToolBars(self.chat.parent.GMChatPanel, self.changes[i])
-            except: pass
-            for panel in self.chat.parent.whisper_tabs: self.toggleToolBars(panel, self.changes[i])
-            for panel in self.chat.parent.group_tabs: self.toggleToolBars(panel, self.changes[i])
-            for panel in self.chat.parent.null_tabs: self.toggleToolBars(panel, self.changes[i])
+            elif self.changes[i][0] == 'GMWhisperTab' and self.changes[i][1] == '1': self.chat.parent.create_gm_tab()
 
-            if self.changes[i][0] == 'player': self.session.name = str(self.changes[i][1])
-
-            if (self.changes[i][0][:3] == 'Tab' and self.changes[i][1][:6] == 'custom') or\
+            elif (self.changes[i][0][:3] == 'Tab' and self.changes[i][1][:6] == 'custom') or\
                 (self.changes[i][0][:3] == 'Tab' and self.settings.get_setting('TabTheme')[:6] == 'custom'):
-
                 gfrom = self.settings.get_setting('TabGradientFrom')
                 (fred, fgreen, fblue) = rgbconvert.rgb_tuple(gfrom)
-
                 gto = self.settings.get_setting('TabGradientTo')
                 (tored, togreen, toblue) = rgbconvert.rgb_tuple(gto)
-
                 tabtext = self.settings.get_setting('TabTextColor')
                 (tred, tgreen, tblue) = rgbconvert.rgb_tuple(tabtext)
-
                 for wnd in tabbedwindows:
                     style = wnd.GetWindowStyleFlag()
-                    # remove old tabs style
                     mirror = ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS | FNB.FNB_COLORFUL_TABS)
                     style &= mirror
                     if self.settings.get_setting('TabTheme') == 'customslant': style |= FNB.FNB_VC8
@@ -208,14 +166,74 @@
                     wnd.SetNonActiveTabTextColour(wx.Color(tred, tgreen, tblue))
                     wnd.Refresh()
 
-            if self.changes[i][0] == 'TabBackgroundGradient':
-                for wnd in tabbedwindows:
-                    (red, green, blue) = rgbconvert.rgb_tuple(self.changes[i][1])
-                    wnd.SetTabAreaColour(wx.Color(red, green, blue))
-                    wnd.Refresh()
+            self.toggleToolBars(self.chat, self.changes[i])
+            try: self.toggleToolBars(self.chat.parent.GMChatPanel, self.changes[i])
+            except: pass
+            for panel in self.chat.parent.whisper_tabs: self.toggleToolBars(panel, self.changes[i])
+            for panel in self.chat.parent.group_tabs: self.toggleToolBars(panel, self.changes[i])
+            for panel in self.chat.parent.null_tabs: self.toggleToolBars(panel, self.changes[i])
+
         self.settings.save()
         self.Destroy()
 
+    def tab_gradient_ok(self, changes):
+        for wnd in tabbedwindows:
+            (red, green, blue) = rgbconvert.rgb_tuple(changes)
+            wnd.SetTabAreaColour(wx.Color(red, green, blue))
+            wnd.Refresh()
+
+    def dieroller_ok(self, changes):
+        rm = component.get('DiceManager')
+        try:
+            rm.setRoller(changes)
+            self.chat.SystemPost('You have changed your die roller to the <b>"' + changes + '"</b> roller.')
+        except:
+            rm.setRoller('std')
+            self.settings.change('dieroller', 'std')
+            self.chat.SystemPost('<b>"' + changes + '"</b> is an invalid roller. Setting roller to <b>"std"</b>')
+
+    def colortree_ok(self, changes):
+        if changes == '1':
+            top_frame.tree.SetBackgroundColour(self.settings.get_setting('bgcolor'))
+            top_frame.tree.SetForegroundColour(self.settings.get_setting('textcolor'))
+            top_frame.tree.Refresh()
+            top_frame.players.SetBackgroundColour(self.settings.get_setting('bgcolor'))
+            top_frame.players.SetForegroundColour(self.settings.get_setting('textcolor'))
+            top_frame.players.Refresh()
+        else:
+            top_frame.tree.SetBackgroundColour('white')
+            top_frame.tree.SetForegroundColour('black')
+            top_frame.tree.Refresh()
+            top_frame.players.SetBackgroundColour('white')
+            top_frame.players.SetForegroundColour('black')
+            top_frame.players.Refresh()
+
+    def font_ok(self, changes):
+        self.chat.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'), 
+                                                self.settings.get_setting('defaultfontsize'))
+        self.chat.InfoPost("Font is now " + 
+                            self.settings.get_setting('defaultfont') + " point size " + 
+                            self.settings.get_setting('defaultfontsize'))
+        self.chat.chatwnd.scroll_down()
+
+    def text_ok(self, changes):
+        self.chat.chatwnd.SetPage(self.chat.ResetPage())
+        self.chat.chatwnd.scroll_down()
+        if self.settings.get_setting('ColorTree') == '1':
+            top_frame.tree.SetBackgroundColour(self.settings.get_setting('bgcolor'))
+            top_frame.tree.SetForegroundColour(self.settings.get_setting('textcolor'))
+            top_frame.tree.Refresh()
+            top_frame.players.SetBackgroundColour(self.settings.get_setting('bgcolor'))
+            top_frame.players.SetForegroundColour(self.settings.get_setting('textcolor'))
+            top_frame.players.Refresh()
+        else:
+            top_frame.tree.SetBackgroundColour('white')
+            top_frame.tree.SetForegroundColour('black')
+            top_frame.tree.Refresh()
+            top_frame.players.SetBackgroundColour('white')
+            top_frame.players.SetForegroundColour('black')
+            top_frame.players.Refresh()
+
     def toggleToolBars(self, panel, changes):
         if changes[0] == 'AliasTool_On': panel.toggle_alias(changes[1])
         elif changes[0] == 'DiceButtons_On': panel.toggle_dice(changes[1])