HiI got a first version of the games plugin working. Maybe someone with more knowledge about Freevo 2.0 takes a look at it and tels me what i should improve. I didn't write it as a MediaItem since i saw know way this would fit. There are two different game plugins at the moment the emulator plugin, this should work for most of the emulators (i have only tested with zsnes, but since it just calls an emulator with the parameters it should work with others). The second plugin is for PcGames with this it is possible to run usual games. What i would like to add would be a plugin for the scummvm, it will not work with the emulator plugin, since the scummvm does not needs one rom file. But this should be easily possible with the current structure. What i think isn't done very well is the EmulatorMenuItem (emulator.py) since this is almost the same as MediaMenu but i couldn't get MediaMenu to do what i wanted, so i copied it and changed it a bit.
I hope i haven't done to many things the wrong way, since the architecture of Freevo 2.0 isn't that easy to get through.
Thanks Mathias
Index: freevo_trunk/ui/src/gui/compat.py =================================================================== --- freevo_trunk/ui/src/gui/compat.py (revision 9318) +++ freevo_trunk/ui/src/gui/compat.py (working copy) @@ -108,6 +108,10 @@ def update(self): self.engine.canvas.update() + +class _Gamesplayer(BaseApplication): + name = 'games' + areas = () class _Videoplayer(BaseApplication): Index: freevo_trunk/ui/src/games/plugins/.zsnes.py.swp =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: freevo_trunk/ui/src/games/plugins/.zsnes.py.swp ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: freevo_trunk/ui/src/games/plugins/emulator.py =================================================================== --- freevo_trunk/ui/src/games/plugins/emulator.py (revision 0) +++ freevo_trunk/ui/src/games/plugins/emulator.py (revision 0) @@ -0,0 +1,365 @@ +# -*- coding: iso-8859-1 -*- +# ----------------------------------------------------------------------------- +# emulator.py - the plugin for the emulators +# ----------------------------------------------------------------------------- +# $Id$ +# +# This is a generic emulator player. This should work with most emulators. +# If somthing special is needed it should be possible to create a specialized +# version easely. See pcgames.py for an example. +# +# ----------------------------------------------------------------------------- +# Freevo - A Home Theater PC framework +# Copyright (C) 2002-2007 Krister Lagerstrom, Dirk Meyer, et al. +# +# First Edition: Mathias Weber <[EMAIL PROTECTED]> +# Maintainer: Mathias Weber <[EMAIL PROTECTED]> +# +# Please see the file doc/CREDITS for a complete list of authors. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MER- +# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# ----------------------------------------------------------------------------- + +# python imports +import logging +import os + +# kaa imports +import kaa.notifier +from kaa.notifier import Event +from kaa.weakref import weakref +import kaa.beacon + +# freevo imports +import freevo.conf +from freevo.ui.mainmenu import MainMenuItem, MainMenuPlugin +from freevo.ui.directory import DirItem +from freevo.ui.event import * +from freevo.ui.menu import Item, Action, Menu +from freevo.ui.config import config +from freevo.ui.plugins.mediamenu import MediaMenu + +# games imports +import freevo.ui.games.player as gameplayer + +log = logging.getLogger('games') + + +class PluginInterface(MainMenuPlugin): + """ + Add the emualtor items to the games menu + """ + mediatype = [ 'games' ] + + def roms(self, parent, listing, configitem): + """ + Show all roms. + """ + items = [] + for suffix in self.suffix(configitem): + # if is only one object don't iterate over it. + if isinstance(listing, kaa.beacon.file.File): + filename = listing.get('name') + if filename.endswith(suffix): + # cut the fileending off the file for the displaying name + name = filename[:-(len(suffix)+1)] + items.append(EmulatorItem(parent, name, \ + listing.filename, configitem)) + break + return items + + + def suffix(self, configitem): + """ + return the list of suffixes this class handles + """ + return configitem.suffix.split(',') + + + def items(self, parent): + """ + Return the main menu item. + """ + list = [] + for item in config.games.plugin.emulator.items: + log.info('add menu entry for %s' % item.emulator_name) + list.append(EmulatorMenuItem(parent, item.emulator_name, item.paths, self.roms, item, root=True)) + return list + + +class EmulatorItem(Item): + """ + Basic Item for all emulator types + """ + + def __init__(self, parent, name, url="", configitem=None): + Item.__init__(self, parent) + self.name = name + self.url = url + self.configitem = configitem + log.info('create EmulatorItem name=%s, url=%s'%(name, url)) + + + def play(self): + """ + Start the emulator with the generic EmulatorPlayer. + """ + gameplayer.play(self, EmulatorPlayer(self.configitem.bin, \ + self.configitem.parameters)) + + + def remove(self): + """ + Delete Rom from the disk + """ + #FIXME + log.info('Remove rom %s (FIXME not implemented)'%self.name) + + + def actions(self): + """ + Default action for the itmes. There are two actions available play + and remove. Remove is for deleting a rom. + """ + return [ Action(_('Play %s') % self.name, self.play), + Action(_('Remove %s') % self.name, self.remove)] + + +class EmulatorPlayer(object): + """ + Generic game player. + """ + def __init__(self, command_name=None, parameters=""): + self.command_name = command_name + self.parameters = parameters + self.url = None + self.child = None + + self.signals = { + "open": kaa.notifier.Signal(), + "start": kaa.notifier.Signal(), + "failed": kaa.notifier.Signal(), + "end": kaa.notifier.Signal(), + } + + def open(self, emulatoritem): + """ + Open an emulatoritem, prepare for playing. Load url parameter from + EmulatorItem + """ + self.url = emulatoritem.url + + + def play(self): + """ + Play game. Should work with most emulators. Will start + [command_name] [parameters] [url] + """ + self._releaseJoystick() + params = "%s %s" % (self.parameters, self.url) + log.info('Start playing EmulatorItem (%s %s)' % \ + (self.command_name, params)) + self.child = kaa.notifier.Process(self.command_name) + self.child.start(params).connect(self.completed) + self.signals = self.child.signals + stop = kaa.notifier.WeakCallback(self.stop) + self.child.set_stop_command(stop) + + + def is_running(self): + """ + check if player is still running + """ + if self.child: + return self.child.is_alive() + + return False + + + def completed(self, child): + """ + The game was quit. Send stop event to get back to the menu. + """ + Event(STOP, handler=gameplayer.player.eventhandler).post() + self._acquireJoystick() + log.info('emulator completed') + + + def stop(self): + """ + Stop the game from playing + """ + if self.child: + self.child.stop() + + + def _releaseJoystick(self): + """ + Release Joystick that it can be used by the game/emulator + """ + #FIXME + pass + + + def _acquireJoystick(self): + """ + Acquire Joysitck back that it can be used by freevo + """ + #FIXME + pass + + + +class EmulatorMenuItem(MainMenuItem): + """ + This is a menu entry for the different emulators in the games subdirectory. + This class has a lot of similarities with the MediaMenu, maybe there + could be some integration with this. + """ + + def __init__(self, parent, title, items, gamepluginlist, configitem, + image=None, root=False): + MainMenuItem.__init__(self,parent, title, image=image) + if root: + kaa.beacon.signals['media.add'].connect(self.media_change) + kaa.beacon.signals['media.remove'].connect(self.media_change) + + self.menutitle = title + self.item_menu = None + self.gamepluginlist = gamepluginlist + self.configitem = configitem + self.isRoot = root + + self._items = items + + # add listener for the different directories + for filename in self._items: + if hasattr(filename, 'path'): + #replace home variable + filename = filename.path.replace('$(HOME)', \ + os.environ.get('HOME')) + if isinstance(filename, kaa.beacon.file.File): + continue + if not isinstance(filename, (str, unicode)): + filename = filename[1] + filename = os.path.abspath(filename) + if os.path.isdir(filename) and \ + not os.environ.get('NO_CRAWLER') and \ + not filename == os.environ.get('HOME') and \ + not filename == '/': + kaa.beacon.monitor(filename) + + def main_menu_generate(self): + """ + generate the itmes for the games menu. This is needed when first + generating the menu and if something changes by pressing the EJECT + button for example + """ + items = [] + for item in self._items: + try: + filename = '' + title = '' + if hasattr(item, 'path'): + title = unicode(item.name) + filename = item.path.replace('$(HOME)', \ + os.environ.get('HOME')) + elif isinstance(item, (str, unicode)): + # only a filename is given + title, filename = u'', item + elif isinstance(item, kaa.beacon.file.File): + title = u'' + filename = item.filename + filename = os.path.abspath(filename) + if os.path.isdir(filename): + query = kaa.beacon.query(filename=filename) + for d in query.get(filter='extmap').get('beacon:dir'): + items.append(EmulatorMenuItem(self, "[%s]"%title, \ + d.list().get(), self.gamepluginlist, \ + self.configitem)) + continue + + if not os.path.isfile(filename) and \ + filename.startswith(os.getcwd()): + # file is in share dir + filename = filename[len(os.getcwd()):] + if filename[0] == '/': + filename = filename[1:] + filename = os.path.join(freevo.conf.SHAREDIR, filename) + + query = kaa.beacon.query(filename=filename) + listing = query.get() + g_items = self.gamepluginlist(self, listing, self.configitem) + if g_items: + items += g_items + except: + log.exception('Error parsing %s' %str(item)) + continue + if self.isRoot: + for media in kaa.beacon.media: + if media.mountpoint == '/': + continue + listing = kaa.beacon.wrap(media.root, filter='extmap') + g_items = self.gamepluginlist(self, listing, self.configitem) + if g_items: + items += g_items + for d in listing.get('beacon:dir'): + items.append(EmulatorMenuItem(self, "[%s]"%media.label, \ + d.list().get(), self.gamepluginlist, \ + self.configitem)) + + return items + + def select(self): + """ + display the emulator menu + """ + items = self.main_menu_generate() + + type = "" + item_menu = Menu(self.menutitle, items, type=type, \ + reload_func=self.reload) + item_menu.autoselect = True + item_menu.skin_force_view = False + self.item_menu = item_menu + self.pushmenu(item_menu) + + + def reload(self): + """ + Reload the menu items + """ + if self.item_menu: + self.item_menu.set_items(self.main_menu_generate()) + + + def media_change(self, media): + """ + Media change from kaa.beacon + """ + if self.item_menu: + self.item_menu.set_items(self.main_menu_generate()) + + def eventhandler(self, event): + """ + Handle events, eject for a media item + """ + if event == EJECT and self.item_menu and \ + self.item_menu.selected.info['parent'] == \ + self.item_menu.selected.info['media']: + self.item_menu.selected.info['media'].eject() + + Index: freevo_trunk/ui/src/games/plugins/.emulator.py.swp =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: freevo_trunk/ui/src/games/plugins/.emulator.py.swp ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: freevo_trunk/ui/src/games/plugins/__init__.py =================================================================== Index: freevo_trunk/ui/src/games/plugins/pcgames.py =================================================================== --- freevo_trunk/ui/src/games/plugins/pcgames.py (revision 0) +++ freevo_trunk/ui/src/games/plugins/pcgames.py (revision 0) @@ -0,0 +1,137 @@ +# -*- coding: iso-8859-1 -*- +# ----------------------------------------------------------------------------- +# pcgames.py - the pycgames item and player +# ----------------------------------------------------------------------------- +# $Id$ +# +# The PcGamesItem represents a PC game that can be started through the +# PcGamesPlayer. Both classes are derived from the corresponding classes +# in emulator module. +# The PluginInterface class creates the list with all the games. The games +# here have to be listed in the config file since there are no roms involved. +# +# ----------------------------------------------------------------------------- +# Freevo - A Home Theater PC framework +# Copyright (C) 2002-2007 Krister Lagerstrom, Dirk Meyer, et al. +# +# First Edition: Mathias Weber <[EMAIL PROTECTED]> +# Maintainer: Mathias Weber <[EMAIL PROTECTED]> +# +# Please see the file doc/CREDITS for a complete list of authors. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MER- +# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# ----------------------------------------------------------------------------- + +# python imports +import logging + +# Freevo imports +from freevo.ui.mainmenu import MainMenuPlugin +from freevo.ui.menu import ActionItem, Menu, Action +from freevo.ui.config import config +from freevo.ui.event import * + +# games imports +from emulator import EmulatorItem, EmulatorPlayer +import freevo.ui.games.player as gameplayer + +log = logging.getLogger('games') + +class PcGamePlayer(EmulatorPlayer): + """ + The PcGamePlayer loader. + """ + def __init__(self): + EmulatorPlayer.__init__(self) + + + def open(self, emulatoritem): + """ + Open a PcGameItem, get executable and parameters for playing + """ + self.command_name = emulatoritem.binary + self.parameters = emulatoritem.parameters + + + def play(self): + """ + Play PcGame + """ + log.info('Start playing PcGame (%s %s)' % \ + (self.command_name, self.parameters)) + self.child = kaa.notifier.Process(self.command_name) + self.child.start(self.parameters).connect(self.completed) + self.signals = self.child.signals + stop = kaa.notifier.WeakCallback(self.stop) + self.child.set_stop_command(stop) + + + def completed(self, child): + """ + The game was quit. Send Stop event to get back to the menu. + """ + Event(STOP, handler=gameplayer.player.eventhandler).post() + log.info('Game completed') + + + def actions(self): + """ + The actions for the games + """ + return [ Action(_('Play %s') % self.name, self.play) ] + + +class PcGameItem(EmulatorItem): + """ + Item for a PC game. + """ + + def __init__(self, bin, parameters, name, screenshotfile, parent): + EmulatorItem.__init__(self, parent, name) + self.binary = bin + self.parameters = parameters + self.screenshotfile = screenshotfile + + + def play(self): + """ + Start the game. + """ + gameplayer.play(self, PcGamePlayer()) + + +class PluginInterface(MainMenuPlugin): + """ + Add PC game to games menu + """ + + def roms(self, parent): + """ + Show all games. + """ + items = [] + for item in config.games.plugin.pcgames.items: + items.append(PcGameItem(item.bin, item.parameters, \ + item.name, item.screenshot, parent)) + parent.pushmenu(Menu(_('PC Games'), items, type='games')) + + + def items(self, parent): + """ + Return the main menu item. + """ + return [ ActionItem(_('PC Games'), parent, self.roms) ] + Index: freevo_trunk/ui/src/games/plugins/config.cxml =================================================================== --- freevo_trunk/ui/src/games/plugins/config.cxml (revision 0) +++ freevo_trunk/ui/src/games/plugins/config.cxml (revision 0) @@ -0,0 +1,70 @@ +<?xml version="1.0"?> +<config name="games.plugin"> + <desc lang="en">games plugins</desc> + + <group name="emulator" plugin="10"> + <desc> + Set the parameters for the emulator. + + games.plugin.emulator.items[0].paths[0].path = $(HOME)/snes + games.plugin.emulator.items[0].paths[0].name = Main Roms + games.plugin.emulator.items[0].emulator_name = SNes Games + games.plugin.emulator.items[0].bin = /usr/local/bin/zsnes + games.plugin.emulator.items[0].parameters = -m -r3 -k 100 -cs -u + games.plugin.emulator.items[0].suffix = smc,zip + </desc> + <list name="items"> + <list name='paths'> + <var name="name" type="unicode"> + <desc>Name for the path to the roms</desc> + </var> + <var name="path" type="str"> + <desc>The path to find the roms</desc> + </var> + </list> + <var name="emulator_name" type="unicode"> + <desc>Name in the games menu</desc> + </var> + <var name="bin" type="str"> + <desc>The binary for the emulator</desc> + </var> + <var name="parameters" type="str"> + <desc>The parameters to give to the emulator on start</desc> + </var> + <var name="suffix" default="zip"> + <desc>The suffix of the roms</desc> + </var> + </list> + </group> + <group name="pcgames" plugin="20"> + <desc> + Set the parameters for the PC games. + + games.plugin.pcgames.name = PC Games + games.plugin.pcgames.items[0].bin = /usr/games/bin/einstein + games.plugin.pcgames.items[0].parameters = + games.plugin.pcgames.items[0].name = Einstein + games.plugin.pcgames.items[0].screenshot = + </desc> + <var name="name" type="unicode"> + <desc>Name in the games menu</desc> + </var> + + <list name="items"> + <var name="name" type="unicode"> + <desc>Name of the game</desc> + </var> + <var name="bin" type="str"> + <desc>The binary for the emulator</desc> + </var> + <var name="parameters" type="str"> + <desc>The parameters to give to the emulator on start</desc> + </var> + <var name="screenshot" default="str"> + <desc>A image file with a screenshot of the game</desc> + </var> + </list> + </group> + +</config> + Index: freevo_trunk/ui/src/games/plugins/.pcgames.py.swp =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: freevo_trunk/ui/src/games/plugins/.pcgames.py.swp ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: freevo_trunk/ui/src/games/plugins/.config.cxml.swp =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: freevo_trunk/ui/src/games/plugins/.config.cxml.swp ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: freevo_trunk/ui/src/games/player.py =================================================================== --- freevo_trunk/ui/src/games/player.py (revision 0) +++ freevo_trunk/ui/src/games/player.py (revision 0) @@ -0,0 +1,170 @@ +# -*- coding: iso-8859-1 -*- +# ----------------------------------------------------------------------------- +# player.py - a generic player for the games +# ----------------------------------------------------------------------------- +# $Id$ +# +# This player starts a emulator player. This class handles all the events +# from the freevo system and sends them to the different players. +# +# ----------------------------------------------------------------------------- +# Freevo - A Home Theater PC framework +# Copyright (C) 2002-2007 Krister Lagerstrom, Dirk Meyer, et al. +# +# First Edition: Mathias Weber <[EMAIL PROTECTED]> +# Maintainer: Mathias Weber <[EMAIL PROTECTED]> +# +# Please see the file doc/CREDITS for a complete list of authors. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MER- +# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# ----------------------------------------------------------------------------- + +__all__ = [ 'play', 'stop'] + +# python imports +import logging + +# kaa imports +import kaa.utils +import kaa.notifier + +# freevo imports +from freevo.ui.event import * +from freevo.ui.application import Application, STATUS_RUNNING, \ + STATUS_STOPPING, STATUS_STOPPED, STATUS_IDLE, CAPABILITY_FULLSCREEN + +log = logging.getLogger('games') + +class GamesPlayer(Application): + """ + Games player object. + """ + def __init__(self): + capabilities = (CAPABILITY_FULLSCREEN, ) + Application.__init__(self, 'gamesplayer', 'games', capabilities) + self.player = None + + + def play(self, item, player): + """ + play an item + """ + if player == None: + return False + self.player = player + if not self.status in (STATUS_IDLE, STATUS_STOPPED): + # Already running, stop the current player by sending a STOP + # event. The event will also get to the playlist behind the + # current item and the whole list will be stopped. + Event(STOP, handler=self.eventhandler).post() + # Now connect to our own 'stop' signal once to repeat this current + # function call without the player playing + self.signals['stop'].connect_once(self.play, item) + return True + + if not kaa.notifier.running: + # Freevo is in shutdown mode, do not start a new player, the old + # only stopped because of the shutdown. + return False + + # Try to get VIDEO and AUDIO resources. The ressouces will be freed + # by the system when the application switches to STATUS_STOPPED or + # STATUS_IDLE. + blocked = self.get_resources('AUDIO', 'VIDEO') + if 'VIDEO' in blocked: + # Something has the video resource blocked. The only application + # possible is the tv player right now. It would be possible to + # ask the user what to do with a popup but we assume the user + # does not care about the tv and just stop it. FIXME ask user + Event(STOP, handler=blocked['VIDEO'].eventhandler).post() + # Now connect to the 'stop' signal once to repeat this current + # function call without the player playing + blocked['VIDEO'].signals['stop'].connect_once(retry) + return True + if 'AUDIO' in blocked: + # AUDIO is blocked, VIDEO is not. This is most likely the audio + # player and we can pause it. Do this if possible. + if not blocked['AUDIO'].has_capability(CAPABILITY_PAUSE): + # Unable to pause, just stop it + Event(STOP, handler=blocked['AUDIO'].eventhandler).post() + # Now connect to the 'stop' signal once to repeat this current + # function call without the player playing + blocked['AUDIO'].signals['stop'].connect_once(retry) + return True + # Now pause the current player. On its pause signal this player can + # play again. And on the stop signal of this player (STATUS_IDLE) + # the other player can be resumed again. + in_progress = blocked['AUDIO'].pause() + if isinstance(in_progress, kaa.notifier.InProgress): + # takes some time, wait + in_progress.connect(retry).set_ignore_caller_args() + if in_progress is not False: + # we paused the application, resume on our stop + self.signals['stop'].connect_once(blocked['AUDIO'].resume) + return True + + # store item + self.item = item + self.status = STATUS_RUNNING + + self.player.open(self.item) + self.player.signals['failed'].connect_once(self._play_failed) + self.player.signals['end'].connect_once(PLAY_END.post, self.item) + self.player.signals['start'].connect_once(PLAY_START.post, self.item) + self.player.play() + + + def _play_failed(self): + """ + Playing this item failed. + """ + log.error('playback failed for %s', self.item) + + + def stop(self): + """ + Stop playing. + """ + if self.get_status() != STATUS_RUNNING: + return True + self.player.stop() + self.status = STATUS_STOPPING + + + def eventhandler(self, event): + """ + React on events and do the right command with the game. + """ + if event == STOP: + self.stop() + if not self.player.is_running(): + self.item.eventhandler(event) + self.status = STATUS_IDLE + return True + + elif event == PLAY_END: + self.stop() + self.show() + self.item.eventhandler(event) + return True + + return self.item.eventhandler(event) + + +player = kaa.utils.Singleton(GamesPlayer) +play = player.play +stop = player.stop + Index: freevo_trunk/ui/src/games/__init__.py =================================================================== --- freevo_trunk/ui/src/games/__init__.py (revision 0) +++ freevo_trunk/ui/src/games/__init__.py (revision 0) @@ -0,0 +1,37 @@ +# -*- coding: iso-8859-1 -*- +# ----------------------------------------------------------------------------- +# __init__.py - interface to games +# ----------------------------------------------------------------------------- +# $Id: __init__.py 9151 2007-02-03 20:49:32Z dmeyer $ +# +# This file imports everything needed to use this games module. +# There is only one class provided for games files, the PluginInterface +# from interface.py. +# +# ----------------------------------------------------------------------------- +# Freevo - A Home Theater PC framework +# Copyright (C) 2002-2007 Krister Lagerstrom, Dirk Meyer, et al. +# +# First Edition: Mathias Weber <[EMAIL PROTECTED]> +# Maintainer: Mathias Weber <[EMAIL PROTECTED]> +# +# Please see the file AUTHORS for a complete list of authors. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MER- +# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# ----------------------------------------------------------------------------- + +from interface import * + Index: freevo_trunk/ui/src/games/config.cxml =================================================================== --- freevo_trunk/ui/src/games/config.cxml (revision 0) +++ freevo_trunk/ui/src/games/config.cxml (revision 0) @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<config name="games" plugin="30"> + <desc lang="en">games plugin</desc> +</config> + Index: freevo_trunk/ui/src/games/interface.py =================================================================== --- freevo_trunk/ui/src/games/interface.py (revision 0) +++ freevo_trunk/ui/src/games/interface.py (revision 0) @@ -0,0 +1,64 @@ +# -*- coding: iso-8859-1 -*- +# ----------------------------------------------------------------------------- +# interface.py - interface between mediamenu and games +# ----------------------------------------------------------------------------- +# $Id$ +# +# This creates the MainMenuEntry and loads all the sub plugins for the game +# entry. +# +# ----------------------------------------------------------------------------- +# Freevo - A Home Theater PC framework +# Copyright (C) 2002-2007 Krister Lagerstrom, Dirk Meyer, et al. +# +# First Edition: Mathias Weber <[EMAIL PROTECTED]> +# Maintainer: Mathias Weber <[EMAIL PROTECTED]> +# +# Please see the file doc/CREDITS for a complete list of authors. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MER- +# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# ----------------------------------------------------------------------------- + +import logging + +#freevo imports +from freevo.ui.mainmenu import MainMenuItem, MainMenuPlugin +from freevo.ui.menu import Menu + +log = logging.getLogger('games') + +class PluginInterface(MainMenuPlugin): + """ + Create the GamesMenu Item. + """ + + def items(self, parent): + return [ GamesMenu(parent) ] + +class GamesMenu(MainMenuItem): + """ + The Games main menu. + """ + skin_type = 'games' + + def select(self): + items = [] + plugins_list = MainMenuPlugin.plugins('games') + for p in plugins_list: + items += p.items(self) + + m = Menu(_('Games Main Menu'), items, type = 'main') + self.pushmenu(m)
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Freevo-devel mailing list Freevo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-devel