示例#1
0
文件: grid.py 项目: xjzpguob/libRPG
    def __init__(self,
                 width,
                 height,
                 width_in_cells,
                 height_in_cells,
                 visible=False,
                 focusable=False,
                 theme=None):
        Div.__init__(self, width, height, focusable, theme)
        self.visible = visible
        self.width_in_cells = width_in_cells
        self.height_in_cells = height_in_cells
        self.cell_width = self.width / self.width_in_cells
        self.cell_height = self.height / self.height_in_cells

        self.cells = Matrix(width_in_cells, height_in_cells)
        for y in xrange(height_in_cells):
            for x in xrange(width_in_cells):
                div = Div(self.cell_width,
                          self.cell_height,
                          focusable=False,
                          theme=self.theme)
                pos = (x * self.cell_width, y * self.cell_height)
                self.cells[x, y] = div
                self.add_widget(div, pos)
示例#2
0
    def __init__(self,
                 width,
                 height,
                 x=0,
                 y=0,
                 theme=None,
                 bg=None,
                 mouse_control=MOUSE_LOOSE,
                 blocking=True):
        Model.__init__(self)
        Div.__init__(self, width, height, False, theme)
        self.x = x
        self.y = y
        self.cursor = None
        self.menu = self
        self.all_widgets = []
        self.init_bg(bg)
        assert mouse_control in (Menu.MOUSE_OFF,
                                 Menu.MOUSE_STRICT,
                                 Menu.MOUSE_LOOSE),\
                                'mouse_control must be 0, 1 or 2'
        self.mouse_control = mouse_control
        self.blocking = blocking

        self.should_close = False
示例#3
0
文件: menu.py 项目: Eronarn/libRPG
 def draw(self):
     scr = get_screen()
     scr.blit(self.bg.get_surface(), (self.x, self.y))
     Div.draw(self)
     Div.render(self, scr, self.x, self.y)
     if self.cursor is not None:
         self.cursor.draw()
         self.cursor.render(scr)
示例#4
0
 def draw(self):
     scr = get_screen()
     scr.blit(self.bg.get_surface(), (self.x, self.y))
     Div.draw(self)
     Div.render(self, scr, self.x, self.y)
     if self.cursor is not None:
         self.cursor.draw()
         self.cursor.render(scr)
示例#5
0
文件: grid.py 项目: Eronarn/libRPG
    def __init__(self, width, height, width_in_cells, height_in_cells,
                 visible=False, focusable=False, theme=None):
        Div.__init__(self, width, height, focusable, theme)
        self.visible = visible
        self.width_in_cells = width_in_cells
        self.height_in_cells = height_in_cells
        self.cell_width = self.width / self.width_in_cells
        self.cell_height = self.height / self.height_in_cells

        self.cells = Matrix(width_in_cells, height_in_cells)
        for y in xrange(height_in_cells):
            for x in xrange(width_in_cells):
                div = Div(self.cell_width, self.cell_height, focusable=False,
                          theme=self.theme)
                pos = (x * self.cell_width, y * self.cell_height)
                self.cells[x, y] = div
                self.add_widget(div, pos)
示例#6
0
文件: menu.py 项目: Eronarn/libRPG
    def __init__(self, width, height, x=0, y=0, theme=None, bg=None,
                 mouse_control=MOUSE_LOOSE, blocking=True):
        Model.__init__(self)
        Div.__init__(self, width, height, False, theme)
        self.x = x
        self.y = y
        self.cursor = None
        self.menu = self
        self.all_widgets = []
        self.init_bg(bg)
        assert mouse_control in (Menu.MOUSE_OFF,
                                 Menu.MOUSE_STRICT,
                                 Menu.MOUSE_LOOSE),\
                                'mouse_control must be 0, 1 or 2'
        self.mouse_control = mouse_control
        self.blocking = blocking

        self.should_close = False
示例#7
0
文件: grid.py 项目: xjzpguob/libRPG
    def add_columns(self, number_of_columns=1):
        """
        Add one or more cell columns to the Grid.

        The Grid's dimensions will be expanded, while the size of each
        cell will remain unchanged.

        *number_of_columns* specifies how many columns will be added. This
        defaults to 1.
        """
        old_width = self.width_in_cells
        self.width_in_cells += number_of_columns
        self.cells.resize(self.width_in_cells, self.height_in_cells)

        for y in xrange(self.height_in_cells):
            for x in xrange(old_width, self.width_in_cells):
                div = Div(self.cell_width,
                          self.cell_height,
                          focusable=False,
                          theme=self.theme)
                pos = (x * self.cell_width, y * self.cell_height)
                self.cells[x, y] = div
                self.add_widget(div, pos)
示例#8
0
 def render(self, screen, x_offset, y_offset):
     Widget.render(self, screen, x_offset, y_offset)
     Div.render(self, screen, x_offset, y_offset)
示例#9
0
 def draw(self):
     r = pygame.Rect(0, 0, self.width, self.height)
     if self.image is None:
         self.image = self.theme.draw_panel(r)
     Div.draw(self)
示例#10
0
文件: panel.py 项目: Eronarn/libRPG
 def render(self, screen, x_offset, y_offset):
     Widget.render(self, screen, x_offset, y_offset)
     Div.render(self, screen, x_offset, y_offset)
示例#11
0
文件: panel.py 项目: Eronarn/libRPG
 def draw(self):
     r = pygame.Rect(0, 0, self.width, self.height)
     if self.image is None:
         self.image = self.theme.draw_panel(r)
     Div.draw(self)