Mercurial > traipse_dev
view orpg/tools/orpg_sound.py @ 226:b29454610f36 beta
Traipse Beta 'OpenRPG' {100503-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)
Moved to Stable!
New Features:
New Namespace method with two new syntaxes
New Namespace Internal is context sensitive, always!
New Namespace External is 'as narrow as you make it'
New Namespace FutureCheck helps ensure you don't receive an incorrect node
New Namespace 2.0 documentation in the User Manual
New Namespace plugin, Allows Traipse users to use the Standard syntax !@ :: @!
New Mini Library with minis from Devin Knight
New PluginDB access for URL2Link plugin
New to Forms, they now show their content in Design Mode
New to Update Manager, checks Repo for updates on software start
New to Mini Lib node, change title in design mode
New to Game Tree, never lose a node, appends a number to the end of corrupted trees
New to Server GUI, Traipse Suite's Debug Console
New Warhammer PC Sheet
Updates:
Update to White Board layer, uses a pencil image for color button
Update to Grid Layer, uses a grid image for color button
Update to Chat Window, size of drop down menus
Update to default lobby message
Update to template Text node
Update to 4e PC Sheet node
Update to how display names are acquired
Update to Server, added some 'Pious' technology
Update to features node
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
Fix to Backgrounds not loading through remote loader
Fix to Node name errors
Fix to rolling dice in chat Whispers
Fix to Splitters Sizing issues
Fix to URL2Link plugin, modified regex compilation should remove memory leak
Fix to mapy.py, a roll back due to zoomed grid issues
Fix to whiteboard_handler, Circles work by you clicking the center of the circle
Fix to Servers parse_incoming_dom which was outdated and did not respect XML
Fix to a broken link in the server welcome message
Fix to InterParse and logger requiring traceback
Fix to Update Manager Status Bar
Fix to failed image and erroneous pop up
Fix to Mini Lib node that was preventing use
Fix to plugins that parce dice but did not call InterParse
Fix to nodes for name changing by double click
Fix to Game Tree, node ordering on drag and drop corrected
Fix to Game Tree, corrupted error message was not showing
Fix to Update Manager, checks for internet connection
Fix to Update Manager, Auto Update corrections
Fix to Server GUI's broadcast, room, player messaging
author | sirebral |
---|---|
date | Mon, 03 May 2010 03:29:14 -0500 |
parents | c54768cffbd4 |
children |
line wrap: on
line source
from orpg.orpgCore import * from orpg.orpg_wx import * class orpgSound(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, -1) self.parent = parent self.log = component.get("log") self.settings = component.get('settings') self.log.log("Enter orpgSound", ORPG_DEBUG) # Create some controls try: self.mc = wx.media.MediaCtrl(self, wx.ID_ANY, size=(1,1)) self.OldPlayer = False self.Bind(wx.media.EVT_MEDIA_LOADED, self.OnMediaLoaded) self.log.log("wx.media Used", ORPG_DEBUG) except NotImplementedError: self.OldPlayer = True self.log.log("Old Player Used", ORPG_DEBUG) else: btn2 = wx.Button(self, -1, "Play") self.Bind(wx.EVT_BUTTON, self.OnPlay, btn2) self.playBtn = btn2 self.playBtn.Disable() btn3 = wx.Button(self, -1, "stop") self.Bind(wx.EVT_BUTTON, self.OnStop, btn3) self.stopBtn = btn3 self.playList = wx.Choice(self, wx.ID_ANY) self.playDict = {} self.pslider = wx.Slider(self, wx.ID_ANY, 0, 0, 100, size=wx.Size(100, -1)) self.Bind(wx.EVT_SLIDER, self.onSeek, self.pslider) self.pos = wx.StaticText(self, wx.ID_ANY, "Position:") self.vol = wx.StaticText(self, wx.ID_ANY, "Volume:") self.vslider = wx.Slider(self, wx.ID_ANY, 100, 0, 100, size=wx.Size(50, -1)) self.Bind(wx.EVT_SLIDER, self.onVol, self.vslider) self.log.log("Buttons Created", ORPG_DEBUG) self.loopSound = False self.seeking = False self.lastlen = 0 # setup the layout sizer = wx.GridBagSizer(hgap=1, vgap=1) sizer.Add(self.mc, (0,20)) sizer.Add(self.playList, (0,0), span=(1,2)) sizer.Add(btn2, (0,2)) sizer.Add(btn3, (0,3)) sizer.Add(self.pos, (1,0), flag=wx.ALIGN_CENTER) sizer.Add(self.pslider, (1,1), flag=wx.EXPAND) sizer.Add(self.vol, (1,2), flag=wx.ALIGN_CENTER) sizer.Add(self.vslider, (1,3), flag=wx.EXPAND) sizer.AddGrowableCol(0) sizer.AddGrowableCol(3) sizer.SetEmptyCellSize((0,0)) self.SetSizer(sizer) self.SetAutoLayout(True) self.log.log("Sizer Set", ORPG_DEBUG) self.Fit() self.Bind(wx.EVT_CHOICE, self.PlaySelected, self.playList) self.Bind(wx.EVT_CLOSE, self.OnClose) self.timer = wx.Timer(self, wx.NewId()) self.Bind(wx.EVT_TIMER, self.OnTimer) self.timer.Start(100) self.log.log("Events Bound", ORPG_DEBUG) self.log.log("Exit orpgSound", ORPG_DEBUG) def play(self, sound_file, type="local", loop_sound=False): self.log.log("Enter orpgSound->play(self, sound_file, type, loop_sound)", ORPG_DEBUG) if self.OldPlayer: if wx.Platform == '__WXMSW__': import winsound self.play_windows(sound_file.replace('&', '&')) elif wx.Platform == '__WXGTK__': self.play_unix(sound_file.replace('&', '&')) else: self.loopSound = loop_sound self.LoadSound(sound_file.replace('&', '&'), type) self.log.log("Exit orpgSound->play(self, sound_file, type, loop_sound)", ORPG_DEBUG) def play_windows(self,sound_file): self.log.log("Enter orpgSound->play_windows(self,sound_file)", ORPG_DEBUG) winsound.PlaySound(sound_file, winsound.SND_FILENAME) self.log.log("Exit orpgSound->play_windows(self,sound_file)", ORPG_DEBUG) def play_unix(self, sound_file): self.log.log("Enter orpgSound->play_unix(self, sound_file)", ORPG_DEBUG) unix_player = self.settings.get_setting('UnixSoundPlayer') if unix_player != '': os.system(unix_player + " " + sound_file) self.log.log("Exit orpgSound->play_unix(self, sound_file)", ORPG_DEBUG) def onSeek(self, evt): self.log.log("Enter orpgSound->onSeek(self, evt)", ORPG_DEBUG) offset = self.pslider.GetValue() self.mc.Seek(offset) self.log.log("Exit orpgSound->onSeek(self, evt)", ORPG_DEBUG) def PlaySelected(self, evt): self.log.log("Enter orpgSound->PlaySelected(self, evt)", ORPG_DEBUG) name = self.playList.GetStringSelection() info = self.playDict[name] sound_file = info[0] pos = info[1] self.mc.LoadURI(sound_file) pane = self.parent._mgr.GetPane("Sound Control Toolbar") pane.window.SetInitialSize() pane.BestSize(pane.window.GetEffectiveMinSize() + (0, 1)) self.parent._mgr.Update() if pos > 0: self.seeking = True wx.CallAfter(self.mc.Pause) self.log.log("Exit orpgSound->PlaySelected(self, evt)", ORPG_DEBUG) def LoadSound(self, sound_file, type="local"): self.log.log("Enter orpgSound->LoadSound(self, sound_file, type)", ORPG_DEBUG) if self.mc.GetState() == wx.media.MEDIASTATE_PLAYING: pos = self.mc.Tell() len = self.mc.Length() self.mc.Stop() if (len-pos) <= 2000: pos = 0 pname = self.playList.GetStringSelection() self.playDict[pname][1] = pos (path, name) = os.path.split(sound_file) if type != "local": self.mc.LoadURI(sound_file) else: self.mc.Load(sound_file) if not self.playDict.has_key(name): self.playList.Append(name) pane = self.parent._mgr.GetPane("Sound Control Toolbar") pane.window.SetInitialSize() pane.BestSize(pane.window.GetEffectiveMinSize() + (0, 1)) self.parent._mgr.Update() self.playDict[name] = [sound_file, 0] self.playList.SetStringSelection(name) self.log.log("Exit orpgSound->LoadSound(self, sound_file, type)", ORPG_DEBUG) return def OnMediaLoaded(self, evt): self.log.log("Enter orpgSound->OnMediaLoaded(self, evt)", ORPG_DEBUG) self.mc.Play() self.playBtn.Enable() self.log.log("Exit orpgSound->OnMediaLoaded(self, evt)", ORPG_DEBUG) def OnPlay(self, evt): self.log.log("Enter orpgSound->OnPlay(self, evt)", ORPG_DEBUG) self.mc.Play() self.log.log("Exit orpgSound->OnPlay(self, evt)", ORPG_DEBUG) def OnStop(self, evt): self.log.log("Enter orpgSound->OnStop(self, evt)", ORPG_DEBUG) self.loopSound = False self.mc.Stop() self.log.log("Exit orpgSound->OnStop(self, evt)", ORPG_DEBUG) def OnClose(self, evt): self.log.log("Enter orpgSound->OnClose(self, evt)", ORPG_DEBUG) self.timer.Stop() del self.timer self.log.log("Exit orpgSound->OnClose(self, evt)", ORPG_DEBUG) def __del__(self): self.timer.Stop() def onVol(self, evt): self.log.log("Enter orpgSound->onVol(self, evt)", ORPG_DEBUG) vol = float(self.vslider.GetValue())/100 self.mc.SetVolume(vol) self.log.log("Exit orpgSound->onVol(self, evt)", ORPG_DEBUG) def OnTimer(self, args): if not self.OldPlayer: if self.mc.GetState() == wx.media.MEDIASTATE_PLAYING and not self.stopBtn.IsEnabled(): self.stopBtn.Enable() elif self.mc.GetState() != wx.media.MEDIASTATE_PLAYING and self.stopBtn.IsEnabled(): self.stopBtn.Disable() if self.mc.Length() > 0 and self.lastlen != self.mc.Length(): self.pslider.SetRange(0, self.mc.Length()) self.lastlen = self.mc.Length() if not self.seeking: self.pslider.SetValue(self.mc.Tell()) if self.mc.GetState() != wx.media.MEDIASTATE_PLAYING and self.loopSound: self.mc.Play() if self.seeking: name = self.playList.GetStringSelection() info = self.playDict[name] if self.mc.Tell() >= info[1]: self.seeking = False else: self.pslider.SetValue(info[1]) wx.CallAfter(self.onSeek, None) elif self.stopBtn.IsShown(): self.playBtn.Hide() self.stopBtn.Hide() return class SoundFrame(wx.Frame): def __init__(self, openrpg): wx.Frame.__init__(self, None, title="Sound Control Toolbar", style=wx.CAPTION | wx.SYSTEM_MENU | wx.STAY_ON_TOP) self.soundCtrl = orpgSound(self, openrpg) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.soundCtrl, 1, wx.EXPAND) self.SetSizer(sizer) self.SetSizer(sizer) self.SetAutoLayout(True) self.Fit() class BlankApp(wx.App): def OnInit(self): self.frame = SoundFrame() self.frame.Show() self.SetTopWindow(self.frame) return True def OnChar(self, event): #Not sure how to determin if only Tab or Shift Tab was used to initiate self.tabgroup.GoNext( self.frame1.FindFocus() ) if __name__ == "__main__": app = BlankApp(0) app.MainLoop()