Exemplo n.º 1
0
def test_edit_jump(main_window):
    _jump_index = 0
    jump_list = main_window.jump_list

    # GIVEN the jump list with a selected jump and its textual representation
    jump_before = main_window.level_ref.jumps[_jump_index]

    # manually select jump in list
    jump_list.setCurrentRow(_jump_index)
    list_index = jump_list.currentIndex()

    jump_list_item_text_before = jump_list.currentItem().text()

    # WHEN a jump is edited and the callback of MainWindow is called
    updated_jump = Jump.from_properties(
        jump_before.screen_index + 1,
        jump_before.exit_action + 1,
        jump_before.exit_horizontal + 1,
        jump_before.exit_vertical + 1,
    )

    main_window.on_jump_edited(updated_jump)

    # THEN the jump in the level and the text in the jump list should be updated
    # reselect jump in list
    jump_list.setCurrentIndex(list_index)

    jump_after = main_window.level_ref.jumps[_jump_index]

    jump_list_item_text_after = jump_list.currentItem().text()

    assert jump_before != jump_after
    assert jump_after == updated_jump
    assert jump_list_item_text_before != jump_list_item_text_after
Exemplo n.º 2
0
    def from_data(self, data: bytearray, index: int):
        if Jump.is_jump(data):
            return Jump(data)

        assert self.pattern_table is not None

        # todo get rid of index by fixing ground map
        return LevelObject(
            data,
            self.object_set,
            self.palette_group,
            self.pattern_table,
            self.objects_ref,
            self.vertical_level,
            index,
            size_minimal=self.size_minimal,
        )
Exemplo n.º 3
0
    def on_ok(self):
        self.jump = Jump.from_properties(
            self.screen_spinner.value(),
            self.exit_action.currentIndex(),
            self.exit_horizontal.value(),
            self.exit_vertical.currentIndex(),
        )

        self.close()
Exemplo n.º 4
0
    def add_jump(self):
        self.jumps.append(Jump.from_properties(0, 0, 0, 0))

        self.data_changed.emit()