Restructure event handling
Events start in the Interface. The interface gets first crack at any incoming events. If the interface doesn't handle the event, it is given to the engine. The engine has an EngineEventHandler that yields actions just like the event handler prior to this change. The interface's event handler passes events to each window in the interface. Windows can choose to handle events however they like, and they return a bool indicating whether the event was fully handled.
This commit is contained in:
parent
ee1c6f2222
commit
003aedf30e
6 changed files with 197 additions and 116 deletions
|
@ -9,6 +9,7 @@ from . import log
|
|||
from .configuration import Configuration, FontConfiguration, FontConfigurationError
|
||||
from .engine import Engine
|
||||
from .geometry import Size
|
||||
from .interface import Interface
|
||||
|
||||
|
||||
def parse_args(argv, *a, **kw):
|
||||
|
@ -45,15 +46,15 @@ def main(argv):
|
|||
|
||||
configuration = Configuration(
|
||||
console_font_configuration=font_config,
|
||||
map_size=Size(80, 24),
|
||||
map_size=Size(80, 40),
|
||||
sandbox=args.sandbox)
|
||||
|
||||
engine = Engine(configuration)
|
||||
|
||||
interface = Interface(configuration.console_size, engine)
|
||||
tileset = configuration.console_font_configuration.tileset
|
||||
console = tcod.Console(*configuration.console_size.numpy_shape, order='F')
|
||||
with tcod.context.new(columns=console.width, rows=console.height, tileset=tileset) as context:
|
||||
engine.run_event_loop(context, console)
|
||||
|
||||
with tcod.context.new(columns=interface.console.width, rows=interface.console.height, tileset=tileset) as context:
|
||||
interface.run_event_loop(context)
|
||||
|
||||
return 0
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue