Package horizons :: Package gui :: Package widgets :: Module messagewidget :: Class MessageWidget
[hide private]
[frames] | no frames]

Class MessageWidget

source code

util.living.LivingObject --+
                           |
                          MessageWidget

Class that organizes the messages. Displayed on left screen edge. It uses _IngameMessage instances to store messages and manages the archive.

Instance Methods [hide private]
 
__init__(self, session) source code
 
add(self, string_id, point=None, msg_type=None, message_dict=None, play_sound=True, check_duplicate=False)
Adds a message to the MessageWidget.
source code
 
remove(self, messagetext)
Remove a message containing the text *messagetext*
source code
 
add_custom(self, messagetext, point=None, msg_type=None, visible_for=40, icon_id=1)
See docstring for add().
source code
 
add_chat(self, player, messagetext, icon_id=1)
See docstring for add().
source code
 
_add_message(self, message, sound=None)
Internal function for adding messages.
source code
 
draw_widget(self)
Updates whole messagewidget (all messages): draw icons.
source code
 
show_text(self, index)
Shows the text for a button.
source code
 
hide_text(self)
Hides the text.
source code
 
tick(self)
Check whether a message is old enough to be put into the archives
source code
 
end(self)
Put all the code the object needs to end safely here.
source code
 
save(self, db) source code
 
load(self, db) source code
Class Variables [hide private]
  BG_IMAGE_MIDDLE = 'content/gui/images/background/widgets/messa...
  IMG_HEIGHT = 24
  LINE_HEIGHT = 17
  ICON_TEMPLATE = 'messagewidget_icon.xml'
  MSG_TEMPLATE = 'messagewidget_message.xml'
  CHARS_PER_LINE = 31
  SHOW_NEW_MESSAGE_TEXT = 7
  MAX_MESSAGES = 5
  _DUPLICATE_TIME_THRESHOLD = 10
  _DUPLICATE_SPACE_THRESHOLD = 8
  OVERVIEW_WIDGET = 'messagewidget_overview.xml'
  log = logging.getLogger('gui.widgets.messagewidget')
Method Details [hide private]

add(self, string_id, point=None, msg_type=None, message_dict=None, play_sound=True, check_duplicate=False)

source code 

Adds a message to the MessageWidget.

Parameters:
  • point - point where the action took place. Clicks on the message will then focus that spot.
  • id - message id string, needed to retrieve the message text from the content database.
  • msg_type - message type; determines what happens on click
  • message_dict - dict with strings to replace in the message, e.g. {'player': 'Arthus'}
  • play_sound - whether to play the default message speech for string_id
  • check_duplicate - check for pseudo-duplicates (similar messages recently nearby)

add_custom(self, messagetext, point=None, msg_type=None, visible_for=40, icon_id=1)

source code 

See docstring for add(). Uses no predefined message template from content database like add() does. Instead, directly provides text and icon to be shown (messagetext, icon_id)

Parameters:
  • visible_for - how many seconds the message will stay visible in the widget

_add_message(self, message, sound=None)

source code 

Internal function for adding messages. Do not call directly.

Parameters:
  • message - _IngameMessage instance
  • sound - path to soundfile

draw_widget(self)

source code 

Updates whole messagewidget (all messages): draw icons. Inactive messages need their icon hovered to display their text again

show_text(self, index)

source code 

Shows the text for a button.

Parameters:
  • index - index of button

end(self)

source code 

Put all the code the object needs to end safely here. Make sure it always contains the super(YOUROBJECT, self).end() call, to ensure all parentobjects are deinited correctly.

Overrides: util.living.LivingObject.end
(inherited documentation)

Class Variable Details [hide private]

BG_IMAGE_MIDDLE

Value:
'content/gui/images/background/widgets/message_bg_middle.png'