# HG changeset patch
# User prock@33b003aa-7bff-0310-803a-e67f0ece8222
# Date 1274385319 0
# Node ID 3951042a701e89290517553a89ffaafb136d0383
# Parent c8820cc201dbe2adc66063a0e4c510c99cf75747
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
diff -r c8820cc201db -r 3951042a701e demos/rpg/fonts/FreeSans.ttf
Binary file demos/rpg/fonts/FreeSans.ttf has changed
diff -r c8820cc201db -r 3951042a701e demos/rpg/maps/level1.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/rpg/maps/level1.xml Thu May 20 19:55:19 2010 +0000
@@ -0,0 +1,46 @@
+
+
diff -r c8820cc201db -r 3951042a701e demos/rpg/maps/town.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/rpg/maps/town.xml Thu May 20 19:55:19 2010 +0000
@@ -0,0 +1,46 @@
+
+
diff -r c8820cc201db -r 3951042a701e demos/rpg/objects/ground/grass/01/45.png
Binary file demos/rpg/objects/ground/grass/01/45.png has changed
diff -r c8820cc201db -r 3951042a701e demos/rpg/objects/ground/grass/01/object.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/rpg/objects/ground/grass/01/object.xml Thu May 20 19:55:19 2010 +0000
@@ -0,0 +1,4 @@
+
+
diff -r c8820cc201db -r 3951042a701e demos/rpg/run.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/rpg/run.py Thu May 20 19:55:19 2010 +0000
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+
+# -*- coding: utf-8 -*-
+
+# ####################################################################
+# Copyright (C) 2005-2010 by the FIFE team
+# http://www.fifengine.net
+# This file is part of FIFE.
+#
+# FIFE is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+# ####################################################################
+# This is the rio de hola client for FIFE.
+
+import sys, os, re, math, random, shutil
+
+fife_path = os.path.join('..','..','engine','python')
+if os.path.isdir(fife_path) and fife_path not in sys.path:
+ sys.path.insert(0,fife_path)
+
+from fife import fife
+print "Using the FIFE python module found here: ", os.path.dirname(fife.__file__)
+
+from fife.extensions.fife_settings import Setting
+from scripts.rpg import RPGApplication
+
+
+TDS = Setting(app_name="rpg",
+ settings_file="./settings.xml",
+ settings_gui_xml="")
+
+def main():
+ app = RPGApplication(TDS)
+ app.run()
+
+if __name__ == '__main__':
+ if TDS.get("FIFE", "ProfilingOn"):
+ import hotshot, hotshot.stats
+ print "Starting profiler"
+ prof = hotshot.Profile("fife.prof")
+ prof.runcall(main)
+ prof.close()
+ print "analysing profiling results"
+ stats = hotshot.stats.load("fife.prof")
+ stats.strip_dirs()
+ stats.sort_stats('time', 'calls')
+ stats.print_stats(20)
+ else:
+ if TDS.get("FIFE", "UsePsyco"):
+ # Import Psyco if available
+ try:
+ import psyco
+ psyco.full()
+ print "Psyco acceleration in use"
+ except ImportError:
+ print "Psyco acceleration not used"
+ else:
+ print "Psyco acceleration not used"
+ main()
diff -r c8820cc201db -r 3951042a701e demos/rpg/scripts/__init__.py
diff -r c8820cc201db -r 3951042a701e demos/rpg/scripts/common/__init__.py
diff -r c8820cc201db -r 3951042a701e demos/rpg/scripts/common/eventlistenerbase.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/rpg/scripts/common/eventlistenerbase.py Thu May 20 19:55:19 2010 +0000
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+
+# ####################################################################
+# Copyright (C) 2005-2010 by the FIFE team
+# http://www.fifengine.net
+# This file is part of FIFE.
+#
+# FIFE is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+# ####################################################################
+
+from fife import fife
+
+class EventListenerBase(fife.IKeyListener, fife.ICommandListener, fife.IMouseListener, fife.ConsoleExecuter):
+ def __init__(self, engine, regKeys=False, regCmd=False, regMouse=False, regConsole=False, regWidget=False):
+ self.eventmanager = engine.getEventManager()
+
+ fife.IKeyListener.__init__(self)
+ if regKeys:
+ self.eventmanager.addKeyListener(self)
+ fife.ICommandListener.__init__(self)
+ if regCmd:
+ self.eventmanager.addCommandListener(self)
+ fife.IMouseListener.__init__(self)
+ if regMouse:
+ self.eventmanager.addMouseListener(self)
+ fife.ConsoleExecuter.__init__(self)
+ if regConsole:
+ engine.getGuiManager().getConsole().setConsoleExecuter(self)
+
+
+ def mousePressed(self, evt):
+ pass
+ def mouseReleased(self, evt):
+ pass
+ def mouseEntered(self, evt):
+ pass
+ def mouseExited(self, evt):
+ pass
+ def mouseClicked(self, evt):
+ pass
+ def mouseWheelMovedUp(self, evt):
+ pass
+ def mouseWheelMovedDown(self, evt):
+ pass
+ def mouseMoved(self, evt):
+ pass
+ def mouseDragged(self, evt):
+ pass
+ def keyPressed(self, evt):
+ pass
+ def keyReleased(self, evt):
+ pass
+ def onCommand(self, command):
+ pass
+ def onToolsClick(self):
+ print "No tools set up yet"
+ def onConsoleCommand(self, command):
+ pass
+ def onWidgetAction(self, evt):
+ pass
diff -r c8820cc201db -r 3951042a701e demos/rpg/scripts/gamecontroller.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/rpg/scripts/gamecontroller.py Thu May 20 19:55:19 2010 +0000
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+# -*- coding: utf-8 -*-
+
+# ####################################################################
+# Copyright (C) 2005-2010 by the FIFE team
+# http://www.fifengine.net
+# This file is part of FIFE.
+#
+# FIFE is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+# ####################################################################
+# This is the rio de hola client for FIFE.
+
+import sys, os, re, math, random, shutil
+
+from fife import fife
+
+class GameController(object):
+ def __init__(self, application, engine, settings):
+ self._application = application
+ self._engine = engine
+ self._settings = settings
+
+ def pump(self):
+ pass
diff -r c8820cc201db -r 3951042a701e demos/rpg/scripts/rpg.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/rpg/scripts/rpg.py Thu May 20 19:55:19 2010 +0000
@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+
+# -*- coding: utf-8 -*-
+
+# ####################################################################
+# Copyright (C) 2005-2010 by the FIFE team
+# http://www.fifengine.net
+# This file is part of FIFE.
+#
+# FIFE is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+# ####################################################################
+# This is the rio de hola client for FIFE.
+
+import sys, os, re, math, random, shutil
+
+from fife import fife
+from fife.extensions import *
+from scripts.gamecontroller import GameController
+from scripts.common import eventlistenerbase
+from fife.extensions.basicapplication import ApplicationBase
+from fife.extensions import pychan
+from fife.extensions.pychan import widgets
+from fife.extensions.fife_utils import getUserDataDirectory
+
+class KeyFilter(fife.IKeyFilter):
+ def __init__(self, keys):
+ fife.IKeyFilter.__init__(self)
+ self._keys = keys
+
+ def isFiltered(self, event):
+ return event.getKey().getValue() in self._keys
+
+class ApplicationListener(eventlistenerbase.EventListenerBase):
+ def __init__(self, engine, gamecontroller):
+ super(ApplicationListener, self).__init__(engine,regKeys=True,regCmd=True, regMouse=False, regConsole=True, regWidget=True)
+ self._engine = engine
+ self._gamecontroller = gamecontroller
+
+ keyfilter = KeyFilter([fife.Key.ESCAPE])
+ keyfilter.__disown__()
+
+ self._engine.getEventManager().setKeyFilter(keyfilter)
+
+ self.quit = False
+
+ def keyPressed(self, evt):
+ keyval = evt.getKey().getValue()
+ keystr = evt.getKey().getAsString().lower()
+ consumed = False
+ if keyval == fife.Key.ESCAPE:
+ self.quit = True
+ evt.consume()
+ elif keyval == fife.Key.F10:
+ self.engine.getGuiManager().getConsole().toggleShowHide()
+ evt.consume()
+ elif keystr == 'p':
+ self.engine.getRenderBackend().captureScreen('screenshot.png')
+ evt.consume()
+
+ def onCommand(self, command):
+ self.quit = (command.getCommandType() == fife.CMD_QUIT_GAME)
+ if self.quit:
+ command.consume()
+
+ def onConsoleCommand(self, command):
+ result = ''
+ if command.lower() in ('quit', 'exit'):
+ self.quit = True
+ result = 'quitting'
+ elif command.lower() in ( 'help', 'help()' ):
+ self.engine.getGuiManager().getConsole().println( open( 'misc/infotext.txt', 'r' ).read() )
+ result = "-- End of help --"
+ else:
+ pass
+ #result = self.world.onConsoleCommand(command)
+ if not result:
+ try:
+ result = str(eval(command))
+ except:
+ pass
+ if not result:
+ result = 'no result'
+ return result
+
+class RPGApplication(ApplicationBase):
+ def __init__(self, TDS):
+ super(RPGApplication,self).__init__(TDS)
+ self._settings = TDS
+
+ pychan.init(self.engine, debug=self._settings.get("FIFE", "PychanDebug", False))
+
+ self._gamecontroller = GameController(self, self.engine, self._settings)
+
+ def createListener(self):
+ """
+ @note: This function had to be overloaded otherwise the default
+ listener would have been created.
+ """
+ self._listener = ApplicationListener(self.engine, self._gamecontroller)
+ return self._listener
+
+ def requestQuit(self):
+ cmd = fife.Command()
+ cmd.setSource(None)
+ cmd.setCommandType(fife.CMD_QUIT_GAME)
+ self.engine.getEventManager().dispatchCommand(cmd)
+
+ def _pump(self):
+ if self._listener.quit:
+ self.breakRequested = True
+ else:
+ self._gamecontroller.pump()
diff -r c8820cc201db -r 3951042a701e demos/rpg/settings-dist.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/rpg/settings-dist.xml Thu May 20 19:55:19 2010 +0000
@@ -0,0 +1,29 @@
+
+
+
+ 0
+ 1
+ OpenGL
+ 1024
+ 768
+ 0
+ 5.0
+ 1
+ FIFE - RPG Demo
+
+ fonts/FreeSans.ttf
+ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"
+ 16
+ controller
+ False
+ 1
+ False
+ False
+ 0
+
+
+
+ maps/town.xml
+ maps/level1.xml
+
+