def populatePanel(self, contentPanel, headerPanel): contentSizer = contentPanel.GetSizer() self.panel = contentPanel self.headerPanel = headerPanel # Custom header EHP headerContentSizer = self.headerPanel.Parent.GetHeaderContentSizer() self.stEff = wx.StaticText(headerPanel, wx.ID_ANY, "( Effective HP: ") headerContentSizer.Add(self.stEff) headerPanel.GetParent().AddToggleItem(self.stEff) self.labelEhp = wx.StaticText(headerPanel, wx.ID_ANY, "0") headerContentSizer.Add(self.labelEhp, 0) headerPanel.GetParent().AddToggleItem(self.labelEhp) stCls = wx.StaticText(headerPanel, wx.ID_ANY, " )") headerPanel.GetParent().AddToggleItem(stCls) headerContentSizer.Add(stCls) # headerContentSizer.Add(wx.StaticLine(headerPanel, wx.ID_ANY), 1, wx.ALIGN_CENTER) # Display table col = 0 row = 0 sizerResistances = wx.GridBagSizer() contentSizer.Add(sizerResistances, 0, wx.EXPAND, 0) # Add an empty label, then the rest. sizerResistances.Add(wx.StaticText(contentPanel, wx.ID_ANY), wx.GBPosition(row, col), wx.GBSpan(1, 1)) col += 1 toolTipText = { "em": "Electromagnetic resistance", "thermal": "Thermal resistance", "kinetic": "Kinetic resistance", "explosive": "Explosive resistance" } for damageType in ("em", "thermal", "kinetic", "explosive"): bitmap = BitmapLoader.getStaticBitmap("%s_big" % damageType, contentPanel, "gui") tooltip = wx.ToolTip(toolTipText[damageType]) bitmap.SetToolTip(tooltip) sizerResistances.Add(bitmap, wx.GBPosition(row, col), wx.GBSpan(1, 1), wx.ALIGN_CENTER) col += 1 self.stEHPs = wx.Button(contentPanel, style=wx.BU_EXACTFIT, label="EHP") self.stEHPs.SetToolTip( wx.ToolTip("Click to toggle between effective HP and raw HP")) self.stEHPs.Bind(wx.EVT_BUTTON, self.toggleEHP) for i in range(4): sizerResistances.AddGrowableCol(i + 1) sizerResistances.Add(self.stEHPs, wx.GBPosition(row, col), wx.GBSpan(1, 1), wx.ALIGN_CENTER) col = 0 row += 1 gaugeColours = (((38, 133, 198), (52, 86, 98)), ((198, 38, 38), (83, 65, 67)), ((163, 163, 163), (74, 90, 93)), ((198, 133, 38), (81, 83, 67))) toolTipText = { "shield": "Shield resistance", "armor": "Armor resistance", "hull": "Hull resistance", "damagePattern": "Incoming damage pattern" } for tankType in ("shield", "armor", "hull", "separator", "damagePattern"): if tankType != "separator": bitmap = BitmapLoader.getStaticBitmap("%s_big" % tankType, contentPanel, "gui") tooltip = wx.ToolTip(toolTipText[tankType]) bitmap.SetToolTip(tooltip) sizerResistances.Add(bitmap, wx.GBPosition(row, col), wx.GBSpan(1, 1), wx.ALIGN_CENTER) col += 1 else: sizerResistances.Add(wx.StaticLine(contentPanel, wx.ID_ANY), wx.GBPosition(row, col), wx.GBSpan(1, 6), wx.EXPAND | wx.ALIGN_CENTER) row += 1 col = 0 continue currGColour = 0 font = wx.Font(fonts.NORMAL, wx.SWISS, wx.NORMAL, wx.NORMAL, False) for damageType in ("em", "thermal", "kinetic", "explosive"): box = wx.BoxSizer(wx.HORIZONTAL) sizerResistances.Add(box, wx.GBPosition(row, col), wx.GBSpan(1, 1), wx.ALIGN_CENTER) # Fancy gauges addon pgColour = gaugeColours[currGColour] fc = pgColour[0] bc = pgColour[1] currGColour += 1 lbl = PyGauge(contentPanel, font, 100) lbl.SetMinSize((48, 16)) lbl.SetBackgroundColour(wx.Colour(bc[0], bc[1], bc[2])) lbl.SetBarColour(wx.Colour(fc[0], fc[1], fc[2])) lbl.SetBarGradient() lbl.SetFractionDigits(1) setattr( self, "gaugeResistance%s%s" % (tankType.capitalize(), damageType.capitalize()), lbl) box.Add(lbl, 0, wx.ALIGN_CENTER) col += 1 box = wx.BoxSizer(wx.VERTICAL) box.SetMinSize(wx.Size(self.getTextExtentW("WWWWk"), -1)) lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0" if tankType != "damagePattern" else "") box.Add(lbl, 0, wx.ALIGN_CENTER) setattr(self, "labelResistance%sEhp" % tankType.capitalize(), lbl) sizerResistances.Add(box, wx.GBPosition(row, col), wx.GBSpan(1, 1), wx.ALIGN_CENTER) row += 1 col = 0 self.stEHPs.SetToolTip( wx.ToolTip("Click to toggle between effective HP and raw HP"))
def populatePanel(self, contentPanel, headerPanel): contentSizer = contentPanel.GetSizer() root = wx.BoxSizer(wx.VERTICAL) contentSizer.Add(root, 0, wx.EXPAND, 0) sizer = wx.BoxSizer(wx.HORIZONTAL) root.Add(sizer, 0, wx.EXPAND) root.Add(wx.StaticLine(contentPanel, wx.ID_ANY, style=wx.HORIZONTAL), 0, wx.EXPAND) sizerResources = wx.BoxSizer(wx.HORIZONTAL) root.Add(sizerResources, 1, wx.EXPAND, 0) parent = self.panel = contentPanel self.headerPanel = headerPanel panel = "full" base = sizerResources sizer.AddStretchSpacer() # Turrets & launcher hardslots display tooltipText = { "turret": "Turret hardpoints", "launcher": "Launcher hardpoints", "drones": "Drones active", "fighter": "Fighter squadrons active", "calibration": "Calibration" } for type_ in ("turret", "launcher", "drones", "fighter", "calibration"): box = wx.BoxSizer(wx.HORIZONTAL) bitmap = BitmapLoader.getStaticBitmap("%s_big" % type_, parent, "gui") tooltip = wx.ToolTip(tooltipText[type_]) bitmap.SetToolTip(tooltip) box.Add(bitmap, 0, wx.ALIGN_CENTER) sizer.Add(box, 0, wx.ALIGN_CENTER) suffix = { 'turret': 'Hardpoints', 'launcher': 'Hardpoints', 'drones': 'Active', 'fighter': 'Tubes', 'calibration': 'Points' } lbl = wx.StaticText(parent, wx.ID_ANY, "0") setattr( self, "label%sUsed%s%s" % (panel.capitalize(), type_.capitalize(), suffix[type_].capitalize()), lbl) box.Add(lbl, 0, wx.ALIGN_CENTER | wx.LEFT, 5) box.Add(wx.StaticText(parent, wx.ID_ANY, "/"), 0, wx.ALIGN_CENTER) lbl = wx.StaticText(parent, wx.ID_ANY, "0") setattr( self, "label%sTotal%s%s" % (panel.capitalize(), type_.capitalize(), suffix[type_].capitalize()), lbl) box.Add(lbl, 0, wx.ALIGN_CENTER) setattr(self, "boxSizer{}".format(type_.capitalize()), box) # Hack - We add a spacer after each thing, but we are always hiding something. The spacer is stil there. # This way, we only have one space after the drones/fighters if type_ != "drones": sizer.AddStretchSpacer() gauge_font = wx.Font(fonts.NORMAL, wx.SWISS, wx.NORMAL, wx.NORMAL, False) # PG, Cpu & drone stuff tooltipText = { "cpu": "CPU", "pg": "PowerGrid", "droneBay": "Drone bay", "fighterBay": "Fighter bay", "droneBandwidth": "Drone bandwidth", "cargoBay": "Cargo bay" } for i, group in enumerate( (("cpu", "pg"), ("cargoBay", "droneBay", "fighterBay", "droneBandwidth"))): main = wx.BoxSizer(wx.VERTICAL) base.Add(main, 1, wx.ALIGN_CENTER) for type_ in group: capitalizedType = type_[0].capitalize() + type_[1:] bitmap = BitmapLoader.getStaticBitmap(type_ + "_big", parent, "gui") tooltip = wx.ToolTip(tooltipText[type_]) bitmap.SetToolTip(tooltip) stats = wx.BoxSizer(wx.VERTICAL) absolute = wx.BoxSizer(wx.HORIZONTAL) stats.Add(absolute, 0, wx.ALIGN_CENTER_HORIZONTAL) b = wx.BoxSizer(wx.HORIZONTAL) main.Add(b, 1, wx.ALIGN_CENTER) b.Add(bitmap, 0, wx.ALIGN_BOTTOM) b.Add(stats, 1, wx.EXPAND) lbl = wx.StaticText(parent, wx.ID_ANY, "0") setattr( self, "label%sUsed%s" % (panel.capitalize(), capitalizedType), lbl) absolute.Add(lbl, 0, wx.ALIGN_LEFT | wx.LEFT, 3) absolute.Add(wx.StaticText(parent, wx.ID_ANY, "/"), 0, wx.ALIGN_LEFT) lbl = wx.StaticText(parent, wx.ID_ANY, "0") setattr( self, "label%sTotal%s" % (panel.capitalize(), capitalizedType), lbl) absolute.Add(lbl, 0, wx.ALIGN_LEFT) units = { "cpu": " tf", "pg": " MW", "droneBandwidth": " mbit/s", "droneBay": " m\u00B3", "fighterBay": " m\u00B3", "cargoBay": " m\u00B3" } lbl = wx.StaticText(parent, wx.ID_ANY, "%s" % units[type_]) absolute.Add(lbl, 0, wx.ALIGN_LEFT) # Gauges modif. - Darriele gauge = PyGauge(parent, gauge_font, 1) gauge.SetValueRange(0, 0) gauge.SetMinSize( (self.getTextExtentW("1.999M / 1.999M MW"), 23)) gauge.SetFractionDigits(2) setattr(self, "gauge%s%s" % (panel.capitalize(), capitalizedType), gauge) stats.Add(gauge, 0, wx.ALIGN_CENTER) setattr(self, "base%s%s" % (panel.capitalize(), capitalizedType), b) setattr(self, "bitmap%s%s" % (panel.capitalize(), capitalizedType), bitmap) self.toggleContext("drone")