Exemplo n.º 1
0
    def _setup_events(self):
        '''Setup all events.

        ..notes:
            All events should be handled by the manager itself.
        '''
        events_mask = (gtk.gdk.KEY_RELEASE_MASK
                       | gtk.gdk.POINTER_MOTION_MASK
                       | gtk.gdk.BUTTON_PRESS_MASK
                       | gtk.gdk.BUTTON_RELEASE_MASK)
        self.root.window.add_events(events_mask)

        # register events
        handlers = (
            ('destroy', self.on_destroy),
            ('expose-event', self.on_expose),
            ('button-press-event', self.on_button_press),
            ('button-release-event', self.on_button_release),
            ('motion-notify-event', self.on_motion_notify),
            ('key-press-event', self.on_key_press)
        )
        for name, handler in handlers:
            self.root.window.connect(name, handler)

        # register custom signals
        handlers = (
            ('screenshot-save', self.on_save_screenshot),
            ('screenshot-copy', self.on_copy_screenshot),
            ('screenshot-discard', self.on_destroy)
        )
        for name, handler in handlers:
            signals.register(name, handler)
Exemplo n.º 2
0
 def _cat(self, x, y):
     self.cat = Cat(x, y, self.batch,
                 self.images['catbody'], self.images['cathead'])
     self.cat.parent = self
     self.actors.append(self.cat)
     register('cathit', self.cat.move)
     return self.cat
Exemplo n.º 3
0
 def _gravity(self, x, y):
     """Make a gravity well near the click location."""
     gravity = make_gravity(x, y, self.batch, self.images['gravity'],
                             self.space)
     gravity.parent = self
     self.actors.append(gravity)
     register('vortexhit', gravity.hitbyball)
     return gravity
Exemplo n.º 4
0
    def init(self, levels):
        """Expects a levels keyword argument."""
        self.level = level = levels[0]()
        self.images = {}
        self.labels = {}
        self.actors = []
        self.batch = pyglet.graphics.Batch()
        self.interfaces = []

        # load our images
        self.init_content()

        # create a fps readout
        self.fps_label = text.Label('FPS goes here', 
                                    font_name='Arial', 
                                    font_size=10,
                                    x=10, y=10,)
        # window width and height.
        width, height = self.get_size()

        # create a turret
        (turx, tury) = level.turret
        self.turret = Turret(turx * width, tury * height, self.batch,
                    self.images['frame'], self.images['barrel'])
        self.turret.initPowerBar(self.images['powerbar'], self.batch, 4, 25, 70)
                
        self.actors.append(self.turret)

        #----------------------
        # schrocat live on.
        catx, caty = level.next_cat
        cat = self._cat(catx * width, caty * width)

        #----------------------
        # make a bunch of vortexes..
        vortexes_or_vortecii_which_is_correct = level.get_vortexes_for_level(1)
        for v in vortexes_or_vortecii_which_is_correct:
            (x, y), strength, level = v
            gravity = self._gravity(x * width, y * height)
            gravity.strength = strength

        self._over = False
        self._window_active = True

        def make_callback_for(obj):

            def someonehit(*args, **kwargs):
                """ball or cat needs to remove 1 from meter qty."""
                obj.remove(qty=1)
            return someonehit

        self.ballMeter = Meter(10, 80, 50, 340,
                            (1.0,0.0,0.0), (0.0,1.0,0.0), 10, 5, True)
        self.catMeter = Meter(580, 80, 50, 340,
                            (1.0,0.0,0.0), (0.0,1.0,0.0), 10, 5, True)

        self.catMeter.parent = self

        self.interfaces.append(self.ballMeter)
        self.interfaces.append(self.catMeter)

        # now make some callbacks to remove meter points when hit.
        callback = make_callback_for(self.ballMeter)
        register('shoot', callback)

        callback = make_callback_for(self.catMeter)
        register('cathit', callback)

        add_three_balls = functools.partial(self.ballMeter.add, 3)
        register('cathit', add_three_balls)

        register('kill', self.remove_object)

        return self
