Author: dmeyer
Date: Fri Apr 7 17:20:56 2006
New Revision: 8140
Modified:
trunk/ui/doc/local_conf.py.example
trunk/ui/src/config/__init__.py
trunk/ui/src/games/gameitem.py
trunk/ui/src/games/interface.py
trunk/ui/src/plugins/mediamenu.py
Log:
games patch from Chris Lack
Modified: trunk/ui/doc/local_conf.py.example
==============================================================================
--- trunk/ui/doc/local_conf.py.example (original)
+++ trunk/ui/doc/local_conf.py.example Fri Apr 7 17:20:56 2006
@@ -190,7 +190,7 @@
#
# Enable this for joystick support:
-# plugin.activate('joy')
+# plugin.activate('input.joystick')
# ======================================================================
# Freevo directory settings:
@@ -408,45 +408,91 @@
# Freevo games settings:
# ======================================================================
+# YET ANOTHER NEW GAMES SYSTEM : (as of Freevo 2)
+# ==============================
#
-# MAME is an emulator for old arcade video games. It supports almost
-# 2000 different games! The actual emulator is not included in Freevo,
-# you'll need to download and install it separately. The main MAME
-# website is at http://www.mame.net, but the version that is used here
-# is at http://x.mame.net since the regular MAME is for Windows.
-#
-# SNES stands for Super Nintendo Entertainment System. Freevo relies
-# on other programs that are not included in Freevo to play these games.
-#
-# NEW GAMES SYSTEM :
-# =================
-# The GAMES_ITEMS structure is now build as follows :
-# <NAME>, <FOLDER>, (<TYPE>, <COMMAND_PATH>, <COMMAND_ARGS>, <IMAGE_PATH>, \
-# [<FILE_SUFFIX_FOR_GENERIC>])
-# where :
-# - <TYPE> : Internal game types (MAME or SNES) or
-# generic one (GENERIC)
-# - <COMMAND_PATH> : Emulator command
-# - <COMMAND_ARGS> : Arguments for the emulator
-# - <IMAGE_PATH> : Optionnal path to the picture
-# - <FILE_SUFFIX_FOR_GENERIC> : If the folder use the GENERIC
-# type, then you must specify here
-# the file suffix used by the emulator
-# GAMES_ITEMS = [ ('MAME', '/home/media/games/xmame/roms',
-# ('MAME', '/usr/local/bin/xmame.SDL', '-fullscreen -modenumber
6',
-# '/home/media/games/xmame/shots', None)),
-# ('SUPER NINTENDO', '/home/media/games/snes/roms',
-# ('SNES', '/usr/local/bin/zsnes', '-m -r 3 -k 100 -cs -u', '',
None )),
-# ('Visual Boy Advance', '/home/media/games/vba/roms/',
-# ('GENERIC', '/usr/local/vba/VisualBoyAdvance', ' ', '', [
'gba' ] )),
-# ('MEGADRIVE', '/home/media/games/megadrive/roms',
-# ('GENESIS', '/usr/local/bin/generator-svgalib', '', '', '' ))
]
+# The GAMES_ITEMS structure is now built as follows :
#
-# GAMES_ITEMS = None
-
+# ( <TYPE>, <LISTING NAME>, ( <ROMPATH1>, <ROMPATH2>, . . . <ROMPATHx> ),
+# [ ( <EMU1_ID>, <EXECUTABLE>, <EMU1_ARGS> ),
+# ( <EMU2_ID>, <EXECUTABLE>, <EMU2_ARGS> ),
+# ( <EMUx_ID>, <EXECUTABLE>, <EMUx_ARGS> ) ],
+# <SCREENSHOTS>, [ <EXT1>, <EXT2>, <EXTx> ] )
#
-# These settings are used for the MAME arcade emulator:
+# where :
+# - <TYPE> : Internal known game types:
+# NES - Nintendo Entertainment System
+# SNES - Super Nintendo
+# N64 - Nintendo 64
+# GB - Gameboy handheld
+# GBC - Gameboy Color handheld
+# GBA - Gameboy Advance handheld
+# VBOY - Virtual Boy (or 'that which shall not be
+# spoken of' at Nintendo HQ)
+# SMS - Sega Master System
+# SMD - Sega Megadrive (Genesis)
+# SG1K - Sega SG-1000/SC-3000
+# GG - Sega Game Gear handheld
+# PCE - NEC PC-Engine (Turbografx-16)
+# SGX - NEC Supergrafx
+# 2600 - Atari 2600
+# 5200 - Atari 5200
+# 7800 - Atari 7800
+# JAG - Atari Jaguar
+# LYNX - Atari Lynx handheld
+# USER - Formerly GENERIC. For user specified entries
+# - <LISTING NAME> : What will be shown for a USER entry
+# in the main games menu. Ignored for known
+# game types.
+# - <ROMPATH> : A comma seperated list of all the directories
+# where games of TYPE can be found.
+# *IMPORTANT* - <EMU_ID> : This is a completely arbitrary name the user
+# specifies for each emulator/argument set.
+# The games database will store this value as
+# the reference to your preferred emulator and
+# command line on a per-rom basis. This allows
+# you to update command line options and even
+# change the emulator used while hopefully
+# maintaining a desired ability to play certain
+# games a certain way. See the example below
+# for an idea of how this could be useful.
+# Each EMU_ID needs to be unique per TYPE.
+# You could use LIGHTGUN as your EMU_ID for
+# both NES and SMS, but not have two LIGHTGUN
+# entries for NES.
+# - <EXECUTABLE> : Emulator command. May contain the path or
+# just the binary if its within your path.
+# - <EMU_ARGS> : Arguments for the emulator
+# - <SCREENSHOTS> : Path to a directory containing either
+# individual game screenshots in png form,
+# named the same as what the game appears as
+# within the menu (with .png of course), or
+# the path can point directly to a zipfile
+# containing all the screenshots for <TYPE>.
+# - <EXT> : If this is a USER type definition, then you
+# must specify the file suffix used by the
+# valid roms you need to emulate
+#
+# GAMES_ITEMS = [
+# ( 'NES', None, ( '/shared/roms/NES', '/home/user/Nintendo' ),
+# [ ( 'DEFAULT', 'mednafen', '-fs 1 -nes.stretch 1' ),
+# ( 'LIGHTGUN', 'mednafen', '-nes.input1 zapper' ),
+# ( 'FCE', 'fceu', '-somefceopt' ),
+# ( 'FAKE', 'fakenes', '-fakenesopt1 -fakenesopt2' ) ],
+# '/shared/roms/NES/.screens', None ),
+#
+# ( 'USER', 'Wanderswan', ( '/shared/roms/WS' ),
+# [ ( 'DEFAULT', 'xe', '-ws 1' ) ],
'/shared/roms/WS/screens.zip',
+# [ 'ws', 'bws' ] ),
+#
+# # Changing the shell scripts for most linux games from
game-name
+# # to game-name.sh would allow something like this easily
enough.
+# ( 'USER', 'Native Games', ( '/usr/games/bin' ),
+# [ ( 'DEFAULT', 'bash', '' ) ],
'/usr/games/share/screenshots.zip',
+# [ 'sh' ] )
+# ]
#
+# GAMES_ITEMS = None
# Priority of the game process
# 0 = Don't change the priority
@@ -455,11 +501,6 @@
#
# GAMES_NICE = -20
-#
-# MAME cache directory
-#
-# GAMES_MAME_CACHE = '%s/romlist-%s.pickled' % (FREEVO_CACHEDIR, os.getuid())
-
# ======================================================================
# Freevo SKIN settings:
# ======================================================================
Modified: trunk/ui/src/config/__init__.py
==============================================================================
--- trunk/ui/src/config/__init__.py (original)
+++ trunk/ui/src/config/__init__.py Fri Apr 7 17:20:56 2006
@@ -217,15 +217,21 @@
elif type == 'games':
abs = []
for d in x:
- pos = d[1].find(':')
- if pos == -1:
- abs.append((d[0], os.path.abspath(d[1]), d[2]))
- else:
- if pos > d[1].find('/'):
- abs.append((d[0], os.path.abspath(d[1]), d[2]))
+ dirs = []
+
+ for p in d[2]:
+ pos = p.find(':')
+
+ if pos == -1:
+ dirs.append(os.path.abspath(p))
else:
- abs.append((d[0], d[1][0:pos+1] + \
- os.path.abspath(d[1][pos+1:]), d[2]))
+ if pos > p.find('/'):
+ dirs.append(os.path.abspath(p))
+ else:
+ dirs.append(p[0:pos + 1] + os.path.abspath(p[pos +
1:]))
+
+ abs.append(( d[0], d[1], dirs, d[3], d[4], d[5] ))
+
exec ('%s = abs' % n)
else:
# The algorithm doesn't work for GAMES_ITEMS, so we leave it out
Modified: trunk/ui/src/games/gameitem.py
==============================================================================
--- trunk/ui/src/games/gameitem.py (original)
+++ trunk/ui/src/games/gameitem.py Fri Apr 7 17:20:56 2006
@@ -31,39 +31,50 @@
#
# -----------------------------------------------------------------------------
from menu import MediaItem, Action
+import machine
+import config
+import logging
+
+log = logging.getLogger('games')
+
class GameItem(MediaItem):
"""
This is a virtual representation of the rom.
"""
- def __init__(self, parent, url, system):
+ def __init__(self, parent, url, gi_ind, imgpath):
MediaItem.__init__(self, parent, type='games')
self.set_url(url)
self.__emu = None
- self.__sys = system
+ self.__ind = gi_ind
# try to load a screen shot if it is available...
try:
- import kaa.imlib2, zipfile, os.path
- (path, name) = (url.dirname, url.basename)
- # TODO: Change hard coded mame path to a more general case...
- # TODO: cache screen shots ?
- snaps = zipfile.ZipFile(os.path.join(path, '../snap/snap.zip'))
- shotname = name.split('.')[0] + '.png'
- self.image = kaa.imlib2.open_from_memory(snaps.read(shotname))
+ import kaa.imlib2, zipfile
+
+ shot = url.basename.split('.')[0] + '.png'
+
+ if '.zip' in imgpath[-4:]:
+ zf = zipfile.ZipFile(imgpath)
+ self.image = kaa.imlib2.open_from_memory(zf.read(shot))
+ else:
+ self.image = imgpath + '/' + shot
except:
- pass
+ self.image = None
+
def actions(self):
items = [Action(_('Play'), self.play)]
return items
+
def play(self):
- from factory import Factory
- self.__emu = Factory().player(self)
+ self.__emu = machine.emu(self)
self.__emu.launch(self)
- def get_system(self):
- return self.__sys
- system = property(get_system, None)
+ def get_ind(self):
+ return self.__ind
+
+
+ gi_ind = property(get_ind, None)
Modified: trunk/ui/src/games/interface.py
==============================================================================
--- trunk/ui/src/games/interface.py (original)
+++ trunk/ui/src/games/interface.py Fri Apr 7 17:20:56 2006
@@ -31,8 +31,13 @@
# -----------------------------------------------------------------------------
import plugin
import config
+import machine
from gameitem import GameItem
+import logging
+log = logging.getLogger('games')
+
+
class PluginInterface(plugin.MimetypePlugin):
"""
Plugin to handle all kinds of game items
@@ -41,42 +46,57 @@
plugin.MimetypePlugin.__init__(self)
self.display_type = [ 'games' ]
- import logging
- self.__log = logging.getLogger('games')
-
# activate the mediamenu for video
plugin.activate('mediamenu', level=plugin.is_active('games')[2],
args='games')
- def suffix(self):
+
+ def suffix(self, ind):
"""
the suffixes are specified in the config file.
"""
- suf = []
- for item in config.GAMES_ITEMS:
- suf += item[2][4]
- self.__log.debug('The supported suffixes are %s' % suf)
+ if config.GAMES_ITEMS[ind][0] is 'USER':
+ suf = config.GAMES_ITEMS[ind][5]
+ else:
+ suf = machine.ext(config.GAMES_ITEMS[ind][0])
+
+ log.debug('The supported suffixes are %s' % suf)
return suf
+
def get(self, parent, listing):
items = []
- self.__log.info('Adding %s to menu' % listing)
+ try:
+ file = listing.visible[0]
+ except:
+ log.warning("Empty directory")
+ return items
+
+ log.info('Adding %s to menu' % file.dirname)
+
+ systemmarker = imgpath = None
+ dirname = file.dirname
+ ind, done = 0, 0
- systemmarker = None
- dirname = listing.dirname[:-1]
for item in config.GAMES_ITEMS:
- if item[1] == dirname:
- systemmarker = item[2][0]
+ for dir in item[2]:
+ if dir in dirname:
+ systemmarker = item[0]
+ imgpath = item[4]
+ done = 1
+ break
+ if done:
break
+ ind = ind + 1
- all_files = listing.match_suffix(self.suffix())
+ all_files = listing.match_suffix(self.suffix(ind))
all_files.sort(lambda l, o: cmp(l.basename.upper(),
o.basename.upper()))
for file in all_files:
# TODO: Build snapshots of roms.
- items.append(GameItem(parent, file, systemmarker))
+ items.append(GameItem(parent, file, ind, imgpath))
return items
Modified: trunk/ui/src/plugins/mediamenu.py
==============================================================================
--- trunk/ui/src/plugins/mediamenu.py (original)
+++ trunk/ui/src/plugins/mediamenu.py Fri Apr 7 17:20:56 2006
@@ -50,6 +50,7 @@
from menu import Menu, Item
from mediadb import FileListing, watcher
from gui.windows import ProgressBox
+from games import machine
# get logging object
log = logging.getLogger()
@@ -168,6 +169,14 @@
if isinstance(item, (str, unicode)):
# only a filename is given
title, filename = u'', item
+ elif self.display_type == 'games':
+ # has to be handled specially
+ if item[0] is 'USER':
+ title, filename = item[1], item[2][0]
+ else:
+ title, filename = machine.title(item[0]), item[2][0]
+
+ add_args = item[3:]
else:
# title and filename are given
(title, filename) = item[:2]
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog