[Python-ogre-commit] SF.net SVN: python-ogre:[662] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
|
From: <and...@us...> - 2008-07-17 10:38:42
|
Revision: 662
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=662&view=rev
Author: andy_miller
Date: 2008-07-17 10:38:12 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
CEGUI Demo updates thanks to Dermont
Changes to support CEGUI 0.6.1
Modified Paths:
--------------
trunk/python-ogre/PythonOgreConfig_nt.py
trunk/python-ogre/demos/cegui/CEGUI_framework.py
trunk/python-ogre/demos/cegui/resources.cfg
trunk/python-ogre/demos/ogreode/SimpleScenes.py
trunk/python-ogre/demos/ogreode/SimpleScenes_Buggy.py
trunk/python-ogre/demos/ogreode/SimpleScenes_Chain.py
trunk/python-ogre/demos/ogreode/SimpleScenes_Joints.py
trunk/python-ogre/demos/ogreode/SimpleScenes_TriMesh.py
trunk/python-ogre/environment.py
Added Paths:
-----------
trunk/python-ogre/demos/cegui/Demo_CEGUI_DragnDropv061.py
trunk/python-ogre/demos/cegui/Demo_CEGUI_Falgard1v061.py
trunk/python-ogre/demos/cegui/Demo_CEGUI_FirstWindowv061.py
trunk/python-ogre/demos/cegui/Demo_CEGUI_FontDemov061.py
trunk/python-ogre/demos/cegui/Demo_CEGUI_ScrollablePanev061.py
trunk/python-ogre/demos/cegui/Demo_CEGUI_TabControlv061.py
trunk/python-ogre/demos/cegui/Demo_CEGUI_Treev061.py
trunk/python-ogre/demos/cegui/datafiles/
trunk/python-ogre/demos/cegui/datafiles/configs/
trunk/python-ogre/demos/cegui/datafiles/configs/CEGUIConfig.xsd
trunk/python-ogre/demos/cegui/datafiles/fonts/
trunk/python-ogre/demos/cegui/datafiles/fonts/Commonv2c.ttf
trunk/python-ogre/demos/cegui/datafiles/fonts/Commonwealth-10.font
trunk/python-ogre/demos/cegui/datafiles/fonts/DejaVuSans-10.font
trunk/python-ogre/demos/cegui/datafiles/fonts/DejaVuSans.ttf
trunk/python-ogre/demos/cegui/datafiles/fonts/FairChar-30.font
trunk/python-ogre/demos/cegui/datafiles/fonts/Font.xsd
trunk/python-ogre/demos/cegui/datafiles/fonts/Iconified-12.font
trunk/python-ogre/demos/cegui/datafiles/fonts/Iconiv2.ttf
trunk/python-ogre/demos/cegui/datafiles/fonts/Legal.txt
trunk/python-ogre/demos/cegui/datafiles/fonts/README
trunk/python-ogre/demos/cegui/datafiles/fonts/common.txt
trunk/python-ogre/demos/cegui/datafiles/fonts/fkp-16.font
trunk/python-ogre/demos/cegui/datafiles/fonts/fkp.de.pcf
trunk/python-ogre/demos/cegui/datafiles/fonts/icon.txt
trunk/python-ogre/demos/cegui/datafiles/imagesets/
trunk/python-ogre/demos/cegui/datafiles/imagesets/DriveIcons.imageset
trunk/python-ogre/demos/cegui/datafiles/imagesets/DriveIcons.png
trunk/python-ogre/demos/cegui/datafiles/imagesets/FairChar.imageset
trunk/python-ogre/demos/cegui/datafiles/imagesets/FairChar.tga
trunk/python-ogre/demos/cegui/datafiles/imagesets/GPN-2000-001437.tga
trunk/python-ogre/demos/cegui/datafiles/imagesets/Imageset.xsd
trunk/python-ogre/demos/cegui/datafiles/imagesets/ReadMe.txt
trunk/python-ogre/demos/cegui/datafiles/imagesets/TaharezLook.imageset
trunk/python-ogre/demos/cegui/datafiles/imagesets/TaharezLook.tga
trunk/python-ogre/demos/cegui/datafiles/imagesets/Vanilla.imageset
trunk/python-ogre/demos/cegui/datafiles/imagesets/WindowsLook.imageset
trunk/python-ogre/demos/cegui/datafiles/imagesets/WindowsLook.tga
trunk/python-ogre/demos/cegui/datafiles/imagesets/vanilla.tga
trunk/python-ogre/demos/cegui/datafiles/layouts/
trunk/python-ogre/demos/cegui/datafiles/layouts/Console.wnd
trunk/python-ogre/demos/cegui/datafiles/layouts/Demo7Windows.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/Demo8.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/DragDropDemo.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/FontDemo.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/GUILayout.xsd
trunk/python-ogre/demos/cegui/datafiles/layouts/TabControlDemo.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/TabPage.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/TabPage1.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/TabPage2.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/TextDemo.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/TreeDemoTaharez.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/VanillaConsole.layout
trunk/python-ogre/demos/cegui/datafiles/layouts/VanillaWindows.layout
trunk/python-ogre/demos/cegui/datafiles/looknfeel/
trunk/python-ogre/demos/cegui/datafiles/looknfeel/Falagard.xsd
trunk/python-ogre/demos/cegui/datafiles/looknfeel/TaharezLook.looknfeel
trunk/python-ogre/demos/cegui/datafiles/looknfeel/Vanilla.looknfeel
trunk/python-ogre/demos/cegui/datafiles/looknfeel/WindowsLook.looknfeel
trunk/python-ogre/demos/cegui/datafiles/lua_scripts/
trunk/python-ogre/demos/cegui/datafiles/lua_scripts/IConsole.lua
trunk/python-ogre/demos/cegui/datafiles/lua_scripts/InstancedInit.lua
trunk/python-ogre/demos/cegui/datafiles/lua_scripts/demo8.lua
trunk/python-ogre/demos/cegui/datafiles/schemes/
trunk/python-ogre/demos/cegui/datafiles/schemes/Demo8.scheme
trunk/python-ogre/demos/cegui/datafiles/schemes/GUIScheme.xsd
trunk/python-ogre/demos/cegui/datafiles/schemes/TaharezLook.scheme
trunk/python-ogre/demos/cegui/datafiles/schemes/TaharezLookWidgetAliases.scheme
trunk/python-ogre/demos/cegui/datafiles/schemes/TaharezLookWidgets.scheme
trunk/python-ogre/demos/cegui/datafiles/schemes/VanillaSkin.scheme
trunk/python-ogre/demos/cegui/datafiles/schemes/WindowsLook.scheme
trunk/python-ogre/demos/cegui/datafiles/schemes/WindowsLookWidgets.scheme
trunk/python-ogre/demos/cegui/v061/
trunk/python-ogre/demos/cegui/v061/TreeDemoMaterial.layout
trunk/python-ogre/demos/cegui/v061/TreeDemoTaharez.layout
trunk/python-ogre/demos/cegui/v061/TreeDemoVanilla.layout
Modified: trunk/python-ogre/PythonOgreConfig_nt.py
===================================================================
--- trunk/python-ogre/PythonOgreConfig_nt.py 2008-07-17 08:53:19 UTC (rev 661)
+++ trunk/python-ogre/PythonOgreConfig_nt.py 2008-07-17 10:38:12 UTC (rev 662)
@@ -38,8 +38,7 @@
PATH_THIRDPARTY = os.path.join(module_dir, 'ThirdParty' )
PATH_Ogre = os.path.join(BASE_DIR, 'ogre')
PATH_OgreAddons = os.path.join(BASE_DIR, 'OgreAddons')
-PATH_CEGUI = os.path.join(BASE_DIR, 'CEGUI-0.5.0')
-PATH_CEGUI = os.path.join(BASE_DIR, 'CEGUI-0.6.0')
+PATH_CEGUI = os.path.join(BASE_DIR, 'CEGUI-0.6.1')
PATH_OIS = os.path.join(BASE_DIR, 'ois' ) ##'ois-1.0RC1')
PATH_Newton = os.path.join(BASE_DIR, 'newtonsdk','sdk')
@@ -56,7 +55,7 @@
PATH_ogreforests= os.path.join(PATH_THIRDPARTY,'forests')
PATH_OGREAL= os.path.join(PATH_THIRDPARTY,'ogreal')
-PATH_OGREAL= os.path.join(BASE_DIR,'ogreal')
+# PATH_OGREAL= os.path.join(BASE_DIR,'ogreal')
PATH_OPCODE= os.path.join(PATH_THIRDPARTY,'opcode')
PATH_quickgui= os.path.join(PATH_THIRDPARTY,'quickgui')
@@ -107,7 +106,7 @@
PATH_LIB_OgreOdePrefab = os.path.join( PATH_OgreOde, 'prefab/lib/Release' )
PATH_LIB_OgreOdeLoader = os.path.join( PATH_OgreOde, 'loader/lib/Release' )
-PATH_LIB_OgreAL = os.path.join( PATH_OGREAL, 'lib/Release' )
+PATH_LIB_OgreAL = os.path.join( PATH_OGREAL ) # , 'lib/Release' )
PATH_LIB_betagui = PATH_betagui
PATH_LIB_quickgui = PATH_quickgui
PATH_LIB_NxOgre= os.path.join(PATH_NxOgre, 'lib')
@@ -140,7 +139,7 @@
PATH_INCLUDE_OPCODE = PATH_OPCODE
PATH_INCLUDE_ODESOURCE = os.path.join( PATH_ODE, 'ode/src')
-PATH_INCLUDE_OgreAL = os.path.join( PATH_OGREAL, 'include' )
+PATH_INCLUDE_OgreAL = os.path.join( PATH_OGREAL ) #, 'include' )
PATH_INCLUDE_OPENAL = os.path.join( PATH_OPENAL, 'include')
PATH_INCLUDE_OGG= os.path.join( PATH_OGG, 'include' )
PATH_INCLUDE_VORBIS= os.path.join( PATH_VORBIS, 'include' )
Modified: trunk/python-ogre/demos/cegui/CEGUI_framework.py
===================================================================
--- trunk/python-ogre/demos/cegui/CEGUI_framework.py 2008-07-17 08:53:19 UTC (rev 661)
+++ trunk/python-ogre/demos/cegui/CEGUI_framework.py 2008-07-17 10:38:12 UTC (rev 662)
@@ -1,96 +1,96 @@
-import ctypes
-
-# The follow patch from Tim (Mithro) fixes a loder issue with CEGUI - previously we'd patched CEGUI to
-# ensure the CEGUIBase was linked to every module to solve the issue with Python dynamically loading
-# the _cegui_.so module without RTLD_GLOBAL set - then when CEGUI opened it's dynamic modules it
-# couldn't find all the symbols.
-
-print ctypes.CDLL("../../../root/usr/lib/libCEGUIBase.so", ctypes.RTLD_GLOBAL )
-
-import ogre.gui.CEGUI as CEGUI
-
-# Another fix for CEGUI to ensure we get a working parser..
-CEGUI.System.setDefaultXMLParserName("TinyXMLParser")
-
-import ogre.io.OIS as OIS
-import SampleFramework
-
-##----------------------------------------------------------------##
-def convertOISMouseButtonToCegui( buttonID):
- if buttonID ==0:
- return CEGUI.LeftButton
- elif buttonID ==1:
- return CEGUI.RightButton
- elif buttonID ==2:
- return CEGUI.MiddleButton
- elif buttonID ==3:
- return CEGUI.X1Button
- else:
- return CEGUI.LeftButton
-
-def _PointHack(x, y):
- return CEGUI.Vector2(x, y)
-CEGUI.Point = _PointHack
-
-def cegui_reldim ( x ) :
- return CEGUI.UDim((x),0)
-
-class MouseListener ( OIS.MouseListener ):
- def __init__(self):
- OIS.MouseListener.__init__( self)
-
- ##----------------------------------------------------------------##
- def mouseMoved( self, arg ):
- CEGUI.System.getSingleton().injectMouseMove( arg.get_state().X.rel, arg.get_state().Y.rel )
- return True
-
- ##----------------------------------------------------------------##
- def mousePressed( self, arg, id ):
- CEGUI.System.getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id))
- return True
-
- ##----------------------------------------------------------------##
- def mouseReleased( self, arg, id ):
- CEGUI.System.getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id))
- return True
-
-
-class GuiFrameListener(SampleFramework.FrameListener , OIS.KeyListener, OIS.MouseListener):
-
- def __init__(self, renderWindow, camera, CEGUIRenderer):
-
- SampleFramework.FrameListener.__init__(self, renderWindow, camera, True, True, True)
- OIS.KeyListener.__init__(self)
- self.mouselistener = MouseListener ()
- #OIS.MouseListener.__init_(self)
-
- self.Mouse.setEventCallback(self.mouselistener)
- self.Keyboard.setEventCallback(self)
-
- self.ShutdownRequested = False
- self.GUIRenderer = CEGUIRenderer
- self.keepRendering = True # whether to continue rendering or not
- self.numScreenShots = 0 # screen shot count
-
- ## Tell the frame listener to exit at the end of the next frame
- def requestShutdown( self ):
- self.ShutdownRequested = True
-
- def frameEnded(self, evt):
- if self.ShutdownRequested:
- return False
- else:
- return SampleFramework.FrameListener.frameEnded(self, evt)
-
- ##----------------------------------------------------------------##
- def keyPressed( self, arg ):
- if arg.key == OIS.KC_ESCAPE:
- self.ShutdownRequested = True
- CEGUI.System.getSingleton().injectKeyDown( arg.key )
- CEGUI.System.getSingleton().injectChar( arg.text )
- return True
-
- ##----------------------------------------------------------------##
- def keyReleased( self, arg ):
- CEGUI.System.getSingleton().injectKeyUp( arg.key )
- return True
+import ctypes
+
+# The follow patch from Tim (Mithro) fixes a loder issue with CEGUI - previously we'd patched CEGUI to
+# ensure the CEGUIBase was linked to every module to solve the issue with Python dynamically loading
+# the _cegui_.so module without RTLD_GLOBAL set - then when CEGUI opened it's dynamic modules it
+# couldn't find all the symbols.
+
+#print ctypes.CDLL("../../../root/usr/lib/libCEGUIBase.so", ctypes.RTLD_GLOBAL )
+
+import ogre.gui.CEGUI as CEGUI
+
+# Another fix for CEGUI to ensure we get a working parser..
+CEGUI.System.setDefaultXMLParserName("TinyXMLParser")
+
+import ogre.io.OIS as OIS
+import SampleFramework
+
+##----------------------------------------------------------------##
+def convertOISMouseButtonToCegui( buttonID):
+ if buttonID ==0:
+ return CEGUI.LeftButton
+ elif buttonID ==1:
+ return CEGUI.RightButton
+ elif buttonID ==2:
+ return CEGUI.MiddleButton
+ elif buttonID ==3:
+ return CEGUI.X1Button
+ else:
+ return CEGUI.LeftButton
+
+def _PointHack(x, y):
+ return CEGUI.Vector2(x, y)
+CEGUI.Point = _PointHack
+
+def cegui_reldim ( x ) :
+ return CEGUI.UDim((x),0)
+
+class MouseListener ( OIS.MouseListener ):
+ def __init__(self):
+ OIS.MouseListener.__init__( self)
+
+ ##----------------------------------------------------------------##
+ def mouseMoved( self, arg ):
+ CEGUI.System.getSingleton().injectMouseMove( arg.get_state().X.rel, arg.get_state().Y.rel )
+ return True
+
+ ##----------------------------------------------------------------##
+ def mousePressed( self, arg, id ):
+ CEGUI.System.getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id))
+ return True
+
+ ##----------------------------------------------------------------##
+ def mouseReleased( self, arg, id ):
+ CEGUI.System.getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id))
+ return True
+
+
+class GuiFrameListener(SampleFramework.FrameListener , OIS.KeyListener, OIS.MouseListener):
+
+ def __init__(self, renderWindow, camera, CEGUIRenderer):
+
+ SampleFramework.FrameListener.__init__(self, renderWindow, camera, True, True, True)
+ OIS.KeyListener.__init__(self)
+ self.mouselistener = MouseListener ()
+ #OIS.MouseListener.__init_(self)
+
+ self.Mouse.setEventCallback(self.mouselistener)
+ self.Keyboard.setEventCallback(self)
+
+ self.ShutdownRequested = False
+ self.GUIRenderer = CEGUIRenderer
+ self.keepRendering = True # whether to continue rendering or not
+ self.numScreenShots = 0 # screen shot count
+
+ ## Tell the frame listener to exit at the end of the next frame
+ def requestShutdown( self ):
+ self.ShutdownRequested = True
+
+ def frameEnded(self, evt):
+ if self.ShutdownRequested:
+ return False
+ else:
+ return SampleFramework.FrameListener.frameEnded(self, evt)
+
+ ##----------------------------------------------------------------##
+ def keyPressed( self, arg ):
+ if arg.key == OIS.KC_ESCAPE:
+ self.ShutdownRequested = True
+ CEGUI.System.getSingleton().injectKeyDown( arg.key )
+ CEGUI.System.getSingleton().injectChar( arg.text )
+ return True
+
+ ##----------------------------------------------------------------##
+ def keyReleased( self, arg ):
+ CEGUI.System.getSingleton().injectKeyUp( arg.key )
+ return True
Added: trunk/python-ogre/demos/cegui/Demo_CEGUI_DragnDropv061.py
===================================================================
--- trunk/python-ogre/demos/cegui/Demo_CEGUI_DragnDropv061.py (rev 0)
+++ trunk/python-ogre/demos/cegui/Demo_CEGUI_DragnDropv061.py 2008-07-17 10:38:12 UTC (rev 662)
@@ -0,0 +1,167 @@
+#/***************************************************************************
+# * Copyright (C) 2004 - 2008 Paul D Turner & The CEGUI Development Team
+# *
+# * Permission is hereby granted, free of charge, to any person obtaining
+# * a copy of this software and associated documentation files (the
+# * "Software"), to deal in the Software without restriction, including
+# * without limitation the rights to use, copy, modify, merge, publish,
+# * distribute, sublicense, and/or sell copies of the Software, and to
+# * permit persons to whom the Software is furnished to do so, subject to
+# * the following conditions:
+# *
+# * The above copyright notice and this permission notice shall be
+# * included in all copies or substantial portions of the Software.
+# *
+# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# * OTHER DEALINGS IN THE SOFTWARE.
+# ***************************************************************************/
+
+
+import sys
+sys.path.insert(0,'..')
+import PythonOgreConfig
+
+import ogre.renderer.OGRE as ogre
+import ogre.io.OIS as OIS
+import ogre.gui.CEGUI as CEGUI
+import SampleFramework
+
+from CEGUI_framework import *
+
+
+def createUVector2( x, y):
+ return CEGUI.UVector2(CEGUI.UDim(x,0), CEGUI.UDim(y,0))
+
+def handle_ItemDropped(args):
+ if not args.window.getChildCount():
+ # add dragdrop item as child of target if target has no item already
+ args.window.addChildWindow(args.dragDropItem)
+ # Now we must reset the item position from it's 'dropped' location,
+ # since we're now a child of an entirely different window
+ args.dragDropItem.setPosition(
+ createUVector2(0.05, 0.05) )
+ return True
+
+
+
+
+class GEUIApplication(SampleFramework.Application):
+
+ def __init__(self):
+ SampleFramework.Application.__init__(self)
+ self.CEGUIRenderer = 0
+ self.CEGUISystem = 0
+
+ def _createScene(self):
+
+ sceneManager = self.sceneManager
+ sceneManager.ambientLight = ogre.ColourValue(0.25, 0.25, 0.25)
+
+ # initiaslise CEGUI Renderer
+ self.CEGUIRenderer = CEGUI.OgreCEGUIRenderer(self.renderWindow,
+ ogre.RenderQueueGroupID.RENDER_QUEUE_OVERLAY,
+ False, 3000,
+ self.sceneManager)
+
+ self.CEGUISystem = CEGUI.System(self.CEGUIRenderer)
+ CEGUI.Logger.getSingleton().loggingLevel = CEGUI.Insane
+
+ # load TaharezLook scheme
+ CEGUI.SchemeManager.getSingleton().loadScheme("WindowsLook.scheme")
+
+ # load font and setup default if not loaded via scheme
+ if not CEGUI.FontManager.getSingleton().isFontPresent("DejaVuSans-10.font"):
+ try:
+ CEGUI.FontManager.getSingleton().createFont("DejaVuSans-10.font")
+ except:
+ ## assume font is defined in loaded scheme
+ pass
+
+ ## set up defaults
+ CEGUI.System.getSingleton().setDefaultMouseCursor("WindowsLook", "MouseArrow")
+ CEGUI.System.getSingleton().setDefaultFont("DejaVuSans-10")
+
+ # load the drive icons imageset
+ CEGUI.ImagesetManager.getSingleton().createImageset("DriveIcons.imageset")
+
+ ## load the initial layout
+ CEGUI.System.getSingleton().setGUISheet(
+ CEGUI.WindowManager.getSingleton().loadWindowLayout("DragDropDemo.layout", False))
+
+ ## setup events
+ self._subscribeEvents()
+
+
+ def _subscribeEvents(self):
+ wmgr = CEGUI.WindowManager.getSingleton()
+
+
+ # Subscribe the same handler to each of the twelve slots
+ base_name = "Root/MainWindow/Slot"
+ for i in range(1,13):
+ try:
+ # get the window pointer for this slot
+ wnd = wmgr.getWindow(base_name + CEGUI.PropertyHelper.intToString(i))
+ wnd.subscribeEvent(
+ CEGUI.Window.EventDragDropItemDropped, handle_ItemDropped,"")
+ except CEGUI.Exception, e:
+ print e
+
+ def _createCamera(self):
+ self.camera = self.sceneManager.createCamera("PlayerCam")
+ self.camera.nearClipDistance = 5
+
+ def _createFrameListener(self):
+ self.frameListener = CEGUIFrameListener(self.renderWindow, self.camera, self.sceneManager)
+ self.root.addFrameListener(self.frameListener)
+ self.frameListener.showDebugOverlay(True)
+
+ def __del__(self):
+ "Clear variables, this is needed to ensure the correct order of deletion"
+ del self.camera
+ del self.sceneManager
+ del self.frameListener
+ del self.CEGUISystem
+ del self.CEGUIRenderer
+ del self.root
+ del self.renderWindow
+
+class CEGUIFrameListener(GuiFrameListener):
+
+ def __init__(self, renderWindow, camera, sceneManager):
+ GuiFrameListener.__init__(self, renderWindow, camera, sceneManager)
+
+ self.keepRendering = True # whether to continue rendering or not
+
+ # Subscribe handler to deal with user closing the frame window
+ try:
+ main_wnd = CEGUI.WindowManager.getSingleton().getWindow("Root/MainWindow")
+ main_wnd.subscribeEvent(
+ CEGUI.FrameWindow.EventCloseClicked, self, "handle_CloseButton")
+
+ # if something goes wrong, log the issue but do not bomb!
+ except CEGUI.Exception, e:
+ print e
+
+ def handle_CloseButton(self, args):
+ self.keepRendering = False
+ return True
+
+ def frameStarted(self, evt):
+ if not self.keepRendering:
+ return False
+ else:
+ return GuiFrameListener.frameStarted(self,evt)
+
+
+if __name__ == '__main__':
+ try:
+ ta = GEUIApplication()
+ ta.go()
+ except ogre.OgreException, e:
+ print e
Added: trunk/python-ogre/demos/cegui/Demo_CEGUI_Falgard1v061.py
===================================================================
--- trunk/python-ogre/demos/cegui/Demo_CEGUI_Falgard1v061.py (rev 0)
+++ trunk/python-ogre/demos/cegui/Demo_CEGUI_Falgard1v061.py 2008-07-17 10:38:12 UTC (rev 662)
@@ -0,0 +1,283 @@
+#/***************************************************************************
+# * Copyright (C) 2004 - 2008 Paul D Turner & The CEGUI Development Team
+# *
+# * Permission is hereby granted, free of charge, to any person obtaining
+# * a copy of this software and associated documentation files (the
+# * "Software"), to deal in the Software without restriction, including
+# * without limitation the rights to use, copy, modify, merge, publish,
+# * distribute, sublicense, and/or sell copies of the Software, and to
+# * permit persons to whom the Software is furnished to do so, subject to
+# * the following conditions:
+# *
+# * The above copyright notice and this permission notice shall be
+# * included in all copies or substantial portions of the Software.
+# *
+# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# * OTHER DEALINGS IN THE SOFTWARE.
+# ***************************************************************************/
+
+
+import sys
+sys.path.insert(0,'..')
+import PythonOgreConfig
+
+import ogre.renderer.OGRE as ogre
+import ogre.io.OIS as OIS
+import ogre.gui.CEGUI as CEGUI
+import SampleFramework
+
+from CEGUI_framework import *
+
+
+def cegui_reldim ( x ) :
+ return CEGUI.UDim((x),0)
+
+def ceguimax ( x, y ) :
+ if x>y: return x
+ return y
+def ceguimin ( x, y ) :
+ if x<y: return x
+ return y
+
+
+
+
+class DemoConsole():
+
+ SubmitButtonID = 1
+ EntryBoxID = 2
+ HistoryID = 3
+
+ def __init__(self, id_name, parent=None):
+
+ d_root = CEGUI.WindowManager.getSingleton().loadWindowLayout("VanillaConsole.layout", id_name, 'General')
+ self.d_historyPos = 0
+ self.d_root = d_root
+ self.d_history = []
+
+ # we will destroy the console box windows ourselves
+ d_root.setDestroyedByParent(False)
+
+
+
+ # Do events wire-up
+ d_root.subscribeEvent(
+ CEGUI.Window.EventKeyDown, self, "handleKeyDown")
+
+ d_root.getChild(self.SubmitButtonID).subscribeEvent(
+ CEGUI.PushButton.EventClicked, self, "handleSubmit")
+ d_root.getChild(self.EntryBoxID).subscribeEvent(
+ CEGUI.Editbox.EventTextAccepted, self, "handleSubmit")
+
+ # decide where to attach the console main window
+ def attachTo(parent, sheet):
+ if parent : return parent
+ return sheet
+
+ parent = attachTo(parent , CEGUI.System.getSingleton().getGUISheet() )
+
+ # attach this window if parent is valid
+ if parent:
+ parent.addChildWindow(d_root)
+
+
+ def __del__(self):
+ # destroy the windows that we loaded earlier
+ CEGUI.WindowManager.getSingleton().destroyWindow(self.d_root)
+ self.d_root = 0
+
+
+ def toggleVisibility(self):
+ if self.d_root.isVisible(True):
+ self.d_root.hide()
+ else:
+ self.d_root.show()
+
+
+ def isVisible(self):
+ return self.d_root.isVisible()
+
+ def handleSubmit(self, args):
+
+ # get the text entry editbox
+ editbox = self.d_root.getChild(self.EntryBoxID)
+
+ # get text out of the editbox
+ edit_text = editbox.getText()
+
+ # if the string is not empty
+ if len(edit_text.c_str())>0:
+ # add this entry to the command history buffer
+ self.d_history.append(edit_text)
+ # reset history position
+ self.d_historyPos = len(self.d_history)
+ # append newline to this entry
+ edit_text += '\n'
+ # get history window
+ history = self.d_root.getChild(self.HistoryID)
+ print dir(history)
+ # append new text to history output
+ history.setText(history.getText() + edit_text)
+ # scroll to bottom of history output
+ history.setCaratIndex(-1)
+ # erase text in text entry box.
+ editbox.setText("")
+
+ # re-activate the text entry box
+ editbox.activate()
+
+ return True
+
+ def handleKeyDown(self, args):
+
+ # get the text entry editbox
+ editbox = self.d_root.getChild(self.EntryBoxID)
+
+ if args.scancode == CEGUI.Key.ArrowUp :
+ self.d_historyPos = ceguimax(self.d_historyPos - 1, -1)
+ if self.d_historyPos >= 0:
+ editbox.setText(self.d_history[self.d_historyPos])
+ editbox.setCaratIndex(-1)
+ else:
+ editbox.setText("")
+ editbox.activate()
+
+ elif args.scancode == CEGUI.Key.ArrowDown :
+ self.d_historyPos = ceguimin(self.d_historyPos + 1, len(self.d_history) )
+ if self.d_historyPos < len(self.d_history):
+ editbox.setText(self.d_history[self.d_historyPos])
+ editbox.setCaratIndex(-1)
+ else:
+ editbox.setText("")
+
+ editbox.activate()
+
+ else:
+ return False
+
+ return True
+
+
+class GEUIApplication(SampleFramework.Application):
+
+ def __init__(self):
+ SampleFramework.Application.__init__(self)
+ self.CEGUIRenderer = 0
+ self.CEGUISystem = 0
+ self.d_console = None
+
+ def _createScene(self):
+
+ sceneManager = self.sceneManager
+ sceneManager.ambientLight = ogre.ColourValue(0.25, 0.25, 0.25)
+
+ # initiaslise OgreCEGUI Renderer
+
+ self.CEGUIRenderer = CEGUI.OgreCEGUIRenderer(self.renderWindow,
+ ogre.RenderQueueGroupID.RENDER_QUEUE_OVERLAY,
+ False, 3000,
+ self.sceneManager)
+ self.CEGUISystem = CEGUI.System(self.CEGUIRenderer)
+
+ ## set the logging level
+ CEGUI.Logger.getSingleton().loggingLevel = CEGUI.Insane
+
+ ## we will make extensive use of the WindowManager.
+ winMgr = CEGUI.WindowManager.getSingleton()
+
+ # Load the scheme to initialse the VanillaSkin which we use in this sample
+ CEGUI.SchemeManager.getSingleton().loadScheme("VanillaSkin.scheme")
+ # set default mouse image
+ CEGUI.System.getSingleton().setDefaultMouseCursor("Vanilla-Images", "MouseArrow")
+
+ # load an image to use as a background
+ CEGUI.ImagesetManager.getSingleton().createImagesetFromImageFile("BackgroundImage", "GPN-2000-001437.tga")
+
+ # here we will use a StaticImage as the root, then we can use
+ # it to place a background image
+ background = winMgr.createWindow("Vanilla/StaticImage")
+ # set area rectangle
+ background.setArea(CEGUI.URect(cegui_reldim(0), cegui_reldim(0),
+ cegui_reldim(1), cegui_reldim(1)))
+ # disable frame and standard background
+ background.setProperty("FrameEnabled", "false")
+ background.setProperty("BackgroundEnabled", "false")
+ # set the background image
+ background.setProperty("Image", "set:BackgroundImage image:full_image")
+ # install this as the root GUI sheet
+ CEGUI.System.getSingleton().setGUISheet(background)
+
+ if not CEGUI.FontManager.getSingleton().isFontPresent("Iconified-12"):
+ CEGUI.FontManager.getSingleton().createFont("Iconified-12.font")
+
+ # load some demo windows and attach to the background 'root'
+ background.addChildWindow(winMgr.loadWindowLayout("VanillaWindows.layout", False))
+
+ # create an instance of the console class.
+ self.d_console = DemoConsole("Demo")
+
+ # listen for key presses on the root window.
+ background.subscribeEvent(
+ CEGUI.Window.EventKeyDown,
+ self, 'handleRootKeyDown')
+
+ # activate the background window
+ background.activate()
+
+ def handleRootKeyDown(self, args):
+ keyArgs = args
+
+ if keyArgs.scancode == CEGUI.Key.F12:
+ self.d_console.toggleVisibility()
+
+ else:
+ return False
+ return True
+
+
+
+ def _createCamera(self):
+ self.camera = self.sceneManager.createCamera("PlayerCam")
+ self.camera.nearClipDistance = 5
+
+ def _createFrameListener(self):
+ self.frameListener = CEGUIFrameListener(self.renderWindow, self.camera, self.sceneManager)
+ self.root.addFrameListener(self.frameListener)
+ self.frameListener.showDebugOverlay(True)
+
+ def cleanUp(self):
+ print "Cleaning Up"
+ del self.d_console
+
+ def __del__(self):
+ "Clear variables, this is needed to ensure the correct order of deletion"
+ del self.camera
+ del self.sceneManager
+ del self.frameListener
+ del self.CEGUISystem
+ del self.CEGUIRenderer
+ del self.root
+ del self.renderWindow
+
+class CEGUIFrameListener(GuiFrameListener):
+
+ def __init__(self, renderWindow, camera, sceneManager):
+ GuiFrameListener.__init__(self, renderWindow, camera, sceneManager)
+ self.MenuMode=True
+ self.keepRendering = True # whether to continue rendering or not
+
+
+
+if __name__ == '__main__':
+ try:
+ ta = GEUIApplication()
+ ta.go()
+ ta.cleanUp()
+ except ogre.OgreException, e:
+ print e
+
Added: trunk/python-ogre/demos/cegui/Demo_CEGUI_FirstWindowv061.py
===================================================================
--- trunk/python-ogre/demos/cegui/Demo_CEGUI_FirstWindowv061.py (rev 0)
+++ trunk/python-ogre/demos/cegui/Demo_CEGUI_FirstWindowv061.py 2008-07-17 10:38:12 UTC (rev 662)
@@ -0,0 +1,273 @@
+#/***************************************************************************
+# * Copyright (C) 2004 - 2008 Paul D Turner & The CEGUI Development Team
+# *
+# * Permission is hereby granted, free of charge, to any person obtaining
+# * a copy of this software and associated documentation files (the
+# * "Software"), to deal in the Software without restriction, including
+# * without limitation the rights to use, copy, modify, merge, publish,
+# * distribute, sublicense, and/or sell copies of the Software, and to
+# * permit persons to whom the Software is furnished to do so, subject to
+# * the following conditions:
+# *
+# * The above copyright notice and this permission notice shall be
+# * included in all copies or substantial portions of the Software.
+# *
+# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# * OTHER DEALINGS IN THE SOFTWARE.
+# ***************************************************************************/
+
+
+import sys
+sys.path.insert(0,'..')
+import PythonOgreConfig
+
+import ogre.renderer.OGRE as ogre
+import ogre.io.OIS as OIS
+import ogre.gui.CEGUI as CEGUI
+import SampleFramework
+
+from CEGUI_framework import *
+
+
+
+def cegui_reldim ( x ) :
+ return CEGUI.UDim((x),0)
+
+class GEUIApplication(SampleFramework.Application):
+
+ def __init__(self):
+ SampleFramework.Application.__init__(self)
+ self.CEGUIRenderer = 0
+ self.CEGUISystem = 0
+ self.MenuMode = True
+ self.menuItems = []
+
+ def _createScene(self):
+
+ sceneManager = self.sceneManager
+ sceneManager.ambientLight = ogre.ColourValue(0.25, 0.25, 0.25)
+
+ # initiaslise OgreCEGUI Renderer
+ ## Parameters are:
+ ## a) OgreRenderWindow object.
+ ## b) param post_queue
+ ## set to True to have GUI rendered after render queue
+ ## queue_id, or False to have the GUI rendered before
+ ## render queue
+ ## c) render queue_id.
+ ## where ogre.RenderQueueGroupID.RENDER_QUEUE_OVERLAY indicates
+ ## ceguiogre window is rendered above all else
+ ## d) param max_quads
+ ## obsolete
+ ## e) sceneManager
+
+ self.CEGUIRenderer = CEGUI.OgreCEGUIRenderer(self.renderWindow,
+ ogre.RenderQueueGroupID.RENDER_QUEUE_OVERLAY,
+ False, 3000,
+ self.sceneManager)
+
+ ## Note it is also possible to initialise the OgreCEGUI renderer
+ ## with out the scenemanager, e.g:
+ ## self.CEGUIRenderer = CEGUI.OgreCEGUIRenderer(self.renderWindow,
+ ## ogre.RenderQueueGroupID.RENDER_QUEUE_OVERLAY,
+ ## False, 3000)
+ ##
+ ## However you must call setTargetSceneManager before rendering
+ ## self.CEGUIRenderer.setTargetSceneManager(self.sceneManager)
+
+ self.CEGUISystem = CEGUI.System(self.CEGUIRenderer)
+
+ ## set the logging level
+ CEGUI.Logger.getSingleton().loggingLevel = CEGUI.Insane
+
+ ## CEGUI relies on various systems being set-up, so this is what we do
+ ## here first.
+ ##
+ ## Note that is is possible, and even usual, for most of these steps to
+ ## be done automatically via a "scheme" definition, or even from the
+ ## cegui.conf configuration file, however for completeness, and as an
+ ## example, virtually everything is being done manually in this example
+ ## code.
+ ##
+ ## Imagesets area a collection of named areas within a texture or image
+ ## file. Each area becomes an Image, and has a unique name by which it
+ ## can be referenced. This sample is using the TaharezLook widgets, and
+ ## these rely upon the TaharezLook Imageset; so we must load this in
+ ## before doing anything else. Note that the Imageset would normally be
+ ## specified as part of a scheme file, although as this example is
+ ## demonstrating, it is not a requirement.
+ ##
+ ## Load TaharezLook imageset by making use of the ImagesetManager
+ ## singleton.
+
+ taharezImages = CEGUI.ImagesetManager.getSingleton().createImageset("TaharezLook.imageset")
+
+ ## The next thing we do is to set a default mouse cursor image. This is
+ ## not strictly essential, although it is nice to always have a visible
+ ## cursor if a window or widget does not explicitly set one of its own.
+ ##
+ ## The TaharezLook Imageset contains an Image named "MouseArrow"
+ ## which is the ideal thing to have as a defult mouse cursor image.
+
+ CEGUI.System.getSingleton().setDefaultMouseCursor(taharezImages.getImage("MouseArrow"))
+
+
+ ## Now we have the gui imagery side of thigs set up, we should load
+ ## in a font.
+ ## You should always load in at least one font, this is to ensure
+ ## that there is a default available for any gui element which
+ ## needs to draw text.
+ ## The first font you load is automatically set as the initial
+ ## default font, although you can change the default later on
+ ## if so desired. Again, it is possible to list fonts to be
+ ## automatically loaded as part of a scheme, so
+ ## this step may not usually be performed explicitly.
+ ##
+ ## Fonts are loaded via the FontManager singleton.
+
+ CEGUI.FontManager.getSingleton().createFont("Commonwealth-10.font")
+
+ ## The widgets that we will be using for this sample are the
+ ## TaharezLook widgets,
+ ## and to enable us to use this 'skin' we must load the xml
+ ## specification - which within cegui is known as a "looknfeel" file.
+ ##
+ ## We load the looknfeel via the WidgetLookManager singleton.
+
+ CEGUI.WidgetLookManager.getSingleton().parseLookNFeelSpecification("TaharezLook.looknfeel")
+
+
+ ## The final step of basic initialisation that is usually peformed is
+ ## registering some widgets with the system via a scheme file.
+ ## The scheme basically states the name of a dynamically loaded module
+ ## that contains the widget classes that we wish to use.
+ ## As stated previously, a scheme can actually conatin much more
+ ## information, though for the sake of this first example, we
+ ## load a scheme which only contains what is required to register
+ ## some widgets.
+ ##
+ ## Use the SchemeManager singleton to load in a scheme that
+ ## registers widgets, for TaharezLook.
+
+ CEGUI.SchemeManager.getSingleton().loadScheme("TaharezLookWidgets.scheme")
+
+
+ ## Now the system is initialised, we can actually create some
+ ## UI elements, for this first example, a full-screen 'root' window
+ ## is set as the active GUI sheet, and then a simple frame window
+ ## will be created and attached to it.
+
+ ## All windows and widgets are created via the WindowManager singleton.
+
+ winMgr = CEGUI.WindowManager.getSingleton()
+
+ ## Here we create a "DeafultWindow". This is a native type, that is,
+ ## it does not have to be loaded via a scheme, it is always available.
+ ## One common use for the DefaultWindow is as a generic container for
+ ## other windows. Its size defaults to 1.0 x 1.0 using the Relative
+ ## metrics mode, which means when it is set as the root GUI sheet
+ ## window, it will cover the entire display.
+ ## The DefaultWindow does not perform any rendering of its own,
+ ## so is invisible.
+ ##
+ ## Create a DefaultWindow called 'Root'.
+
+ root = winMgr.createWindow("DefaultWindow", "Root")
+
+ # set the GUI root window (also known as the GUI "sheet"),
+ # so the gui we set up will be visible.
+
+ CEGUI.System.getSingleton().setGUISheet(root)
+
+ ## A FrameWindow is a window with a frame and a titlebar which
+ ## may be moved around and resized.
+ ##
+ ## Create a FrameWindow in the TaharezLook style, and name it
+ ## 'Demo Window'
+
+ wnd = winMgr.createWindow("TaharezLook/FrameWindow", "Demo Window")
+
+ ## Here we attach the newly created FrameWindow to the previously
+ ## created DefaultWindow which we will be using as the root of the
+ ## displayed gui.
+
+ root.addChildWindow(wnd)
+
+ ## Windows are in Relative metrics mode by default. This means that
+ ## we can specify sizes and positions without having to know the
+ ## exact pixel size of the elements in advance. The relative
+ ## metrics mode co-ordinates are relative to the parent of the
+ ## window where the co-ordinates are being set.
+ ## This means that if 0.5 is specified as the width for a window,
+ ## that window will be half as its parent window.
+ ##
+ ## Here we set the FrameWindow so that it is half the size of
+ ## the display, and centered within the display.
+ ## Note that cegui_reldim in python is a convenience method specified
+ ## at the strat of this program
+
+ wnd.setPosition(CEGUI.UVector2( cegui_reldim(0.25),
+ cegui_reldim(0.25)))
+ wnd.setSize(CEGUI.UVector2( cegui_reldim(0.5),
+ cegui_reldim(0.5)))
+
+ ## now we set the maximum and minum sizes for the new window.
+ ## These are specified using relative co-ordinates, but the
+ ## important thing to note is that these settings are aways
+ ## relative to the display rather than the parent window.
+ ##
+ ## here we set a maximum size for the FrameWindow which is
+ ## equal to the size of the display, and a minimum size of
+ ##one tenth of the display.
+
+ wnd.setMaxSize(CEGUI.UVector2( cegui_reldim( 1.0),
+ cegui_reldim( 1.0)))
+ wnd.setMinSize(CEGUI.UVector2( cegui_reldim( 0.1),
+ cegui_reldim( 0.1)))
+
+ ## As a final step in the initialisation of our sample window,
+ ## we set the window's text to "Hello World!", so that this text
+ ## will appear as the caption in the FrameWindow's titlebar.
+ wnd.setText("Hello World!")
+
+
+ def _createCamera(self):
+ self.camera = self.sceneManager.createCamera("PlayerCam")
+ self.camera.nearClipDistance = 5
+
+ def _createFrameListener(self):
+ self.frameListener = CEGUIFrameListener(self.renderWindow, self.camera, self.sceneManager)
+ self.root.addFrameListener(self.frameListener)
+ self.frameListener.showDebugOverlay(True)
+
+ def __del__(self):
+ "Clear variables, this is needed to ensure the correct order of deletion"
+ del self.camera
+ del self.sceneManager
+ del self.frameListener
+ del self.CEGUISystem
+ del self.CEGUIRenderer
+ del self.root
+ del self.renderWindow
+
+class CEGUIFrameListener(GuiFrameListener):
+
+ def __init__(self, renderWindow, camera, sceneManager):
+ GuiFrameListener.__init__(self, renderWindow, camera, sceneManager)
+ self.MenuMode=True
+
+ def frameStarted(self, evt):
+ return GuiFrameListener.frameStarted(self,evt)
+
+
+if __name__ == '__main__':
+ try:
+ ta = GEUIApplication()
+ ta.go()
+ except ogre.OgreException, e:
+ print e
Added: trunk/python-ogre/demos/cegui/Demo_CEGUI_FontDemov061.py
===================================================================
--- trunk/python-ogre/demos/cegui/Demo_CEGUI_FontDemov061.py (rev 0)
+++ trunk/python-ogre/demos/cegui/Demo_CEGUI_FontDemov061.py 2008-07-17 10:38:12 UTC (rev 662)
@@ -0,0 +1,302 @@
+# -*- coding: utf-8 -*-
+
+#/***************************************************************************
+# * Copyright (C) 2004 - 2008 Paul D Turner & The CEGUI Development Team
+# *
+# * Permission is hereby granted, free of charge, to any person obtaining
+# * a copy of this software and associated documentation files (the
+# * "Software"), to deal in the Software without restriction, including
+# * without limitation the rights to use, copy, modify, merge, publish,
+# * distribute, sublicense, and/or sell copies of the Software, and to
+# * permit persons to whom the Software is furnished to do so, subject to
+# * the following conditions:
+# *
+# * The above copyright notice and this permission notice shall be
+# * included in all copies or substantial portions of the Software.
+# *
+# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# * OTHER DEALINGS IN THE SOFTWARE.
+#/////# -*- coding: latin-1 -*-
+# ***************************************************************************/
+
+
+import sys
+sys.path.insert(0,'..')
+import PythonOgreConfig
+
+import ogre.renderer.OGRE as ogre
+import ogre.io.OIS as OIS
+import ogre.gui.CEGUI as CEGUI
+import SampleFramework
+
+from CEGUI_framework import *
+
+
+def createUVector2( x, y):
+ return CEGUI.UVector2(CEGUI.UDim(x,0), CEGUI.UDim(y,0))
+def cegui_reldim ( x ) :
+ return CEGUI.UDim((x),0)
+
+def getFontDict():
+ SCHEME_FONT = {}
+ SCHEME_FONT['Commonwealth-10'] = "Commonwealth-10.font"
+ SCHEME_FONT['BlueHighway-12'] = "bluehighway-12.font"
+ SCHEME_FONT['BlueHighway-10'] = "bluehighway-10.font"
+ SCHEME_FONT['BlueHighway-8'] = "bluehighway-8.font"
+ SCHEME_FONT['DejaVuSans-10'] = "DejaVuSans-10.font"
+ SCHEME_FONT['Commonwealth-10'] = "Commonwealth-10.font"
+ SCHEME_FONT['Iconified-12'] = "Iconified-12.font"
+ SCHEME_FONT['fkp-16'] = "fkp-16.font"
+ SCHEME_FONT['FairChar-30'] = "FairChar-30.font"
+ return SCHEME_FONT
+
+
+def getLanguageDict():
+ LANGUAGE_DICT = {}
+ LANGUAGE_DICT['English'] = "THIS IS SOME TEXT IN UPPERCASE\n and this is lowercase...\n Try Catching The Brown Fox While It's Jumping Over The Lazy Dog"
+ LANGUAGE_DICT['Russian'] = u"Всё ускоряющаяся эволюция компьютерных технологий предъявила жёсткие требования к производителям как собственно вычислительной техники, так и периферийных устройств.\n"
+ LANGUAGE_DICT['Romanian'] = u"CEI PATRU APOSTOLI\n au fost trei:\n Luca şi Matfei\n"
+ LANGUAGE_DICT['Danish'] = u"FARLIGE STORE BOGSTAVER\n og flere men små...\n Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Walther spillede på xylofon\n"
+ LANGUAGE_DICT['French'] = u'La Peña'
+ return LANGUAGE_DICT
+
+global MIN_POINT_SIZE
+MIN_POINT_SIZE=6.0
+
+
+class GEUIApplication(SampleFramework.Application):
+
+ def __init__(self):
+ SampleFramework.Application.__init__(self)
+ self.CEGUIRenderer = 0
+ self.CEGUISystem = 0
+ self.MenuMode = True
+ self.ListItems = []
+
+ def _createScene(self):
+
+ sceneManager = self.sceneManager
+ sceneManager.ambientLight = ogre.ColourValue(0.25, 0.25, 0.25)
+
+ # initiaslise CEGUI Renderer
+ self.CEGUIRenderer = CEGUI.OgreCEGUIRenderer(self.renderWindow,
+ ogre.RenderQueueGroupID.RENDER_QUEUE_OVERLAY,
+ False, 3000,
+ self.sceneManager)
+
+ self.CEGUISystem = CEGUI.System(self.CEGUIRenderer)
+ CEGUI.Logger.getSingleton().loggingLevel = CEGUI.Insane
+
+ winMgr = CEGUI.WindowManager.getSingleton()
+
+ # load scheme and set up defaults
+ CEGUI.SchemeManager.getSingleton().loadScheme ("TaharezLook.scheme")
+ CEGUI.System.getSingleton().setDefaultMouseCursor ("TaharezLook", "MouseArrow")
+
+ # load all the fonts except Commonwealth which has been already loaded
+ fontDict = getFontDict()
+ for f in fontDict.keys():
+ if not CEGUI.FontManager.getSingleton().isFontPresent(f):
+ CEGUI.FontManager.getSingleton().createFont(fontDict[f])
+
+
+ # load an image to use as a background
+ CEGUI.ImagesetManager.getSingleton().createImagesetFromImageFile("BackgroundImage", "GPN-2000-001437.tga")
+
+ # here we will use a StaticImage as the root, then we
+ # can use it to place a background image
+ background = winMgr.createWindow ("TaharezLook/StaticImage")
+ # set area rectangle
+ background.setArea (CEGUI.URect(cegui_reldim (0), cegui_reldim (0),
+ cegui_reldim (1), cegui_reldim (1)))
+ # disable frame and standard background
+ background.setProperty ("FrameEnabled", "false")
+ background.setProperty ("BackgroundEnabled", "false")
+ # set the background image
+ background.setProperty ("Image", "set:BackgroundImage image:full_image")
+ # install this as the root GUI sheet
+ CEGUI.System.getSingleton().setGUISheet (background)
+
+ #/ set tooltip styles (by default there is none)
+ CEGUI.System.getSingleton().setDefaultTooltip ("TaharezLook/Tooltip")
+
+ # load some demo windows and attach to the background 'root'
+ background.addChildWindow (winMgr.loadWindowLayout ("FontDemo.layout", False))
+
+ # Add the font names to the listbox
+ fontDict = getFontDict()
+ lbox = winMgr.getWindow ("FontDemo/FontList")
+ for f in fontDict.keys():
+ item = CEGUI.ListboxTextItem(f)
+ item.setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
+ # ensure Python is in control of it's "deletion"
+ item.AutoDeleted = False
+ lbox.addItem( item)
+ self.ListItems.append(item)
+
+ # set up the font listbox callback
+ lbox.subscribeEvent(
+ CEGUI.Listbox.EventSelectionChanged, self, "handleFontSelection")
+ # select the first font
+ lbox.setItemSelectState(0, True)
+
+ # Add language list to the listbox
+ lbox = winMgr.getWindow ("FontDemo/LangList")
+ languageDict = getLanguageDict()
+ for l in languageDict.keys():
+ item = CEGUI.ListboxTextItem(l)
+ item.setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
+ # ensure Python is in control of it's "deletion"
+ item.AutoDeleted = False
+ lbox.addItem( item)
+ self.ListItems.append(item)
+
+ # set up the language listbox callback
+ lbox.subscribeEvent(
+ CEGUI.Listbox.EventSelectionChanged, self, "handleLangSelection")
+ # select the first language
+ lbox.setItemSelectState(0, True)
+
+ winMgr.getWindow("FontDemo/AutoScaled").subscribeEvent(
+ CEGUI.Checkbox.EventCheckStateChanged,
+ self, 'handleAutoScaled')
+ winMgr.getWindow("FontDemo/Antialiased").subscribeEvent (
+ CEGUI.Checkbox.EventCheckStateChanged,
+ self, 'handleAntialiased')
+ winMgr.getWindow("FontDemo/PointSize").subscribeEvent (
+ CEGUI.Scrollbar.EventScrollPositionChanged,
+ self, 'handlePointSize')
+
+
+
+ ## Event Handlers ##
+ def setFontDesc(self):
+ winMgr = CEGUI.WindowManager.getSingleton()
+ mle = winMgr.getWindow("FontDemo/FontSample")
+ f = mle.getFont()
+ s = f.getProperty("Name")
+ if f.isPropertyPresent("PointSize"):
+ s += "." + f.getProperty("PointSize")
+ winMgr.getWindow("FontDemo/FontDesc").setText(s)
+
+ def handleFontSelection(self,e):
+ lbox = e.window
+ if lbox.getFirstSelectedItem():
+ f = CEGUI.FontManager.getSingleton().getFont(
+ lbox.getFirstSelectedItem().getText())
+
+ winMgr = CEGUI.WindowManager.getSingleton()
+ winMgr.getWindow("FontDemo/FontSample").setFont(f)
+ b = f.isPropertyPresent("AutoScaled")
+ cb = winMgr.getWindow("FontDemo/AutoScaled")
+ cb.setEnabled(b)
+ if b:
+ cb.setSelected(CEGUI.PropertyHelper.stringToBool(f.getProperty ("AutoScaled")))
+
+ b = f.isPropertyPresent("Antialiased")
+ cb = winMgr.getWindow("FontDemo/Antialiased")
+ cb.setEnabled (b)
+ if b:
+ cb.setSelected(CEGUI.PropertyHelper.stringToBool(f.getProperty ("Antialiased")))
+
+ b = f.isPropertyPresent ("PointSize")
+ sb = winMgr.getWindow("FontDemo/PointSize")
+ sb.setEnabled(b)
+ if b:
+ sb.setScrollPosition ( CEGUI.PropertyHelper.stringToFloat(f.getProperty("PointSize")) - MIN_POINT_SIZE)
+
+ self.setFontDesc()
+
+ return True
+
+
+ def handleAutoScaled (self, e):
+ winMgr = CEGUI.WindowManager.getSingleton()
+ cb = e.window
+ mle = winMgr.getWindow("FontDemo/FontSample")
+ f = mle.getFont()
+ f.setProperty("AutoScaled",
+ CEGUI.PropertyHelper.boolToString(cb.isSelected()))
+
+ return True
+
+
+ def handleAntialiased(self, e):
+ winMgr = CEGUI.WindowManager.getSingleton()
+ cb = e.window
+ mle = winMgr.getWindow("FontDemo/FontSample")
+ f = mle.getFont()
+ f.setProperty ("Antialiased",
+ CEGUI.PropertyHelper.boolToString(cb.isSelected()))
+
+ return True
+
+ def handlePointSize(self, e):
+ winMgr = CEGUI.WindowManager.getSingleton()
+ sb = e.window
+ f = winMgr.getWindow("FontDemo/FontSample").getFont()
+ f.setProperty ("PointSize",
+ CEGUI.PropertyHelper.intToString (
+ int(MIN_POINT_SIZE + sb.getScrollPosition ())))
+ self.setFontDesc()
+
+ return True
+
+ def handleLangSelection(self, e):
+ lbox = e.window
+ if lbox.getFirstSelectedItem():
+ idx = lbox.getItemIndex(lbox.getFirstSelectedItem())
+ winMgr = CEGUI.WindowManager.getSingleton()
+
+ cs = CEGUI.String()
+ cs.assign( getLanguageDict().values()[idx].encode("utf-8") )
+ winMgr.getWindow("FontDemo/FontSample").setText(cs)
+
+ return True
+
+
+ def _createCamera(self):
+ self.camera = self.sceneManager.createCamera("PlayerCam")
+ self.camera.nearClipDistance = 5
+
+ def _createFrameListener(self):
+ self.frameListener = CEGUIFrameListener(self.renderWindow, self.camera, self.sceneManager)
+ self.root.addFrameListener(self.frameListener)
+ self.frameListener.showDebugOverlay(True)
+
+ def __del__(self):
+ "Clear variables, this is needed to ensure the correct order of deletion"
+ del self.camera
+ del self.sceneManager
+ del self.frameListener
+ del self.CEGUISystem
+ del self.CEGUIRenderer
+ del self.root
+ del self.renderWindow
+
+class CEGUIFrameListener(GuiFrameListener):
+
+ def __init__(self, renderWindow, camera, sceneManager):
+ GuiFrameListener.__init__(self, renderWindow, camera, sceneManager)
+
+ self.keepRendering = True # whether to continue rendering or not
+
+
+ def frameStarted(self, evt):
+ if not self.keepRendering:
+ return False
+ else:
+ return GuiFrameListener.frameStarted(self,evt)
+
+
+if __name__ == '__main__':
+ try:
+ ta = GEUIApplication()
+ ta.go()
+ except ogre.OgreException, e:
+ print e
Added: trunk/python-ogre/demos/cegui/Demo_CEGUI_ScrollablePanev061.py
===================================================================
--- trunk/python-ogre/demos/cegui/Demo_CEGUI_ScrollablePanev061.py (rev 0)
+++ trunk/python-ogre/demos/cegui/Demo_CEGUI_ScrollablePanev061.py 2008-07-17 10:38:12 UTC (rev 662)
@@ -0,0 +1,252 @@
+#/***************************************************************************
+# * Copyright (C) 2004 - 2008 Paul D Turner & The CEGUI Development Team
+# *
+# * Permission is hereby granted, free of charge, to any person obtaining
+# * a copy of this software and associated documentation files (the
+# * "Software"), to deal in the Software without restriction, including
+# * without limitation the rights to use, copy, modify, merge, publish,
+# * distribute, sublicense, and/or sell copies of the Software, and to
+# * permit persons to whom the Software is furnished to do so, subject to
+# * the following conditions:
+# *
+# * The above copyright notice and this permission notice shall be
+# * included in all copies or substantial portions of the Software.
+# *
+# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# * OTHER DEALINGS IN THE SOFTWARE.
+# ***************************************************************************/
+
+
+import sys
+sys.path.insert(0,'..')
+import PythonOgreConfig
+
+import ogre.renderer.OGRE as ogre
+import ogre.io.OIS as OIS
+import ogre.gui.CEGUI as CEGUI
+import SampleFramework
+
+from CEGUI_framework import *
+
+
+def createUVector2( x, y):
+ return CEGUI.UVector2(CEGUI.UDim(x,0), CEGUI.UDim(y,0))
+
+# Handler for the 'Demo -> New dialog' menu item
+def demoNewDialog(args):
+ # add a dialog to this pane so we have some more stuff to drag around :)
+ dlg = CEGUI.WindowManager.getSingletonPtr().createWindow("WindowsLook/FrameWindow")
+ dlg.setMinSize(CEGUI.UVector2(CEGUI.UDim(0,200),CEGUI.UDim(0,100)))
+ dlg.setText("Drag me around too!")
+
+ # we put this in the center of the viewport into the scrollable pane
+ uni_center = CEGUI.UVector2( CEGUI.UDim(0.5,0), CEGUI.UDim(0.5,0) )
+ d_root = CEGUI.WindowManager.getSingletonPtr().getWindow("RootWindow")
+ d_pane = CEGUI.WindowManager.getSingletonPtr().getWindow("DialogPane")
+
+ center = CEGUI.CoordConverter.windowToScreen(d_root, uni_center)
+ target = CEGUI.CoordConverter.screenToWindow(d_pane.getContentPane(), center)
+ dlg.setPosition(CEGUI.UVector2( CEGUI.UDim(0,target.d_x-100),
+ CEGUI.UDim(0,target.d_y-50)))
+
+ d_pane.addChildWindow(dlg)
+
+ return True
+
+#Handler for global hotkeys
+def hotkeysHandler(e):
+ k = e
+ if k.scancode == CEGUI.Key.Space:
+ # space is a hotkey for demo -> new dialog
+ # this handler does not use the event args at all so this is fine :)
+ # though maybe a bit hackish...
+ demoNewDialog(e)
+ else:
+ return False
+ return True
+
+class GEUIApplication(SampleFramework.Application):
+
+ def __init__(self):
+ SampleFramework.Application.__init__(self)
+ self.CEGUIRenderer = 0
+ self.CEGUISystem = 0
+ self.menuItems = []
+
+ def _createScene(self):
+
+ sceneManager = self.sceneManager
+ sceneManager.ambientLight = ogre.ColourValue(0.25, 0.25, 0.25)
+
+ # initiaslise CEGUI Renderer
+ self.CEGUIRenderer = CEGUI.OgreCEGUIRenderer(self.renderWindow,
+ ogre.Rende...
[truncated message content] |