Ejemplo n.º 1
0
def test_save_load_window_size():
    x1 = Dice.roll()[0]
    y1 = Dice.roll()[0]
    prefs.save_window_size(playername, window_name, x1, y1)
    x2, y2 = prefs.load_window_size(playername, window_name)
    assert x2 == x1
    assert y2 == y1
Ejemplo n.º 2
0
def test_save_load_window_size():
    x1 = Dice.roll()[0]
    y1 = Dice.roll()[0]
    prefs.save_window_size(playername, window_name, x1, y1)
    x2, y2 = prefs.load_window_size(playername, window_name)
    assert x2 == x1
    assert y2 == y1
Ejemplo n.º 3
0
    def __init__(self, playername=None, scale=None):
        gtk.Window.__init__(self)

        self.playername = playername
        self.game = None
        self.lobby = None
        self.guiboard = None
        self.accel_group = None

        self.set_icon(icon.pixbuf)
        self.set_title("Slugathon - %s" % (self.playername))
        self.connect("delete-event", self.cb_delete_event)
        self.connect("destroy", self.cb_destroy)
        self.connect("configure-event", self.cb_configure_event)

        if scale is None:
            self.scale = self.compute_scale()
        else:
            self.scale = scale
        # TODO
        self.set_default_size(1024, 768)

        if self.playername:
            tup = prefs.load_window_position(self.playername,
                                             self.__class__.__name__)
            if tup:
                x, y = tup
                self.move(x, y)
            tup = prefs.load_window_size(self.playername,
                                         self.__class__.__name__)
            if tup:
                width, height = tup
                self.resize(width, height)

        self.notebook = gtk.Notebook()
        self.notebook.connect("switch-page", self.cb_switch_page)
        self.add(self.notebook)
        self.notebook.set_tab_pos(gtk.POS_BOTTOM)
        self.show_all()
Ejemplo n.º 4
0
    def __init__(self, playername=None, scale=None):
        Gtk.Window.__init__(self)

        self.playername = playername
        self.game = None
        self.lobby = None
        self.guiboard = None
        self.accel_group = None

        self.set_icon(icon.pixbuf)
        self.set_title("Slugathon - %s" % (self.playername))
        self.connect("delete-event", self.cb_delete_event)
        self.connect("destroy", self.cb_destroy)
        self.connect("configure-event", self.cb_configure_event)

        if scale is None:
            self.scale = self.compute_scale()
        else:
            self.scale = scale
        # TODO
        self.set_default_size(1024, 768)

        if self.playername:
            tup = prefs.load_window_position(self.playername,
                                             self.__class__.__name__)
            if tup:
                x, y = tup
                self.move(x, y)
            tup = prefs.load_window_size(self.playername,
                                         self.__class__.__name__)
            if tup:
                width, height = tup
                self.resize(width, height)

        self.notebook = Gtk.Notebook()
        self.notebook.connect("switch-page", self.cb_switch_page)
        self.add(self.notebook)
        self.notebook.set_tab_pos(Gtk.PositionType.BOTTOM)
        self.show_all()
Ejemplo n.º 5
0
    def __init__(self, board, masterhex, entry_sides, def1, parent,
                 playername=None, scale=None):
        gtk.Dialog.__init__(self, "Pick Entry Side - %s" % playername, parent)

        terrain = masterhex.terrain
        # We always orient the map as if for entry side 5.
        self.battlemap = BattleMap.BattleMap(terrain, 5)
        self.entry_sides = entry_sides
        self.deferred = def1
        self.playername = playername
        self.board = board

        self.set_icon(icon.pixbuf)
        self.set_transient_for(parent)
        self.set_destroy_with_parent(True)
        self.set_title("PickEntrySide - Slugathon - %s" % self.playername)

        self.hbox1 = gtk.HBox(homogeneous=True)
        self.hbox2 = gtk.HBox()
        self.hbox3 = gtk.HBox()
        self.vbox.pack_start(self.hbox1, expand=False)
        self.vbox.pack_start(self.hbox2, fill=True)
        self.vbox.pack_start(self.hbox3, expand=False)

        if scale is None:
            self.scale = self.compute_scale()
        else:
            self.scale = scale
        self.area = gtk.DrawingArea()
        self.area.set_size_request(self.compute_width(), self.compute_height())

        if self.playername:
            tup = prefs.load_window_position(self.playername,
                                             self.__class__.__name__)
            if tup:
                x, y = tup
                self.move(x, y)
            tup = prefs.load_window_size(self.playername,
                                         self.__class__.__name__)
            if tup:
                width, height = tup
                self.resize(width, height)

        own_hex_label = self.masterhex_label(masterhex)
        left_hex = masterhex.neighbors[4] or masterhex.neighbors[5]
        left_hex_label = self.masterhex_label(left_hex)
        top_hex = masterhex.neighbors[0] or masterhex.neighbors[1]
        top_hex_label = self.masterhex_label(top_hex)
        bottom_hex = masterhex.neighbors[2] or masterhex.neighbors[3]
        bottom_hex_label = self.masterhex_label(bottom_hex)
        spacer_label = self.masterhex_label(None)
        self.hbox1.pack_start(own_hex_label)
        self.hbox1.pack_start(top_hex_label)
        self.hbox2.pack_start(left_hex_label)
        self.hbox2.pack_start(self.area)
        self.hbox3.pack_start(spacer_label)
        self.hbox3.pack_start(bottom_hex_label)

        self.guihexes = {}
        for hex1 in self.battlemap.hexes.itervalues():
            # Don't show entrances.
            if hex1.label not in ["ATTACKER", "DEFENDER"]:
                self.guihexes[hex1.label] = GUIBattleHex.GUIBattleHex(hex1,
                                                                      self)
        self.repaint_hexlabels = set()
        # Hexes that need their bounding rectangles cleared, too.
        # This fixes chits.
        self.clear_hexlabels = set()

        self.area.connect("expose-event", self.cb_area_expose)
        self.area.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.area.connect("button-press-event", self.cb_click)

        self.connect("destroy", self.callback_with_none)

        for hexlabel, entry_side in hexlabel_to_entry_side.iteritems():
            if entry_side in self.entry_sides:
                self.guihexes[hexlabel].selected = True
        self.show_all()
