## halo 3 spawn timer # author: Absinthe # revision: see exe name # for: (a)button, parent Liberi Gaming # copyright: Absinthe, (a)button, Liberi Gaming, 2008 # license: Open Source # MLG version accomodation mlg_version = 4 # File imports import os import wx import time class MainWindow(wx.Frame): '''MainWindow container class.''' # Used for message boxes about_message = " This application was made by Absinthe for abutton.net. When you click a map, a timer will be set" about_message += " for each power weapon. You'll be alerted whenever each timer reaches 0." about_message += " Email me@nilved.net if you require more assistance." # Used for timers active_timer = False def __init__(self,parent,id,title): '''Initializer for MainWindow.''' wx.Frame.__init__(self,parent,wx.ID_ANY, title, size = (423,95),) # Set some GUI aspects self.SetBackgroundColour("white") self.Centre() # Create the map buttons. self.button_cstruct = wx.Button(self, id=-1, label="Construct", pos=(5, 5), size=(75, 20)) self.button_cstruct.Bind(wx.EVT_BUTTON, self.Construct) self.button_guardian = wx.Button(self, id=-1, label="Guardian", pos=(85, 5), size=(75, 20)) self.button_guardian.Bind(wx.EVT_BUTTON, self.Guardian) self.button_pit = wx.Button(self, id=-1, label="The Pit", pos=(165, 5), size=(75, 20)) self.button_pit.Bind(wx.EVT_BUTTON, self.Pit) self.button_ons = wx.Button(self, id=-1, label="Onslaught", pos=(245, 5), size=(75, 20)) self.button_ons.Bind(wx.EVT_BUTTON, self.Onslaught) self.button_narrows = wx.Button(self, id=-1, label="Narrows", pos=(325, 5), size=(75, 20)) self.button_narrows.Bind(wx.EVT_BUTTON, self.Narrows) # Create a close button self.button_close = wx.Button(self, id=-1, label="Close", pos=(325, 30), size=(75, 20)) self.button_close.Bind(wx.EVT_BUTTON, self.EndApp) # Create an About button. self.button_about = wx.Button(self, id=-1, label="About", pos=(245, 30), size=(75, 20)) self.button_about.Bind(wx.EVT_BUTTON, self.OnAbout) # Create the panel for the description. self.description = wx.Panel(self, -1, (5, 30), (224, 20)) self.description.SetBackgroundColour("white") self.dtext = wx.StaticText(self.description, -1, "Choose a map...", (4,3), (314,30)) # Finish up self.Show(True) def Construct(self,e): '''Map function for Construct.''' self.SetTimers() self.button_cstruct.Disable() self.button_guardian.Enable() self.button_pit.Enable() self.button_ons.Enable() self.button_narrows.Enable() self.EndAllTimers() self.ChangeDescription() def Guardian(self,e): '''Map function for Guardian.''' self.SetTimers() self.button_cstruct.Enable() self.button_guardian.Disable() self.button_pit.Enable() self.button_ons.Enable() self.button_narrows.Enable() self.EndAllTimers() self.ChangeDescription() def Pit(self,e): '''Map function for The Pit.''' self.SetTimers() self.button_cstruct.Enable() self.button_guardian.Enable() self.button_pit.Disable() self.button_ons.Enable() self.button_narrows.Enable() self.EndAllTimers() self.ChangeDescription() def Onslaught(self,e): '''Map function for Onslaught.''' self.SetTimers() self.button_cstruct.Enable() self.button_guardian.Enable() self.button_pit.Enable() self.button_ons.Disable() self.button_narrows.Enable() self.EndAllTimers() self.ChangeDescription() def Narrows(self,e): '''Map function for Narrows.''' self.SetTimers(1) self.button_cstruct.Enable() self.button_guardian.Enable() self.button_pit.Enable() self.button_ons.Enable() self.button_narrows.Disable() self.EndAllTimers() self.ChangeDescription() def EndApp(self,e): '''Close the application.''' if self.active_timer != False: self.EndAllTimers() self.Close(True) def OnAbout(self,e): '''Display an about dialog.''' self.Alert(self.about_message, wx.ICON_QUESTION) def ChangeDescription(self, msg=False): if not msg: self.dtext = wx.StaticText(self.description, -1, "You'll be alerted when a weapon respawns.", (4,3), (314,30)) else: self.dtext = wx.StaticText(self.description, -1, msg, (4,3), (314,30)) def SetTimers(self, is_narrows=False, start_timers=True): '''Sets self.active_timers.''' if is_narrows: self.active_timer = { "sniper": (100*60*2) * 1000, "mauler": (100*60*3)+(100*4) * 1000, "rockets": (100*60*3)+(100*4) * 1000, } else: self.active_timer = { "sniper": (100*60*2)+(100*34) * 100, "mauler": (100*60*3)+(100*4) * 100, "rockets": (100*60*3)+(100*4) * 100, } if start_timers: self.timer_sniper = UpdateTimer(self.Alert_Sniper) self.timer_sniper.Start(self.active_timer['sniper']) self.timer_mauler = UpdateTimer(self.Alert_Mauler) self.timer_mauler.Start(self.active_timer['mauler']) self.timer_rockets = UpdateTimer(self.Alert_Rockets) self.timer_rockets.Start(self.active_timer['rockets']) def EndAllTimers(self): self.timer_sniper.Destroy() self.timer_mauler.Destroy() self.timer_rockets.Destroy() def Alert(self, msg, style=wx.ICON_EXCLAMATION): '''Prints a visible message to the user.''' title = "[%s] NOTICE" % time.strftime("%M:%S") dialog = wx.MessageDialog(self, msg, title, wx.OK|style) dialog.ShowModal() dialog.Destroy() def Alert_Sniper(self): self.Alert("The sniper rifle has respawned!") def Alert_Mauler(self): self.Alert("The mauler has respawned!") def Alert_Rockets(self): self.Alert("The rockets have respawned!") def Alert_Dummy(self): self.Alert("Dummy!") class UpdateTimer(wx.Timer): def __init__(self, cb): wx.Timer.__init__(self) self.cb = cb def Notify(self): self.cb() app = wx.PySimpleApp() frame = MainWindow(None, -1, "Halo 3 Spawn Timer (For MLG v%s)" % mlg_version) app.MainLoop()