Exemplo n.º 1
0
    def move_up_frame(self, fwidget):
        direction = direction_sprite.get_direction(self.cb_direction.currentText())
        if fwidget.frame_id > 0:
            f_id = fwidget.frame_id

            tmp_frame = self.sprite.frames[direction][f_id]

            self.sprite.frames[direction][f_id] =  self.sprite.frames[direction][f_id-1]
            self.sprite.frames[direction][f_id-1] = tmp_frame

            self.__fill_frames()
Exemplo n.º 2
0
    def move_down_frame(self, fwidget):
        direction = direction_sprite.get_direction(self.cb_direction.currentText())
        if fwidget.frame_id < len(self.frames_widget) - 1:

            f_id = fwidget.frame_id

            tmp_frame = self.sprite.frames[direction][f_id]

            self.sprite.frames[direction][f_id] =  self.sprite.frames[direction][f_id+1]
            self.sprite.frames[direction][f_id+1] = tmp_frame

            self.__fill_frames()
Exemplo n.º 3
0
    def move_up_frame(self, fwidget):
        direction = direction_sprite.get_direction(
            self.cb_direction.currentText())
        if fwidget.frame_id > 0:
            f_id = fwidget.frame_id

            tmp_frame = self.sprite.frames[direction][f_id]

            self.sprite.frames[direction][f_id] = self.sprite.frames[
                direction][f_id - 1]
            self.sprite.frames[direction][f_id - 1] = tmp_frame

            self.__fill_frames()
Exemplo n.º 4
0
    def move_down_frame(self, fwidget):
        direction = direction_sprite.get_direction(
            self.cb_direction.currentText())
        if fwidget.frame_id < len(self.frames_widget) - 1:

            f_id = fwidget.frame_id

            tmp_frame = self.sprite.frames[direction][f_id]

            self.sprite.frames[direction][f_id] = self.sprite.frames[
                direction][f_id + 1]
            self.sprite.frames[direction][f_id + 1] = tmp_frame

            self.__fill_frames()
Exemplo n.º 5
0
    def add_frame(self):
        imgpath = str(QtGui.QFileDialog.getOpenFileName(self, "Add a frame"))
        direction = direction_sprite.get_direction(self.cb_direction.currentText())

        if len(imgpath) > 0:
            fp = open(imgpath, 'rb')
            img_data = fp.read(1024)
            chunk = img_data

            while len(chunk) == 1024:
                chunk = fp.read(1024)
                img_data += chunk

            fp.close()
            frame = direction_sprite.sprite_frame(direction, img_data)
            self.sprite.frames[direction].append(frame)
            self.__fill_frames()
        else:
            #todo error message maybe
            pass
Exemplo n.º 6
0
    def __fill_frames(self):

        for fw in self.frames_widget:
            fw.deleteLater()
            self.layout_frames.removeWidget(fw)

        self.frames_widget = []

        direction = direction_sprite.get_direction(str(self.cb_direction.currentText()))
        frames = self.sprite.frames[direction]
        i = 0
        for f in frames:
            fw = frame_widget.frame_widget(i, f.img_data)
            fw.move_down = self.move_down_frame
            fw.move_up = self.move_up_frame
            fw.delete_frame = self.delete_frame
            #todo handle delete
            self.frames_widget.append(fw)
            self.layout_frames.addWidget(fw)
            i += 1
Exemplo n.º 7
0
    def add_frame(self):
        imgpath = str(QtGui.QFileDialog.getOpenFileName(self, "Add a frame"))
        direction = direction_sprite.get_direction(
            self.cb_direction.currentText())

        if len(imgpath) > 0:
            fp = open(imgpath, 'rb')
            img_data = fp.read(1024)
            chunk = img_data

            while len(chunk) == 1024:
                chunk = fp.read(1024)
                img_data += chunk

            fp.close()
            frame = direction_sprite.sprite_frame(direction, img_data)
            self.sprite.frames[direction].append(frame)
            self.__fill_frames()
        else:
            #todo error message maybe
            pass
Exemplo n.º 8
0
    def __fill_frames(self):

        for fw in self.frames_widget:
            fw.deleteLater()
            self.layout_frames.removeWidget(fw)

        self.frames_widget = []

        direction = direction_sprite.get_direction(
            str(self.cb_direction.currentText()))
        frames = self.sprite.frames[direction]
        i = 0
        for f in frames:
            fw = frame_widget.frame_widget(i, f.img_data)
            fw.move_down = self.move_down_frame
            fw.move_up = self.move_up_frame
            fw.delete_frame = self.delete_frame
            #todo handle delete
            self.frames_widget.append(fw)
            self.layout_frames.addWidget(fw)
            i += 1
Exemplo n.º 9
0
 def delete_frame(self, fwidget):
     direction = direction_sprite.get_direction(self.cb_direction.currentText())
     self.sprite.frames[direction].pop(fwidget.frame_id)
     self.__fill_frames()
Exemplo n.º 10
0
 def delete_frame(self, fwidget):
     direction = direction_sprite.get_direction(
         self.cb_direction.currentText())
     self.sprite.frames[direction].pop(fwidget.frame_id)
     self.__fill_frames()