Package horizons :: Package component :: Module selectablecomponent :: Class SelectableBuildingComponent
[hide private]
[frames] | no frames]

Class SelectableBuildingComponent

source code

      Component --+    
                  |    
SelectableComponent --+
                      |
                     SelectableBuildingComponent

Nested Classes [hide private]
  ListHolder
Instance Methods [hide private]
 
__init__(self, tabs, enemy_tabs, active_tab=None, range_applies_only_on_island=True)
Used for initialization code that does not require any other components.
source code
 
initialize(self)
This is called by the ComponentHolder after it set the instance.
source code
 
load(self, db, worldid)
This does on load what __init() and initalize() together do on constructions at runtime.
source code
 
select(self, reset_cam=False)
Runs necessary steps to select the building.
source code
 
set_selection_outline(self)
Only set the selection outline.
source code
 
deselect(self)
Runs neccassary steps to deselect the building.
source code
    Inherited from SelectableComponent
 
remove(self)
Removes component and reference to instance
source code
 
selected(self) source code
 
show_menu(self, jump_to_tabclass=None)
Shows tabwidget tabs of this instance.
source code
    Inherited from Component
 
__gt__(self, other) source code
 
__lt__(self, other) source code
 
save(self, db)
Will do nothing, but will be always called in componentholder code, even if not implemented.
source code
Class Methods [hide private]
 
reset(cls)
Called on session end to get rid of static data and init variables
source code
 
select_building(cls, session, position, settlement, radius, range_applies_only_on_island)
Select a hypothecial instance of this class.
source code
 
deselect_building(cls, session)
@see select_building Used by building tool, allows incremental updates @return list of tiles that were deselected (only normal tiles, no fake tiles)
source code
 
select_many(cls, buildings, renderer)
Same as calling select() on many instances, but way faster.
source code
 
_do_select(cls, renderer, position, world, settlement, radius, range_applies_only_on_island) source code
 
_init_fake_tile(cls)
Sets the _fake_tile_obj class variable with a ready to use fife object.
source code
 
_add_fake_tile(cls, x, y, layer, renderer)
Adds a fake tile to the position.
source code
 
_add_selected_tile(cls, tile, renderer, remember=True) source code
    Inherited from SelectableComponent
 
get_instance(cls, arguments)
This function is used to instantiate classes from yaml data.
source code
Class Variables [hide private]
  selection_color = 255, 255, 32, 192
  _selected_tiles = ListHolder()
  _selected_fake_tiles = ListHolder()
    Inherited from SelectableComponent
  NAME = "selectablecomponent"
hash(x)
    Inherited from Component
  DEPENDENCIES = []
Properties [hide private]
    Inherited from Component
  session
Method Details [hide private]

__init__(self, tabs, enemy_tabs, active_tab=None, range_applies_only_on_island=True)
(Constructor)

source code 

Used for initialization code that does not require any other components. This is always called first, on construction and on load.

Overrides: Component.__init__
(inherited documentation)

initialize(self)

source code 

This is called by the ComponentHolder after it set the instance. Use this to initialize any needed infrastructure. When this is called, it is guaranteed that all other components this one has a dependency on have been added, but initalize may not have been called on them, only __init__. It is only called after construction, not on load().

Overrides: Component.initialize
(inherited documentation)

load(self, db, worldid)

source code 

This does on load what __init() and initalize() together do on constructions at runtime. Has to set up everything that is not setup in __init__(). Note that on loading __init__() is called with the data needed by the component through get_instance(), but initialize() is not, so any work needed for loading as well should be moved to a separate method and called here.

Overrides: Component.load
(inherited documentation)

select(self, reset_cam=False)

source code 

Runs necessary steps to select the building.

Overrides: SelectableComponent.select

set_selection_outline(self)

source code 

Only set the selection outline. Useful when it has been removed by some kind of interference

deselect(self)

source code 

Runs neccassary steps to deselect the building. Only deselects if this building has been selected.

Overrides: SelectableComponent.deselect

select_building(cls, session, position, settlement, radius, range_applies_only_on_island)
Class Method

source code 

Select a hypothecial instance of this class. Use Case: Buildingtool. Only works on a subclass of BuildingClass, since it requires certain class attributes.

Parameters:
  • session - Session instance
  • position - Position of building, usually Rect
  • settlement - Settlement instance the building belongs to

select_many(cls, buildings, renderer)
Class Method

source code 

Same as calling select() on many instances, but way faster. Limited functionality, only use on real buildings of a settlement.

_init_fake_tile(cls)
Class Method

source code 

Sets the _fake_tile_obj class variable with a ready to use fife object.

To create a new fake tile, use _add_fake_tile().

_add_fake_tile(cls, x, y, layer, renderer)
Class Method

source code 

Adds a fake tile to the position. Requires 'cls._fake_tile_obj' to be set.

_add_selected_tile(cls, tile, renderer, remember=True)
Class Method

source code 
Parameters:
  • remember - whether to keep track of this tile. Set to False on recolorings.