示例#1
0
    def populatePanel(self, contentPanel, headerPanel):

        contentSizer = contentPanel.GetSizer()
        root = wx.BoxSizer(wx.VERTICAL)
        contentSizer.Add(root, 0, wx.EXPAND, 0)

        sizer = wx.GridSizer(1, 4)
        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

        #Turrets & launcher hardslots display
        tooltipText = {
            "turret": "Turret hardpoints",
            "launcher": "Launcher hardpoints",
            "drones": "Drones active",
            "calibration": "Calibration"
        }
        for type in ("turret", "launcher", "drones", "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',
                '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)

        #PG, Cpu & drone stuff
        tooltipText = {
            "cpu": "CPU",
            "pg": "PowerGrid",
            "droneBay": "Drone bay",
            "droneBandwidth": "Drone bandwidth",
            "cargoBay": "Cargo bay"
        }
        for i, group in enumerate(
            (("cpu", "pg"), ("cargoBay", "droneBay", "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.EXPAND)

                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": u" m\u00B3",
                    "cargoBay": u" m\u00B3"
                }
                lbl = wx.StaticText(parent, wx.ID_ANY, "%s" % units[type])
                absolute.Add(lbl, 0, wx.ALIGN_LEFT)

                # Gauges modif. - Darriele

                gauge = PG.PyGauge(parent, wx.ID_ANY, 1)
                gauge.SetValueRange(0, 0)
                gauge.SetMinSize((self.getTextExtentW("1.999M/1.99M 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.toggleCargoGauge(False)
示例#2
0
    def populatePanel(self, contentPanel, headerPanel):
        contentSizer = contentPanel.GetSizer()
        self.panel = contentPanel

        self.headerPanel = headerPanel
        # Custom header  EHP
        headerContentSizer = wx.BoxSizer(wx.HORIZONTAL)
        hsizer = headerPanel.GetSizer()
        hsizer.Add(headerContentSizer, 0, 0, 0)
        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 xrange(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

            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 = PG.PyGauge(contentPanel, wx.ID_ANY, 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"))
示例#3
0
    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.AddSpacer((0, 0), 1, wx.EXPAND, 5)
        #Turrets & launcher hardslots display
        tooltipText = {
            "turret": _("StatsViews_resources_Turret hardpoints"),
            "launcher": _("StatsViews_resources_Launcher hardpoints"),
            "drones": _("StatsViews_resources_Drones active"),
            "fighter": _("StatsViews_resources_Fighter squadrons active"),
            "calibration": _("StatsViews_resources_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.AddSpacer((0, 0), 1, wx.EXPAND, 5)

        #PG, Cpu & drone stuff
        tooltipText = {
            "cpu": _("StatsViews_resources_CPU"),
            "pg": _("StatsViews_resources_PowerGrid"),
            "droneBay": _("StatsViews_resources_Drone bay"),
            "fighterBay": _("StatsViews_resources_Fighter bay"),
            "droneBandwidth": _("StatsViews_resources_Drone bandwidth"),
            "cargoBay": _("StatsViews_resources_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.EXPAND)

                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": u" m\u00B3",
                    "fighterBay": u" m\u00B3",
                    "cargoBay": u" m\u00B3"
                }
                lbl = wx.StaticText(parent, wx.ID_ANY, "%s" % units[type])
                absolute.Add(lbl, 0, wx.ALIGN_LEFT)

                # Gauges modif. - Darriele

                gauge = PG.PyGauge(parent, wx.ID_ANY, 1)
                gauge.SetValueRange(0, 0)
                gauge.SetMinSize((self.getTextExtentW("1.999M/1.99M 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")