Package horizons :: Package component :: Module inventoryoverlaycomponent :: Class InventoryOverlayComponent
[hide private]
[frames] | no frames]

Class InventoryOverlayComponent

source code

Component --+
            |
           InventoryOverlayComponent

Display different additional graphics ("animation overlays" in FIFE terminology) depending on inventory status of a building or unit.

Instance Methods [hide private]
 
__init__(self, overlays=None)
Used for initialization code that does not require any other components.
source code
 
action_set(self)
E.g.
source code
 
fife_instance(self) source code
 
identifier(self)
E.g.
source code
 
initialize(self)
This is called by the ComponentHolder after it set the instance.
source code
 
add_overlay(self, overlay_set, z_order=10)
Creates animation overlay from action set *overlay_set* and adds it to fife instance.
source code
 
remove_overlay(self, res_id)
Removes animation overlay associated with resource *res_id* from fife instance.
source code
 
inventory_changed(self, message)
A changelistener notified the StorageComponent of this instance.
source code
 
update_overlay(self, res_id, new_amount)
Called when inventory amount of one resource changes.
source code
 
load(self, db, worldid)
This does on load what __init() and initalize() together do on constructions at runtime.
source code
 
remove(self)
Removes all animation overlays from the fife 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
 
session(self) source code
Class Methods [hide private]
    Inherited from Component
 
get_instance(cls, arguments=None)
This function is used to instantiate classes from yaml data.
source code
Class Variables [hide private]
  NAME = "inventoryoverlay"
hash(x)
  DEPENDENCIES = ['StorageComponent']
  log = logging.getLogger('component.overlays')
Method Details [hide private]

__init__(self, overlays=None)
(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)

action_set(self)

source code 

E.g. 'as_lumberjack_barrack0'

Decorators:
  • @property

fife_instance(self)

source code 
Decorators:
  • @property

identifier(self)

source code 

E.g. 'idle_as_lumberjack_barrack0'

Decorators:
  • @property

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)

add_overlay(self, overlay_set, z_order=10)

source code 

Creates animation overlay from action set *overlay_set* and adds it to fife instance.

Parameters:
  • overlay_set - action set with images to be used as animation overlay
  • z_order - the (numerical) drawing order identifier. Usually res_id.

remove_overlay(self, res_id)

source code 

Removes animation overlay associated with resource *res_id* from fife instance.

We use *res_id* as z-order identifier, which removeAnimationOverlay actually asks for.

inventory_changed(self, message)

source code 

A changelistener notified the StorageComponent of this instance.

Because it did not tell us which resources were added or removed, we need to check everything in the inventory for possible updates.

update_overlay(self, res_id, new_amount)

source code 

Called when inventory amount of one resource changes.

Looks for a fitting animation overlay based on the new inventory amount for that resource. If that overlay is different from the currently displayed one, removes the old overlay for that resource and adds a new one based on what fits *new_amount* best.

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)

remove(self)

source code 

Removes all animation overlays from the fife instance.

Also converts the animation overlay on drawing order 0 (i.e. the old base image) back to a plain "action set" in UH terminology.

Overrides: Component.remove