comparison plugins/xxgsc.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 4385a7d0efd1
children
comparison
equal deleted inserted replaced
182:4b2884f29a72 195:b633f4c64aae
1 import os 1 import os, wx
2 from orpg.orpg_wx import *
3 import random 2 import random
4 import orpg.pluginhandler 3 import orpg.pluginhandler
5
6 4
7 ID_ROLL = wx.NewId() 5 ID_ROLL = wx.NewId()
8 6
9 class Plugin(orpg.pluginhandler.PluginHandler): 7 class Plugin(orpg.pluginhandler.PluginHandler):
10 # Initialization subroutine. 8 # Initialization subroutine.
13 # !chat : instance of the chat window to write to 11 # !chat : instance of the chat window to write to
14 def __init__(self, plugindb, parent): 12 def __init__(self, plugindb, parent):
15 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent) 13 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
16 14
17 self.name = 'Game Status Controller' 15 self.name = 'Game Status Controller'
18 self.author = 'Woody, updated by mDuo13' 16 self.author = 'Woody, updated by mDuo13 and Calchexas'
19 self.help = 'This plugin lets you quickly and easily manage a status that includes \n' 17 self.help = 'This plugin lets you quickly and easily manage a status that includes \n'
20 self.help += 'your HP and AC for AD&D 2nd Edition. Type /gsc to open up the manager\n' 18 self.help += 'your HP and AC for AD&D 2nd Edition. Type /gsc to open up the manager\n'
21 self.help += 'window, and from there just change the values as necessary and the changes\n' 19 self.help += 'window, and from there just change the values as necessary and the changes\n'
22 self.help += 'will be reflected in your status. To revert to your regular status, close\n' 20 self.help += 'will be reflected in your status. To revert to your regular status, close\n'
23 self.help += 'the GSC window.' 21 self.help += 'the GSC window.'
24 22
25 self.frame = None 23 self.frame = None
26 24
27 def plugin_enabled(self): 25 def plugin_enabled(self):
28 self.plugin_addcommand('/gsc', self.on_gsc, '- The GSC command') 26 self.plugin_addcommand('/gsc', self.on_gsc, '- The GSC command')
29 self.frame = RollerFrame(None, -1, "Game Status Ctrl (GSC)", self) 27 self.frame = RollerFrame(None, -1, "Game Status Controller (GSC)", self)
30 self.frame.Hide() 28 self.frame.Hide()
31 29
32 item = wx.MenuItem(self.menu, wx.ID_ANY, "GSC Window", "GSC Window", wx.ITEM_CHECK) 30 def plugin_menu(self):
33 self.topframe.Bind(wx.EVT_MENU, self._toggleWindow, item) 31 self.menu = wx.Menu()
34 self.menu.AppendItem(item) 32 self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'GSC Window')
33 self.topframe.Bind(wx.EVT_MENU, self._toggleWindow, self.toggle)
34 self.toggle.Check(False)
35 35
36 def plugin_disabled(self): 36 def plugin_disabled(self):
37 self.plugin_removecmd('/gsc') 37 self.plugin_removecmd('/gsc')
38 try: 38 try:
39 self.frame.TimeToQuit(1) 39 self.frame.TimeToQuit(1)
46 self.frame.Show() 46 self.frame.Show()
47 self.frame.Raise() 47 self.frame.Raise()
48 48
49 #Events 49 #Events
50 def _toggleWindow(self, evt): 50 def _toggleWindow(self, evt):
51 id = evt.GetId()
52 item = self.menu.FindItemById(id)
53 if self.frame.IsShown(): 51 if self.frame.IsShown():
54 self.frame.Hide() 52 self.frame.Hide()
55 item.Check(False) 53 self.toggle.Check(False)
56 else: 54 else:
57 self.frame.Show() 55 self.frame.Show()
58 item.Check(True) 56 self.toggle.Check(True)
59 57
60 58
61 class RollerFrame(wx.Frame): 59 class RollerFrame(wx.Frame):
62 def __init__(self, parent, ID, title, plugin): 60 def __init__(self, parent, ID, title, plugin):
63 wx.Frame.__init__(self, parent, ID, title, 61 wx.Frame.__init__(self, parent, ID, title,
64 wx.DefaultPosition, wx.Size(200, 70)) 62 wx.DefaultPosition, wx.Size(250, 110))
65 63
66 self.settings = plugin.settings 64 self.settings = plugin.settings
67 self.session = plugin.session 65 self.session = plugin.session
68 self.plugin = plugin 66 self.plugin = plugin
69 67
70 self.panel = wx.Panel(self,-1) 68 self.panel = wx.Panel(self,-1)
69 sizer = wx.GridBagSizer(1, 2)
70 self.panel.SetSizer(sizer)
71 menu = wx.Menu() 71 menu = wx.Menu()
72 menu.AppendSeparator() 72 menu.AppendSeparator()
73 menu.Append(wx.ID_EXIT, "&Close", "Close this window") 73 menu.Append(wx.ID_EXIT, "&Close", "Close this window")
74 menuBar = wx.MenuBar() 74 menuBar = wx.MenuBar()
75 menuBar.Append(menu, "&File"); 75 menuBar.Append(menu, "&File");
76 self.SetMenuBar(menuBar) 76 self.SetMenuBar(menuBar)
77 77
78 self.old_idle = self.settings.get_setting('IdleStatusAlias') 78 self.old_idle = self.settings.get_setting('IdleStatusAlias')
79 79
80 wx.StaticText(self.panel, -1, "AC:", wx.Point(0, 5)) 80 ac_text = wx.StaticText(self.panel, -1, "AC:", wx.Point(0, 5))
81 self.ac = wx.SpinCtrl(self.panel, ID_ROLL, "", wx.Point(18, 0), wx.Size(45, -1), min = -100, max = 100, initial = 10) 81 self.ac = wx.SpinCtrl(self.panel, ID_ROLL, "",
82 wx.Point(18, 0), wx.Size(45, -1), min = -100, max = 100, initial = 10)
82 self.ac.SetValue(10) 83 self.ac.SetValue(10)
83 84
84 wx.StaticText(self.panel, -1, "/", wx.Point(136, 5)) 85 touch_text = wx.StaticText(self.panel, -1, "Touch:", wx.Point(0, 25))
85 self.max_hp = wx.SpinCtrl(self.panel, ID_ROLL, "", wx.Point(144, 0), wx.Size(48, -1), min = -999, max = 999, initial = 10) 86 self.touch = wx.SpinCtrl(self.panel, ID_ROLL, "",
87 wx.Point(60, 25), wx.Size(45, -1), min = -100, max = 100, initial = 10)
88 self.touch.SetValue(10)
89
90 ff_text = wx.StaticText(self.panel, -1, "FF:", wx.Point(115, 25))
91 self.ff = wx.SpinCtrl(self.panel, ID_ROLL, "",
92 wx.Point(165, 25), wx.Size(45, -1), min = -100, max = 100, initial = 10)
93 self.ff.SetValue(10)
94
95 max_hp_text = wx.StaticText(self.panel, -1, "/", wx.Point(150, 5))
96 self.max_hp = wx.SpinCtrl(self.panel, ID_ROLL, "",
97 wx.Point(158, 0), wx.Size(48, -1), min = -999, max = 999, initial = 10)
86 self.max_hp.SetValue(10) 98 self.max_hp.SetValue(10)
87 99
88 wx.StaticText(self.panel, -1, "HP:", wx.Point(65, 5)) 100 hp_text = wx.StaticText(self.panel, -1, "HP:", wx.Point(80, 5))
89 self.hp = wx.SpinCtrl(self.panel, ID_ROLL, "", wx.Point(83, 0), wx.Size(48, -1), min = -999, max = 999, initial = 10) 101 self.hp = wx.SpinCtrl(self.panel, ID_ROLL, "",
102 wx.Point(98, 0), wx.Size(48, -1), min = -999, max = 999, initial = 10)
90 self.hp.SetValue(10) 103 self.hp.SetValue(10)
91 104
105 sizer.Add(ac_text, (1,0), span=(1,1))
106 sizer.Add(self.ac, (1,1), span=(1,1))
107 sizer.Add(touch_text, (1,2), span=(1,1))
108 sizer.Add(self.touch, (1,3), span=(1,1))
109 sizer.Add(ff_text, (1,4), span=(1,1))
110 sizer.Add(self.ff, (1,5), span=(1,1))
111 sizer.Add(hp_text, (0,0), span=(1,1))
112 sizer.Add(self.hp, (0,1), span=(1,1))
113 sizer.Add(max_hp_text, (0,2), span=(1,1))
114 sizer.Add(self.max_hp, (0,3), span=(1,1))
115 self.SetMinSize((350,100))
92 self.Bind(wx.EVT_SPINCTRL, self.SetStatus, id=ID_ROLL) 116 self.Bind(wx.EVT_SPINCTRL, self.SetStatus, id=ID_ROLL)
93 self.Bind(wx.EVT_TEXT, self.SetStatus, id=ID_ROLL) 117 self.Bind(wx.EVT_TEXT, self.SetStatus, id=ID_ROLL)
94 self.Bind(wx.EVT_MENU, self.TimeToQuit, id=wx.ID_EXIT) 118 self.Bind(wx.EVT_MENU, self.TimeToQuit, id=wx.ID_EXIT)
95 self.Bind(wx.EVT_CLOSE, self._close) 119 self.Bind(wx.EVT_CLOSE, self._close)
96 self.SetStatus(None) 120 self.SetStatus(None)
97 121
98 def SetStatus(self, evt): 122 def SetStatus(self, evt):
99 new_status = "AC: " + str(self.ac.GetValue()) + " HP: " + str(self.hp.GetValue()) + "/" + str(self.max_hp.GetValue()) 123 new_status = "AC: " + str(self.ac.GetValue()) + " (Touch: " + str(self.touch.GetValue()) + " FF: " + str(self.ff.GetValue()) + ")" + " HP: " + str(self.hp.GetValue()) + "/" + str(self.max_hp.GetValue())
100 self.settings.set_setting('IdleStatusAlias',new_status) 124 self.settings.set_setting('IdleStatusAlias',new_status)
101 self.session.set_text_status(new_status) 125 self.session.set_text_status(new_status)
102 126
103 def TimeToQuit(self, event): 127 def TimeToQuit(self, event):
104 self.settings.set_setting('IdleStatusAlias',self.old_idle) 128 self.settings.set_setting('IdleStatusAlias',self.old_idle)