示例#1
0
 def find_fillcolor(self):
     terrain = self.battlehex.terrain
     color = colors.battle_terrain_colors.get(
         (terrain, self.battlehex.elevation), None)
     if not color:
         color = colors.battle_terrain_colors.get(terrain)
     return guiutils.rgb_to_float(colors.rgb_colors[color])
示例#2
0
 def find_fillcolor(self):
     terrain = self.battlehex.terrain
     color = colors.battle_terrain_colors.get((terrain,
                                               self.battlehex.elevation),
                                              None)
     if not color:
         color = colors.battle_terrain_colors.get(terrain)
     return guiutils.rgb_to_float(colors.rgb_colors[color])
示例#3
0
    def __init__(self,
                 creature,
                 playercolor,
                 scale=15,
                 dead=False,
                 rotate=0,
                 outlined=False,
                 name=None):
        self.creature = creature
        if creature is None:
            if name is None:
                self.name = "QuestionMark"
            else:
                self.name = name
        else:
            self.name = creature.name
        self.dead = dead
        # Convert from degrees to radians, and from GTK rotation direction
        # to Cairo.
        self.rotate = -rotate * math.pi / 180
        self.outlined = outlined
        self.location = None  # (x, y) of top left corner
        self.chit_scale = CHIT_SCALE_FACTOR * scale

        if creature and creature.name in ["Titan", "Angel"]:
            self.bases = [self.name + playercolor]
        else:
            self.bases = [self.name]
        if creature:
            color_name = creature.color_name
            if creature.flies and creature.rangestrikes:
                self.bases.append("FlyingRangestrikeBase")
            elif creature.flies:
                self.bases.append("FlyingBase")
            elif creature.rangestrikes:
                self.bases.append("RangestrikeBase")
        else:
            color_name = "black"
        if color_name == "by_player":
            color_name = "titan_%s" % playercolor.lower()
        self.rgb = guiutils.rgb_to_float(colors.rgb_colors[color_name])

        self.paths = [
            fileutils.basedir("images/%s/%s.png" % (self.IMAGE_DIR, base))
            for base in self.bases
        ]

        self.event_box = gtk.EventBox()
        self.event_box.chit = self
        self.image = gtk.Image()
        self.event_box.add(self.image)
        self.build_image()
示例#4
0
    def __init__(self, creature, playercolor, scale=15, dead=False,
                 rotate=0, outlined=False, name=None):
        self.creature = creature
        if creature is None:
            if name is None:
                self.name = "QuestionMark"
            else:
                self.name = name
        else:
            self.name = creature.name
        self.dead = dead
        # Convert from degrees to radians, and from GTK rotation direction
        # to Cairo.
        self.rotate = -rotate * math.pi / 180
        self.outlined = outlined
        self.location = None    # (x, y) of top left corner
        self.chit_scale = CHIT_SCALE_FACTOR * scale

        if creature and creature.name in ["Titan", "Angel"]:
            self.bases = [self.name + playercolor]
        else:
            self.bases = [self.name]
        if creature:
            color_name = creature.color_name
            if creature.flies and creature.rangestrikes:
                self.bases.append("FlyingRangestrikeBase")
            elif creature.flies:
                self.bases.append("FlyingBase")
            elif creature.rangestrikes:
                self.bases.append("RangestrikeBase")
        else:
            color_name = "black"
        if color_name == "by_player":
            color_name = "titan_%s" % playercolor.lower()
        self.rgb = guiutils.rgb_to_float(colors.rgb_colors[color_name])

        self.paths = [fileutils.basedir("images/%s/%s.png" %
                      (self.IMAGE_DIR, base)) for base in self.bases]

        self.event_box = Gtk.EventBox()
        self.event_box.chit = self
        self.image = Gtk.Image()
        self.event_box.add(self.image)
        self.build_image()
示例#5
0
    def __init__(self, masterhex, guiboard):
        self.masterhex = masterhex
        self.guiboard = guiboard
        scale = self.guiboard.scale
        self.cx = masterhex.x * 4 * scale
        self.cy = masterhex.y * 4 * SQRT3 * scale
        if not masterhex.inverted:
            self.cy += SQRT3 * scale
        self.fillcolor = guiutils.rgb_to_float(
            colors.rgb_colors[colors.terrain_colors[self.masterhex.terrain]])
        self.center = (self.cx + 3 * scale, self.cy + 1.5 * SQRT3 * scale)
        self.selected = False

        self.init_vertexes()
        self.init_gates()
        iv = guiutils.scale_polygon(self.vertexes, 0.7)
        self.inner_vertexes = []
        for point in iv:
            self.inner_vertexes.append(rp(point))
        self.init_overlay()
示例#6
0
    def __init__(self, masterhex, guiboard):
        self.masterhex = masterhex
        self.guiboard = guiboard
        scale = self.guiboard.scale
        self.cx = masterhex.x * 4 * scale
        self.cy = masterhex.y * 4 * SQRT3 * scale
        if not masterhex.inverted:
            self.cy += SQRT3 * scale
        self.fillcolor = guiutils.rgb_to_float(
            colors.rgb_colors[colors.terrain_colors[self.masterhex.terrain]])
        self.center = (self.cx + 3 * scale, self.cy + 1.5 * SQRT3 * scale)
        self.selected = False

        self.init_vertexes()
        self.init_gates()
        iv = guiutils.scale_polygon(self.vertexes, 0.7)
        self.inner_vertexes = []
        for point in iv:
            self.inner_vertexes.append(rp(point))
        self.init_overlay()