本文整理汇总了Python中horizons.view.View.load方法的典型用法代码示例。如果您正苦于以下问题:Python View.load方法的具体用法?Python View.load怎么用?Python View.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.view.View
的用法示例。
在下文中一共展示了View.load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Session
# 需要导入模块: from horizons.view import View [as 别名]
# 或者: from horizons.view.View import load [as 别名]
class Session(LivingObject):
"""The Session class represents the game's main ingame view and controls cameras and map loading.
It is alive as long as a game is running.
Many objects require a reference to this, which makes it a pseudo-global, from which we would
like to move away in the long term. This is where we hope the components come into play, which
you will encounter later.
This is the most important class if you are going to hack on Unknown Horizons; it provides most of
the important ingame variables.
Here's a small list of commonly used attributes:
* world - horizons.world instance of the currently running horizons. Stores players and islands,
which store settlements, which store buildings, which have productions and collectors.
Therefore, world deserves its name -- it contains the whole game state.
* scheduler - horizons.scheduler instance. Used to execute timed events. Master of time in UH.
* manager - horizons.manager instance. Used to execute commands (used to apply user interactions).
There is a singleplayer and a multiplayer version. Our mp system works by the mp-manager not
executing the commands directly, but sending them to all players, where they will be executed
at the same tick.
* view - horizons.view instance. Used to control the ingame camera.
* ingame_gui - horizons.gui.ingame_gui instance. Used to control the ingame gui framework.
(This is different from gui, which is the main menu and general session-independent gui)
* cursor - horizons.gui.{navigation/cursor/selection/building}tool instance. Used to handle
mouse events.
* selected_instances - Set that holds the currently selected instances (building, units).
TUTORIAL:
For further digging you should now be checking out the load() function.
"""
timer = livingProperty()
manager = livingProperty()
view = livingProperty()
ingame_gui = livingProperty()
keylistener = livingProperty()
scenario_eventhandler = livingProperty()
log = logging.getLogger('session')
def __init__(self, gui, db, rng_seed=None):
super(Session, self).__init__()
assert isinstance(db, horizons.util.uhdbaccessor.UhDbAccessor)
self.log.debug("Initing session")
self.gui = gui # main gui, not ingame gui
self.db = db # main db for game data (game.sql)
# this saves how often the current game has been saved
self.savecounter = 0
self.is_alive = True
self._clear_caches()
#game
self.random = self.create_rng(rng_seed)
assert isinstance(self.random, Random)
self.timer = self.create_timer()
Scheduler.create_instance(self.timer)
self.manager = self.create_manager()
self.view = View(self)
Entities.load(self.db)
self.scenario_eventhandler = ScenarioEventHandler(self) # dummy handler with no events
self.campaign = {}
#GUI
self.gui.session = self
self.ingame_gui = IngameGui(self, self.gui)
self.keylistener = IngameKeyListener(self)
self.coordinates_tooltip = None
self.display_speed()
LastActivePlayerSettlementManager.create_instance(self)
self.status_icon_manager = StatusIconManager(
renderer=self.view.renderer['GenericRenderer'],
layer=self.view.layers[LAYERS.OBJECTS]
)
self.production_finished_icon_manager = None
self.create_production_finished_icon_manager()
self.selected_instances = set()
self.selection_groups = [set() for _ in range(10)] # List of sets that holds the player assigned unit groups.
self._old_autosave_interval = None
def create_production_finished_icon_manager(self):
""" Checks the settings if we should display resrouce icons.
If True: Create the ProductionFinishedIconManager
If False and a manager is currently running: End it
"""
show_resource_icons = bool(horizons.globals.fife.get_uh_setting("ShowResourceIcons"))
if show_resource_icons:
self.production_finished_icon_manager = ProductionFinishedIconManager(
renderer=self.view.renderer['GenericRenderer'],
layer=self.view.layers[LAYERS.OBJECTS]
)
else:
self.end_production_finished_icon_manager()
def start(self):
"""Actually starts the game."""
self.timer.activate()
#.........这里部分代码省略.........
示例2: Session
# 需要导入模块: from horizons.view import View [as 别名]
# 或者: from horizons.view.View import load [as 别名]
class Session(LivingObject):
"""Session class represents the games main ingame view and controls cameras and map loading.
This is the most important class if you are going to hack on Unknown Horizons, it provides most of
the important ingame variables.
Here's a small list of commonly used attributes:
* manager - horizons.manager instance. Used to execute commands that need to be tick,
synchronized check the class for more information.
* scheduler - horizons.scheduler instance. Used to execute timed events that do not effect
network games but rather control the local simulation.
* view - horizons.view instance. Used to control the ingame camera.
* ingame_gui - horizons.gui.ingame_gui instance. Used to controll the ingame gui.
* cursor - horizons.gui.{navigation/cursor/selection/building}tool instance. Used to controll
mouse events, check the classes for more info.
* selected_instances - Set that holds the currently selected instances (building, units).
* world - horizons.world instance of the currently running horizons. Stores islands, players,
for later access.
TUTORIAL:
For further digging you should now be checking out the load() function.
"""
timer = livingProperty()
manager = livingProperty()
view = livingProperty()
ingame_gui = livingProperty()
keylistener = livingProperty()
cursor = livingProperty()
world = livingProperty()
scenario_eventhandler = livingProperty()
log = logging.getLogger('session')
def __init__(self, gui, db):
super(Session, self).__init__()
self.log.debug("Initing session")
self.gui = gui # main gui, not ingame gui
self.db = db # main db for game data (game.sqlite)
# this saves how often the current game has been saved
self.savecounter = 0
self.is_alive = True
WorldObject.reset()
NamedObject.reset()
#game
self.random = self.create_rng()
self.timer = Timer()
Scheduler.create_instance(self.timer)
self.manager = self.create_manager()
self.view = View(self, (15, 15))
Entities.load(self.db)
self.scenario_eventhandler = ScenarioEventHandler(self) # dummy handler with no events
self.campaign = {}
#GUI
self.gui.session = self
self.ingame_gui = IngameGui(self, self.gui)
self.keylistener = IngameKeyListener(self)
self.display_speed()
self.selected_instances = set()
self.selection_groups = [set()] * 10 # List of sets that holds the player assigned unit groups.
def start(self):
"""Acctually starts the game."""
self.timer.activate()
def create_manager(self):
"""Returns instance of command manager (currently MPManager or SPManager)"""
raise NotImplementedError
def create_rng(self):
"""Returns a RNG (random number generator). Must support the python random.Random interface"""
raise NotImplementedError
def end(self):
self.log.debug("Ending session")
self.is_alive = False
self.gui.session = None
Scheduler().rem_all_classinst_calls(self)
ExtScheduler().rem_all_classinst_calls(self)
if horizons.main.fife.get_fife_setting("PlaySounds"):
for emitter in horizons.main.fife.emitter['ambient'][:]:
emitter.stop()
horizons.main.fife.emitter['ambient'].remove(emitter)
horizons.main.fife.emitter['effects'].stop()
horizons.main.fife.emitter['speech'].stop()
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()
#.........这里部分代码省略.........
示例3: Session
# 需要导入模块: from horizons.view import View [as 别名]
# 或者: from horizons.view.View import load [as 别名]
class Session(LivingObject):
"""The Session class represents the game's main ingame view and controls cameras and map loading.
It is alive as long as a game is running.
Many objects require a reference to this, which makes it a pseudo-global, from which we would
like to move away in the long term. This is where we hope the components come into play, which
you will encounter later.
This is the most important class if you are going to hack on Unknown Horizons; it provides most of
the important ingame variables.
Here's a small list of commonly used attributes:
* world - horizons.world instance of the currently running horizons. Stores players and islands,
which store settlements, which store buildings, which have productions and collectors.
Therefore, world deserves its name -- it contains the whole game state.
* scheduler - horizons.scheduler instance. Used to execute timed events. Master of time in UH.
* manager - horizons.manager instance. Used to execute commands (used to apply user interactions).
There is a singleplayer and a multiplayer version. Our mp system works by the mp-manager not
executing the commands directly, but sending them to all players, where they will be executed
at the same tick.
* view - horizons.view instance. Used to control the ingame camera.
* ingame_gui - horizons.gui.ingame_gui instance. Used to control the ingame gui framework.
(This is different from gui, which is the main menu and general session-independent gui)
* selected_instances - Set that holds the currently selected instances (building, units).
TUTORIAL:
For further digging you should now be checking out the load() function.
"""
timer = livingProperty()
manager = livingProperty()
view = livingProperty()
ingame_gui = livingProperty()
scenario_eventhandler = livingProperty()
log = logging.getLogger('session')
def __init__(self, db, rng_seed=None, ingame_gui_class=IngameGui):
super(Session, self).__init__()
assert isinstance(db, horizons.util.uhdbaccessor.UhDbAccessor)
self.log.debug("Initing session")
self.db = db # main db for game data (game.sql)
# this saves how often the current game has been saved
self.savecounter = 0
self.is_alive = True
self._clear_caches()
#game
self.random = self.create_rng(rng_seed)
assert isinstance(self.random, Random)
self.timer = self.create_timer()
Scheduler.create_instance(self.timer)
self.manager = self.create_manager()
self.view = View()
Entities.load(self.db)
self.scenario_eventhandler = ScenarioEventHandler(self) # dummy handler with no events
#GUI
self._ingame_gui_class = ingame_gui_class
self.selected_instances = set()
# List of sets that holds the player assigned unit groups.
self.selection_groups = [set()] * 10
self._old_autosave_interval = None
def start(self):
"""Actually starts the game."""
self.timer.activate()
self.scenario_eventhandler.start()
self.reset_autosave()
SettingChanged.subscribe(self._on_setting_changed)
def reset_autosave(self):
"""(Re-)Set up autosave. Called if autosave interval has been changed."""
# get_uh_setting returns floats like 4.0 and 42.0 since slider stepping is 1.0.
interval = int(horizons.globals.fife.get_uh_setting("AutosaveInterval"))
if interval != self._old_autosave_interval:
self._old_autosave_interval = interval
ExtScheduler().rem_call(self, self.autosave)
if interval != 0: #autosave
self.log.debug("Initing autosave every %s minutes", interval)
ExtScheduler().add_new_object(self.autosave, self, interval * 60, -1)
def _on_setting_changed(self, message):
if message.setting_name == 'AutosaveInterval':
self.reset_autosave()
def create_manager(self):
"""Returns instance of command manager (currently MPManager or SPManager)"""
raise NotImplementedError
def create_rng(self, seed=None):
"""Returns a RNG (random number generator). Must support the python random.Random interface"""
raise NotImplementedError
def create_timer(self):
"""Returns a Timer instance."""
raise NotImplementedError
@classmethod
#.........这里部分代码省略.........
示例4: Session
# 需要导入模块: from horizons.view import View [as 别名]
# 或者: from horizons.view.View import load [as 别名]
class Session(LivingObject):
"""Session class represents the games main ingame view and controls cameras and map loading.
It is alive as long as a game is running.
Many objects require a reference to this, which makes it a pseudo-global, from what we would
like to move away long-term. This is where we hope the components come into play, which
you will encounter later
This is the most important class if you are going to hack on Unknown Horizons, it provides most of
the important ingame variables.
Here's a small list of commonly used attributes:
* world - horizons.world instance of the currently running horizons. Stores players and islands,
which store settlements, which store buildings, which have productions and collectors.
Therefore world deserves its name, it contains the whole game state.
* scheduler - horizons.scheduler instance. Used to execute timed events. Master of time in UH.
* manager - horizons.manager instance. Used to execute commands (used to apply user interactions).
There is a singleplayer and a multiplayer version. Our mp system works by the mp-manager not
executing the commands directly, but sending them to all players, where they will be executed
at the same tick.
* view - horizons.view instance. Used to control the ingame camera.
* ingame_gui - horizons.gui.ingame_gui instance. Used to control the ingame gui framework.
(This is different from gui, which is the main menu and general session-independent gui)
* cursor - horizons.gui.{navigation/cursor/selection/building}tool instance. Used to handle
mouse events.
* selected_instances - Set that holds the currently selected instances (building, units).
TUTORIAL:
For further digging you should now be checking out the load() function.
"""
timer = livingProperty()
manager = livingProperty()
view = livingProperty()
ingame_gui = livingProperty()
keylistener = livingProperty()
world = livingProperty()
scenario_eventhandler = livingProperty()
log = logging.getLogger('session')
def __init__(self, gui, db, rng_seed=None):
super(Session, self).__init__()
assert isinstance(gui, Gui)
assert isinstance(db, horizons.util.uhdbaccessor.UhDbAccessor)
self.log.debug("Initing session")
self.gui = gui # main gui, not ingame gui
self.db = db # main db for game data (game.sql)
# this saves how often the current game has been saved
self.savecounter = 0
self.is_alive = True
self.message_bus = MessageBus()
# misc
WorldObject.reset()
NamedComponent.reset()
AIPlayer.clear_caches()
#game
self.random = self.create_rng(rng_seed)
assert isinstance(self.random, Random)
self.timer = self.create_timer()
Scheduler.create_instance(self.timer)
self.manager = self.create_manager()
self.view = View(self)
Entities.load(self.db)
self.scenario_eventhandler = ScenarioEventHandler(self) # dummy handler with no events
self.campaign = {}
#GUI
self.gui.session = self
self.ingame_gui = IngameGui(self, self.gui)
self.keylistener = IngameKeyListener(self)
self.coordinates_tooltip = None
self.display_speed()
LastActivePlayerSettlementManager.create_instance(self)
self.status_icon_manager = StatusIconManager(self)
self.selected_instances = set()
self.selection_groups = [set()] * 10 # List of sets that holds the player assigned unit groups.
def start(self):
"""Actually starts the game."""
self.timer.activate()
def create_manager(self):
"""Returns instance of command manager (currently MPManager or SPManager)"""
raise NotImplementedError
def create_rng(self, seed=None):
"""Returns a RNG (random number generator). Must support the python random.Random interface"""
raise NotImplementedError
def create_timer(self):
"""Returns a Timer instance."""
raise NotImplementedError
def end(self):
self.log.debug("Ending session")
#.........这里部分代码省略.........