Author: dmeyer
Date: Mon Oct 17 20:29:36 2005
New Revision: 7736

Modified:
   trunk/freevo-ui/src/games/__init__.py
   trunk/freevo-ui/src/games/gameitem.py
   trunk/freevo-ui/src/games/interface.py
   trunk/freevo-ui/src/games/plugins/zsnes.py

Log:
repair errors when renaming freevo to freevo-ui

Modified: trunk/freevo-ui/src/games/__init__.py
==============================================================================
--- trunk/freevo-ui/src/games/__init__.py       (original)
+++ trunk/freevo-ui/src/games/__init__.py       Mon Oct 17 20:29:36 2005
@@ -8,7 +8,7 @@
 # Todo:        
 #
 # -----------------------------------------------------------------------
-# $Log$
+# $Log: __init__.py,v $
 # Revision 1.23  2005/09/03 08:01:54  dischi
 # make it work again (patch from [EMAIL PROTECTED])
 #
@@ -49,4 +49,3 @@
 # ----------------------------------------------------------------------- */
 
 from interface import *
-from player import gamesplayer

Modified: trunk/freevo-ui/src/games/gameitem.py
==============================================================================
--- trunk/freevo-ui/src/games/gameitem.py       (original)
+++ trunk/freevo-ui/src/games/gameitem.py       Mon Oct 17 20:29:36 2005
@@ -1,37 +1,69 @@
-# game item
-# Daniel Casimiro
-
-import logging
-import event
-from player import gamesplayer
-
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# emulator.py - the Freevo game item.
+# -----------------------------------------------------------------------------
+#
+# This class is used to display roms in the freevo menu.  It also connects the
+# roms to the correct emulators.
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
+#
+# First Edition: Dan Casimiro <[EMAIL PROTECTED]>
+# Maintainer:    Dan Casimiro <[EMAIL PROTECTED]>
+#
+# Please see the file freevo/Docs/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
+#
+# -----------------------------------------------------------------------------
 from menu import MediaItem, Action
 
-log = logging.getLogger('games')
-log.setLevel(logging.DEBUG)
-
 class GameItem(MediaItem):
-    def __init__(self, url, parent):
+    """
+    This is a virtual representation of the rom.
+    """
+    def __init__(self, parent, url, system):
         MediaItem.__init__(self, parent, type='games')
-
-        self.player = None
-        log.debug('Initialized GameItem. URL is %s' % (url))
         self.set_url(url)
+        self.__emu = None
+        self.__sys = system
+
+        # 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))
+        except:
+            pass
 
     def actions(self):
         items = [Action(_('Play'), self.play)]
         return items
 
     def play(self):
-        gamesplayer().play(self)
-
-    def stop(self):
-        gamesplayer().stop()
+        from factory import Factory
+        self.__emu = Factory().player(self)
+        self.__emu.launch(self)
 
-    def eventhandler(self, ev):
-        print "Game Item event handler:", ev
-        if ev == event.MENU:
-            self.player.stop()
-            return True
+    def get_system(self):
+        return self.__sys
 
-        return MediaItem.eventhandler(self, ev)
+    system = property(get_system, None)

Modified: trunk/freevo-ui/src/games/interface.py
==============================================================================
--- trunk/freevo-ui/src/games/interface.py      (original)
+++ trunk/freevo-ui/src/games/interface.py      Mon Oct 17 20:29:36 2005
@@ -1,4 +1,36 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# interface.py - the Freevo interface to the games section
+# -----------------------------------------------------------------------------
+#
+# Populates the games section with the available roms
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
+#
+# First Edition: Dan Casimiro <[EMAIL PROTECTED]>
+# Maintainer:    Dan Casimiro <[EMAIL PROTECTED]>
+#
+# Please see the file freevo/Docs/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 plugin
+import config
 from gameitem import GameItem
 
 class PluginInterface(plugin.MimetypePlugin):
@@ -9,22 +41,42 @@
         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):
-        return ['smc']
+        """
+        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)
+        return suf
 
     def get(self, parent, listing):
         items = []
 
-        all_files = listing.match_suffix('smc')
+        self.__log.info('Adding %s to menu' % listing)
+
+        systemmarker = None
+        dirname = listing.dirname[:-1]
+        for item in config.GAMES_ITEMS:
+            if item[1] == dirname:
+                systemmarker = item[2][0]
+                break
+
+        all_files = listing.match_suffix(self.suffix())
         all_files.sort(lambda l, o: cmp(l.basename.upper(),
-                                         o.basename.upper()))
+                                        o.basename.upper()))
 
         for file in all_files:
             # TODO: Build snapshots of roms.
-            items.append(GameItem(file, parent))
+            items.append(GameItem(parent, file, systemmarker))
             
         return items

Modified: trunk/freevo-ui/src/games/plugins/zsnes.py
==============================================================================
--- trunk/freevo-ui/src/games/plugins/zsnes.py  (original)
+++ trunk/freevo-ui/src/games/plugins/zsnes.py  Mon Oct 17 20:29:36 2005
@@ -1,11 +1,36 @@
-# ZSNES plugin
-# Daniel Casimiro <[EMAIL PROTECTED]>
-
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# zsnes.py - the Freevo zsnes support
+# -----------------------------------------------------------------------------
+#
+# Add support for the zsnes emulator
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
+#
+# First Edition: Dan Casimiro <[EMAIL PROTECTED]>
+# Maintainer:    Dan Casimiro <[EMAIL PROTECTED]>
+#
+# Please see the file freevo/Docs/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 plugin
-import config
-from event import *
-
-from application import ChildApp
+from emulator import Emulator
 
 class PluginInterface(plugin.Plugin):
     """
@@ -15,27 +40,10 @@
     def __init__(self):
         plugin.Plugin.__init__(self)
         plugin.register(Zsnes(), plugin.GAMES, True)
-        print 'zsnes activated!'
 
-class Zsnes(ChildApp):
+class Zsnes(Emulator):
     """
     Use this interface to control zsnes.
     """
     def __init__(self):
-        ChildApp.__init__(self, 'zsnes', 'games', True, False, True)
-    
-
-    def play(self, item, player):
-        self.player = player
-        cmd = 'zsnes'
-        self.child_start([cmd, item.filename], stop_cmd='quit\n')
-
-    def eventhandler(self, event):
-        print 'zsnes eventhandler:', event
-
-        if event == PLAY_END:
-            self.stop()
-            self.player.eventhandler(event)
-            return True
-
-        return False
+        Emulator.__init__(self, 'zsnes', 'SNES')


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to