post arbitrary events
This commit is contained in:
parent
f1591fad20
commit
dfa83f466c
|
@ -68,3 +68,9 @@ class Audio(GameChild):
|
|||
if channel:
|
||||
channel.pause()
|
||||
self.paused = not paused
|
||||
|
||||
def is_bgm_playing(self):
|
||||
current = self.current_channel
|
||||
if current and current.get_sound():
|
||||
return True
|
||||
return music.get_busy()
|
||||
|
|
|
@ -80,6 +80,7 @@ class Configuration(RawConfigParser):
|
|||
set_option(section, "left", "K_LEFT, K_a")
|
||||
set_option(section, "capture-screen", "K_F9")
|
||||
set_option(section, "toggle-fullscreen", "K_F11")
|
||||
set_option(section, "reset-game", "K_F8")
|
||||
section = "event"
|
||||
add_section(section)
|
||||
set_option(section, "custom-event-id", "USEREVENT")
|
||||
|
|
|
@ -15,7 +15,7 @@ class Display(GameChild):
|
|||
|
||||
def set_screen(self, flags=0):
|
||||
self.screen = display.set_mode(self.config["dimensions"], flags)
|
||||
// robot spaceman ninja ranger
|
||||
# robot spaceman ninja ranger
|
||||
|
||||
def set_caption(self):
|
||||
display.set_caption(self.config["caption"])
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from os.path import exists, join, basename, normpath, abspath
|
||||
from sys import argv
|
||||
|
||||
from pygame import mixer
|
||||
from pygame import mixer, event
|
||||
from pygame.locals import *
|
||||
|
||||
import Game
|
||||
|
@ -39,7 +39,7 @@ class GameChild:
|
|||
if self.is_shared_mode() and not self.is_absolute_path(root):
|
||||
continue
|
||||
path = join(root, rel_path)
|
||||
if (exists(path)):
|
||||
if exists(path):
|
||||
return path
|
||||
self.print_debug("Couldn't find resource: {0}, {1}".\
|
||||
format(section, option))
|
||||
|
@ -71,3 +71,9 @@ class GameChild:
|
|||
name = self.get_configuration().get("event", "command-event-name")
|
||||
return evt.type == self.get_custom_event_id() and evt.name == name and \
|
||||
evt.command == cmd
|
||||
|
||||
def post_command(self, command):
|
||||
name = self.get_configuration().get("event", "command-event-name")
|
||||
event.post(event.Event(self.get_custom_event_id(), name=name,
|
||||
command=command))
|
||||
|
||||
|
|
Loading…
Reference in New Issue