예제 #1
0
    def screen2world(self, pos):
        pos = Pointf(pos)
        sa = math.sin(-self.rotation / 180.0 * math.pi)
        ca = math.cos(-self.rotation / 180.0 * math.pi)

        dx = pos.x - self.width / 2
        dy = pos.y - self.height / 2

        pos.x = self.width / 2 + (ca * dx - sa * dy)
        pos.y = self.height / 2 + (sa * dx + ca * dy)

        return Pointf((float(pos.x) / self.zoom) - self.offset.x,
                      (float(pos.y) / self.zoom) - self.offset.y)
예제 #2
0
    def __init__(self):
        super().__init__()

        self.scrolling = False
        self.click_pos = Point(0, 0)
        self.old_trans_offset = Pointf(0, 0)
        self.layer = None
예제 #3
0
    def update(self, event):
        gc_state = EditorMapComponent.current.get_gc_state()

        sa = math.sin(-gc_state.get_rotation() / 180.0 * math.pi)
        ca = math.cos(-gc_state.get_rotation() / 180.0 * math.pi)

        dx = ca * (self.click_pos.x - event.mouse_pos.x) - sa * (self.click_pos.y - event.mouse_pos.y)
        dy = sa * (self.click_pos.x - event.mouse_pos.x) + ca * (self.click_pos.y - event.mouse_pos.y)

        gc_state.set_pos(Pointf(self.old_trans_offset.x + dx / EditorMapComponent.current.get_gc_state().get_zoom(),
                                self.old_trans_offset.y + dy / EditorMapComponent.current.get_gc_state().get_zoom()))
예제 #4
0
    def __init__(self, gui_manager):
        super().__init__()

        self.manager = gui_manager

        self.state = ObjMapSelectTool.STATE_NONE
        # Left click + drag rectangle
        self.drag_start = Pointf(0, 0)
        self.selection_rect = Rectf(0, 0, 0, 0)

        # For selected objects do: self.context.object_selection
        self.deselected = []  # Objects that were selected before

        self.offset = Pointf(0, 0)
        self.move_command = None

        self.control_point = None
        self.context = ToolContext.current

        # Never used:
        # self.sig_popup_menu_display = Signal()
        self.sig_right_click = Signal()
예제 #5
0
    def update_control_points(self):
        # Correct the control point position by 8 pixels (so that they align perfectly)
        pos = self.pos - Pointf(8, 8)

        self.cp_top_left.set_pos_raw(pos)
        self.cp_top_right.set_pos_raw(pos + Pointf(self.size.width, 0))
        self.cp_bottom_left.set_pos_raw(pos + Pointf(0, self.size.height))
        self.cp_bottom_right.set_pos_raw(
            pos + Pointf(self.size.width, self.size.height))
        self.cp_top_middle.set_pos_raw(pos + Pointf(self.size.width / 2, 0))
        self.cp_bottom_middle.set_pos_raw(pos + Pointf(self.size.width /
                                                       2, self.size.height))
        self.cp_middle_left.set_pos_raw(pos + Pointf(0, self.size.height / 2))
        self.cp_middle_right.set_pos_raw(
            pos + Pointf(self.size.width, self.size.height / 2))
예제 #6
0
    def __init__(self, rect, color, metadata):
        super().__init__(Pointf(rect.left, rect.top), metadata)

        self.size = Sizef(rect.width, rect.height)
        self.color = color

        self.cp_top_left = ObjMapControlPoint(
            Sprite.from_file("data/images/icons16/resize1.png"), Pointf())

        self.cp_bottom_right = ObjMapControlPoint(
            Sprite.from_file("data/images/icons16/resize1.png"), Pointf())

        self.cp_top_right = ObjMapControlPoint(
            Sprite.from_file("data/images/icons16/resize2.png"), Pointf())

        self.cp_bottom_left = ObjMapControlPoint(
            Sprite.from_file("data/images/icons16/resize2.png"), Pointf())

        self.cp_middle_left = ObjMapControlPoint(
            Sprite.from_file("data/images/icons16/resize_horz.png"), Pointf())
        self.cp_middle_right = ObjMapControlPoint(
            Sprite.from_file("data/images/icons16/resize_horz.png"), Pointf())
        self.cp_top_middle = ObjMapControlPoint(
            Sprite.from_file("data/images/icons16/resize_vert.png"), Pointf())

        self.cp_bottom_middle = ObjMapControlPoint(
            Sprite.from_file("data/images/icons16/resize_vert.png"), Pointf())

        self.cp_top_right.sig_set_pos.connect(self.cp_top_right_move)
        self.cp_bottom_right.sig_set_pos.connect(self.cp_bottom_right_move)

        self.cp_top_left.sig_set_pos.connect(self.cp_top_left_move)
        self.cp_bottom_left.sig_set_pos.connect(self.cp_bottom_left_move)

        self.cp_middle_left.sig_set_pos.connect(self.cp_middle_left_move)
        self.cp_middle_right.sig_set_pos.connect(self.cp_middle_right_move)

        self.cp_top_middle.sig_set_pos.connect(self.cp_top_middle_move)
        self.cp_bottom_middle.sig_set_pos.connect(self.cp_bottom_middle_move)
예제 #7
0
 def get_bound_rect(self):
     return Rectf(Pointf(self.pos),
                  Sizef(self.surface.width, self.surface.height))
예제 #8
0
 def set_rect(self, rect):
     self.pos = Pointf(rect.left, rect.top)
     self.size = Sizef(rect.width, rect.height)
예제 #9
0
    def __init__(self, tilemap_layer, metadata):
        super().__init__(Pointf(0, 0), metadata)

        self.tilemap_layer = tilemap_layer
예제 #10
0
    def zoom_in(self, pos):
        self.gc_state.set_zoom(self.gc_state.get_zoom() * 1.25,
                               Pointf(pos.x, pos.y))

        self.editormap_widget.repaint()
        self.update_scrollbars()
예제 #11
0
 def get_bound_rect(self):
     return Rectf(self.pos - Pointf(16, 16), Sizef(32, 32))
예제 #12
0
 def get_pos(self):
     return Pointf(-self.offset.x + (self.width / 2 / self.zoom),
                   -self.offset.y + (self.height / 2 / self.zoom))
예제 #13
0
 def get_clip_rect(self):
     return Rectf(Pointf(-self.offset.x,
                         -self.offset.y),
                  Sizef(self.width / self.zoom,
                        self.height / self.zoom))
예제 #14
0
 def __init__(self, w=1, h=1):
     self.width = w
     self.height = h
     self.offset = Pointf(0, 0)
     self.zoom = 1.0
     self.rotation = 0
예제 #15
0
    def move_to_y(self, y):
        self.gc_state.set_pos(Pointf(self.gc_state.get_pos().x, y))

        self.editormap_widget.repaint()
        self.update_scrollbars()
예제 #16
0
 def __init__(self):
     self.data = None
     self.pos = Pointf(0, 0)
     self.metadata = None
예제 #17
0
 def __init__(self):
     self.scrolling = False
     self.click_pos = Point(0, 0)
     self.old_trans_offset = Pointf(0, 0)