""" Some global variables. """ try: import wx except: print "* Warning: Failed to import wx in Global" import os import traceback RetromancerVersion = "0.23 (6/13/2009)" LogFile = None def Log(Message): global LogFile if not LogFile: LogFile = open("BootstrapLog.txt", "wb") LogFile.write(str(Message)) LogFile.write("\n") LogFile.flush() def LogException(): Message = traceback.format_exc() Log(Message) class Options: KeepRecentRecords = 10 KeepTopRecords = 20 class ImageHandlerClass: def __init__(self): self.Images = {} self.ThrobberImages = {} def HandleSpecialDelays(self, Stub, ImageList): if Stub == "Bronze": TempList = [] for X in range(20): TempList.append(ImageList[0]) TempList.extend(ImageList[1:]) return TempList if Stub == "Dot": TempList = [] for X in range(7): TempList.append(ImageList[0]) TempList.append(ImageList[1]) TempList.append(ImageList[2]) TempList.append(ImageList[3]) TempList.append(ImageList[3]) TempList.append(ImageList[2]) TempList.append(ImageList[1]) return TempList return ImageList # default def GetThrobberImages(self, Stub, CacheFlag = 1): if not self.ThrobberImages.has_key(Stub): ImageList = [] # Collect up to 20 animation frames, stopping on the first missing file: Stub = Stub.replace("/", os.sep) Stub = Stub.replace("\\", os.sep) for Index in range(1, 20): FilePath = os.path.join("Images", "%s.%s.png"%(Stub, Index)) if not os.path.exists(FilePath): break Image = wx.Bitmap(FilePath, wx.BITMAP_TYPE_ANY) ImageList.append(Image) ImageList = self.HandleSpecialDelays(Stub, ImageList) if not CacheFlag: return ImageList self.ThrobberImages[Stub] = ImageList return self.ThrobberImages[Stub] def GetImage(self, FileName): if not self.Images.has_key(FileName): self.Images[FileName] = wx.Bitmap(os.path.join("Images", FileName), wx.BITMAP_TYPE_ANY) return self.Images[FileName] #self.Images[FileName] = wx.Bitmap(os.path.join("Images", FileName), wx.BITMAP_TYPE_ANY) # Global dictionary of game info # (Type, Driver.lower()) -> GameInfo Games = {} def GetGame(GameType, DriverName): Key = (GameType, DriverName.lower()) Game = Games.get(Key, None) if not Game: Log("GAME NOT FOUND:%s"%str(Key)) for KnownKey in Games.keys(): Log(" Known: %s"%str(KnownKey)) return Game Config = None QGroup = None Metagame = None Player = None App = None UIMap = None