Ejemplo n.º 6
0
    def __init__(self,
                 board,
                 masterhex,
                 entry_sides,
                 def1,
                 parent,
                 playername=None,
                 scale=None):
        gtk.Dialog.__init__(self, "Pick Entry Side - %s" % playername, parent)

        terrain = masterhex.terrain
        # We always orient the map as if for entry side 5.
        self.battlemap = BattleMap.BattleMap(terrain, 5)
        self.entry_sides = entry_sides
        self.deferred = def1
        self.playername = playername
        self.board = board

        self.set_icon(icon.pixbuf)
        self.set_transient_for(parent)
        self.set_destroy_with_parent(True)
        self.set_title("PickEntrySide - Slugathon - %s" % self.playername)

        self.hbox1 = gtk.HBox(homogeneous=True)
        self.hbox2 = gtk.HBox()
        self.hbox3 = gtk.HBox()
        self.vbox.pack_start(self.hbox1, expand=False)
        self.vbox.pack_start(self.hbox2, fill=True)
        self.vbox.pack_start(self.hbox3, expand=False)

        if scale is None:
            self.scale = self.compute_scale()
        else:
            self.scale = scale
        self.area = gtk.DrawingArea()
        self.area.set_size_request(self.compute_width(), self.compute_height())

        if self.playername:
            tup = prefs.load_window_position(self.playername,
                                             self.__class__.__name__)
            if tup:
                x, y = tup
                self.move(x, y)
            tup = prefs.load_window_size(self.playername,
                                         self.__class__.__name__)
            if tup:
                width, height = tup
                self.resize(width, height)

        own_hex_label = self.masterhex_label(masterhex)
        left_hex = masterhex.neighbors[4] or masterhex.neighbors[5]
        left_hex_label = self.masterhex_label(left_hex)
        top_hex = masterhex.neighbors[0] or masterhex.neighbors[1]
        top_hex_label = self.masterhex_label(top_hex)
        bottom_hex = masterhex.neighbors[2] or masterhex.neighbors[3]
        bottom_hex_label = self.masterhex_label(bottom_hex)
        spacer_label = self.masterhex_label(None)
        self.hbox1.pack_start(own_hex_label)
        self.hbox1.pack_start(top_hex_label)
        self.hbox2.pack_start(left_hex_label)
        self.hbox2.pack_start(self.area)
        self.hbox3.pack_start(spacer_label)
        self.hbox3.pack_start(bottom_hex_label)

        self.guihexes = {}
        for hex1 in self.battlemap.hexes.itervalues():
            # Don't show entrances.
            if hex1.label not in ["ATTACKER", "DEFENDER"]:
                self.guihexes[hex1.label] = GUIBattleHex.GUIBattleHex(
                    hex1, self)
        self.repaint_hexlabels = set()
        # Hexes that need their bounding rectangles cleared, too.
        # This fixes chits.
        self.clear_hexlabels = set()

        self.area.connect("expose-event", self.cb_area_expose)
        self.area.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.area.connect("button-press-event", self.cb_click)

        self.connect("destroy", self.callback_with_none)

        for hexlabel, entry_side in hexlabel_to_entry_side.iteritems():
            if entry_side in self.entry_sides:
                self.guihexes[hexlabel].selected = True
        self.show_all()