Package horizons :: Package gui :: Package widgets :: Module resourceoverviewbar :: Class ResourceOverviewBar
[hide private]
[frames] | no frames]

Class ResourceOverviewBar

source code

The thing on the top left.

http://wiki.unknown-horizons.org/w/HUD

Features:
- display contents of currently relevant inventory (settlement/ship)
- always show gold of local player
- show costs of current build
- configure the resources to show
        - per settlement
        - add new slots
        - switch displayed resources to construction relevant res on build
        - res selection consistent with other res selection dlgs

Invariants:
- it should be obvious that the res bar can be configured
- it should be obvious that the res bar can be set per settlement

Has distinguished treatment of gold because it's distinguished by a bigger icon
and by being shown always.

Instance Methods [hide private]
 
__init__(self, session) source code
 
hide(self) source code
 
end(self) source code
 
_update_default_configuration(self) source code
 
save(self, db) source code
 
load(self, db) source code
 
redraw(self) source code
 
_on_different_settlement(self, message) source code
 
set_inventory_instance(self, instance, keep_construction_mode=False, force_update=False)
Display different inventory.
source code
 
set_construction_mode(self, resource_source_instance, build_costs)
Show resources relevant to construction and build costs
source code
 
close_construction_mode(self, update_slots=True)
Return to normal configuration
source code
 
_drop_cost_labels(self)
Removes all labels below the slots indicating building costs
source code
 
_update_gold(self, force=False)
Changelistener to upate player gold
source code
 
_update_balance_display(self)
Updates balance info below gold icon
source code
 
_update_resources(self)
Same as _update_gold but for all other slots
source code
 
_get_current_resources(self)
Return list of resources to display now
source code
 
_get_current_inventory(self) source code
 
get_size(self)
Returns (x,y) size tuple.
source code
 
_show_resource_selection_dialog(self, slot_num)
Shows gui for selecting a resource for slot slot_num
source code
 
_make_configuration_default(self, reset=False)
Saves current resources as default via game settings
source code
 
_drop_settlement_resource_configuration(self)
Forget resource configuration for a settlement
source code
 
_set_resource_slot(self, slot_num, res_id)
Show res_id in slot slot_num
source code
 
_hide_resource_selection_dialog(self) source code
 
close_resource_selection_mode(self)
Fully disable resource selection mode
source code
 
_on_tab_widget_changed(self, msg=None) source code
 
_show_dummy_slot(self)
Show the dummy button at the end to allow for addition of slots
source code
 
_hide_dummy_slot(self) source code
 
_on_res_slot_click(self, widget, event)
Called when you click on a resource slot in the bar (not the selection dialog)
source code
 
_toggle_stats(self) source code
 
_show_stats(self)
Show data below gold icon when balance label is clicked
source code
 
_update_stats(self)
Fills in (refreshes) numeric values in expanded stats area.
source code
 
_hide_stats(self)
Inverse of show_stats
source code
 
_init_stats_gui(self) source code
 
_get_res_background_icon_position(self) source code
 
_get_gold_background_icon_position(self) source code
Class Variables [hide private]
  GOLD_ENTRY_GUI_FILE = "resource_overview_bar_gold.xml"
  INITIAL_X_OFFSET = 100
  ENTRY_GUI_FILE = "resource_overview_bar_entry.xml"
  ENTRY_X_OFFSET = 52
  ENTRY_Y_OFFSET = 17
  ENTRY_Y_HEIGHT = 66
  CONSTRUCTION_LABEL_HEIGHT = 22
  STATS_GUI_FILE = "resource_overview_bar_stats.xml"
  STYLE = "resource_bar"
  DEFAULT_RESOURCES = [RES.TOOLS, RES.BOARDS, RES.BRICKS, RES.FO...
  CONSTRUCTION_RESOURCES = {TIER.SAILORS: [RES.TOOLS, RES.BOARDS...
Method Details [hide private]

set_inventory_instance(self, instance, keep_construction_mode=False, force_update=False)

source code 

Display different inventory. May change resources that are displayed

set_construction_mode(self, resource_source_instance, build_costs)

source code 

Show resources relevant to construction and build costs

Parameters:
  • resource_source_instance - object with StorageComponent
  • build_costs - dict, { res : amount }

get_size(self)

source code 

Returns (x,y) size tuple.

Used by the cityinfo to determine how to change its position if the widgets overlap using default positioning (resource bar can get arbitrarily long). Note that the money icon has the same offset effect as all entry icons have (height 73 + padding 10 == height 66 + padding 17), thus the calculation only needs of regular items (ENTRY_Y_*) to determine the maximum widget height.

_set_resource_slot(self, slot_num, res_id)

source code 

Show res_id in slot slot_num

Parameters:
  • slot_num - starting at 0, will be added as new slot if greater than no of slots
  • res_id - a resource id or 0 for remove slot

_get_res_background_icon_position(self)

source code 
Decorators:
  • @cachedmethod

_get_gold_background_icon_position(self)

source code 
Decorators:
  • @cachedmethod

Class Variable Details [hide private]

DEFAULT_RESOURCES

Value:
[RES.TOOLS, RES.BOARDS, RES.BRICKS, RES.FOOD, RES.TEXTILE, RES.SALT]

CONSTRUCTION_RESOURCES

Value:
{TIER.SAILORS: [RES.TOOLS, RES.BOARDS], TIER.PIONEERS: [RES.TOOLS, RES\
.BOARDS, RES.BRICKS], TIER.SETTLERS: [RES.TOOLS, RES.BOARDS, RES.BRICK\
S], TIER.CITIZENS: [RES.TOOLS, RES.BOARDS, RES.BRICKS], TIER.MERCHANTS\
: [RES.TOOLS, RES.BOARDS, RES.BRICKS],}