本文整理汇总了Python中horizons.gui.widgets.messagewidget.MessageWidget.load方法的典型用法代码示例。如果您正苦于以下问题:Python MessageWidget.load方法的具体用法?Python MessageWidget.load怎么用?Python MessageWidget.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.gui.widgets.messagewidget.MessageWidget
的用法示例。
在下文中一共展示了MessageWidget.load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IngameGui
# 需要导入模块: from horizons.gui.widgets.messagewidget import MessageWidget [as 别名]
# 或者: from horizons.gui.widgets.messagewidget.MessageWidget import load [as 别名]
#.........这里部分代码省略.........
@param menu: str with the guiname or pychan object.
"""
if self._old_menu is not None:
if hasattr(self._old_menu, "remove_remove_listener"):
self._old_menu.remove_remove_listener( Callback(self.show_menu, None) )
self._old_menu.hide()
self._old_menu = self._get_menu_object(menu)
if self._old_menu is not None:
if hasattr(self._old_menu, "add_remove_listener"):
self._old_menu.add_remove_listener( Callback(self.show_menu, None) )
self._old_menu.show()
self.minimap_to_front()
TabWidgetChanged.broadcast(self)
def hide_menu(self):
self.show_menu(None)
def toggle_menu(self, menu):
"""Shows a menu or hides it if it is already displayed.
@param menu: parameter supported by show_menu().
"""
if self.get_cur_menu() == self._get_menu_object(menu):
self.hide_menu()
else:
self.show_menu(menu)
def save(self, db):
self.message_widget.save(db)
self.logbook.save(db)
self.resource_overview.save(db)
def load(self, db):
self.message_widget.load(db)
self.logbook.load(db)
self.resource_overview.load(db)
cur_settlement = LastActivePlayerSettlementManager().get_current_settlement()
self._cityinfo_set( HoverSettlementChanged(self, cur_settlement) )
self.minimap.draw() # update minimap to new world
def show_change_name_dialog(self, instance):
"""Shows a dialog where the user can change the name of a NamedComponant.
The game gets paused while the dialog is executed."""
events = {
OkButton.DEFAULT_NAME: Callback(self.change_name, instance),
CancelButton.DEFAULT_NAME: self._hide_change_name_dialog
}
self.main_gui.on_escape = self._hide_change_name_dialog
changename = self.widgets['change_name']
oldname = changename.findChild(name='old_name')
oldname.text = instance.get_component(SettlementNameComponent).name
newname = changename.findChild(name='new_name')
changename.mapEvents(events)
newname.capture(Callback(self.change_name, instance))
def forward_escape(event):
# the textfield will eat everything, even control events
if event.getKey().getValue() == fife.Key.ESCAPE:
self.main_gui.on_escape()
newname.capture( forward_escape, "keyPressed" )
changename.show()
newname.requestFocus()
示例2: IngameGui
# 需要导入模块: from horizons.gui.widgets.messagewidget import MessageWidget [as 别名]
# 或者: from horizons.gui.widgets.messagewidget.MessageWidget import load [as 别名]
class IngameGui(LivingObject):
"""Class handling all the ingame gui events.
Assumes that only 1 instance is used (class variables)"""
message_widget = livingProperty()
minimap = livingProperty()
keylistener = livingProperty()
def __init__(self, session):
super(IngameGui, self).__init__()
self.session = session
assert isinstance(self.session, horizons.session.Session)
self.settlement = None
self._old_menu = None
self.cursor = None
self.coordinates_tooltip = None
self.keylistener = IngameKeyListener(self.session)
self.cityinfo = CityInfo(self)
LastActivePlayerSettlementManager.create_instance(self.session)
self.message_widget = MessageWidget(self.session)
# Windows
self.windows = WindowManager()
self.show_popup = self.windows.show_popup
self.show_error_popup = self.windows.show_error_popup
self.logbook = LogBook(self.session, self.windows)
self.players_overview = PlayersOverview(self.session)
self.players_settlements = PlayersSettlements(self.session)
self.players_ships = PlayersShips(self.session)
self.chat_dialog = ChatDialog(self.windows, self.session)
self.change_name_dialog = ChangeNameDialog(self.windows, self.session)
self.pausemenu = PauseMenu(self.session, self, self.windows, in_editor_mode=False)
self.help_dialog = HelpDialog(self.windows, session=self.session)
# Icon manager
self.status_icon_manager = StatusIconManager(
renderer=self.session.view.renderer['GenericRenderer'],
layer=self.session.view.layers[LAYERS.OBJECTS]
)
self.production_finished_icon_manager = ProductionFinishedIconManager(
renderer=self.session.view.renderer['GenericRenderer'],
layer=self.session.view.layers[LAYERS.OBJECTS]
)
# 'minimap' is the guichan gui around the actual minimap, which is saved
# in self.minimap
self.mainhud = load_uh_widget('minimap.xml')
self.mainhud.position_technique = "right:top"
icon = self.mainhud.findChild(name="minimap")
self.minimap = Minimap(icon,
targetrenderer=horizons.globals.fife.targetrenderer,
imagemanager=horizons.globals.fife.imagemanager,
session=self.session,
view=self.session.view)
def speed_up():
SpeedUpCommand().execute(self.session)
def speed_down():
SpeedDownCommand().execute(self.session)
self.mainhud.mapEvents({
'zoomIn' : self.session.view.zoom_in,
'zoomOut' : self.session.view.zoom_out,
'rotateRight' : Callback.ChainedCallbacks(self.session.view.rotate_right, self.minimap.rotate_right),
'rotateLeft' : Callback.ChainedCallbacks(self.session.view.rotate_left, self.minimap.rotate_left),
'speedUp' : speed_up,
'speedDown' : speed_down,
'destroy_tool' : self.toggle_destroy_tool,
'build' : self.show_build_menu,
'diplomacyButton' : self.show_diplomacy_menu,
'gameMenuButton' : self.toggle_pause,
'logbook' : lambda: self.windows.toggle(self.logbook)
})
self.mainhud.show()
hotkey_replacements = {
'rotateRight': 'ROTATE_RIGHT',
'rotateLeft': 'ROTATE_LEFT',
'speedUp': 'SPEED_UP',
'speedDown': 'SPEED_DOWN',
'destroy_tool': 'DESTROY_TOOL',
'build': 'BUILD_TOOL',
'gameMenuButton': 'ESCAPE',
'logbook': 'LOGBOOK',
}
for (widgetname, action) in hotkey_replacements.iteritems():
widget = self.mainhud.findChild(name=widgetname)
keys = horizons.globals.fife.get_keys_for_action(action)
# No `.upper()` here: "Pause" looks better than "PAUSE".
keyname = HOTKEYS.DISPLAY_KEY.get(keys[0], keys[0].capitalize())
widget.helptext = widget.helptext.format(key=keyname)
#.........这里部分代码省略.........
示例3: IngameGui
# 需要导入模块: from horizons.gui.widgets.messagewidget import MessageWidget [as 别名]
# 或者: from horizons.gui.widgets.messagewidget.MessageWidget import load [as 别名]
#.........这里部分代码省略.........
def show_menu(self, menu):
"""Shows a menu
@param menu: str with the guiname or pychan object.
"""
if self._old_menu is not None:
if hasattr(self._old_menu, "remove_remove_listener"):
self._old_menu.remove_remove_listener( Callback(self.show_menu, None) )
self._old_menu.hide()
self._old_menu = self._get_menu_object(menu)
if self._old_menu is not None:
if hasattr(self._old_menu, "add_remove_listener"):
self._old_menu.add_remove_listener( Callback(self.show_menu, None) )
self._old_menu.show()
self.minimap_to_front()
def hide_menu(self):
self.show_menu(None)
def toggle_menu(self, menu):
"""Shows a menu or hides it if it is already displayed.
@param menu: parameter supported by show_menu().
"""
if self.get_cur_menu() == self._get_menu_object(menu):
self.hide_menu()
else:
self.show_menu(menu)
def save(self, db):
self.message_widget.save(db)
self.logbook.save(db)
self.resource_overview.save(db)
def load(self, db):
self.message_widget.load(db)
self.logbook.load(db)
self.resource_overview.load(db)
cur_settlement = LastActivePlayerSettlementManager().get_current_settlement()
self._cityinfo_set( HoverSettlementChanged(self, cur_settlement) )
self.minimap.draw() # update minimap to new world
def show_change_name_dialog(self, instance):
"""Shows a dialog where the user can change the name of a NamedComponant.
The game gets paused while the dialog is executed."""
events = {
OkButton.DEFAULT_NAME: Callback(self.change_name, instance),
CancelButton.DEFAULT_NAME: self._hide_change_name_dialog
}
self.main_gui.on_escape = self._hide_change_name_dialog
changename = self.widgets['change_name']
oldname = changename.findChild(name='old_name')
oldname.text = instance.get_component(SettlementNameComponent).name
newname = changename.findChild(name='new_name')
changename.mapEvents(events)
newname.capture(Callback(self.change_name, instance))
def forward_escape(event):
# the textfield will eat everything, even control events
if event.getKey().getValue() == fife.Key.ESCAPE:
self.main_gui.on_escape()
newname.capture( forward_escape, "keyPressed" )
changename.show()
newname.requestFocus()
示例4: IngameGui
# 需要导入模块: from horizons.gui.widgets.messagewidget import MessageWidget [as 别名]
# 或者: from horizons.gui.widgets.messagewidget.MessageWidget import load [as 别名]
class IngameGui(LivingObject):
"""Class handling all the ingame gui events.
Assumes that only 1 instance is used (class variables)"""
message_widget = livingProperty()
minimap = livingProperty()
keylistener = livingProperty()
def __init__(self, session, gui):
super(IngameGui, self).__init__()
self.session = session
assert isinstance(self.session, horizons.session.Session)
self.main_gui = gui
self.main_widget = None
self.settlement = None
self._old_menu = None
self.cursor = None
self.coordinates_tooltip = None
self.keylistener = IngameKeyListener(self.session)
self.cityinfo = CityInfo(self)
LastActivePlayerSettlementManager.create_instance(self.session)
self.logbook = LogBook(self.session)
self.message_widget = MessageWidget(self.session)
self.players_overview = PlayersOverview(self.session)
self.players_settlements = PlayersSettlements(self.session)
self.players_ships = PlayersShips(self.session)
self.chat_dialog = ChatDialog(self.main_gui, self, self.session)
self.change_name_dialog = ChangeNameDialog(self.main_gui, self, self.session)
self.pausemenu = PauseMenu(self.session, self.main_gui, self, in_editor_mode=False)
# Icon manager
self.status_icon_manager = StatusIconManager(
renderer=self.session.view.renderer['GenericRenderer'],
layer=self.session.view.layers[LAYERS.OBJECTS]
)
self.production_finished_icon_manager = ProductionFinishedIconManager(
renderer=self.session.view.renderer['GenericRenderer'],
layer=self.session.view.layers[LAYERS.OBJECTS]
)
# 'minimap' is the guichan gui around the actual minimap, which is saved
# in self.minimap
self.mainhud = load_uh_widget('minimap.xml')
self.mainhud.position_technique = "right+0:top+0"
icon = self.mainhud.findChild(name="minimap")
self.minimap = Minimap(icon,
targetrenderer=horizons.globals.fife.targetrenderer,
imagemanager=horizons.globals.fife.imagemanager,
session=self.session,
view=self.session.view)
def speed_up():
SpeedUpCommand().execute(self.session)
def speed_down():
SpeedDownCommand().execute(self.session)
self.mainhud.mapEvents({
'zoomIn' : self.session.view.zoom_in,
'zoomOut' : self.session.view.zoom_out,
'rotateRight' : Callback.ChainedCallbacks(self.session.view.rotate_right, self.minimap.rotate_right),
'rotateLeft' : Callback.ChainedCallbacks(self.session.view.rotate_left, self.minimap.rotate_left),
'speedUp' : speed_up,
'speedDown' : speed_down,
'destroy_tool' : self.toggle_destroy_tool,
'build' : self.show_build_menu,
'diplomacyButton' : self.show_diplomacy_menu,
'gameMenuButton' : self.toggle_pause,
'logbook' : self.logbook.toggle_visibility
})
self.mainhud.show()
self.resource_overview = ResourceOverviewBar(self.session)
# Register for messages
SettlerUpdate.subscribe(self._on_settler_level_change)
SpeedChanged.subscribe(self._on_speed_changed)
self.session.view.add_change_listener(self._update_zoom)
self._display_speed(self.session.timer.ticks_per_second)
def end(self):
self.mainhud.mapEvents({
'zoomIn' : None,
'zoomOut' : None,
'rotateRight' : None,
'rotateLeft': None,
'destroy_tool' : None,
'build' : None,
'diplomacyButton' : None,
'gameMenuButton' : None
})
self.message_widget = None
#.........这里部分代码省略.........
示例5: IngameGui
# 需要导入模块: from horizons.gui.widgets.messagewidget import MessageWidget [as 别名]
# 或者: from horizons.gui.widgets.messagewidget.MessageWidget import load [as 别名]
#.........这里部分代码省略.........
"""
if isinstance(menu, str):
menu = self.widgets[menu]
return menu
def get_cur_menu(self):
"""Returns menu that is currently displayed"""
return self._old_menu
def show_menu(self, menu):
"""Shows a menu
@param menu: str with the guiname or pychan object.
"""
if self._old_menu is not None:
self._old_menu.hide()
self._old_menu = self._get_menu_object(menu)
if self._old_menu is not None:
self._old_menu.show()
self.minimap_to_front()
def hide_menu(self):
self.show_menu(None)
def toggle_menu(self, menu):
"""Shows a menu or hides it if it is already displayed.
@param menu: parameter supported by show_menu().
"""
if self.get_cur_menu() == self._get_menu_object(menu):
self.hide_menu()
else:
self.show_menu(menu)
def build_load_tab(self, num):
"""Loads a subcontainer into the build menu and changes the tabs background.
@param num: number representing the tab to load.
"""
tab1 = self.widgets['build'].findChild(name=('tab'+str(self.active_build)))
tab2 = self.widgets['build'].findChild(name=('tab'+str(num)))
activetabimg, nonactiveimg= tab1._getImage(), tab2._getImage()
tab1._setImage(nonactiveimg)
tab2._setImage(activetabimg)
contentarea = self.widgets['build'].findChild(name='content')
contentarea.removeChild(self.widgets['build_tab'+str(self.active_build)])
contentarea.addChild(self.widgets['build_tab'+str(num)])
contentarea.adaptLayout()
self.active_build = num
def set_status_position(self, resource_name):
icon_name = resource_name + '_icon'
for i in xrange(1, 3):
lbl_name = resource_name + '_' + str(i)
# tools_1 = inventory amount, tools_2 = cost of to-be-built building
if resource_name == 'gold':
self._set_label_position('status_gold', lbl_name, icon_name, 33, 31 + i*20)
else:
self._set_label_position('status', lbl_name, icon_name, 24, 31 + i*20)
def _set_label_position(self, widget, lbl_name, icon_name, xoffset, yoffset):
icon = self.widgets[widget].child_finder(icon_name)
label = self.widgets[widget].child_finder(lbl_name)
label.position = (icon.position[0] - label.size[0]/2 + xoffset, yoffset)
def save(self, db):
self.message_widget.save(db)
self.logbook.save(db)
示例6: IngameGui
# 需要导入模块: from horizons.gui.widgets.messagewidget import MessageWidget [as 别名]
# 或者: from horizons.gui.widgets.messagewidget.MessageWidget import load [as 别名]
#.........这里部分代码省略.........
"""
if isinstance(menu, str):
menu = self.widgets[menu]
return menu
def get_cur_menu(self):
"""Returns menu that is currently displayed"""
return self._old_menu
def show_menu(self, menu):
"""Shows a menu
@param menu: str with the guiname or pychan object.
"""
if self._old_menu is not None:
self._old_menu.hide()
self._old_menu = self._get_menu_object(menu)
if self._old_menu is not None:
self._old_menu.show()
self.minimap_to_front()
def hide_menu(self):
self.show_menu(None)
def toggle_menu(self, menu):
"""Shows a menu or hides it if it is already displayed.
@param menu: parameter supported by show_menu().
"""
if self.get_cur_menu() == self._get_menu_object(menu):
self.hide_menu()
else:
self.show_menu(menu)
def build_load_tab(self, num):
"""Loads a subcontainer into the build menu and changes the tabs background.
@param num: number representing the tab to load.
"""
tab1 = self.widgets['build'].findChild(name=('tab'+str(self.active_build)))
tab2 = self.widgets['build'].findChild(name=('tab'+str(num)))
activetabimg, nonactiveimg= tab1._getImage(), tab2._getImage()
tab1._setImage(nonactiveimg)
tab2._setImage(activetabimg)
contentarea = self.widgets['build'].findChild(name='content')
contentarea.removeChild(self.widgets['build_tab'+str(self.active_build)])
contentarea.addChild(self.widgets['build_tab'+str(num)])
contentarea.adaptLayout()
self.active_build = num
def save(self, db):
self.message_widget.save(db)
self.logbook.save(db)
def load(self, db):
self.message_widget.load(db)
self.logbook.load(db)
self.minimap.draw() # update minimap to new world
def show_change_name_dialog(self, instance):
"""Shows a dialog where the user can change the name of a NamedObject.
The game gets paused while the dialog is executed."""
self.session.speed_pause()
events = {
'okButton': Callback(self.change_name, instance),
'cancelButton': self._hide_change_name_dialog
}
示例7: IngameGui
# 需要导入模块: from horizons.gui.widgets.messagewidget import MessageWidget [as 别名]
# 或者: from horizons.gui.widgets.messagewidget.MessageWidget import load [as 别名]
#.........这里部分代码省略.........
"""
if isinstance(menu, str):
menu = self.widgets[menu]
return menu
def get_cur_menu(self):
"""Returns menu that is currently displayed"""
return self._old_menu
def show_menu(self, menu):
"""Shows a menu
@param menu: str with the guiname or pychan object.
"""
if self._old_menu is not None:
self._old_menu.hide()
self._old_menu = self._get_menu_object(menu)
if self._old_menu is not None:
self._old_menu.show()
self.minimap_to_front()
def hide_menu(self):
self.show_menu(None)
def toggle_menu(self, menu):
"""Shows a menu or hides it if it is already displayed.
@param menu: parameter supported by show_menu().
"""
if self.get_cur_menu() == self._get_menu_object(menu):
self.hide_menu()
else:
self.show_menu(menu)
def build_load_tab(self, num):
"""Loads a subcontainer into the build menu and changes the tabs background.
@param num: number representing the tab to load.
"""
tab1 = self.widgets['build'].findChild(name=('tab'+str(self.active_build)))
tab2 = self.widgets['build'].findChild(name=('tab'+str(num)))
activetabimg, nonactiveimg= tab1._getImage(), tab2._getImage()
tab1._setImage(nonactiveimg)
tab2._setImage(activetabimg)
contentarea = self.widgets['build'].findChild(name='content')
contentarea.removeChild(self.widgets['build_tab'+str(self.active_build)])
contentarea.addChild(self.widgets['build_tab'+str(num)])
contentarea.adaptLayout()
self.active_build = num
def set_status_position(self, resource_name):
for i in xrange(1, 4):
icon_name = resource_name + '_icon'
plusx = 0
if i > 1:
# increase x position for lines greater the 1
plusx = 20
if resource_name == 'gold':
self.widgets['status_gold'].child_finder(resource_name + '_' + str(i)).position = (
self.widgets['status_gold'].child_finder(icon_name).position[0] + 33 - self.widgets['status_gold'].findChild(name = resource_name + '_' + str(i)).size[0]/2,
41 + 10 * i + plusx
)
else:
self.widgets['status'].child_finder(resource_name + '_' + str(i)).position = (
self.widgets['status'].child_finder(icon_name).position[0] + 24 - self.widgets['status'].child_finder(resource_name + '_' + str(i)).size[0]/2,
41 + 10 * i + plusx
)