Example #1
0
File: panel.py Project: Sk00g/arena
    def __init__(self, position, size, child_list=None):
        Element.__init__(self, position)
        self._size = size
        self._child_list = []

        if child_list:
            for child in child_list:
                self.add_child(child)
Example #2
0
 def __init__(self, position, size, bar_color):
     Element.__init__(self, position)
     self.color = bar_color
     self.size = size
     self._fill = 1.0
     self._target_fill = 1.0
     self._image = pygame.Surface((size[0], size[1]), pygame.SRCALPHA, 32)
     self._render()
     self._bar_image = assets.load_image(BAR_IMAGE_SOURCE[self.color])
Example #3
0
    def __init__(self,
                 position,
                 size,
                 fill_color=(0, 0, 0, 255),
                 border_color=None,
                 border_thickness=1):
        Element.__init__(self, position)

        self._size = size
        self._fill_color = fill_color
        self._border_color = border_color
        self._border_thickness = border_thickness

        self._render()
Example #4
0
    def __init__(self,
                 image: pygame.Surface,
                 callback,
                 position,
                 size=None,
                 source_rect=None):
        Element.__init__(self, position)
        self.icon = Image(image, position, size, source_rect)
        self._callback = callback
        self._state = BTN_STATE_DEFAULT
        self._highlight_surface = pygame.Surface(size, pygame.SRCALPHA, 32)
        self._pressed_surface = pygame.Surface(size, pygame.SRCALPHA, 32)

        # Setup three surfaces
        self._render()
Example #5
0
File: label.py Project: Sk00g/arena
    def __init__(self,
                 position,
                 text: str,
                 font_size=-1,
                 color=(255, 255, 255)):
        Element.__init__(self, position)
        self._text = text
        self._color = color
        self._size = SuieContext.Instance.default_font_size if font_size == -1 else font_size
        self._font_object = assets.load_font(SuieContext.Instance.default_font,
                                             self._size)
        self.surface = None

        # Create the initial surface to draw (populates self.surface)
        self._render()
Example #6
0
    def __init__(self, position, text: str, callback):
        Element.__init__(self, position)
        self._text = text
        self._callback = callback
        self._default_surface = pygame.Surface((281, 56), pygame.SRCALPHA, 32)
        self._highlight_surface = pygame.Surface((281, 56), pygame.SRCALPHA, 32)
        self._pressed_surface = pygame.Surface((281, 56), pygame.SRCALPHA, 32)
        self._surface_list = [self._default_surface,
                              self._highlight_surface,
                              self._pressed_surface]
        self._state = BTN_STATE_DEFAULT
        self._font_object = assets.load_font(SuieContext.Instance.default_font,
                                             SuieContext.Instance.default_font_size)

        # Initial render
        self._render()
Example #7
0
 def __init__(self,
              position,
              size,
              bgnd_color=(0, 0, 0),
              border_type=BORDER_TYPE_SINGLE):
     Element.__init__(self, position)
     self._size = size
     # Including border pixels
     self._full_size = (size[0] + SINGLE_BORDER_SIZE,
                        size[1] + SINGLE_BORDER_SIZE)
     self._background_color = bgnd_color
     self._border_type = border_type
     # Surface list starts from top left and works clockwise to left (bottom left)
     self._surface_list = list()
     self._populate_surface_list()
     # Generate our surfaces
     self._render()
Example #8
0
    def __init__(self,
                 image: pygame.Surface,
                 position,
                 size=None,
                 source_rect=None):
        Element.__init__(self, position)

        self._size = size if size else image.get_rect()[2:4]
        self._flipx = False
        self._flipy = False

        # Grab only the subsection we need
        if source_rect:
            self._original_image = pygame.Surface(size=source_rect[2:4])
            self._original_image.blit(image, (0, 0), source_rect)
        else:
            self._original_image = image

        self._image = None

        # Generate our initial surface
        self._render()
Example #9
0
File: panel.py Project: Sk00g/arena
 def remove_child(self, child: Element):
     self._child_list.remove(child)
     child._host_panel = None
Example #10
0
File: panel.py Project: Sk00g/arena
 def add_child(self, child: Element):
     self._child_list.append(child)
     child._host_panel = self