""" A simple dialog to display "you must do XXX to open this door" """ import wx import JoyTracker import Config import UIUtils from Global import Log, LogException class MessageDialog(wx.Dialog, JoyTracker.JoyTracker): def __init__(self, Parent, Message, Title = "Retromancer", ProgressLevel = None, Color = None, *args, **kw): try: wx.Dialog.__init__(self, Parent, title = Title, style = wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS, *args, **kw) except: LogException() JoyTracker.JoyTracker.__init__(self) self.GaugeColor = Color if not self.GaugeColor: self.GaugeColor = "white" self.BackgroundColor = "black" self.ForegroundColor = "white" self.SetBackgroundColour(self.BackgroundColor) self.BigFont = wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL) self.BuildWidgets(Message, ProgressLevel) self.FocusGamepadState = self.GetRawGamepad() self.Timer = wx.CallLater(100, self.OnTimer) def OnTimer(self, *args, **kw): try: self.SetGamepad() if self.ButtonState[Config.KeyConfig.ButtonB] or self.ButtonState[Config.KeyConfig.ButtonA]: self.Destroy() if self.KeyState.get(wx.WXK_RETURN, 0) or self.KeyState.get(wx.WXK_NUMPAD_ENTER, 0): self.Destroy() self.Timer.Restart(25) except: LogException() def BuildWidgets(self, Message, ProgressLevel = None): self.MasterSizer = wx.BoxSizer(wx.VERTICAL) Text = wx.StaticText(self, -1, Message) Text.SetFont(self.BigFont) Text.SetForegroundColour(self.ForegroundColor) self.MasterSizer.Add(Text, 1, wx.BORDER | wx.LEFT | wx.RIGHT | wx.TOP, 15) Eater = UIUtils.KeyEater(self) self.MasterSizer.Add(Eater) if ProgressLevel != None: Gauge = wx.Gauge(self, -1, 100, style = wx.GA_SMOOTH) Gauge.SetBackgroundColour(self.BackgroundColor) Gauge.SetForegroundColour(self.GaugeColor) Gauge.SetValue(ProgressLevel) self.MasterSizer.Add(Gauge, 0, wx.BORDER | wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 10) ButtonSizer = wx.BoxSizer(wx.HORIZONTAL) OKButton = wx.Button(self, wx.ID_OK) OKButton.SetDefault() self.MasterSizer.Add(OKButton, 0, wx.BORDER | wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 10) self.SetSizer(self.MasterSizer) self.MasterSizer.Fit(self) self.SetAutoLayout(True) self.Layout()