class LimbDamageLabel(BlackEventBox): def __init__(self, limb_name): BlackEventBox.__init__(self) self.limb_name = limb_name self.title_label = FormattedLabel(limb_name) self.data_label = FormattedLabel("") self.damage = 0 self.hits_left = 0 self.confirmed_damage = 0 self.hits = 0 f = BlackFrame("") self.add(f) t = gtk.Table(rows=1, columns=3, homogeneous=True) f.add(t) t.attach(self.title_label, bottom_attach=1, top_attach=0, left_attach=0, right_attach=1) t.attach(self.data_label, bottom_attach=1, top_attach=0, left_attach=1, right_attach=3) self.update(self.damage, self.hits_left, self.confirmed_damage, self.hits) def update(self, damage, hits_left, confirmed_damage, hits): self.damage = damage self.hits_left = hits_left self.confirmed_damage = confirmed_damage t = {0: "Non", 0.33: "Hrt", 0.66: "Inj"} c = {0: ge.OFF_WHITE, 0.33: ge.YELLOW, 0.66: ge.ORANGE} self.data_label.set_text("%s: %d/%d %.2f" % (t[self.confirmed_damage], hits, hits_left, damage)) self.data_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(c[confirmed_damage]))
def __init__(self, label, color): BlackEventBox.__init__(self) self.label = FormattedLabel(label) self.color = color self.label.modify_font(pango.FontDescription("monospace 12")) self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(self.color)) self.add(self.label)
def __init__(self, max_value): BlackEventBox.__init__(self) self.l = FormattedLabel(0) self.l.modify_font(pango.FontDescription("monospace 12")) self.max_value = max_value self.add(self.l)
class ToggleLabel(BlackEventBox): def __init__(self, label, color): BlackEventBox.__init__(self) self.label = FormattedLabel(label) self.color = color self.label.modify_font(pango.FontDescription("monospace 12")) self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(self.color)) self.add(self.label) def set_state(self, state): if state: self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.BG_BLACK)) self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(self.color)) else: self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(self.color)) self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.BG_BLACK))
def __init__(self, limb_name): BlackEventBox.__init__(self) self.limb_name = limb_name self.title_label = FormattedLabel(limb_name) self.data_label = FormattedLabel("") self.damage = 0 self.hits_left = 0 self.confirmed_damage = 0 self.hits = 0 f = BlackFrame("") self.add(f) t = gtk.Table(rows=1, columns=3, homogeneous=True) f.add(t) t.attach(self.title_label, bottom_attach=1, top_attach=0, left_attach=0, right_attach=1) t.attach(self.data_label, bottom_attach=1, top_attach=0, left_attach=1, right_attach=3) self.update(self.damage, self.hits_left, self.confirmed_damage, self.hits)
class CountdownTimer(BlackEventBox): def __init__(self, max_value): BlackEventBox.__init__(self) self.l = FormattedLabel(0) self.l.modify_font(pango.FontDescription("monospace 12")) self.max_value = max_value self.add(self.l) def set_value(self, value): self.l.set_text("%0.2f" % value) if value > self.max_value: self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.RED)) self.l.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.OFF_WHITE)) else: self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.BG_BLACK)) if value == 0: self.l.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.OFF_WHITE)) elif value < 0.25 * self.max_value: self.l.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.GREEN)) elif value < 0.5 * self.max_value: self.l.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.YELLOW)) elif value < 0.75 * self.max_value: self.l.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.ORANGE)) else: self.l.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(ge.RED))