Esempio n. 1
0
 def __init__(self, map_file_path, textures, **kwargs):
     """
     Charge la carte dans un layout.
     :param map_file_path: Chemin de la carte
     :param textures: dictionnaire de textures
     :param kwargs: Argumens du layout
     """
     super(Level, self).__init__(**kwargs)
     self.map_canvas = MapCanvas(map_file_path, textures)
     self.add_widget(self.map_canvas)
    def __init__(self):
        self.canvas = None
        self.window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event)
        self.window.set_title("jXPMap Editor")
        self.box0 = gtk.GtkVBox(gtk.FALSE, 0)
        menubar = self.buildMenuBar()
        self.box0.pack_start(menubar, gtk.FALSE, gtk.FALSE, 0)
        self.box1 = gtk.GtkHBox(gtk.FALSE, 0)
        self.box0.pack_start(self.box1, gtk.TRUE, gtk.TRUE, 0)
        self.window.add(self.box0)
        self.buildToolBar()
        #self.ActionMap()
        #self.buildInputMap()

        # The visual calls are needed to make sure drawing bitmaps
        # (draw_*_image) works
        # ... at least according to some documentation that doesn't look
        # entirely reliable

        gtk.push_rgb_visual()
        area = gtk.GtkDrawingArea()
        gtk.pop_visual()
        area.size(500, 500)
        self.box1.pack_start(area, gtk.TRUE, gtk.TRUE, 0)
        area.connect("expose-event", self.area_expose_cb)

        # Change the default background to black so that the window
        # doesn't flash badly when resizing

        style = area.get_style().copy()
        style.bg[gtk.STATE_NORMAL] = area.get_colormap().alloc(0, 0, 0)
        area.set_style(style)
        area.connect("button_press_event", self.mouse_event)
        area.connect("button_release_event", self.mouse_event)
        area.connect("motion_notify_event", self.mouse_event)
        area.connect("configure_event", self.configure_event)
        area.set_events(GDK.EXPOSURE_MASK | GDK.BUTTON_PRESS_MASK
                        | GDK.BUTTON_RELEASE_MASK | GDK.POINTER_MOTION_MASK
                        | GDK.POINTER_MOTION_HINT_MASK)

        # The HINT_MASK means there won't be a callback for every mouse
        # motion event, only after certain other events or after an explicit
        # reading of the location with x, y = window.pointer.
        # This helps to avoid getting a queue of events if they're not handled
        # quickly enough.

        area.show()
        self.zoom = 0
        self.box1.show()
        self.box0.show()
        self.window.show()
        self.canvas = MapCanvas(area)
Esempio n. 3
0
 def _edit_map(self):
     selected = self.dst_tv.selection()
     if len(selected) == 1:
         fname = self.dst_tv.get_filepath(selected[0])
         map_data = BBMap(fname)
         MapCanvas(self, map_data)
Esempio n. 4
0
 def post_splash(self, dt):
     rows, cols = map_sizes[self.difficulty-1]
     self.game_map = MapCanvas(cols, rows, self.difficulty, self.hardcoreOption, self.soundsOption,
                               self.musicOption)
     self.content.clear_widgets()
     self.content.add_widget(self.game_map)