本文整理汇总了Python中horizons.gui.mousetools.SelectionTool类的典型用法代码示例。如果您正苦于以下问题:Python SelectionTool类的具体用法?Python SelectionTool怎么用?Python SelectionTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SelectionTool类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
def load(self, savegame, players, is_scenario=False, campaign={}):
"""Loads a map.
@param savegame: path to the savegame database.
@param players: iterable of dictionaries containing id, name, color and local
@param is_scenario: Bool whether the loaded map is a scenario or not
"""
if is_scenario:
# savegame is a yaml file, that contains reference to actual map file
self.scenario_eventhandler = ScenarioEventHandler(self, savegame)
savegame = os.path.join(SavegameManager.maps_dir, \
self.scenario_eventhandler.get_map_file())
self.campaign = campaign
self.log.debug("Session: Loading from %s", savegame)
savegame_db = SavegameAccessor(savegame) # Initialize new dbreader
try:
# load how often the game has been saved (used to know the difference between
# a loaded and a new game)
self.savecounter = SavegameManager.get_metadata(savegame)['savecounter']
except KeyError:
self.savecounter = 0
self.world = World(self) # Load horizons.world module (check horizons/world/__init__.py)
self.world._init(savegame_db)
self.view.load(savegame_db) # load view
if not self.is_game_loaded():
# NOTE: this must be sorted before iteration, cause there is no defined order for
# iterating a dict, and it must happen in the same order for mp games.
for i in sorted(players):
self.world.setup_player(i['id'], i['name'], i['color'], i['local'])
center = self.world.init_new_world()
self.view.center(center[0], center[1])
else:
# try to load scenario data
self.scenario_eventhandler.load(savegame_db)
self.manager.load(savegame_db) # load the manager (there might me old scheduled ticks).
self.ingame_gui.load(savegame_db) # load the old gui positions and stuff
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` IS NULL"): # Set old selected instance
obj = WorldObject.get_object_by_id(instance_id[0])
self.selected_instances.add(obj)
obj.select()
for group in xrange(len(self.selection_groups)): # load user defined unit groups
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` = ?", group):
self.selection_groups[group].add(WorldObject.get_object_by_id(instance_id[0]))
# cursor has to be inited last, else player interacts with a not inited world with it.
self.cursor = SelectionTool(self)
self.cursor.apply_select() # Set cursor correctly, menus might need to be opened.
assert hasattr(self.world, "player"), 'Error: there is no human player'
"""
示例2: IngameGui
class IngameGui(LivingObject):
minimap = livingProperty()
keylistener = livingProperty()
message_widget = livingProperty()
def __init__(self, session):
self.session = session
self.cursor = None
self.coordinates_tooltip = None
self.keylistener = IngameKeyListener(self.session)
# used by NavigationTool
LastActivePlayerSettlementManager.create_instance(self.session)
# Mocks needed to act like the real IngameGui
self.show_menu = lambda x: 0
self.hide_menu = lambda: 0
# a logbook Dummy is necessary for message_widget to work
self.logbook = DummyLogbook()
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)
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),
'gameMenuButton': self.toggle_pause,
})
self.mainhud.show()
ZoomChanged.subscribe(self._update_zoom)
# Hide unnecessary buttons in hud
for widget in ("build", "speedUp", "speedDown", "destroy_tool", "diplomacyButton", "logbook"):
self.mainhud.findChild(name=widget).hide()
self.windows = WindowManager()
self.message_widget = MessageWidget(self.session)
self.pausemenu = PauseMenu(self.session, self, self.windows, in_editor_mode=True)
self.help_dialog = HelpDialog(self.windows)
def end(self):
self.mainhud.mapEvents({
'zoomIn': None,
'zoomOut': None,
'rotateRight': None,
'rotateLeft': None,
'gameMenuButton': None
})
self.mainhud.hide()
self.mainhud = None
self._settings_tab.hide()
self._settings_tab = None
self.windows.close_all()
self.minimap = None
self.keylistener = None
LastActivePlayerSettlementManager().remove()
LastActivePlayerSettlementManager.destroy_instance()
ZoomChanged.unsubscribe(self._update_zoom)
if self.cursor:
self.cursor.remove()
self.cursor.end()
self.cursor = None
super(IngameGui, self).end()
def handle_selection_group(self, num, ctrl_pressed):
# Someday, maybe cool stuff will be possible here.
# That day is not today, I'm afraid.
pass
def toggle_pause(self):
self.windows.toggle(self.pausemenu)
def toggle_help(self):
self.windows.toggle(self.help_dialog)
def load(self, savegame):
self.minimap.draw()
self.cursor = SelectionTool(self.session)
def setup(self):
"""Called after the world editor was initialized."""
self._settings_tab = TabWidget(self, tabs=[SettingsTab(self.session.world_editor, self)])
self._settings_tab.show()
def minimap_to_front(self):
"""Make sure the full right top gui is visible and not covered by some dialog"""
#.........这里部分代码省略.........
示例3: load
def load(self, savegame):
self.minimap.draw()
self.cursor = SelectionTool(self.session)
示例4: Session
#.........这里部分代码省略.........
self.timer = None
self.scenario_eventhandler = None
Scheduler().end()
Scheduler.destroy_instance()
self.selected_instances = None
self.selection_groups = None
self.status_icon_manager.end()
self.status_icon_manager = None
horizons.main._modules.session = None
self._clear_caches()
# subscriptions shouldn't survive listeners
MessageBus().reset()
def toggle_cursor(self, which, *args, **kwargs):
"""Alternate between the cursor which and default.
args and kwargs are used to construct which."""
if self.current_cursor == which:
self.set_cursor()
else:
self.set_cursor(which, *args, **kwargs)
def set_cursor(self, which='default', *args, **kwargs):
"""Sets the mousetool (i.e. cursor).
This is done here for encapsulation and control over destructors.
Further arguments are passed to the mouse tool constructor."""
self.cursor.remove()
self.current_cursor = which
klass = {
'default' : SelectionTool,
'selection' : SelectionTool,
'tearing' : TearingTool,
'pipette' : PipetteTool,
'attacking' : AttackingTool,
'building' : BuildingTool
}[which]
self.cursor = klass(self, *args, **kwargs)
def toggle_destroy_tool(self):
"""Initiate the destroy tool"""
self.toggle_cursor('tearing')
def autosave(self):
raise NotImplementedError
def quicksave(self):
raise NotImplementedError
def quickload(self):
raise NotImplementedError
def save(self, savegame=None):
raise NotImplementedError
def load(self, savegame, players, trader_enabled, pirate_enabled,
natural_resource_multiplier, is_scenario=False, campaign=None,
force_player_id=None, disasters_enabled=True, is_multiplayer=False):
"""Loads a map. Key method for starting a game.
@param savegame: path to the savegame database.
@param players: iterable of dictionaries containing id, name, color, local, ai, and difficulty
@param is_scenario: Bool whether the loaded map is a scenario or not
@param force_player_id: the worldid of the selected human player or default if None (debug option)
"""
"""
TUTORIAL: Here you see how the vital game elements (and some random things that are also required)
示例5: load
def load(self, savegame, players, trader_enabled, pirate_enabled,
natural_resource_multiplier, is_scenario=False, campaign=None,
force_player_id=None, disasters_enabled=True, is_multiplayer=False):
"""Loads a map. Key method for starting a game.
@param savegame: path to the savegame database.
@param players: iterable of dictionaries containing id, name, color, local, ai, and difficulty
@param is_scenario: Bool whether the loaded map is a scenario or not
@param force_player_id: the worldid of the selected human player or default if None (debug option)
"""
"""
TUTORIAL: Here you see how the vital game elements (and some random things that are also required)
are initialised.
"""
if is_scenario:
# savegame is a yaml file, that contains reference to actual map file
self.scenario_eventhandler = ScenarioEventHandler(self, savegame)
# scenario maps can be normal maps or scenario maps:
map_filename = self.scenario_eventhandler.get_map_file()
savegame = os.path.join(SavegameManager.scenario_maps_dir, map_filename)
if not os.path.exists(savegame):
savegame = os.path.join(SavegameManager.maps_dir, map_filename)
self.campaign = {} if not campaign else campaign
self.log.debug("Session: Loading from %s", savegame)
savegame_db = SavegameAccessor(savegame) # Initialize new dbreader
savegame_data = SavegameManager.get_metadata(savegame)
# load how often the game has been saved (used to know the difference between
# a loaded and a new game)
self.savecounter = savegame_data.get('savecounter', 0)
if savegame_data.get('rng_state', None):
rng_state_list = json.loads( savegame_data['rng_state'] )
# json treats tuples as lists, but we need tuples here, so convert back
def rec_list_to_tuple(x):
if isinstance(x, list):
return tuple( rec_list_to_tuple(i) for i in x )
else:
return x
rng_state_tuple = rec_list_to_tuple(rng_state_list)
# changing the rng is safe for mp, as all players have to have the same map
self.random.setstate( rng_state_tuple )
self.world = World(self) # Load horizons.world module (check horizons/world/__init__.py)
self.world._init(savegame_db, force_player_id, disasters_enabled=disasters_enabled)
self.view.load(savegame_db) # load view
if not self.is_game_loaded():
# NOTE: this must be sorted before iteration, cause there is no defined order for
# iterating a dict, and it must happen in the same order for mp games.
for i in sorted(players, lambda p1, p2: cmp(p1['id'], p2['id'])):
self.world.setup_player(i['id'], i['name'], i['color'], i['clientid'] if is_multiplayer else None, i['local'], i['ai'], i['difficulty'])
self.world.set_forced_player(force_player_id)
center = self.world.init_new_world(trader_enabled, pirate_enabled, natural_resource_multiplier)
self.view.center(center[0], center[1])
else:
# try to load scenario data
self.scenario_eventhandler.load(savegame_db)
self.manager.load(savegame_db) # load the manager (there might me old scheduled ticks).
self.world.init_fish_indexer() # now the fish should exist
if self.is_game_loaded():
LastActivePlayerSettlementManager().load(savegame_db) # before ingamegui
self.ingame_gui.load(savegame_db) # load the old gui positions and stuff
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` IS NULL"): # Set old selected instance
obj = WorldObject.get_object_by_id(instance_id[0])
self.selected_instances.add(obj)
obj.get_component(SelectableComponent).select()
for group in xrange(len(self.selection_groups)): # load user defined unit groups
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` = ?", group):
self.selection_groups[group].add(WorldObject.get_object_by_id(instance_id[0]))
# cursor has to be inited last, else player interacts with a not inited world with it.
self.current_cursor = 'default'
self.cursor = SelectionTool(self)
# Set cursor correctly, menus might need to be opened.
# Open menus later; they may need unit data not yet inited
self.cursor.apply_select()
Scheduler().before_ticking()
savegame_db.close()
assert hasattr(self.world, "player"), 'Error: there is no human player'
"""
示例6: Session
#.........这里部分代码省略.........
savegame_db = SavegameAccessor(savegame) # Initialize new dbreader
try:
# load how often the game has been saved (used to know the difference between
# a loaded and a new game)
self.savecounter = SavegameManager.get_metadata(savegame)['savecounter']
except KeyError:
self.savecounter = 0
self.world = World(self) # Load horizons.world module (check horizons/world/__init__.py)
self.world._init(savegame_db)
self.view.load(savegame_db) # load view
if not self.is_game_loaded():
# NOTE: this must be sorted before iteration, cause there is no defined order for
# iterating a dict, and it must happen in the same order for mp games.
for i in sorted(players):
self.world.setup_player(i['id'], i['name'], i['color'], i['local'])
center = self.world.init_new_world()
self.view.center(center[0], center[1])
else:
# try to load scenario data
self.scenario_eventhandler.load(savegame_db)
self.manager.load(savegame_db) # load the manager (there might me old scheduled ticks).
self.ingame_gui.load(savegame_db) # load the old gui positions and stuff
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` IS NULL"): # Set old selected instance
obj = WorldObject.get_object_by_id(instance_id[0])
self.selected_instances.add(obj)
obj.select()
for group in xrange(len(self.selection_groups)): # load user defined unit groups
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` = ?", group):
self.selection_groups[group].add(WorldObject.get_object_by_id(instance_id[0]))
# cursor has to be inited last, else player interacts with a not inited world with it.
self.cursor = SelectionTool(self)
self.cursor.apply_select() # Set cursor correctly, menus might need to be opened.
assert hasattr(self.world, "player"), 'Error: there is no human player'
"""
TUTORIAL:
From here on you should digg into the classes that are loaded above, especially the world class.
(horizons/world/__init__.py). It's where the magic happens and all buildings and units are loaded.
"""
def speed_set(self, ticks):
"""Set game speed to ticks ticks per second"""
raise NotImplementedError
def display_speed(self):
text = u''
tps = self.timer.ticks_per_second
if tps == 0: # pause
text = u'0x'
elif tps == GAME_SPEED.TICKS_PER_SECOND: # normal speed, 1x
pass # display nothing
else:
text = unicode(tps/GAME_SPEED.TICKS_PER_SECOND) + u'x' # 2x, 4x, ...
self.ingame_gui.display_game_speed(text)
def speed_up(self):
if self.timer.ticks_per_second in GAME_SPEED.TICK_RATES:
i = GAME_SPEED.TICK_RATES.index(self.timer.ticks_per_second)
if i + 1 < len(GAME_SPEED.TICK_RATES):
self.speed_set(GAME_SPEED.TICK_RATES[i + 1])
else:
self.speed_set(GAME_SPEED.TICK_RATES[0])
示例7: load
def load(self, savegame, players, is_scenario=False, campaign=None):
"""Loads a map.
@param savegame: path to the savegame database.
@param players: iterable of dictionaries containing id, name, color, local, ai, and difficulty
@param is_scenario: Bool whether the loaded map is a scenario or not
"""
if is_scenario:
# savegame is a yaml file, that contains reference to actual map file
self.scenario_eventhandler = ScenarioEventHandler(self, savegame)
savegame = os.path.join(SavegameManager.maps_dir, \
self.scenario_eventhandler.get_map_file())
self.campaign = {} if not campaign else campaign
self.log.debug("Session: Loading from %s", savegame)
savegame_db = SavegameAccessor(savegame) # Initialize new dbreader
savegame_data = SavegameManager.get_metadata(savegame)
# load how often the game has been saved (used to know the difference between
# a loaded and a new game)
self.savecounter = 0 if not 'savecounter' in savegame_data else savegame_data['savecounter']
if savegame_data.get('rng_state', None):
rng_state_list = json.loads( savegame_data['rng_state'] )
# json treats tuples as lists, but we need tuples here, so convert back
def rec_list_to_tuple(x):
if isinstance(x, list):
return tuple( rec_list_to_tuple(i) for i in x )
else:
return x
rng_state_tuple = rec_list_to_tuple(rng_state_list)
# changing the rng is safe for mp, as all players have to have the same map
self.random.setstate( rng_state_tuple )
self.world = World(self) # Load horizons.world module (check horizons/world/__init__.py)
self.world._init(savegame_db)
self.view.load(savegame_db) # load view
if not self.is_game_loaded():
# NOTE: this must be sorted before iteration, cause there is no defined order for
# iterating a dict, and it must happen in the same order for mp games.
for i in sorted(players, lambda p1, p2: cmp(p1['id'], p2['id'])):
self.world.setup_player(i['id'], i['name'], i['color'], i['local'], i['ai'], i['difficulty'])
center = self.world.init_new_world()
self.view.center(center[0], center[1])
else:
# try to load scenario data
self.scenario_eventhandler.load(savegame_db)
self.manager.load(savegame_db) # load the manager (there might me old scheduled ticks).
self.world.init_fish_indexer() # now the fish should exist
self.ingame_gui.load(savegame_db) # load the old gui positions and stuff
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` IS NULL"): # Set old selected instance
obj = WorldObject.get_object_by_id(instance_id[0])
self.selected_instances.add(obj)
obj.select()
for group in xrange(len(self.selection_groups)): # load user defined unit groups
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` = ?", group):
self.selection_groups[group].add(WorldObject.get_object_by_id(instance_id[0]))
# cursor has to be inited last, else player interacts with a not inited world with it.
self.cursor = SelectionTool(self)
# Set cursor correctly, menus might need to be opened.
# Open menus later, they may need unit data not yet inited
self.cursor.apply_select()
assert hasattr(self.world, "player"), 'Error: there is no human player'
"""
示例8: load
def load(self, options):
"""Loads a map. Key method for starting a game."""
"""
TUTORIAL: Here you see how the vital game elements (and some random things that are also required)
are initialised.
"""
if options.is_scenario:
# game_identifier is a yaml file, that contains reference to actual map file
self.scenario_eventhandler = ScenarioEventHandler(self, options.game_identifier)
# scenario maps can be normal maps or scenario maps:
map_filename = self.scenario_eventhandler.get_map_file()
options.game_identifier = os.path.join(SavegameManager.scenario_maps_dir, map_filename)
if not os.path.exists(options.game_identifier):
options.game_identifier = os.path.join(SavegameManager.maps_dir, map_filename)
options.is_map = True
self.log.debug("Session: Loading from %s", options.game_identifier)
savegame_db = SavegameAccessor(options.game_identifier, options.is_map) # Initialize new dbreader
savegame_data = SavegameManager.get_metadata(savegame_db.db_path)
self.view.resize_layers(savegame_db)
# load how often the game has been saved (used to know the difference between
# a loaded and a new game)
self.savecounter = savegame_data.get('savecounter', 0)
if savegame_data.get('rng_state', None):
rng_state_list = json.loads(savegame_data['rng_state'])
# json treats tuples as lists, but we need tuples here, so convert back
def rec_list_to_tuple(x):
if isinstance(x, list):
return tuple(rec_list_to_tuple(i) for i in x)
else:
return x
rng_state_tuple = rec_list_to_tuple(rng_state_list)
# changing the rng is safe for mp, as all players have to have the same map
self.random.setstate(rng_state_tuple)
self.world = World(self) # Load horizons.world module (check horizons/world/__init__.py)
self.world._init(savegame_db, options.force_player_id, disasters_enabled=options.disasters_enabled)
self.view.load(savegame_db) # load view
if not self.is_game_loaded():
options.init_new_world(self)
else:
# try to load scenario data
self.scenario_eventhandler.load(savegame_db)
self.manager.load(savegame_db) # load the manager (there might me old scheduled ticks).
self.world.init_fish_indexer() # now the fish should exist
if self.is_game_loaded():
LastActivePlayerSettlementManager().load(savegame_db) # before ingamegui
self.ingame_gui.load(savegame_db) # load the old gui positions and stuff
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` IS NULL"): # Set old selected instance
obj = WorldObject.get_object_by_id(instance_id[0])
self.selected_instances.add(obj)
obj.get_component(SelectableComponent).select()
for group in xrange(len(self.selection_groups)): # load user defined unit groups
for instance_id in savegame_db("SELECT id FROM selected WHERE `group` = ?", group):
self.selection_groups[group].add(WorldObject.get_object_by_id(instance_id[0]))
# cursor has to be inited last, else player interacts with a not inited world with it.
self.current_cursor = 'default'
self.cursor = SelectionTool(self)
# Set cursor correctly, menus might need to be opened.
# Open menus later; they may need unit data not yet inited
self.cursor.apply_select()
Scheduler().before_ticking()
savegame_db.close()
assert hasattr(self.world, "player"), 'Error: there is no human player'
"""
示例9: Session
#.........这里部分代码省略.........
horizons.main.fife.sound.emitter['effects'].stop()
horizons.main.fife.sound.emitter['speech'].stop()
if hasattr(self, "cursor"): # the line below would crash uglily on ^C
self.cursor.remove()
self.cursor = None
self.world = None
self.keylistener = None
self.ingame_gui = None
self.view = None
self.manager = None
self.timer = None
self.scenario_eventhandler = None
Scheduler.destroy_instance()
self.selected_instances = None
self.selection_groups = None
def toggle_cursor(self, which, *args, **kwargs):
"""Alternate between the cursor which and default.
args and kwargs are used to construct which."""
if self.current_cursor == which:
self.set_cursor()
else:
self.set_cursor(which, *args, **kwargs)
def set_cursor(self, which='default', *args, **kwargs):
"""Sets the mousetool (i.e. cursor).
This is done here for encapsulation and control over destructors.
Further arguments are passed to the mouse tool constructor."""
self.cursor.remove()
self.current_cursor = which
klass = {
'default' : SelectionTool,
'selection' : SelectionTool,
'tearing' : TearingTool,
'pipette' : PipetteTool,
'attacking' : AttackingTool,
'building' : BuildingTool
}[which]
self.cursor = klass(self, *args, **kwargs)
def toggle_destroy_tool(self):
"""Initiate the destroy tool"""
self.toggle_cursor('tearing')
def autosave(self):
raise NotImplementedError
def quicksave(self):
raise NotImplementedError
def quickload(self):
raise NotImplementedError
def save(self, savegame=None):
raise NotImplementedError
def load(self, savegame, players, trader_enabled, pirate_enabled,
natural_resource_multiplier, is_scenario=False, campaign=None,
force_player_id=None, disasters_enabled=True):
"""Loads a map. Key method for starting a game.
@param savegame: path to the savegame database.
@param players: iterable of dictionaries containing id, name, color, local, ai, and difficulty
@param is_scenario: Bool whether the loaded map is a scenario or not
@param force_player_id: the worldid of the selected human player or default if None (debug option)
"""
"""
TUTORIAL: Here you see how the vital game elements (and some random things that are also required)
示例10: IngameGui
class IngameGui(LivingObject):
minimap = livingProperty()
keylistener = livingProperty()
def __init__(self, session, main_gui):
self.session = session
self.main_gui = main_gui
self.cursor = None
self.coordinates_tooltip = None
self.keylistener = IngameKeyListener(self.session)
# used by NavigationTool
LastActivePlayerSettlementManager.create_instance(self.session)
# Mocks needed to act like the real IngameGui
self.show_menu = Dummy
self.hide_menu = Dummy
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)
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),
'gameMenuButton': self.toggle_pause,
})
self.mainhud.show()
self.session.view.add_change_listener(self._update_zoom)
# Hide unnecessary buttons in hud
for widget in ("build", "speedUp", "speedDown", "destroy_tool", "diplomacyButton", "logbook"):
self.mainhud.findChild(name=widget).hide()
self.save_map_dialog = SaveMapDialog(self.main_gui, self, self.session)
self.pausemenu = PauseMenu(self.session, self.main_gui, self, in_editor_mode=True)
def end(self):
self.mainhud.mapEvents({
'zoomIn': None,
'zoomOut': None,
'rotateRight': None,
'rotateLeft': None,
'gameMenuButton': None
})
self.minimap = None
self.keylistener = None
LastActivePlayerSettlementManager().remove()
LastActivePlayerSettlementManager.destroy_instance()
self.session.view.remove_change_listener(self._update_zoom)
if self.cursor:
self.cursor.remove()
self.cursor.end()
self.cursor = None
super(IngameGui, self).end()
def toggle_pause(self):
self.pausemenu.toggle()
def load(self, savegame):
self.minimap.draw()
self.cursor = SelectionTool(self.session)
def setup(self):
"""Called after the world editor was initialized."""
self._settings_tab = TabWidget(self, tabs=[SettingsTab(self.session.world_editor, self)])
self._settings_tab.show()
def minimap_to_front(self):
"""Make sure the full right top gui is visible and not covered by some dialog"""
self.mainhud.hide()
self.mainhud.show()
def show_save_map_dialog(self):
"""Shows a dialog where the user can set the name of the saved map."""
self.save_map_dialog.show()
def on_escape(self):
pass
def on_key_press(self, action, evt):
_Actions = KeyConfig._Actions
if action == _Actions.ESCAPE:
return self.on_escape()
def set_cursor(self, which='default', *args, **kwargs):
"""Sets the mousetool (i.e. cursor).
This is done here for encapsulation and control over destructors.
#.........这里部分代码省略.........
示例11: destroy_tool
def destroy_tool(self):
"""Initiate the destroy tool"""
if not hasattr(self.cursor, 'tear_tool_active') or \
not self.cursor.tear_tool_active:
self.cursor = TearingTool(self)
self.ingame_gui.hide_menu()