Exemplo n.º 5
0
from signals import register

register('app.activate')
register('app.deactivate')

register('app.pre_start')
register('app.start')
register('app.ready')
register('app.close')
register('app.stop')
register('app.chdir')
register('app.command')
register('app.remote')

register('module.loaded')

register( 'command.new'  )
register( 'command.undo' )
register( 'command.redo' )
register( 'command.clear' )

register('game.pause')
register('game.resume')

register('preview.start')
register('preview.resume')
register('preview.stop')
register('preview.pause')

register('debug.enter')
register('debug.exit')
Exemplo n.º 6
0
from signals import register

register('app.activate')
register('app.deactivate')

register('app.pre_start')
register('app.start')
register('app.ready')
register('app.close')
register('app.stop')
register('app.chdir')
register('app.command')
register('app.remote')

register('module.loaded')

register('command.new')
register('command.undo')
register('command.redo')
register('command.clear')

register('game.pause')
register('game.resume')

register('preview.start')
register('preview.resume')
register('preview.stop')
register('preview.pause')

register('debug.enter')
register('debug.exit')
Exemplo n.º 7
0
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os
import sys
import time
import threading

import xmmsclient
from xmmsclient import collections as coll

import signals

# TODO: better doc (rst)

# args -- id:int
signals.register('xmms-playback-current-id')

# args -- info:dict
signals.register('xmms-playback-current-info')

# args -- milliseconds:int
signals.register('xmms-playback-playtime')

# args -- status:int
#  status values:
#  xmmsclient.PLAYBACK_STATUS_PLAY
#  xmmsclient.PLAYBACK_STATUS_STOP
#  xmmsclient.PLAYBACK_STATUS_PAUSE
signals.register('xmms-playback-status')

# args -- playlist_name:string
Exemplo n.º 8
0
from signals import register

register('app.activate')
register('app.deactivate')

register('app.pre_start')
register('app.start')
register('app.ready')
register('app.close')
register('app.stop')
register('app.chdir')
register('app.command')
register('app.remote')

register('app.open_file')

register('project.init')
register('project.preload')
register('project.presave')
register('project.load')
register('project.save')

register('module.loaded')
register('module.register')
register('module.unregister')
register('module.load')
register('module.unload')

register('preview.start')
register('preview.resume')
register('preview.stop')
Exemplo n.º 9
0
  def on_xmms_playback_playtime(self, milli):
    if self.time/1000 != milli/1000:
      self.time = milli
      self._update()

  def on_xmms_playback_status(self, status):
    self.status = status
    self._update()

  def on_xmms_playback_current_info(self, info):
    self.info = info
    self.ctx = dict(zip((k[1] for k in self.info), self.info.values()))
    self._update()


signals.register('show-message')
signals.register('clear-message')

class StatusArea(urwid.Pile):
  def __init__(self):
    self.status = urwid.AttrWrap(urwid.Text(''), 'status')
    self._empty = urwid.Text('')
    self.last_type = None

    self.__super.__init__([self.status, self._empty], 1)

    signals.connect('xmms-playback-volume-changed', self.on_xmms_playback_volume_changed)
    signals.connect('show-message', self.set_message)
    signals.connect('clear-message', lambda: self.clear_message(clear_loading=True))

  def _restore(self, *args, **kwargs):
Exemplo n.º 10
0
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os
import sys
import time
import threading

import xmmsclient
from xmmsclient import collections as coll

import signals

# TODO: better doc (rst)

# args -- id:int
signals.register('xmms-playback-current-id')

# args -- info:dict
signals.register('xmms-playback-current-info')

# args -- milliseconds:int
signals.register('xmms-playback-playtime')

# args -- status:int
#  status values:
#  xmmsclient.PLAYBACK_STATUS_PLAY
#  xmmsclient.PLAYBACK_STATUS_STOP
#  xmmsclient.PLAYBACK_STATUS_PAUSE
signals.register('xmms-playback-status')

# args -- playlist_name:string