Exemplo n.º 1
0
 def __init__(self, name, object_name, font_name, font_size, font_color=(255, 255, 255), x=0, y=0, size_x=0, size_y=0):
     Widget.__init__(self, name, x, y)
     
     self.object_name = object_name
     obj = get_object(object_name)
     
     if obj is not None and 'Inventory' in obj.components:            
         self.inventory = obj.components['Inventory']
     else:
         self.inventory = None
     
     self.image = None     
     
     self.font_name = font_name 
     self.font_size = font_size
     self.font_color = font_color
     
     self.space_x = 10
     self.space_y = 10
     
     self.size_x = size_x
     self.size_y = size_y
     
     self.active = 0
     self.start = 0
     self.length = 6
     
     self.on_b1_up = None
     self.on_b2_up = None
     
     self.must_update = True
Exemplo n.º 2
0
 def __init__(self, name, object_name, font_name, font_size, font_color=(255, 255, 255), x=0, y=0, size_x=0, size_y=0):
     Widget.__init__(self, name, x, y)
     
     self.object_name = object_name
     obj = get_object(object_name)
     
     if obj is not None and 'EquipmentSlots' in obj.components:            
         self.character = obj.components['EquipmentSlots']
     else:
         self.character = None
     
     self.image = None     
     
     self.font_name = font_name 
     self.font_size = font_size
     self.font_color = font_color
     
     self.space_x = 10
     self.space_y = 10
     
     self.size_x = size_x
     self.size_y = size_y
     
     self.on_b1_up = None
     self.on_b2_up = None
     
     self.must_update = True
Exemplo n.º 3
0
    def __init__(self, rows, transposed=False, relay_focus=False):
        Widget.__init__(self)
        self.rows = rows
        self.transposed = transposed
        #self.rows.obs_list.add_observer(self, '_row_')
        
        for rownum, row in enumerate(self.rows):
            row.obs_list.add_observer(self, '_child_', rownum)
            for child in row:
                child.selectable.obs_value.add_observer(self, '_child_selectable_', child)

        self.relay_focus = relay_focus
        
        # parenting_keymap is the keymap that's active when one of the
        # children is in focus (not the Box itself). IT's next keymap is the active child's keymap.
        self.parenting_keymap = Keymap.Keymap()

        if not self.relay_focus:
            self._allow_leave_child()

        self.set_index([0,0], [0,1])

        if self.relay_focus or self.start_in_child:
            self._enter_child()
        else:
            self._leave_child()
Exemplo n.º 4
0
 def __init__(self, name, image_name, x=0, y=0, size_x=0, size_y=0):
     Widget.__init__(self, name, x, y)
     
     self.raw_image = resource.Image.load(image_name)
     
     self.size_x = size_x
     self.size_y = size_y
     
     self.must_update = True
Exemplo n.º 5
0
 def __init__(self, name, text, font_name, font_size, font_color=(255, 255, 255), x=0, y=0, update=None):
     Widget.__init__(self, name, x, y)
     
     self.text = text
     
     self.font_name = font_name 
     self.font_size = font_size
     self.font_color = font_color
     
     self.update = update
     
     self.update_image()
Exemplo n.º 6
0
 def __init__(self, name, tile, x=0, y=0, size_x=0, size_y=0):
     Widget.__init__(self, name, x, y)
     
     if tile is None:
         self.tile = resource.Tile.default
     else:
         self.tile = tile
     
     self.size_x = size_x
     self.size_y = size_y
     
     self.must_update = True
Exemplo n.º 7
0
 def __init__(self, edge, get_node_widget, line, *args, **kw):
     self.edge = edge
     self.get_node_widget = get_node_widget
     self.edge.obs.add_observer(self, '_edge_')
     Widget.__init__(self, *args, **kw)
     self.line = line
     self.draw_rect = None
     self.cached_arrowhead = None
     self.cached_parent_offset = None
     self.font = draw.get_font(pygame.font.get_default_font(), 14)
     self.rendered_text = self.font.render('', True, self.fg_color)
     self.mouse_area = MouseArea(self.in_bounds)
Exemplo n.º 8
0
 def __init__(self, name, map_name, x=0, y=0, size_x=0, size_y=0, tile_size_x=10, tile_size_y=10):
     Widget.__init__(self, name, x, y)
     
     self.image = None
     self.map = None
     self.map_name = map_name        
     
     self.size_x = size_x
     self.size_y = size_y
     
     self.tile_size_x = tile_size_x
     self.tile_size_y = tile_size_y
     
     self.on_b1_up = None
     self.on_b2_up = None
     
     self.must_update = True
Exemplo n.º 9
0
    def __init__(self, node, *args, **kw):
        self.node = node
        self.style = style._make_style()
        self.text_widget = TextEdit(self.style, self._get_text, self._set_text, [all_printable], {'\r':'\n'})
        
        self.node.obs.add_observer(self, '_node_')
        Widget.__init__(self, *args, **kw)
        
        self._size = MovingValue(Point)
        self._pos = MovingValue(Point)
        from Shapes.Ellipse import Ellipse
        self.shape = Ellipse(pygame.Rect(0,0,1,1))

        self.obs_loc = Observable()
        self._register_keys()

        self.reset_max_text_size()
        self.mouse_area = MouseArea(self.in_bounds)
Exemplo n.º 10
0
    def __init__(self, size, *args, **kw):
        Widget.__init__(self, *args, **kw)
        self._size = MovingValue(Point, final=Point(size))
        self.nodes = set()
        self.edges = set()
        self.node_widgets = Dict()
        self.edge_widgets = Dict()
        self.sorted_widgets = SortedItems(self.node_widgets)

        self.layout = Layout()
        
        self.selected_widget_index = None
        self._update_index()

        self._node_link_start_pos = None
        self._node_link_source_node = None
        self._node_link_color = None
        
        self._register_keys()
        self._save_next_display_update = False
Exemplo n.º 11
0
 def __setstate__(self, d):
     Widget.__setstate__(self, d)
     self._register_keys()
Exemplo n.º 12
0
 def __getstate__(self):
     d = Widget.__getstate__(self)
     del d['parenting_keymap']
     return d
Exemplo n.º 13
0
 def __init__(self, size):
     Widget.__init__(self)
     self.selectable.set(False)
     self.size = size