Browse Source

Remove Python support and pyinvaders sample

Marco Bortolin 6 years ago
parent
commit
847966c288
100 changed files with 8 additions and 7953 deletions
  1. 0 2
      .gitignore
  2. 0 4
      .travis.yml
  3. 0 5
      Build/.gitignore
  4. 5 110
      Build/CMakeLists.txt
  5. 2 8
      Build/builddist.py
  6. 0 79
      Build/cmake/FileList.cmake
  7. 0 35
      Build/cmake/SampleFileList.cmake
  8. 0 19
      Build/cmake/gen_filelists.sh
  9. 1 1
      Build/cmake/gen_samplelists.sh
  10. 0 55
      Dependencies/osx-depends.sh
  11. 0 77
      Include/Rocket/Core/Python/ConverterScriptObject.h
  12. 0 120
      Include/Rocket/Core/Python/ElementInstancer.h
  13. 0 96
      Include/Rocket/Core/Python/ElementWrapper.h
  14. 0 52
      Include/Rocket/Core/Python/Header.h
  15. 0 123
      Include/Rocket/Core/Python/NameIndexInterface.h
  16. 0 87
      Include/Rocket/Core/Python/PickleTypeConverter.h
  17. 0 52
      Include/Rocket/Core/Python/Python.h
  18. 0 111
      Include/Rocket/Core/Python/Utilities.h
  19. 0 118
      Include/Rocket/Core/Python/VectorInterface.h
  20. 0 67
      Include/Rocket/Core/Python/Wrapper.h
  21. 0 122
      Include/Rocket/Core/Python/WrapperIter.h
  22. 0 9
      Samples/README.TXT
  23. 0 35
      Samples/pyinvaders/data/background.rml
  24. BIN
      Samples/pyinvaders/data/background.tga
  25. 0 124
      Samples/pyinvaders/data/game.rml
  26. 0 55
      Samples/pyinvaders/data/help.rml
  27. BIN
      Samples/pyinvaders/data/help_defender.tga
  28. BIN
      Samples/pyinvaders/data/help_invader_mothership.tga
  29. BIN
      Samples/pyinvaders/data/help_invader_rank1.tga
  30. BIN
      Samples/pyinvaders/data/help_invader_rank2.tga
  31. BIN
      Samples/pyinvaders/data/help_invader_rank3.tga
  32. 0 68
      Samples/pyinvaders/data/high_score.rml
  33. BIN
      Samples/pyinvaders/data/high_scores_defender.tga
  34. BIN
      Samples/pyinvaders/data/invaders.tga
  35. 0 23
      Samples/pyinvaders/data/logo.rml
  36. BIN
      Samples/pyinvaders/data/logo.tga
  37. 0 33
      Samples/pyinvaders/data/main_menu.rml
  38. 0 85
      Samples/pyinvaders/data/options.rml
  39. 0 27
      Samples/pyinvaders/data/pause.rml
  40. 0 65
      Samples/pyinvaders/data/start_game.rml
  41. 0 20
      Samples/pyinvaders/data/window.rml
  42. 0 40
      Samples/pyinvaders/python/autoexec.py
  43. 0 1
      Samples/pyinvaders/python/rocket.py
  44. 0 91
      Samples/pyinvaders/src/DecoratorDefender.cpp
  45. 0 57
      Samples/pyinvaders/src/DecoratorDefender.h
  46. 0 69
      Samples/pyinvaders/src/DecoratorInstancerDefender.cpp
  47. 0 56
      Samples/pyinvaders/src/DecoratorInstancerDefender.h
  48. 0 80
      Samples/pyinvaders/src/DecoratorInstancerStarfield.cpp
  49. 0 57
      Samples/pyinvaders/src/DecoratorInstancerStarfield.h
  50. 0 147
      Samples/pyinvaders/src/DecoratorStarfield.cpp
  51. 0 82
      Samples/pyinvaders/src/DecoratorStarfield.h
  52. 0 182
      Samples/pyinvaders/src/Defender.cpp
  53. 0 81
      Samples/pyinvaders/src/Defender.h
  54. 0 114
      Samples/pyinvaders/src/ElementGame.cpp
  55. 0 67
      Samples/pyinvaders/src/ElementGame.h
  56. 0 444
      Samples/pyinvaders/src/Game.cpp
  57. 0 128
      Samples/pyinvaders/src/Game.h
  58. 0 148
      Samples/pyinvaders/src/GameDetails.cpp
  59. 0 107
      Samples/pyinvaders/src/GameDetails.h
  60. 0 236
      Samples/pyinvaders/src/HighScores.cpp
  61. 0 77
      Samples/pyinvaders/src/HighScores.h
  62. 0 269
      Samples/pyinvaders/src/Invader.cpp
  63. 0 114
      Samples/pyinvaders/src/Invader.h
  64. 0 83
      Samples/pyinvaders/src/Mothership.cpp
  65. 0 53
      Samples/pyinvaders/src/Mothership.h
  66. 0 124
      Samples/pyinvaders/src/PythonInterface.cpp
  67. 0 58
      Samples/pyinvaders/src/PythonInterface.h
  68. 0 188
      Samples/pyinvaders/src/Shield.cpp
  69. 0 90
      Samples/pyinvaders/src/Shield.h
  70. 0 52
      Samples/pyinvaders/src/Sprite.cpp
  71. 0 50
      Samples/pyinvaders/src/Sprite.h
  72. 0 215
      Samples/pyinvaders/src/main.cpp
  73. 0 84
      Source/Controls/Python/DataFormatterWrapper.cpp
  74. 0 61
      Source/Controls/Python/DataFormatterWrapper.h
  75. 0 70
      Source/Controls/Python/DataGridRowProxy.cpp
  76. 0 59
      Source/Controls/Python/DataGridRowProxy.h
  77. 0 238
      Source/Controls/Python/DataSourceWrapper.cpp
  78. 0 68
      Source/Controls/Python/DataSourceWrapper.h
  79. 0 255
      Source/Controls/Python/ElementInterface.cpp
  80. 0 94
      Source/Controls/Python/ElementInterface.h
  81. 0 71
      Source/Controls/Python/Module.cpp
  82. 0 57
      Source/Controls/Python/Module.h
  83. 0 84
      Source/Controls/Python/SelectOptionProxy.cpp
  84. 0 69
      Source/Controls/Python/SelectOptionProxy.h
  85. 0 28
      Source/Controls/Python/precompiled.cpp
  86. 0 33
      Source/Controls/Python/precompiled.h
  87. 0 79
      Source/Core/Python/ContextDocumentProxy.cpp
  88. 0 59
      Source/Core/Python/ContextDocumentProxy.h
  89. 0 85
      Source/Core/Python/ContextInstancer.cpp
  90. 0 69
      Source/Core/Python/ContextInstancer.h
  91. 0 151
      Source/Core/Python/ContextInterface.cpp
  92. 0 90
      Source/Core/Python/ContextInterface.h
  93. 0 80
      Source/Core/Python/ContextProxy.cpp
  94. 0 52
      Source/Core/Python/ContextProxy.h
  95. 0 219
      Source/Core/Python/Converters.cpp
  96. 0 38
      Source/Core/Python/Converters.h
  97. 0 87
      Source/Core/Python/ElementAttributeProxy.cpp
  98. 0 79
      Source/Core/Python/ElementAttributeProxy.h
  99. 0 79
      Source/Core/Python/ElementChildrenProxy.cpp
  100. 0 68
      Source/Core/Python/ElementChildrenProxy.h

+ 0 - 2
.gitignore

@@ -1,5 +1,3 @@
-# Ignore compiled python code
-*.pyc
 # Ignore MacOSX directory info
 .DS_Store
 # VS user project files

+ 0 - 4
.travis.yml

@@ -22,8 +22,6 @@ matrix:
             - libstdc++-7-dev
             - cmake
             - build-essential
-            - libboost-dev
-            - libboost-python-dev
             - libsdl2-dev
             - libsdl2-image-dev
             - libfreetype6-dev
@@ -42,8 +40,6 @@ matrix:
             - g++-7
             - cmake
             - build-essential
-            - libboost-dev
-            - libboost-python-dev
             - libsdl2-dev
             - libsdl2-image-dev
             - libfreetype6-dev

+ 0 - 5
Build/.gitignore

@@ -22,7 +22,6 @@ datagrid
 datagrid_tree
 drag
 invaders
-pyinvaders
 luainvaders
 sdl2
 sfml
@@ -100,9 +99,6 @@ drag.vcxproj.filters
 invaders.vcproj
 invaders.vcxproj
 invaders.vcxproj.filters
-pyinvaders.vcproj
-pyinvaders.vcxproj
-pyinvaders.vcxproj.filters
 luainvaders.vcproj
 luainvaders.vcxproj
 luainvaders.vcxproj.filters
@@ -171,7 +167,6 @@ datagrid.app
 datagrid_tree.app
 drag.app
 invaders.app
-pyinvaders.app
 loaddocument.app
 template.app
 treeview.app

+ 5 - 110
Build/CMakeLists.txt

@@ -86,13 +86,6 @@ if(NOT DEFINED ENV{FREETYPE_DIR})
 	set(ENV{FREETYPE_DIR} "${PROJECT_SOURCE_DIR}/../Dependencies")
 endif()
 
-#if(NOT DEFINED ENV{Boost_DIR})
-#	set(ENV{Boost_DIR} "${PROJECT_SOURCE_DIR}/../Dependencies")
-#endif()
-if(NOT DEFINED ENV{BOOST_ROOT})
-	set(ENV{BOOST_ROOT} "${PROJECT_SOURCE_DIR}/../Dependencies/boost")
-endif()
-
 if(NOT DEFINED ENV{LUA_DIR})
 	set(ENV{LUA_DIR} "${PROJECT_SOURCE_DIR}/../Dependencies")
 endif()
@@ -134,7 +127,6 @@ if(NOT IOS)
 	option(BUILD_SHARED_LIBS "Build shared libraries" ON)
 endif(NOT IOS)
 
-option(BUILD_PYTHON_BINDINGS "Build python bindings" OFF)
 option(BUILD_LUA_BINDINGS "Build Lua bindings" OFF)
 
 if(APPLE)
@@ -193,29 +185,6 @@ if(FREETYPE_FOUND)
 endif()
 mark_as_advanced(FREETYPE_INCLUDE_DIRS FREETYPE_LIBRARY FREETYPE_LINK_DIRECTORIES)
 
-# Boost and Python
-if(BUILD_PYTHON_BINDINGS)
-    find_package(PythonInterp 2 REQUIRED)
-    find_package(PythonLibs 2 REQUIRED)
-    execute_process(
-        COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(1,0,prefix=''))"
-        OUTPUT_VARIABLE PYTHON_INSTDIR
-        OUTPUT_STRIP_TRAILING_WHITESPACE
-    )
-    if(PYTHONLIBS_FOUND)
-        include_directories(${PYTHON_INCLUDE_DIR})
-    endif()
-
-    #set(Boost_USE_STATIC_LIBS OFF)
-    #set(Boost_USE_MULTITHREADED ON)
-    find_package(Boost 1.40.0 COMPONENTS python REQUIRED)
-    if(Boost_FOUND)
-        include_directories(${Boost_INCLUDE_DIR})
-        list(APPEND PY_BINDINGS_LINK_LIBS ${PYTHON_LIBRARY} ${Boost_LIBRARIES})
-    endif()
-
-endif()
-
 #Lua
 if(BUILD_LUA_BINDINGS)
     if(CMAKE_MAJOR_VERSION LESS 3)
@@ -354,31 +323,6 @@ else(NOT BUILD_FRAMEWORK)
     set(ROCKET_EXPORTED_TARGETS ${ROCKET_EXPORTED_TARGETS} ${NAME})
 endif(NOT BUILD_FRAMEWORK)
 
-# Build python bindings
-if(BUILD_PYTHON_BINDINGS)
-    set(LIBRARIES core controls)
-
-    foreach(library ${LIBRARIES})
-        set(NAME _rocket${library})
-
-        add_library(${NAME} MODULE ${Py${library}_SRC_FILES}
-                            ${Py${library}_HDR_FILES}
-                            ${Py${library}_PUB_HDR_FILES}
-        )
-
-        set_target_properties(${NAME} PROPERTIES PREFIX "")
-
-        set_property(TARGET ${NAME} PROPERTY CXX_STANDARD 11)
-        set_property(TARGET ${NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
-
-        install(TARGETS ${NAME}
-                EXPORT libRocketTargets
-                LIBRARY DESTINATION ${PYTHON_INSTDIR}
-        )
- 
-    endforeach(library)
-endif()
-
 # Build Lua bindings
 if(BUILD_LUA_BINDINGS)
     set(LIBRARIES Core Controls)
@@ -423,16 +367,6 @@ else(NOT BUILD_FRAMEWORK)
 target_link_libraries(Rocket ${CORE_LINK_LIBS})
 endif(NOT BUILD_FRAMEWORK)
 
-if(BUILD_PYTHON_BINDINGS)
-	if(NOT BUILD_FRAMEWORK)
-		target_link_libraries(_rocketcore RocketCore ${PY_BINDINGS_LINK_LIBS})
-		target_link_libraries(_rocketcontrols RocketControls ${PY_BINDINGS_LINK_LIBS})
-	else(NOT BUILD_FRAMEWORK)
-		target_link_libraries(_rocketcore Rocket ${PY_BINDINGS_LINK_LIBS})
-		target_link_libraries(_rocketcontrols Rocket ${PY_BINDINGS_LINK_LIBS})
-	endif(NOT BUILD_FRAMEWORK)
-endif()
-
 if(BUILD_LUA_BINDINGS)
 	if(NOT BUILD_FRAMEWORK)
 		target_link_libraries(RocketCoreLua RocketCore ${LUA_BINDINGS_LINK_LIBS})
@@ -733,17 +667,6 @@ endif(NOT BUILD_FRAMEWORK)
     	RUNTIME DESTINATION ${SAMPLES_DIR}/invaders
     	BUNDLE DESTINATION ${SAMPLES_DIR})
 
-	if(BUILD_PYTHON_BINDINGS)
-	    # Build and install pyinvaders sample
-	    bl_sample(pyinvaders ${sample_LIBRARIES} ${PYTHON_LIBRARIES} ${PY_BINDINGS_LINK_LIBS})
-		set_property(TARGET pyinvaders PROPERTY CXX_STANDARD 11)
-		set_property(TARGET pyinvaders PROPERTY CXX_STANDARD_REQUIRED ON)
-	    install(DIRECTORY DESTINATION ${SAMPLES_DIR}/pyinvaders)
-	    install(TARGETS pyinvaders
-	    	RUNTIME DESTINATION ${SAMPLES_DIR}/pyinvaders
-	    	BUNDLE DESTINATION ${SAMPLES_DIR})
-	endif()
-    
     if(BUILD_LUA_BINDINGS)
         bl_sample(luainvaders RocketCoreLua RocketControlsLua ${sample_LIBRARIES} ${LUA_BINDINGS_LINK_LIBS})
 		set_property(TARGET luainvaders PROPERTY CXX_STANDARD 11)
@@ -760,37 +683,15 @@ endif()
 # Installation =====================
 #===================================
 
-if(BUILD_LUA_BINDINGS AND BUILD_PYTHON_BINDINGS)
+if(BUILD_LUA_BINDINGS)
     install(DIRECTORY ${PROJECT_SOURCE_DIR}/Include/Rocket
             DESTINATION include
     )
 else()
-	if(NOT BUILD_LUA_BINDINGS AND NOT BUILD_PYTHON_BINDINGS)
-	    install(DIRECTORY ${PROJECT_SOURCE_DIR}/Include/Rocket
-	            DESTINATION include
-	            PATTERN "Python" EXCLUDE
-	            PATTERN "Lua" EXCLUDE
-	    )
-	else()
-		if(BUILD_PYTHON_BINDINGS)
-			install(FILES ${PROJECT_SOURCE_DIR}/bin/rocket.py
-				DESTINATION ${PYTHON_INSTDIR}
-			)
-			install(DIRECTORY ${PROJECT_SOURCE_DIR}/Include/Rocket
-				DESTINATION include
-				PATTERN "Lua" EXCLUDE
-			)
-		else()
-			if(BUILD_LUA_BINDINGS)
-				install(DIRECTORY ${PROJECT_SOURCE_DIR}/Include/Rocket
-					DESTINATION include
-					PATTERN "Python" EXCLUDE
-				)
-			else()
-				message(FATAL_ERROR "ASSERT: Unexpected option combination, this is a logical impossibility.")
-			endif()
-		endif()
-	endif()
+    install(DIRECTORY ${PROJECT_SOURCE_DIR}/Include/Rocket
+            DESTINATION include
+            PATTERN "Lua" EXCLUDE
+    )
 endif()
 
 if(BUILD_SAMPLES)
@@ -820,12 +721,6 @@ if(BUILD_SAMPLES)
             DESTINATION ${SAMPLES_DIR}/invaders
     )
 
-    if(BUILD_PYTHON_BINDINGS)
-        install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/data
-                DESTINATION ${SAMPLES_DIR}/pyinvaders
-        )
-    endif()
-
     if(BUILD_LUA_BINDINGS)
         install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/luainvaders/data 
                 DESTINATION ${SAMPLES_DIR}/luainvaders

+ 2 - 8
Build/builddist.py

@@ -11,7 +11,6 @@ def Usage(args):
 	print sys.argv[0] + ' [-hp] [-r revision]'
 	print ''
 	print ' -r\t: Specify rocket internal revision number'
-	print ' -p\t: Include python libraries'
 	print ' -s\t: Include full source code and build files'
 	print ' -h\t: This help screen'
 	print ''
@@ -31,7 +30,7 @@ def CheckVSVars():
 	
 def ProcessOptions(args):
 
-	options = {'ROCKET_VERSION': 'custom', 'BUILD_PYTHON': False, 'FULL_SOURCE': False, 'ARCHIVE_NAME': 'libRocket-sdk'}
+	options = {'ROCKET_VERSION': 'custom', 'FULL_SOURCE': False, 'ARCHIVE_NAME': 'libRocket-sdk'}
 	
 	try:
 		optlist, args = getopt.getopt(args, 'r:phs')
@@ -44,8 +43,6 @@ def ProcessOptions(args):
 			Usage(args)
 		if opt[0] == '-r':
 			options['ROCKET_VERSION'] = opt[1]
-		if opt[0] == '-p':
-			options['BUILD_PYTHON'] = True
 		if opt[0] == '-s':
 			options['FULL_SOURCE'] = True
 			options['ARCHIVE_NAME'] = 'libRocket-source'
@@ -157,10 +154,7 @@ def main():
 	Build('RocketCore', ['Debug', 'Release'], {'ROCKET_VERSION': '\\"' + options['ROCKET_VERSION'] + '\\"'})
 	Build('RocketControls', ['Debug', 'Release'])
 	Build('RocketDebugger', ['Debug', 'Release'])
-	if options['BUILD_PYTHON']:
-		Build('RocketCorePython', ['Debug', 'Release'])
-		Build('RocketControlsPython', ['Debug', 'Release'])
-		
+	
 	DelTree('../dist/libRocket')
 	CopyFiles('../Include', '../dist/libRocket/Include')
 	CopyFiles('../bin', '../dist/libRocket/bin', ['\.dll$', '^[^_].*\.lib$', '\.py$', '\.pyd$'])

+ 0 - 79
Build/cmake/FileList.cmake

@@ -474,85 +474,6 @@ set(Debugger_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Source/Debugger/SystemInterface.cpp
 )
 
-set(Pycore_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ContextDocumentProxy.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ContextInstancer.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ContextInterface.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ContextProxy.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/Converters.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementAttributeProxy.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementChildrenProxy.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementDocumentWrapper.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementInterface.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementStyleProxy.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventInstancer.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventInterface.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventListener.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventListenerInstancer.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventWrapper.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/Module.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/precompiled.h
-)
-
-set(Pycore_PUB_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/ConverterScriptObject.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/ElementInstancer.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/ElementWrapper.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/Header.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/NameIndexInterface.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/PickleTypeConverter.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/Python.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/Utilities.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/VectorInterface.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/Wrapper.h
-    ${PROJECT_SOURCE_DIR}/Include/Rocket/Core/Python/WrapperIter.h
-)
-
-set(Pycore_SRC_FILES
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ContextDocumentProxy.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ContextInstancer.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ContextInterface.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ContextProxy.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/Converters.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementAttributeProxy.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementChildrenProxy.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementDocumentWrapper.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementInterface.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/ElementStyleProxy.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventInstancer.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventInterface.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventListener.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventListenerInstancer.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/EventWrapper.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/Interfaces.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/Module.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/precompiled.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/Python/Utilities.cpp
-)
-
-set(Pycontrols_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/DataFormatterWrapper.h
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/DataGridRowProxy.h
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/DataSourceWrapper.h
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/ElementInterface.h
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/Module.h
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/precompiled.h
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/SelectOptionProxy.h
-)
-
-set(Pycontrols_PUB_HDR_FILES
-)
-
-set(Pycontrols_SRC_FILES
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/DataFormatterWrapper.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/DataGridRowProxy.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/DataSourceWrapper.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/ElementInterface.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/Module.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/precompiled.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Controls/Python/SelectOptionProxy.cpp
-)
-
 set(LuaCore_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Colourb.h
     ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Colourf.h

+ 0 - 35
Build/cmake/SampleFileList.cmake

@@ -278,41 +278,6 @@ set(luainvaders_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Samples/luainvaders/src/Sprite.cpp
 )
 
-set(pyinvaders_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorDefender.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorInstancerDefender.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorInstancerStarfield.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorStarfield.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Defender.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/ElementGame.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Game.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/GameDetails.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/HighScores.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Invader.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Mothership.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/PythonInterface.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Shield.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Sprite.h
-)
-
-set(pyinvaders_SRC_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorDefender.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorInstancerDefender.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorInstancerStarfield.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorStarfield.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Defender.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/ElementGame.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Game.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/GameDetails.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/HighScores.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Invader.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/main.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Mothership.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/PythonInterface.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Shield.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Sprite.cpp
-)
-
 # Deal with platform specific sources for sample shell
 if(WIN32)
        list(APPEND shell_SRC_FILES

+ 0 - 19
Build/cmake/gen_filelists.sh

@@ -9,7 +9,6 @@ pubhdr='set(lib_PUB_HDR_FILES'
 srcdir='${PROJECT_SOURCE_DIR}'
 srcpath=Source
 hdrpath=Include/Rocket
-pypath=Python
 luapath=Lua
 
 printfiles() {
@@ -31,21 +30,6 @@ printfiles() {
     echo -e ')\n' >>$file
 }
 
-printpyfiles() {
-    # Print headers
-    echo ${hdr/lib/Py${1}} | sed 's/PyCo/Pyco/' >>$file
-    find  $srcpath/$1/$pypath -iname "*.h" -exec echo '    '$srcdir/{} \; 2>/dev/null | sort -f >>$file
-    echo -e ')\n' >>$file
-    # Print public headers
-    echo ${pubhdr/lib/Py${1}} | sed 's/PyCo/Pyco/' >>$file
-    find  $hdrpath/$1/$pypath -iname "*.h" -exec echo '    '$srcdir/{} \; 2>/dev/null | sort -f >>$file 2>/dev/null
-    echo -e ')\n' >>$file
-    # Print source files
-    echo ${src/lib/Py${1}} | sed 's/PyCo/Pyco/' >>$file
-    find  $srcpath/$1/$pypath -iname "*.cpp" -exec echo '    '$srcdir/{} \; 2>/dev/null | sort -f >>$file
-    echo -e ')\n' >>$file
-}
-
 printluafiles() {
     # Print headers
     echo ${hdr/lib/Lua${1}} >>$file
@@ -67,9 +51,6 @@ for lib in "Core" "Controls" "Debugger"; do
     printfiles $lib
 done
 
-for lib in "Core" "Controls"; do
-    printpyfiles $lib
-done
 for lib in "Core" "Controls"; do
     printluafiles $lib
 done

+ 1 - 1
Build/cmake/gen_samplelists.sh

@@ -11,7 +11,7 @@ samples=( 'shell'
 	'basic/sdl2' 'basic/sfml' 'basic/sfml2'
 	'basic/directx' 'basic/directx10'
 	'tutorial/template' 'tutorial/datagrid' 'tutorial/datagrid_tree' 'tutorial/tutorial_drag'
-	'invaders' 'luainvaders' 'pyinvaders'
+	'invaders' 'luainvaders'
 )
 
 printfiles() {

+ 0 - 55
Dependencies/osx-depends.sh

@@ -1,7 +1,6 @@
 #!/usr/bin/env sh
 
 BUILD_FREETYPE2=YES
-BUILD_BOOST_PYTHON=YES
 BUILD_LUA=YES
 BUILD_PLATFORM=osx
 
@@ -62,59 +61,5 @@ build_freetype()
 	cd "${DEPS_DIR}"
 }
 
-build_boostpython()
-{
-	cd "${DEPS_DIR}"
-	if [ ! -d "boost" ]; then
-		git clone --recursive https://github.com/boostorg/boost.git boost
-	fi
-
-	cd boost
-
-	git submodule foreach 'git clean -fdx; git reset --hard'
-	git clean -fdx
-
-	./bootstrap.sh
-	./b2 architecture=x86 address-model=32_64 --with-python
-	##./b2 architecture=x86 address-model=32_64 link=shared --with-python
-	##./b2 architecture=x86 address-model=32_64 link=static --with-python
-
-
-	cp libs/python/include/boost/python.hpp boost/
-	cp libs/utility/include/boost/utility/value_init.hpp boost/utility/
-	cp libs/lexical_cast/include/boost/lexical_cast.hpp boost/
-cp -R libs/lexical_cast/include/boost/lexical_cast boost/
-	cp libs/lexical_cast/include/boost/detail/lcast_precision.hpp boost/detail/
-#	mkdir -p boost/math
-#	cp libs/math/include/boost/math/special_functions/sign.hpp boost/math/special_functions/
-#	cp libs/math/include/boost/math/special_functions/math_fwd.hpp boost/math/special_functions/
-#	cp libs/math/include/boost/math/special_functions/detail/round_fwd.hpp boost/math/special_functions/detail/
-#	cp libs/math/include/boost/math/special_functions/detail/fp_traits.hpp boost/math/special_functions/detail/
-	cp -R libs/math/include/boost/math boost/math
-
-#	mkdir -p boost/math/tools
-#	cp libs/math/include/boost/math/tools/config.hpp boost/math/tools/
-#	cp libs/math/include/boost/math/tools/user.hpp boost/math/tools/
-#	cp libs/math/include/boost/math/tools/promotion.hpp boost/math/tools/
-	mkdir -p boost/math/policies
-	cp libs/math/include/boost/math/policies/policy.hpp boost/math/policies/
-
-	cp libs/predef/include/boost/detail/endian.hpp boost/detail/
-
-	cp libs/math/include/boost/math/special_functions/fpclassify.hpp boost/math/special_functions/
-
-	cp libs/math/include/boost/math/tools/real_cast.hpp boost/math/tools/
-
-	cp libs/lexical_cast/include/boost/detail/basic_pointerbuf.hpp boost/detail/
-
-	cp libs/foreach/include/boost/foreach.hpp boost/
-
-	cp -R boost "${BUILD_OUTPUTDIR}/include/"
-	cp -R stage/lib/* "${BUILD_OUTPUTDIR}/lib/"
-	cd "${DEPS_DIR}"
-}
-
-
 
 build_freetype
-build_boostpython

+ 0 - 77
Include/Rocket/Core/Python/ConverterScriptObject.h

@@ -1,77 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONCONVERTERSCRIPTOBJECT_H
-#define ROCKETCOREPYTHONCONVERTERSCRIPTOBJECT_H
-
-#include "Python.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-/**
-	Templated class for converting from a script object to a python object
-	
-	Simply construct this class in your application start up and it
-	will do the necessary registration of the object with the boost
-	type conversion repository.
-
-	@author Lloyd Weehuizen
- */
-
-template <typename T>
-struct ConverterScriptObject
-{
-	ConverterScriptObject()
-	{
-		// Register custom RKTElement to python converter
-		boost::python::to_python_converter< T*, ConverterScriptObject< T > >();
-	}
-
-	static PyObject* convert(T* object)
-	{
-		PyObject* pyobject = Py_None;
-		if (object)
-		{
-			PyObject* script_object = (PyObject*)object->GetScriptObject();
-			if (script_object) 
-			{
-				pyobject = script_object;
-			}
-		}
-
-		Py_INCREF(pyobject);
-		return pyobject;
-	}
-};
-
-}
-}
-}
-
-#endif

+ 0 - 120
Include/Rocket/Core/Python/ElementInstancer.h

@@ -1,120 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONELEMENTINSTANCER_H
-#define ROCKETCOREPYTHONELEMENTINSTANCER_H
-
-#include "../String.h"
-#include "../XMLParser.h"
-#include "Python.h"
-#include "../Element.h"
-#include "../ElementInstancer.h"
-#include "../Header.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-/**
-	Python Element Instancer 
-
-	This object provides the standard ElementInstancer 
-	interface for instancing python elements.
-
-	NOTE: This is all inline so that it can be used by 3rdparty plugins
-
-	@author Lloyd Weehuizen 
- */
-
-class ElementInstancer : public Rocket::Core::ElementInstancer
-{
-public:
-	ElementInstancer(PyObject* _class_definition)
-	{
-		class_definition = _class_definition;
-		Py_INCREF(class_definition);
-	}
-	virtual ~ElementInstancer()
-	{
-		Py_DECREF(class_definition);
-	}
-
-	/// Instances an element given the tag name and attributes
-	/// @param tag Name of the element to instance
-	/// @param attributes vector of name value pairs
-	virtual Element* InstanceElement(Element* ROCKET_UNUSED_PARAMETER(parent), const Rocket::Core::String& tag, const Rocket::Core::XMLAttributes& ROCKET_UNUSED_PARAMETER(attributes))
-	{
-		ROCKET_UNUSED(parent);
-		ROCKET_UNUSED(attributes);
-
-		// Build the arguments
-		PyObject* args = PyTuple_New(1);
-		PyTuple_SetItem(args, 0, PyString_FromString(tag.CString()));
-
-		PyObject* instance = PyObject_CallObject(class_definition, args);
-		Py_DECREF(args);
-
-		// Check the instance was created successfully
-		if (instance == NULL)
-		{
-			PyErr_Print();
-			return NULL;
-		}
-
-		Element* element = python::extract<Element*>(python::object(python::handle<>(python::borrowed(instance))));	
-
-		// Need to switch the Python reference count to a true C++ reference count.
-		element->AddReference(); // Adds to C++ and Python reference counts.
-		Py_DECREF( instance );   // Removes from Python.
-
-		return element;
-	}
-
-	/// Releases the given element
-	/// @param element to release
-	virtual void ReleaseElement(Element* ROCKET_UNUSED_PARAMETER(element))
-	{
-		ROCKET_UNUSED(element);
-
-		// Never release Python elements, Python will manage this for us.
-	}
-
-	/// Release the instancer
-	virtual void Release()
-	{
-		delete this;
-	}
-
-private:
-	PyObject* class_definition;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 96
Include/Rocket/Core/Python/ElementWrapper.h

@@ -1,96 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONELEMENTWRAPPER_H
-#define ROCKETCOREPYTHONELEMENTWRAPPER_H
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-/**
-	Python Wrapper class for Elements 
- 
-	This class maintains is a standard boost wrapper class that 
-	the self pointer for an element and provides virtual 
-	overrides for the hook methods. 
- 
-	@author Lloyd Weehuizen 
- */
-
-template <typename T>
-class ElementWrapper : public T
-{
-public:
-	ElementWrapper( PyObject* self, const char* tag ) : self( self ), T( tag )
-	{
-		// Force remove reference, to reduce the count to 0 as python has instanced
-		// this object. If the call originally came from C++ (PyBRElementInstancer)
-		// then it will add its own reference
-		T::RemoveReference();
-
-		// If the C++ reference count is not 0 at this point, it means additional references have been added
-		// during the classes constructor. We have to propogate these references into python.
-		for (int i = 0; i < this->T::GetReferenceCount(); i++)
-			Py_INCREF(self);
-	}
-	virtual ~ElementWrapper() {}
-
-	/// Return the python script object associated with this element
-	virtual void* GetScriptObject() const { return self; }
-
-	// Propogate add ref's into python
-	virtual void AddReference()
-	{
-		Py_INCREF( self );
-
-		T::AddReference();
-	}
-
-	// Propogate remove ref's into python
-	virtual void RemoveReference()
-	{
-		T::RemoveReference();
-
-		Py_DECREF( self );
-	}
-
-	virtual void OnReferenceDeactivate()
-	{
-		// Ignore reference deactivated
-	}
-
-private:
-	// Python representation of this object
-	PyObject* self;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 52
Include/Rocket/Core/Python/Header.h

@@ -1,52 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONHEADER_H
-#define ROCKETCOREPYTHONHEADER_H
-
-#include "../Platform.h"
-
-#ifdef STATIC_LIB
-	#define ROCKET_STATIC_LIB
-	#pragma message("DEPRECATED: STATIC_LIB macro has been deprecated in favor of ROCKET_STATIC_LIB and support will be removed in a future release")
-#endif
-
-#if !defined ROCKET_STATIC_LIB
-#if defined ROCKET_PLATFORM_WIN32
-	#if defined RocketCorePython_EXPORTS
-		#define ROCKETCOREPYTHON_API __declspec(dllexport)
-	#else
-		#define ROCKETCOREPYTHON_API __declspec(dllimport)
-	#endif
-#else
-	#define ROCKETCOREPYTHON_API __attribute__((visibility("default")))
-#endif
-#else
-	#define ROCKETCOREPYTHON_API
-#endif
-
-#endif

+ 0 - 123
Include/Rocket/Core/Python/NameIndexInterface.h

@@ -1,123 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONNAMEINDEXINTERFACE_H
-#define ROCKETCOREPYTHONNAMEINDEXINTERFACE_H
-
-#include "Utilities.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-template < typename HostType >
-class NameAccessorInvalid
-{
-public:
-	python::object operator()(HostType& host, const char* name)
-	{
-		PyErr_SetString(PyExc_KeyError, "Invalid key.");
-		python::throw_error_already_set();
-
-		return python::object();
-	}
-};
-
-/**
-	Template class for generating a lightweight proxy object for providing array-style lookups on a C++ object.
-
-	@author Peter Curry
- */
-
-template < typename HostType, typename LengthAccessor, typename IndexAccessor, typename NameAccessor = NameAccessorInvalid< HostType > >
-class NameIndexInterface : public python::def_visitor< NameIndexInterface< HostType, LengthAccessor, IndexAccessor, NameAccessor > >
-{
-public:
-	NameIndexInterface()
-	{
-	}
-
-	~NameIndexInterface()
-	{
-	}
-
-	/// Initialise the interface.
-	template < typename ClassType >
-	void visit(ClassType& _class) const
-	{
-		_class.def("__getitem__", &NameIndexInterface< HostType, LengthAccessor, IndexAccessor, NameAccessor >::GetItem);
-		_class.def("__len__", &NameIndexInterface< HostType, LengthAccessor, IndexAccessor, NameAccessor >::Len);
-	}
-
-	/// Python __getitem__ override.
-	static python::object GetItem(HostType& host, python::object key)
-	{
-		static NameAccessor name_accessor;
-		static LengthAccessor length_accessor;
-		static IndexAccessor index_accessor;
-
-		if (PyString_Check(key.ptr()))
-		{
-			return Rocket::Core::Python::Utilities::MakeObject(name_accessor(host, PyString_AsString(key.ptr())));
-		}
-		else if (PyInt_Check(key.ptr()))
-		{
-			int index = PyInt_AsLong(key.ptr());
-
-			// Support indexing from both ends.
-			if (index < 0)
-				index = length_accessor(host) + index;
-
-			// Throw exception if we're out of range, this is required to support python iteration.
-			if (index >= length_accessor(host))
-			{
-				PyErr_SetString(PyExc_IndexError, "Index out of range.");
-				python::throw_error_already_set();
-			}
-
-			return Rocket::Core::Python::Utilities::MakeObject(index_accessor(host, index));
-		}
-
-		PyErr_SetString(PyExc_KeyError, "Invalid key.");
-		python::throw_error_already_set();
-
-		return python::object();
-	}
-
-	/// Python __len__ override.
-	static int Len(HostType& host)
-	{
-		static LengthAccessor length_accessor;
-		return length_accessor(host);
-	}
-};
-
-}
-}
-}
-
-#endif

+ 0 - 87
Include/Rocket/Core/Python/PickleTypeConverter.h

@@ -1,87 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPICKLETYPECONVERTER_H
-#define ROCKETCOREPICKLETYPECONVERTER_H
-
-#include "../TypeConverter.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-/**
-	Generic Python Pickler that does string conversion using an Rocket::Core::TypeConverter.
-
-	@author Lloyd Weehuizen
- */
-
-template <typename T>
-class PickleTypeConverter : public python::pickle_suite
-{
-public:	
-	static python::tuple getstate(python::object obj)
-	{
-		T& object = python::extract<T&>(obj)();
-		
-		String buffer;
-		TypeConverter< T, String >::Convert(object, buffer);
-
-		return python::make_tuple(buffer.CString());
-	}
-
-	static void setstate(python::object obj, python::tuple state)
-	{
-		T& object = python::extract< T& >(obj)();	
-
-		int len = python::extract< int >(state.attr( "__len__" )());
-		if (len != 1)
-		{
-			PyErr_SetObject(PyExc_ValueError,
-							("expected 1-item tuple in call to __setstate__; got %s"
-							% state).ptr()
-				);
-			python::throw_error_already_set();
-		}
-		
-		const char* cstring = python::extract<const char*>(state[0]);
-		String string(cstring);
-		TypeConverter<String, T>::Convert(string, object);
-	}
-
-	static bool getstate_manages_dict()
-	{
-		// Tell boost we've taken care of the dictionary
-		return true; 
-	}
-};
-
-}
-}
-}
-
-#endif

+ 0 - 52
Include/Rocket/Core/Python/Python.h

@@ -1,52 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHON_H
-#define ROCKETCOREPYTHON_H
-
-// RocketCore platform header for the ROCKET_PLATFORM_* define.
-#include "../Platform.h"
-
-// Python header includes
-#include <Python.h>
-
-#ifdef ROCKET_PLATFORM_WIN32
-	#pragma warning(push)
-	#pragma warning(disable: 4244)
-#endif
-
-// Prevent Boost from auto-linking with the wrong library.
-#define BOOST_ALL_NO_LIB
-#include <boost/python.hpp>
-// remap boost::python to python for easier access
-namespace python = boost::python;
-
-#ifdef ROCKET_PLATFORM_WIN32
-	#pragma warning(pop)
-#endif
-
-#endif

+ 0 - 111
Include/Rocket/Core/Python/Utilities.h

@@ -1,111 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONUTILITIES_H
-#define ROCKETCOREPYTHONUTILITIES_H
-
-#include "../Variant.h"
-#include "Header.h"
-#include "Python.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-class ROCKETCOREPYTHON_API Utilities
-{
-public:
-	/// Is the specific method name callable
-	static bool IsCallable(PyObject* self, const char* method_name);
-
-	/// Call a python function
-	/// @param[in] object Python Dictionary or Object
-	/// @param[in] method_name function or method name to call
-	/// @param[in] args Tuple of arguments
-	/// @returns The python result
-	template <typename R>
-	static R Call(PyObject* object, const char* method_name, const python::tuple& args)
-	{
-		PyObject* result = PythonCall(object, method_name, args);		
-		
-		python::converter::return_from_python<R> converter;
-		return converter(result);		
-	}	
-	/// Call a python function
-	/// @param[in] object Python Dictionary or Object to lookup the method in
-	/// @param[in] method_name function or method name to call
-	/// @param[in] args Tuple of arguments
-	/// @returns True on success
-	static bool Call(PyObject* object, const char* method_name, const python::tuple& args);
-
-	/// Creates a boost python object from an existing C++ object pointer
-	/// @param[in] object The C++ object to convert
-	/// @returns A boost::python::object referencing the same object
-	template< typename T >
-	static inline python::object MakeObject(T* object)
-	{
-		// Constructs a boost::object using a result_converter to get a pointer to the existing object
-		typename python::return_by_value::apply< T* >::type result_converter;
-		return python::object(python::handle<>(result_converter(object)));
-	}
-	/// Creates a new python object (copy) from a C++ object
-	/// @param[in] object The C++ object to convert
-	/// @returns A boost::python::object that contains a copy of the object
-	template< typename T >
-	static inline python::object MakeObject(const T& object)
-	{
-		// Constructs a boost::object copy of the C++ object
-		return python::object(object);		
-	}
-
-	/// Print any pending exceptions to stderr
-	/// @param[in] clear_error Clear the error flag
-	static void PrintError(bool clear_error = false);
-
-	/// Converts a python object into an Rocket variant.
-	/// @param[out] variant The variant to convert the object into.
-	/// @param[in] object The python object to convert.
-	/// @return True if the conversion was successful, false otherwise.
-	static bool ConvertToVariant(Variant& variant, PyObject* object);
-
-private:
-	static PyObject* PythonCall(PyObject* object, const char* method_name, const python::tuple& args );
-};
-
-// Template Specialisation for converting from a PyObject*
-template<>
-inline python::object Utilities::MakeObject< PyObject >(PyObject* object)
-{
-	return python::object(python::handle<>(python::borrowed(object)));
-}
-
-}
-}
-}
-
-#endif
-

+ 0 - 118
Include/Rocket/Core/Python/VectorInterface.h

@@ -1,118 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONVECTORINTERFACE_H
-#define ROCKETCOREPYTHONVECTORINTERFACE_H
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-/**
-	Provides a list style python interface to any STL container
-	that can provide a vector style interface.
-
-	Simply contruct one of these objects to register the type
-	with python.
-	
-	VectorInterface< std::vector< std::string > >("StringList");
-
-	@author Lloyd Weehuizen
- */
-template <typename Container>
-class VectorInterface
-{
-public:
-	VectorInterface(const char* name)
-	{
-		python::class_< Container >(name)
-			.def("__len__", &VectorInterface< Container >::Size)
-			.def("__setitem__", &VectorInterface< Container >::SetItem)
-			.def("__delitem__", &VectorInterface< Container >::DelItem)
-			.def("__getitem__", &VectorInterface< Container >::GetItem, python::return_value_policy< python::return_by_value >())
-			.def("__contains__", &VectorInterface< Container >::Contains)			
-		;
-	}
-
-	static size_t Size(const Container& container)
-	{
-		return container.size();
-	}
-
-	static void SetItem(Container& container, int index, const typename Container::value_type& value)
-	{
-		if (index < 0)
-			index = container.size() + index;
-		if (index >= (int)container.size())
-			container.resize(index + 1);
-
-		container[index] = value;
-	}
-
-	static void DelItem(Container& container, int index)
-	{
-		if (index >= (int)container.size())
-		{
-			PyErr_SetString(PyExc_IndexError, String(32, "Invalid index %d", index).CString());
-			python::throw_error_already_set();
-		}
-
-		container.erase(container.begin() + index);
-	}
-
-	static typename Container::value_type& GetItem(Container& container, int index)
-	{
-		if (index < 0)
-			index = container.size() + index;
-
-		if (index >= (int)container.size())
-		{
-			PyErr_SetString(PyExc_IndexError, String(32, "Invalid index %d", index).CString());
-			python::throw_error_already_set();
-		}
-
-		return container[index];
-	}
-
-	static bool Contains(Container& container, const typename Container::value_type& value)
-	{
-		for (typename Container::iterator itr = container.begin(); itr != container.end(); ++itr)
-		{
-			if ((*itr) == value)
-				return true;
-		}
-
-		return false;
-	}
-};
-
-}
-}
-}
-
-#endif
-

+ 0 - 67
Include/Rocket/Core/Python/Wrapper.h

@@ -1,67 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONWRAPPER_H
-#define ROCKETCOREPYTHONWRAPPER_H
-
-#include "../Debug.h"
-#include "Python.h"
-
-#include <boost/none.hpp>
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-/**
-	Generic Python Wrapper, using boost preprocessor iteration for constructor params
-	
-	Defines a basic wrapper, then template overloads it for each variation of the
-	number of arguments.
-
-	@author Lloyd Weehuizen
- */
-
-struct WrapperNone {};
-
-#define WRAPPER_MAX_ARGS	6
-
-#define WRAPPER_TEMPLATE_ARG(z, n, d) BOOST_PP_COMMA_IF(n) typename T##n = WrapperNone
-
-template <typename T, BOOST_PP_REPEAT_1( BOOST_PP_INC(WRAPPER_MAX_ARGS), WRAPPER_TEMPLATE_ARG, N) >
-class Wrapper {};
-
-#undef WRAPPER_TEMPLATE_ARG
-
-#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, WRAPPER_MAX_ARGS, <Rocket/Core/Python/WrapperIter.h>))
-#include BOOST_PP_ITERATE()
-
-}
-}
-}
-
-#endif

+ 0 - 122
Include/Rocket/Core/Python/WrapperIter.h

@@ -1,122 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#if !defined(BOOST_PP_IS_ITERATING)
-#  error PyWrapperIter - do not include this file!
-#endif
-
-#define N BOOST_PP_ITERATION()
-
-/**
-	Generic Python Wrapper, using Boost Preprocessor Iteration to Generate Variants
-	
-	Relies on a Rocket::Core::ReferenceCountable base class for reference counting.
-	
-	Traps ReferenceActivated/Deactivated calls and makes them behave like
-	they should for python based objects.
-	
-	@author Lloyd Weehuizen
- */
-
-#define WRAPPER_PARAM(x, n, d) , d
-
-template < typename T BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS_Z(1, N, typename A) >
-class Wrapper< T BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS_Z(1, N, A) BOOST_PP_REPEAT_1( BOOST_PP_SUB(BOOST_PP_INC(WRAPPER_MAX_ARGS), N), WRAPPER_PARAM, WrapperNone) > : public T
-{
-public:	
-	Wrapper(PyObject* self BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, a)) : T(BOOST_PP_ENUM_PARAMS_Z(1, N, a))
-	{
-		// Set self to NULL, so we can trap the reference deactivated and not pass it down
-		this->self = NULL;
-
-		// We have to remove the C++ reference count that all C++ objects start with here,
-		// otherwise if an object is created in python and destroyed by python, the C++ ref count will
-		// remain 1. The PyWrapperInstancer will increase the refcount again, to ensure a correct refcount
-		// if the object was created by C++
-		T::RemoveReference();
-
-		// If the C++ reference count is not 0 at this point, it means additional references have been added
-		// during the classes constructor. We have to propogate these references into python.
-		for (int i = 0; i < this->T::GetReferenceCount(); i++)
-			Py_INCREF(self);
-
-		// Store self
-		this->self = self;
-	}
-
-	Wrapper(PyObject* self, const T& other) : T(other)
-	{
-		this->self = self;		
-	}
-
-	virtual ~Wrapper()
-	{		
-		// We should only be deleted when python says the refcnt is 0, if we
-		// are being deleted prematurely, something is wrong!
-		ROCKET_ASSERTMSG(self->ob_refcnt == 0, "Python object being cleared up prematurely, reference count not 0.");
-		ROCKET_ASSERT(this->T::GetReferenceCount() == 0);
-	}
-
-	/// Override AddReference so we can push the call through to python
-	virtual void AddReference()
-	{
-		Py_INCREF(self);
-		
-		T::AddReference();
-	}
-
-	/// Overrride RemoveReference so we can push the call through to python
-	virtual void RemoveReference()
-	{
-		T::RemoveReference();
-
-		Py_DECREF(self);
-	}
-	
-	virtual int GetReferenceCount()
-	{
-		// C++ reference counts are always reflected in the python ref count
-		return self->ob_refcnt;
-	}
-
-	virtual void OnReferenceDeactivate()
-	{
-		// If self is NULL, don't pass the call down, as this is the initial 
-		// T::RemoveReference from the constructor
-		if (self)
-			T::OnReferenceDeactivate();
-	}
-
-	// Script object access
-	virtual void* GetScriptObject() const { return self; }
-
-protected:
-	PyObject* self;
-};
-
-#undef WRAPPER_PARAM
-

+ 0 - 9
Samples/README.TXT

@@ -20,12 +20,6 @@ in /samples/shell/) before you compile other samples. All the
 SConstructs will build a debug build by default; to build a release
 version, run 'scons release'.
 
-When compiling Python examples, you will need to set up your build
-paths to point at the local copy of Python and Boost. If using Visual
-Studio, change these in the project's include and library paths. If
-using SCons, edit /build/config.py and change the paths as
-appropriate.
-
 Directory Overview:
 
  * assets     - This directory contains the assets shared by
@@ -45,9 +39,6 @@ Directory Overview:
  * invaders   - A full implementation of the 1970s classic
                 Space Invaders using the libRocket interface.
 
- * pyinvaders - Python version of the above (only installed
-                with the Python plugin).
-
  * luainvaders- Lua version of the invaders (only installed
                 with the Lua plugin).
 

+ 0 - 35
Samples/pyinvaders/data/background.rml

@@ -1,35 +0,0 @@
-<rml>
-	<head>
-		<style>
-			body
-			{
-				width: 100%;
-				height: 100%;
-				z-index: bottom;
-
-				z-index: -1;
-			}
-
-			starfield
-			{
-				display: block;
-				width: 100%;
-				height: 100%;
-				z-index: 1;
-
-				star-decorator: starfield;
-				star-num-layers: 5;
-				star-top-colour: #fffc;
-				star-bottom-colour: #fff3;
-				star-top-speed: 80.0;
-				star-bottom-speed: 20.0;
-				star-top-density: 8;
-				star-bottom-density: 20;
-			}
-		</style>
-	</head>
-	<body>
-		<img src="background.tga" />
-		<starfield />
-	</body>
-</rml>

BIN
Samples/pyinvaders/data/background.tga


+ 0 - 124
Samples/pyinvaders/data/game.rml

@@ -1,124 +0,0 @@
-<rml>
-	<head>
-		<title>game</title>
-		<link type="text/template" href="window.rml" />
-		<style>
-			body
-			{
-				padding: 0px;
-				margin: 0px;
-				width: 100%;
-				height: 100%;
-
-				z-index: -1;
-			}
-			
-			game
-			{
-				display: block;
-				width: 100%;
-				height: 100%;
-			}
-
-			div
-			{
-				height: 47px;
-				padding: 9px 0px 0px 65px;
-				margin: 0px 20px;
-
-				font-size: 20;
-
-				background-decorator: tiled-horizontal;
-				background-left-image: ../../assets/invader.tga 147px 55px 229px 0px;
-				background-center-image: ../../assets/invader.tga stretch 229px 55px 230px 0px;
-				background-right-image: ../../assets/invader.tga 231px 55px 246px 0px;
-			}
-
-			div#score_div
-			{
-				float: left;
-				width: 155px;
-			}
-
-			div#hiscore_div
-			{
-				float: left;
-				width: 205px;
-			}
-
-			div#waves_div
-			{
-				float: right;
-				width: 95px;
-			}
-
-			div#lives_div
-			{
-				float: right;
-				width: 80px;
-			}
-
-			icon
-			{
-				display: block;
-				position: absolute;
-				left: 14px;
-				top: 3px;
-
-				width: 51px;
-				height: 39px;
-				
-				icon-decorator: image;
-				icon-image-src: ../../assets/invader.tga;
-				icon-image-t: 152px 191px;
-			}
-
-			div#score_div icon
-			{
-				icon-image-s: 434px 485px;
-			}
-
-			div#hiscore_div icon
-			{
-				icon-image-s: 281px 332px;
-			}
-
-			div#waves_div icon
-			{
-				icon-image-s: 332px 383px;
-			}
-
-			div#lives_div icon
-			{
-				icon-image-s: 383px 434px;
-			}
-		</style>
-		<script>
-import rocket
-
-def OnKeyDown(event, document):
-	if event.parameters['key_identifier'] == rocket.key_identifier.ESCAPE:
-		document.context.LoadDocument('data/pause.rml').Show()
-		</script>
-	</head>
-	<body id="game_window" onkeydown="OnKeyDown(event, document)" ongameover="LoadMenu('high_score')">
-		<game id="game">
-			<div id="score_div">
-				<icon />
-				score: <span id="score" />
-			</div>
-			<div id="hiscore_div">
-				<icon />
-				high score: <span id="hiscore" />
-			</div>
-			<div id="lives_div">
-				<icon />
-				lives: <span id="lives" />
-			</div>
-			<div id="waves_div">
-				<icon />
-				wave: <span id="waves" />
-			</div>
-		</game>
-	</body>
-</rml>

+ 0 - 55
Samples/pyinvaders/data/help.rml

@@ -1,55 +0,0 @@
-<rml>
-	<head>
-		<title>Help</title>
-		<link type="text/template" href="window.rml" />
-		<style>
-			body
-			{
-				width: 50%;
-				height: 70%;
-				margin: auto;
-			}
-			
-			div#content
-			{
-				overflow-y: scroll;
-			}
-			
-			div#title_bar div#icon
-			{
-				icon-image-s: 128px 179px;
-				icon-image-t: 152px 191px;
-			}
-		</style>
-	</head>
-	<body template="pywindow">
-		<h1>Story</h1>
-		<p>
-			One day, without warning, they came for us; endless waves of the invaders, numbers too vast to count, fresh from the Martian foundries. Earth's orbital defences took a heavy toll, but were inevitably overrun, buying enough time only for a single rocket ship to launch. The prototype X-42 'Defender'-class, not yet tested but piloted by the finest astronaut the Space Corps had to offer.
-		</p>
-		<p>
-			Do you have what it takes to defeat the invaders and save Earth?
-		</p>
-		<h1>The X-42</h1>
-		<p>
-			The culmination of <img src="help_defender.tga" style="float: left; margin: -6px -24px;" />decades of research and the pinnacle of Earth's technology, the X-42 'Defender' is the finest weapon mankind has to fight the alien menace. Equipped with the dual-layer ablative tridranium armour, low-velocity depleted-narconium chain-fed belt gun and state-of-the-art liquid-hydrangea turbo-thrusters, it is still going to be nearly impossible for its pilot to secure the safety of mankind.
-		</p>
-		<h1>The Invaders</h1>
-		<p>
-			The most numerous <img src="help_invader_rank1.tga" style="float: left; margin: -4px 0px;" />invader you'll face is a primitive drone that is primarily employed by its Martian overlords in the mines of Cydonia. It is large, ungainly and poorly-armed, so ill-suited to its new role as the backbone of the invasion fleet. However, whatever it lacks in pugilistic prowess it makes up for with numbers. Each drone is worth 10 points.
-		</p>
-		<p>
-			Behind the drones <img src="help_invader_rank2.tga" style="float: right; margin: -4px 0px;" />stand the formidable berserker units, encased in their zyterium battle-suits and wielding the dreaded Nimbus death-rods. A lone unit is no match for a skilled X-42 pilot, but in large groups they adopt complex flight patterns that can confuse even the best targetting computer. Pick them off and separate them when you can. Each berserker is worth 20 points.
-		</p>
-		<p>
-			The dreaded commander <img src="help_invader_rank3.tga" style="float: left; margin: -4px 0px;" />death-droids lie at the back of every Martian wave. Small, nimble and deadly, these ships are the true test of an X-42 pilot's abilities. Consider yourself warned, and watch out especially for their mind control attack! Each droid is worth 40 points.
-		</p>
-		<p>
-			Occasionally one of the <img src="help_invader_mothership.tga" style="float: right; margin: -6px -12px;" /> invasion motherships will drop into low-orbit to provide the Martian Overbrain with a close look at the progress of the battle; this is when they are most vulnerable, destroy them if you can! The loss of even a single mothership will be keenly felt by the fleet. The points value of each mothership is variable, depending on the seniority of its command synapse.
-		</p>
-		<p>
-			Destroy all the invaders in each wave before any get past your ship to invade Earth, unleash their deadly toxin and wipe out all of humanity!
-		</p>
-		<button onclick="LoadMenu('main_menu')">Back</button>
-	</body>
-</rml>

BIN
Samples/pyinvaders/data/help_defender.tga


BIN
Samples/pyinvaders/data/help_invader_mothership.tga


BIN
Samples/pyinvaders/data/help_invader_rank1.tga


BIN
Samples/pyinvaders/data/help_invader_rank2.tga


BIN
Samples/pyinvaders/data/help_invader_rank3.tga


+ 0 - 68
Samples/pyinvaders/data/high_score.rml

@@ -1,68 +0,0 @@
-<rml>
-	<head>
-		<title>High Scores</title>
-		<link type="text/template" href="window.rml" />
-		<style>
-			body
-			{
-				width: 350px;
-				height: 350px;
-				
-				margin: auto;
-			}
-			
-			div#title_bar div#icon
-			{
-				icon-image-s: 281px 331px;
-				icon-image-t: 152px 191px;
-			}
-			
-			datagrid
-			{
-				margin-bottom: 20px;
-				min-rows: 10;
-			}
-			
-			datagrid data_grid_body
-			{
-				min-height: 200px;
-			}
-			
-			defender
-			{
-				display: block;
-				width: 64px;
-				height: 16px;
-				
-				defender-decorator: defender;
-				defender-image-src: high_scores_defender.tga;
-			}
-		</style>
-		<script>
-import rocket
-
-def OnRowAdd():
-	input = document.GetElementById('player_input')
-	if input:
-		input.Focus()
-
-def OnLoad(window):
-	OnWindowLoad(window)
-	datagrid = window.GetElementById('datagrid')
-	datagrid.AddEventListener('rowupdate', OnRowAdd, False)
-	
-def OnKeyDown(event):
-	if event.parameters['key_identifier'] == rocket.key_identifier.RETURN:
-		game.SetHighScoreName(event.current_element.value)
-		</script>
-	</head>
-	<body template="pywindow" onload="OnLoad(self); game.SubmitHighScore()" onunload="game.SetHighScoreName('Anon')">
-		<datagrid id="datagrid" source="high_scores.scores">
-			<col fields="name,name_required" formatter="name" width="40%">Pilot:</col>
-			<col fields="colour" formatter="ship" width="20%">Ship:</col>
-			<col fields="wave" width="20%">Wave:</col>
-			<col fields="score" width="20%">Score:</col>
-		</datagrid>
-		<button onclick="LoadMenu('main_menu')">Main Menu</button>
-	</body>
-</rml>

BIN
Samples/pyinvaders/data/high_scores_defender.tga


BIN
Samples/pyinvaders/data/invaders.tga


+ 0 - 23
Samples/pyinvaders/data/logo.rml

@@ -1,23 +0,0 @@
-<rml>
-	<head>
-		<style>
-			body
-			{
-				width: 100%;
-				height: 100%;
-
-				z-index: -1;
-			}
-			
-			#rifm_logo
-			{
-				position: absolute;
-				left: 25px;
-				top: 25px;
-			}
-		</style>
-	</head>
-	<body id="logo">
-		<img id="rifm_logo" src="logo.tga" />
-	</body>
-</rml>

BIN
Samples/pyinvaders/data/logo.tga


+ 0 - 33
Samples/pyinvaders/data/main_menu.rml

@@ -1,33 +0,0 @@
-<rml>
-	<head>
-		<title>Main Menu</title>
-		<link type="text/template" href="window.rml" />
-		<style>
-			body
-			{
-				width: 300px;
-				height: 225px;
-
-				margin: auto;
-			}
-			
-			div#title_bar div#icon
-			{
-				icon-image-s: 179px 230px;
-				icon-image-t: 152px 191px;
-			}
-		</style>
-		<script>
-def CloseLogo():
-	if document.context:
-		document.context.documents['logo'].Close()
-		</script>
-	</head>
-	<body template="pywindow" onload="OnWindowLoad(self); document.context.LoadDocument('data/logo.rml').Show()" onunload="CloseLogo()">
-		<button onclick="document.context.LoadDocument('data/start_game.rml').Show(); document.Close()">Start Game</button><br />
-		<button onclick="LoadMenu('high_score')">High Scores</button><br />
-		<button onclick="LoadMenu('options')">Options</button><br />
-		<button onclick="LoadMenu('help')">Help</button><br />
-		<button onclick="import game;game.Shutdown()">Exit</button>
-	</body>
-</rml>

+ 0 - 85
Samples/pyinvaders/data/options.rml

@@ -1,85 +0,0 @@
-<rml>
-	<head>
-		<title>Options</title>
-		<link type="text/template" href="window.rml" />
-		<style>
-			body
-			{
-				width: 350px;
-				height: 350px;
-				
-				margin: auto;
-			}
-
-			div#title_bar div#icon
-			{
-				icon-image-s: 230px 281px;
-				icon-image-t: 152px 191px;
-
-				display: none;
-			}
-
-			form div
-			{
-				width: 200px;
-				margin: auto;
-			}
-		</style>
-		<script>
-import cPickle
-def LoadOptions(document):
-	try:
-		f = open('options.dat', 'rt')
-		options = cPickle.loads("".join(f.readlines()))
-		
-		document.GetElementById(options['graphics']).checked = True
-		document.GetElementById('reverb').checked = options['reverb']
-		document.GetElementById('3d').checked = options['3d']
-		
-	except IOError:
-		pass
-		
-def SaveOptions(event, document):
-	try:
-		if event.parameters['button'] == 'cancel':
-			return
-		
-		options = {}
-		options['graphics'] = event.parameters['graphics']
-		options['reverb'] = 'reverb' in event.parameters
-		options['3d'] = '3d' in event.parameters
-		
-		f = open('options.dat', 'wt')
-		f.write(cPickle.dumps(options))
-		f.close()
-	except IOError:
-		pass
-		
-def DisplayBadGraphics(document, display):
-	if display:
-		document.GetElementById('bad_warning').style.display = 'block'
-	else:
-		document.GetElementById('bad_warning').style.display = 'none'
-	</script>
-	</head>
-	<body template="pywindow" onload="OnWindowLoad(self); LoadOptions(document)">
-		<form onsubmit="SaveOptions(event, document); LoadMenu('main_menu')">
-			<div>
-				<p>
-					Graphics:<br />
-					<input id="good" type="radio" name="graphics" value="good"/> Good<br />
-					<input id="ok" type="radio" name="graphics" value="ok" checked="true"/> OK<br />
-					<input id="bad" type="radio" name="graphics" value="bad" onchange="DisplayBadGraphics(document, self.checked)" /> Bad<br />
-				</p>
-				<p id="bad_warning" style="display: none;">Are you sure about this? Bad graphics are just plain <em>bad.</em></p>
-				<p>
-					Audio:<br />
-					<input id="reverb" type="checkbox" name="reverb" value="true" checked="true" /> Reverb<br />
-					<input id="3d" type="checkbox" name="3d" value="true" /> 3D Spatialisation
-				</p>
-			</div>
-			<input type="submit" name="button" value="accept">Accept</input>
-			<input type="submit" name="button" value="cancel">Cancel</input>
-		</form>
-	</body>
-</rml>

+ 0 - 27
Samples/pyinvaders/data/pause.rml

@@ -1,27 +0,0 @@
-<rml>
-	<head>
-		<title>Quit?</title>
-		<link type="text/template" href="window.rml" />
-		<style>
-			body
-			{
-				width: 350px;
-				height: 135px;
-				
-				margin: auto;
-			}
-			
-			div#title_bar div#icon
-			{
-				icon-image-s: 332px 383px;
-				icon-image-t: 191px 231px;
-			}
-		</style>
-	</head>
-	<body template="pywindow" onload="OnWindowLoad(self); game.SetPaused(True)" onunload="game.SetPaused(False)">
-		<br />
-		<p>Are you sure you want to end this game?</p>
-		<button onclick="LoadMenu('high_score');document.context.documents['game_window'].Close()">Yes</button>
-		<button onclick="document.Close()">No!</button>
-	</body>
-</rml>

+ 0 - 65
Samples/pyinvaders/data/start_game.rml

@@ -1,65 +0,0 @@
-<rml>
-	<head>
-		<title>Start Game</title>
-		<link type="text/template" href="window.rml" />
-		<style>
-			body
-			{
-				width: 300px;
-				height: 225px;
-				
-				margin: auto;
-			}
-			
-			div#title_bar div#icon
-			{
-				icon-image-s: 230px 281px;
-				icon-image-t: 152px 191px;
-			}
-			
-			form div
-			{
-				width: 200px;
-				margin: auto;
-			}
-		</style>
-		<script>
-def SetupGame(event):
-	import rocket
-	if event.parameters['difficulty'] == "hard":
-		game.SetDifficulty(game.difficulty.HARD)
-	else:
-		game.SetDifficulty(game.difficulty.EASY)
-	
-	(red, green, blue) = event.parameters['colour'].split(',')
-	game.SetDefenderColour(rocket.Colourb(int(red), int(green), int(blue), 255))
-	
-	elem = LoadMenu('game').GetElementById('game')
-	elem.Focus()
-		</script>
-	</head>
-	<body template="pywindow">
-		<form onsubmit="SetupGame(event)">
-			<div>
-				<p>
-					Difficulty:<br />
-					<input type="radio" name="difficulty" value="easy" checked="true" /> Easy<br />
-					<input type="radio" name="difficulty" value="hard" /> Hard
-				</p>
-				<p>
-					Colour:<br />
-					<select name="colour">
-						<option value="233,116,81">Burnt Sienna</option>
-						<option value="127,255,0">Chartreuse</option>
-						<option value="21,96,189">Denim</option>
-						<option value="246,74,138">French Rose</option>
-						<option value="255,0,255">Fuschia</option>
-						<option value="218,165,32">Goldenrod</option>
-						<option selected value="255,255,240">Ivory</option>
-					</select>
-				</p>
-			</div>
-			<input type="submit">Start Game!</input>
-		</form>
-	</body>
-</rml>

+ 0 - 20
Samples/pyinvaders/data/window.rml

@@ -1,20 +0,0 @@
-<template name="pywindow" content="content">
-<head>
-	<link type="text/template" href="../../assets/window.rml" />
-	<script>
-import game
-def OnWindowLoad(self):
-	self.owner_document.GetElementById('title').inner_rml = self.title
-	
-def LoadMenu(name):
-	doc = document.context.LoadDocument('data/' + name + '.rml')
-	if doc:
-		doc.Show()
-		document.Close()
-	
-	return doc
-	</script>
-</head>
-<body template="window" onload="OnWindowLoad(self)">
-</body>
-</template>

+ 0 - 40
Samples/pyinvaders/python/autoexec.py

@@ -1,40 +0,0 @@
-import rocket
-
-def Startup():
-	context = rocket.contexts['main']
-	context.LoadDocument('data/background.rml').Show()
-	doc = context.LoadDocument('data/main_menu.rml')
-	doc.Show()
-	
-Startup()
-
-
-class NameDataFormatter(rocket.DataFormatter):
-	def __init__(self):
-		rocket.DataFormatter.__init__(self, "name")
-
-	def FormatData(self, raw_data):
-		""" 
-		Data format:
-		raw_data[0] is the name.
-		raw_data[1] is a bool - True means the name has to be entered. False means the name has been entered already.
-		"""
-		
-		formatted_data = ""
-		
-		if (raw_data[1] == "1"):
-			formatted_data = "<input id=\"player_input\" type=\"text\" name=\"name\" onkeydown=\"OnKeyDown(event)\" />"
-		else:
-			formatted_data = raw_data[0]
-			
-		return formatted_data
-		
-class ShipDataFormatter(rocket.DataFormatter):
-	def __init__(self):
-		rocket.DataFormatter.__init__(self, "ship")
-		
-	def FormatData(self, raw_data):
-		return "<defender style=\"color: rgba(" + raw_data[0] + ");\" />";
-
-name_formatter = NameDataFormatter()
-ship_formatter = ShipDataFormatter()

+ 0 - 1
Samples/pyinvaders/python/rocket.py

@@ -1 +0,0 @@
-../../../bin/rocket.py

+ 0 - 91
Samples/pyinvaders/src/DecoratorDefender.cpp

@@ -1,91 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "DecoratorDefender.h"
-#include <Rocket/Core/Element.h>
-#include <Rocket/Core/Texture.h>
-#include <Rocket/Core/Math.h>
-#include <ShellOpenGL.h>
-
-DecoratorDefender::~DecoratorDefender()
-{
-}
-
-bool DecoratorDefender::Initialise(const Rocket::Core::String& image_source, const Rocket::Core::String& image_path)
-{
-	image_index = LoadTexture(image_source, image_path);
-	if (image_index == -1)
-	{
-		return false;
-	}
-
-	return true;
-}
-
-/// Called on a decorator to generate any required per-element data for a newly decorated element.
-Rocket::Core::DecoratorDataHandle DecoratorDefender::GenerateElementData(Rocket::Core::Element* ROCKET_UNUSED_PARAMETER(element))
-{
-	ROCKET_UNUSED(element);
-
-	return Rocket::Core::Decorator::INVALID_DECORATORDATAHANDLE;
-}
-
-// Called to release element data generated by this decorator.
-void DecoratorDefender::ReleaseElementData(Rocket::Core::DecoratorDataHandle ROCKET_UNUSED_PARAMETER(element_data))
-{
-	ROCKET_UNUSED(element_data);
-}
-
-// Called to render the decorator on an element.
-void DecoratorDefender::RenderElement(Rocket::Core::Element* element, Rocket::Core::DecoratorDataHandle ROCKET_UNUSED_PARAMETER(element_data))
-{
-	ROCKET_UNUSED(element_data);
-
-	Rocket::Core::Vector2f position = element->GetAbsoluteOffset(Rocket::Core::Box::PADDING);
-	Rocket::Core::Vector2f size = element->GetBox().GetSize(Rocket::Core::Box::PADDING);
-
-	glEnable(GL_TEXTURE_2D);
-	glBindTexture(GL_TEXTURE_2D, (GLuint) GetTexture(image_index)->GetHandle(element->GetRenderInterface()));
-	Rocket::Core::Colourb colour = element->GetProperty< Rocket::Core::Colourb >("color");
-	glColor4ubv(element->GetProperty< Rocket::Core::Colourb >("color"));
-	glBegin(GL_QUADS);
-
-		glVertex2f(position.x, position.y);
-		glTexCoord2f(0, 1);
-
-		glVertex2f(position.x, position.y + size.y);
-		glTexCoord2f(1, 1);
-
-		glVertex2f(position.x + size.x, position.y + size.y);
-		glTexCoord2f(1, 0);
-
-		glVertex2f(position.x + size.x, position.y);
-		glTexCoord2f(0, 0);
-
-	glEnd();
-	glColor4ub(255, 255, 255, 255);
-}

+ 0 - 57
Samples/pyinvaders/src/DecoratorDefender.h

@@ -1,57 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSDECORATORDEFENDER_H
-#define ROCKETINVADERSDECORATORDEFENDER_H
-
-#include <Rocket/Core/Decorator.h>
-
-class DecoratorDefender : public Rocket::Core::Decorator
-{
-public:
-	virtual ~DecoratorDefender();
-
-	bool Initialise(const Rocket::Core::String& image_source, const Rocket::Core::String& image_path);
-
-	/// Called on a decorator to generate any required per-element data for a newly decorated element.
-	/// @param element[in] The newly decorated element.
-	/// @return A handle to a decorator-defined data handle, or NULL if none is needed for the element.
-	virtual Rocket::Core::DecoratorDataHandle GenerateElementData(Rocket::Core::Element* element);
-	/// Called to release element data generated by this decorator.
-	/// @param element_data[in] The element data handle to release.
-	virtual void ReleaseElementData(Rocket::Core::DecoratorDataHandle element_data);
-
-	/// Called to render the decorator on an element.
-	/// @param element[in] The element to render the decorator on.
-	/// @param element_data[in] The handle to the data generated by the decorator for the element.
-	virtual void RenderElement(Rocket::Core::Element* element, Rocket::Core::DecoratorDataHandle element_data);
-
-private:
-	int image_index;
-};
-
-#endif

+ 0 - 69
Samples/pyinvaders/src/DecoratorInstancerDefender.cpp

@@ -1,69 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "DecoratorInstancerDefender.h"
-#include <Rocket/Core/Math.h>
-#include <Rocket/Core/String.h>
-#include "DecoratorDefender.h"
-
-DecoratorInstancerDefender::DecoratorInstancerDefender()
-{
-	RegisterProperty("image-src", "").AddParser("string");
-}
-
-DecoratorInstancerDefender::~DecoratorInstancerDefender()
-{
-}
-
-// Instances a decorator given the property tag and attributes from the RCSS file.
-Rocket::Core::Decorator* DecoratorInstancerDefender::InstanceDecorator(const Rocket::Core::String& ROCKET_UNUSED_PARAMETER(name), const Rocket::Core::PropertyDictionary& properties)
-{
-	ROCKET_UNUSED(name);
-
-	const Rocket::Core::Property* image_source_property = properties.GetProperty("image-src");
-	Rocket::Core::String image_source = image_source_property->Get< Rocket::Core::String >();
-
-	DecoratorDefender* decorator = new DecoratorDefender();
-	if (decorator->Initialise(image_source, image_source_property->source))
-		return decorator;
-
-	decorator->RemoveReference();
-	ReleaseDecorator(decorator);
-	return NULL;
-}
-
-// Releases the given decorator.
-void DecoratorInstancerDefender::ReleaseDecorator(Rocket::Core::Decorator* decorator)
-{
-	delete decorator;
-}
-
-// Releases the instancer.
-void DecoratorInstancerDefender::Release()
-{
-	delete this;
-}

+ 0 - 56
Samples/pyinvaders/src/DecoratorInstancerDefender.h

@@ -1,56 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSDECORATORINSTANCERDEFENDER_H
-#define ROCKETINVADERSDECORATORINSTANCERDEFENDER_H
-
-#include <Rocket/Core/DecoratorInstancer.h>
-
-/**
-	@author Robert Curry
- */
-
-class DecoratorInstancerDefender : public Rocket::Core::DecoratorInstancer
-{
-public:
-	DecoratorInstancerDefender();
-	virtual ~DecoratorInstancerDefender();
-
-	/// Instances a decorator given the property tag and attributes from the RCSS file.
-	/// @param[in] name The type of decorator desired. For example, "background-decorator: simple;" is declared as type "simple".
-	/// @param[in] properties All RCSS properties associated with the decorator.
-	/// @return The decorator if it was instanced successful, NULL if an error occured.
-	Rocket::Core::Decorator* InstanceDecorator(const Rocket::Core::String& name, const Rocket::Core::PropertyDictionary& properties);
-	/// Releases the given decorator.
-	/// @param[in] decorator Decorator to release. This is guaranteed to have been constructed by this instancer.
-	void ReleaseDecorator(Rocket::Core::Decorator* decorator);
-
-	/// Releases the instancer.
-	void Release();
-};
-
-#endif

+ 0 - 80
Samples/pyinvaders/src/DecoratorInstancerStarfield.cpp

@@ -1,80 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "DecoratorStarfield.h"
-#include <Rocket/Core/Math.h>
-#include <Rocket/Core/Types.h>
-#include "DecoratorInstancerStarfield.h"
-
-DecoratorInstancerStarfield::DecoratorInstancerStarfield()
-{
-	RegisterProperty("num-layers", "3").AddParser("number");
-	RegisterProperty("top-colour", "#dddc").AddParser("color");
-	RegisterProperty("bottom-colour", "#333c").AddParser("color");
-	RegisterProperty("top-speed", "10.0").AddParser("number");
-	RegisterProperty("bottom-speed", "2.0").AddParser("number");
-	RegisterProperty("top-density", "15").AddParser("number");
-	RegisterProperty("bottom-density", "10").AddParser("number");
-}
-
-DecoratorInstancerStarfield::~DecoratorInstancerStarfield()
-{
-}
-
-// Instances a decorator given the property tag and attributes from the RCSS file.
-Rocket::Core::Decorator* DecoratorInstancerStarfield::InstanceDecorator(const Rocket::Core::String& ROCKET_UNUSED_PARAMETER(name), const Rocket::Core::PropertyDictionary& properties)
-{
-	ROCKET_UNUSED(name);
-
-	int num_layers = Rocket::Core::Math::RealToInteger(properties.GetProperty("num-layers")->Get< float >());
-	Rocket::Core::Colourb top_colour = properties.GetProperty("top-colour")->Get< Rocket::Core::Colourb >();
-	Rocket::Core::Colourb bottom_colour = properties.GetProperty("bottom-colour")->Get< Rocket::Core::Colourb >();
-	float top_speed = properties.GetProperty("top-speed")->Get< float >();
-	float bottom_speed = properties.GetProperty("bottom-speed")->Get< float >();
-	int top_density = Rocket::Core::Math::RealToInteger(properties.GetProperty("top-density")->Get< float >());
-	int bottom_density = Rocket::Core::Math::RealToInteger(properties.GetProperty("bottom-density")->Get< float >());
-
-	DecoratorStarfield* decorator = new DecoratorStarfield();
-	if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density))
-		return decorator;
-
-	decorator->RemoveReference();
-	ReleaseDecorator(decorator);
-	return NULL;
-}
-
-// Releases the given decorator.
-void DecoratorInstancerStarfield::ReleaseDecorator(Rocket::Core::Decorator* decorator)
-{
-	delete decorator;
-}
-
-// Releases the instancer.
-void DecoratorInstancerStarfield::Release()
-{
-	delete this;
-}

+ 0 - 57
Samples/pyinvaders/src/DecoratorInstancerStarfield.h

@@ -1,57 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSDECORATORINSTANCERSTARFIELD_H
-#define ROCKETINVADERSDECORATORINSTANCERSTARFIELD_H
-
-#include <Rocket/Core/DecoratorInstancer.h>
-#include "DecoratorStarfield.h"
-
-/**
-	@author Robert Curry
- */
-
-class DecoratorInstancerStarfield : public Rocket::Core::DecoratorInstancer
-{
-public:
-	DecoratorInstancerStarfield();
-	virtual ~DecoratorInstancerStarfield();
-
-	/// Instances a decorator given the property tag and attributes from the RCSS file.
-	/// @param name The type of decorator desired. For example, "background-decorator: simple;" is declared as type "simple".
-	/// @param properties All RCSS properties associated with the decorator.
-	/// @return The decorator if it was instanced successful, NULL if an error occured.
-	Rocket::Core::Decorator* InstanceDecorator(const Rocket::Core::String& name, const Rocket::Core::PropertyDictionary& properties);
-	/// Releases the given decorator.
-	/// @param decorator Decorator to release. This is guaranteed to have been constructed by this instancer.
-	void ReleaseDecorator(Rocket::Core::Decorator* decorator);
-
-	/// Releases the instancer.
-	void Release();
-};
-
-#endif

+ 0 - 147
Samples/pyinvaders/src/DecoratorStarfield.cpp

@@ -1,147 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "DecoratorStarfield.h"
-#include <Rocket/Core/Math.h>
-#include <Rocket/Core/Element.h>
-#include <Shell.h>
-#include <ShellOpenGL.h>
-#include "GameDetails.h"
-
-float last_update_time = 0.0f;
-
-DecoratorStarfield::~DecoratorStarfield()
-{
-}
-
-bool DecoratorStarfield::Initialise(int _num_layers, const Rocket::Core::Colourb& _top_colour, const Rocket::Core::Colourb& _bottom_colour, float _top_speed, float _bottom_speed, int _top_density, int _bottom_density)
-{
-	num_layers = _num_layers;
-	top_colour = _top_colour;
-	bottom_colour = _bottom_colour;
-	top_speed = _top_speed;
-	bottom_speed = _bottom_speed;
-	top_density = _top_density;
-	bottom_density = _bottom_density;
-
-	return true;
-}
-
-/// Called on a decorator to generate any required per-element data for a newly decorated element.
-Rocket::Core::DecoratorDataHandle DecoratorStarfield::GenerateElementData(Rocket::Core::Element* element)
-{
-	StarField* star_field = new StarField();
-
-	star_field->star_layers.resize(num_layers);
-
-	for (int i = 0; i < num_layers; i++)
-	{
-		float layer_depth = i / (float)num_layers;
-
-		int density = Rocket::Core::Math::RealToInteger((top_density * layer_depth) + (bottom_density * (1.0f - layer_depth)));
-		star_field->star_layers[i].stars.resize(density);
-
-		Rocket::Core::Colourb colour = (top_colour * layer_depth) + (bottom_colour * (1.0f - layer_depth));
-		star_field->star_layers[i].colour = colour;
-
-		float speed = (top_speed * layer_depth) + (bottom_speed * (1.0f - layer_depth));
-		star_field->star_layers[i].speed = speed;
-
-		star_field->dimensions = element->GetBox().GetSize(Rocket::Core::Box::PADDING);
-
-		if (star_field->dimensions.x > 0)
-		{
-			for (int j = 0; j < density; j++)
-			{
-				star_field->star_layers[i].stars[j].x = (float) Rocket::Core::Math::RandomReal(star_field->dimensions.x);
-				star_field->star_layers[i].stars[j].y = (float) Rocket::Core::Math::RandomReal(star_field->dimensions.y);
-			}
-		}
-
-		star_field->last_update = Shell::GetElapsedTime();
-	}
-
-	return reinterpret_cast<Rocket::Core::DecoratorDataHandle>(star_field);
-}
-
-// Called to release element data generated by this decorator.
-void DecoratorStarfield::ReleaseElementData(Rocket::Core::DecoratorDataHandle element_data)
-{
-	delete (StarField*)element_data;
-}
-
-// Called to render the decorator on an element.
-void DecoratorStarfield::RenderElement(Rocket::Core::Element* ROCKET_UNUSED_PARAMETER(element), Rocket::Core::DecoratorDataHandle element_data)
-{
-	ROCKET_UNUSED(element);
-
-	StarField* star_field = (StarField*)element_data;
-	star_field->Update();
-
-	glDisable(GL_TEXTURE_2D);
-	glPointSize(2);
-	glBegin(GL_POINTS);
-
-	for (size_t i = 0; i < star_field->star_layers.size(); i++)
-	{
-		glColor4ubv(star_field->star_layers[i].colour);
-		
-		for (size_t j = 0; j < star_field->star_layers[i].stars.size(); j++)
-		{
-			glVertex2f(star_field->star_layers[i].stars[j].x, star_field->star_layers[i].stars[j].y);
-		}
-	}
-
-	glEnd();
-
-	glColor4ub(255, 255, 255, 255);
-}
-
-void DecoratorStarfield::StarField::Update()
-{
-	float time = Shell::GetElapsedTime();
-	float delta_time = time - last_update;
-	last_update = time;
-
-	if (!GameDetails::GetPaused())
-	{
-		for (size_t i = 0; i < star_layers.size(); i++)
-		{
-			float movement = star_layers[i].speed * delta_time;
-
-			for (size_t j = 0; j < star_layers[i].stars.size(); j++)
-			{
-				star_layers[i].stars[j].y += movement;
-				if (star_layers[i].stars[j].y > dimensions.y)
-				{
-					star_layers[i].stars[j].y = 0;
-					star_layers[i].stars[j].x = Rocket::Core::Math::RandomReal(dimensions.x);
-				}
-			}
-		}
-	}
-}

+ 0 - 82
Samples/pyinvaders/src/DecoratorStarfield.h

@@ -1,82 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSDECORATORSTARFIELD_H
-#define ROCKETINVADERSDECORATORSTARFIELD_H
-
-#include <Rocket/Core/Decorator.h>
-#include <vector>
-
-class DecoratorStarfield : public Rocket::Core::Decorator
-{
-public:
-	virtual ~DecoratorStarfield();
-
-	bool Initialise(int num_layers, const Rocket::Core::Colourb& top_colour, const Rocket::Core::Colourb& bottom_colour, float top_speed, float bottom_speed, int top_density, int bottom_density);
-
-	/// Called on a decorator to generate any required per-element data for a newly decorated element.
-	/// @param[in] element The newly decorated element.
-	/// @return A handle to a decorator-defined data handle, or NULL if none is needed for the element.
-	virtual Rocket::Core::DecoratorDataHandle GenerateElementData(Rocket::Core::Element* element);
-	/// Called to release element data generated by this decorator.
-	/// @param[in] element_data The element data handle to release.
-	virtual void ReleaseElementData(Rocket::Core::DecoratorDataHandle element_data);
-
-	/// Called to render the decorator on an element.
-	/// @param[in] element The element to render the decorator on.
-	/// @param[in] element_data The handle to the data generated by the decorator for the element.
-	virtual void RenderElement(Rocket::Core::Element* element, Rocket::Core::DecoratorDataHandle element_data);
-
-private:
-	int num_layers;
-	Rocket::Core::Colourb top_colour;
-	Rocket::Core::Colourb bottom_colour;
-	float top_speed;
-	float bottom_speed;
-	int top_density;
-	int bottom_density;
-
-	struct StarLayer
-	{
-		typedef std::vector< Rocket::Core::Vector2f > StarList;
-		StarList stars;
-		Rocket::Core::Colourb colour;
-		float speed;
-	};
-
-	struct StarField
-	{
-		void Update();
-		float last_update;
-		Rocket::Core::Vector2f dimensions;
-
-		typedef std::vector< StarLayer > StarLayerList;
-		StarLayerList star_layers;
-	};
-};
-
-#endif

+ 0 - 182
Samples/pyinvaders/src/Defender.cpp

@@ -1,182 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "Defender.h"
-#include <Shell.h>
-#include <ShellOpenGL.h>
-#include "Game.h"
-#include "GameDetails.h"
-#include "Invader.h"
-#include "Mothership.h"
-#include "Shield.h"
-#include "Sprite.h"
-
-const float UPDATE_FREQ = 0.01f;
-const float MOVEMENT_SPEED = 15;
-const float BULLET_SPEED = 15;
-const int SPRITE_WIDTH = 64;
-const float RESPAWN_TIME = 1.0f;
-
-Sprite defender_sprite(Rocket::Core::Vector2f(60, 31), Rocket::Core::Vector2f(0, 0.5), Rocket::Core::Vector2f(0.23437500, 0.98437500));
-Sprite bullet_sprite(Rocket::Core::Vector2f(4, 20), Rocket::Core::Vector2f(0.4921875, 0.515625), Rocket::Core::Vector2f(0.5078125, 0.828125));
-Sprite explosion_sprite(Rocket::Core::Vector2f(52, 28), Rocket::Core::Vector2f(0.71484375f, 0.51562500f), Rocket::Core::Vector2f(0.91796875f, 0.95312500f));
-
-Defender::Defender(Game* _game)
-{
-	move_direction = 0;
-	defender_frame_start = 0;
-	bullet_in_flight = false;
-	game = _game;
-	position.x = game->GetWindowDimensions().x / 2;
-	position.y = game->GetWindowDimensions().y - 50;
-	state = ALIVE;
-	render = true;
-}
-	
-Defender::~Defender()
-{
-}
-
-void Defender::Update()
-{
-	if (Shell::GetElapsedTime() - defender_frame_start < UPDATE_FREQ)
-		return;
-	
-	defender_frame_start = Shell::GetElapsedTime();	
-
-	position.x += (move_direction * MOVEMENT_SPEED);
-
-	if (position.x < 5)
-		position.x = 5;
-	else if (position.x > (game->GetWindowDimensions().x - SPRITE_WIDTH - 5))
-		position.x = game->GetWindowDimensions().x - SPRITE_WIDTH - 5;
-
-	// Update the bullet
-	if (bullet_in_flight)
-	{
-		// Move it up and mark it dead if it flies off the top of the screen
-		bullet_position.y -= BULLET_SPEED;
-		if (bullet_position.y < 0)
-			bullet_in_flight = false;
-	}
-
-	if (state == RESPAWN)
-	{	
-		// Switch the render flag so the defender "flickers"
-		render = !render;
-
-		// Check if we should switch back to our alive state
-		if (Shell::GetElapsedTime() - respawn_start > RESPAWN_TIME)
-		{
-			state = ALIVE;
-			render = true;
-		}		
-	}
-}
-
-void Defender::Render()
-{
-	glColor4ubv(GameDetails::GetDefenderColour());
-
-	// Render our sprite if rendering is enabled
-	if (render)
-		defender_sprite.Render(Rocket::Core::Vector2f(position.x, position.y));
-
-	// Update the bullet, doing collision detection
-	if (bullet_in_flight)
-	{
-		bullet_sprite.Render(Rocket::Core::Vector2f(bullet_position.x, bullet_position.y));
-
-		// Check if we hit the shields
-		for (int i = 0; i < game->GetNumShields(); i++)
-		{
-			if (game->GetShield(i)->CheckHit(bullet_position))
-			{
-				bullet_in_flight = false;
-				break;
-			}
-		}
-
-		if (bullet_in_flight)
-		{
-			for (int i = 0; i < game->GetNumInvaders(); i++)
-			{
-				if (game->GetInvader(i)->CheckHit(bullet_position))
-				{
-					bullet_in_flight = false;
-					break;
-				}
-			}
-		}
-	}
-
-	glColor4ub(255, 255, 255, 255);
-}
-
-void Defender::StartMove(float direction)
-{
-	move_direction = direction > 0.0f ? 1.0f : -1.0f;
-}
-
-void Defender::StopMove(float direction)
-{
-	float stop_direction = direction > 0.0f ? 1.0f : -1.0f;
-	if (stop_direction == move_direction)
-		move_direction = 0.0f;
-}
-
-void Defender::Fire()
-{
-	if (!bullet_in_flight)
-	{
-		bullet_position = position + Rocket::Core::Vector2f((SPRITE_WIDTH/2) - 4, 0);
-		bullet_in_flight = true;
-	}
-}
-
-bool Defender::CheckHit(const Rocket::Core::Vector2f& check_position)
-{	
-	float sprite_width = defender_sprite.dimensions.x;
-	float sprite_height = defender_sprite.dimensions.y;
-
-	// If the position is within our bounds, set ourselves
-	// as exploding and return a valid hit.
-	if (state == ALIVE
-		&& check_position.x >= position.x
-		&& check_position.x <= position.x + sprite_width
-		&& check_position.y >= position.y
-		&& check_position.y <= position.y + sprite_height)
-	{
-		game->RemoveLife();
-		state = RESPAWN;
-		respawn_start = Shell::GetElapsedTime();
-
-		return true;
-	}	
-
-	return false;
-}

+ 0 - 81
Samples/pyinvaders/src/Defender.h

@@ -1,81 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSDEFENDER_H
-#define ROCKETINVADERSDEFENDER_H
-
-#include <Rocket/Core/Types.h>
-
-class Game;
-class Sprite;
-
-/**
-	Represents the Earth defender. Stores position and performs the update of the bullet position and collision detection.
-	@author Lloyd Weehuizen
- */
-
-class Defender
-{
-public:
-	Defender(Game* game);
-	~Defender();
-
-	/// Update the defender state.
-	void Update();
-	/// Render the defender.
-	void Render();
-
-	/// Move the defender left.
-	void StartMove(float direction);	
-	/// Stop the movement.
-	void StopMove(float direction);
-	/// Fire a bullet (if one isn't already in flight).
-	void Fire();	
-
-	/// Check if an object at the given position would hit the defender.
-	bool CheckHit(const Rocket::Core::Vector2f& position);
-
-private:
-	Game* game;
-	Rocket::Core::Vector2f position;	
-	
-	float move_direction;
-	
-	bool bullet_in_flight;
-	Rocket::Core::Vector2f bullet_position;
-
-	float defender_frame_start;
-	float respawn_start;
-
-	bool render;
-
-	enum State { ALIVE, RESPAWN };
-	State state;
-};
-
-
-#endif

+ 0 - 114
Samples/pyinvaders/src/ElementGame.cpp

@@ -1,114 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include <Rocket/Core/Python/Python.h>
-
-#include "ElementGame.h"
-#include <Rocket/Core/ElementDocument.h>
-#include <Rocket/Core/Input.h>
-#include <Rocket/Core/Factory.h>
-#include <Rocket/Core/Python/ElementInstancer.h>
-#include <Rocket/Core/Python/ElementWrapper.h>
-#include "Defender.h"
-#include "Game.h"
-
-ElementGame::ElementGame(const Rocket::Core::String& tag) : Rocket::Core::Element(tag)
-{
-	game = new Game();
-}
-
-ElementGame::~ElementGame()
-{		
-	delete game;
-}
-
-void ElementGame::InitialisePythonInterface()
-{
-	PyObject* object = python::class_<ElementGame, Rocket::Core::Python::ElementWrapper<ElementGame>, python::bases<Rocket::Core::Element>, boost::noncopyable >("ElementGame", python::init<const char*>())
-		.ptr();
-
-	Rocket::Core::Factory::RegisterElementInstancer("game", new Rocket::Core::Python::ElementInstancer(object))->RemoveReference();
-}
-
-// Intercepts and handles key events.
-void ElementGame::ProcessEvent(Rocket::Core::Event& event)
-{
-	Rocket::Core::Element::ProcessEvent(event);
-
-	if (event == "keydown" ||
-		event == "keyup")
-	{
-		bool key_down = event == "keydown";
-		Rocket::Core::Input::KeyIdentifier key_identifier = (Rocket::Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0);		
-
-		// Process left and right keys
-		if (key_down)
-		{
-			if (key_identifier == Rocket::Core::Input::KI_LEFT)
-				game->GetDefender()->StartMove(-1.0f);
-			if (key_identifier == Rocket::Core::Input::KI_RIGHT)
-				game->GetDefender()->StartMove(1.0f);
-			if (key_identifier == Rocket::Core::Input::KI_SPACE)
-				game->GetDefender()->Fire();
-		}		
-		else if (!key_down)
-		{
-			if (key_identifier == Rocket::Core::Input::KI_LEFT)
-				game->GetDefender()->StopMove(-1.0f);
-			if (key_identifier == Rocket::Core::Input::KI_RIGHT)
-				game->GetDefender()->StopMove(1.0f);				
-		}
-	}
-
-	if (event == "load")
-	{
-		game->Initialise();
-	}
-}
-
-// Updates the game.
-void ElementGame::OnUpdate()
-{
-	game->Update();
-
-	if (game->IsGameOver())
-		DispatchEvent("gameover", Rocket::Core::Dictionary(), false);
-}
-
-// Renders the game.
-void ElementGame::OnRender()
-{
-	game->Render();
-}
-
-void ElementGame::OnChildAdd(Rocket::Core::Element* element)
-{
-	Rocket::Core::Element::OnChildAdd(element);
-
-	if (element == this)
-		GetOwnerDocument()->AddEventListener("load", this);
-}

+ 0 - 67
Samples/pyinvaders/src/ElementGame.h

@@ -1,67 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSELEMENTGAME_H
-#define ROCKETINVADERSELEMENTGAME_H
-
-#include <Rocket/Core/Element.h>
-#include <Rocket/Core/EventListener.h>
-
-class Game;
-
-/**
-	@author Peter Curry
- */
-
-class ElementGame : public Rocket::Core::Element, public Rocket::Core::EventListener
-{
-public:
-	ElementGame(const Rocket::Core::String& tag);
-	virtual ~ElementGame();
-
-	/// Initialises the python interface and registers the serialiser
-	static void InitialisePythonInterface();
-
-	/// Intercepts and handles key events.
-	void ProcessEvent(Rocket::Core::Event& event);
-
-	/// Receive notifications when child elements are added
-	/// This will only get called when we're added to the tree,
-	/// which allows us to bind to onload
-	void OnChildAdd(Rocket::Core::Element* element);
-
-protected:
-	/// Updates the game.
-	virtual void OnUpdate();
-	/// Renders the game.
-	virtual void OnRender();
-
-private:
-	Game* game;
-};
-
-#endif

+ 0 - 444
Samples/pyinvaders/src/Game.cpp

@@ -1,444 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "Game.h"
-#include <Rocket/Core.h>
-#include <Shell.h>
-#include <ShellOpenGL.h>
-#include "Defender.h"
-#include "GameDetails.h"
-#include "HighScores.h"
-#include "Invader.h"
-#include "Mothership.h"
-#include "Shield.h"
-
-const int WINDOW_WIDTH = 1024;
-const int WINDOW_HEIGHT = 768;
-
-const int NUM_LIVES = 3;
-
-const int NUM_INVADER_ROWS = 5;
-const int NUM_INVADERS_PER_ROW = 11;
-const int NUM_INVADERS = (NUM_INVADER_ROWS * NUM_INVADERS_PER_ROW);
-const int INVADER_SPACING_X = 64;
-const int INVADER_SPACING_Y = 48;
-const int INVADER_START_Y = 96;
-
-const float INVADER_MOVEMENT = 10;
-const float INVADER_UPDATE_MODIFIER = 0.7f;
-
-const int MOTHERSHIP = NUM_INVADERS;
-
-const int NUM_SHIELD_ARRAYS = 4;
-const int NUM_SHIELDS_PER_ARRAY = 10;
-const int NUM_SHIELDS = (NUM_SHIELD_ARRAYS * NUM_SHIELDS_PER_ARRAY);
-const int SHIELD_SIZE = (NUM_SHIELD_CELLS * PIXEL_SIZE);
-const int SHIELD_SPACING_X = 192;
-const int SHIELD_START_X = 176;
-const int SHIELD_START_Y = 600;
-
-// The game's element context (declared in main.cpp).
-extern Rocket::Core::Context* context;
-
-Game::Game()
-{
-	invader_frame_start = 0;
-	defender_lives = 3;	
-	game_over = false;
-	current_invader_direction = 1.0f;	
-	invaders = new Invader*[NUM_INVADERS + 1];
-	for (int i = 0; i < NUM_INVADERS + 1; i++)
-		invaders[i] = NULL;	
-
-	shields = new Shield*[NUM_SHIELDS];
-	for (int i = 0; i < NUM_SHIELDS; i++)
-		shields[i] = NULL;
-
-	// Use the OpenGL render interface to load our texture.
-	Rocket::Core::Vector2i texture_dimensions;
-	Rocket::Core::GetRenderInterface()->LoadTexture(texture, texture_dimensions, "data/invaders.tga");
-
-	defender = new Defender(this);
-}
-
-Game::~Game()
-{
-	delete defender;
-
-	for (int i = 0; i < NUM_INVADERS + 1; i++)
-		delete invaders[i];
-
-	delete [] invaders;	
-
-	for (int i = 0; i < NUM_SHIELDS; i++)
-		delete shields[i];
-
-	delete [] shields;
-}
-
-void Game::Initialise()
-{
-	// Initialise the scores and wave information
-	SetScore(0);
-	SetWave(1);
-	SetHighScore(HighScores::GetHighScore());
-	SetLives(NUM_LIVES);
-
-	// Initialise the shields.
-	InitialiseShields();
-
-	// Create a new wave
-	InitialiseWave();
-}
-
-void Game::Update()
-{
-	if (!GameDetails::GetPaused())
-	{
-		if (defender_lives <= 0)
-			return;
-
-		// Determine if we should advance the invaders
-		if (Shell::GetElapsedTime() - invader_frame_start >= invader_move_freq)
-		{
-			MoveInvaders();		
-
-			invader_frame_start = Shell::GetElapsedTime();
-		}
-
-		// Update all invaders
-		for (int i = 0; i < NUM_INVADERS + 1; i++)
-			invaders[i]->Update();	
-
-		defender->Update();
-	}
-}
-
-void Game::Render()
-{	
-	if (defender_lives <= 0)
-		return;
-
-	// Render all available shields
-	for (int i = 0; i < NUM_SHIELDS; i++)
-	{
-		shields[i]->Render();
-	}
-
-	glEnable(GL_TEXTURE_2D);
-	glBindTexture(GL_TEXTURE_2D, (GLuint) texture);
-	glColor4ub(255, 255, 255, 255);
-	glBegin(GL_QUADS);
-
-	// Render all available invaders
-	for (int i = 0; i < NUM_INVADERS + 1; i++)
-	{
-		invaders[i]->Render();
-	}
-	
-	defender->Render();
-
-	glEnd();
-}
-
-Defender* Game::GetDefender()
-{
-	return defender;
-}
-
-Invader* Game::GetInvader(int index)
-{
-	return invaders[index];
-}
-
-int Game::GetNumInvaders()
-{
-	return NUM_INVADERS + 1;
-}
-
-bool Game::CanDropBomb(int index)
-{
-	// Determines if the given invader can drop a bomb by checking if theres any other invaders under it
-	int y = (index / NUM_INVADERS_PER_ROW);
-	int x = index - (y * NUM_INVADERS_PER_ROW);
-
-	// The mothership can never drop bombs
-	if (index == MOTHERSHIP)
-		return false;
-
-	// Check each row under the given invader to see if there is space
-	for (int i = y + 1; i < NUM_INVADER_ROWS; i++)
-	{
-		if (invaders[(i * NUM_INVADERS_PER_ROW) + x]->GetState() == Invader::ALIVE)
-			return false;
-	}
-
-	return true;
-}
-
-// Access the shields.
-Shield* Game::GetShield(int index)
-{
-	return shields[index];
-}
-
-// Get the total number of shields
-int Game::GetNumShields()
-{
-	return NUM_SHIELDS;
-}
-
-// Adds a score onto the player's score.
-void Game::AddScore(int score)
-{
-	SetScore(GameDetails::GetScore() + score);
-}
-
-// Sets the player's score.
-void Game::SetScore(int score)
-{
-	GameDetails::SetScore(score);
-
-	Rocket::Core::Element* score_element = context->GetDocument("game_window")->GetElementById("score");
-	if (score_element != NULL)
-		score_element->SetInnerRML(Rocket::Core::String(128, "%d", score).CString());
-
-	// Update the high score if we've beaten it.
-	if (score > HighScores::GetHighScore())
-		SetHighScore(score);
-}
-
-// Sets the player's high-score.
-void Game::SetHighScore(int score)
-{
-	Rocket::Core::Element* high_score_element = context->GetDocument("game_window")->GetElementById("hiscore");
-	if (high_score_element != NULL)
-		high_score_element->SetInnerRML(Rocket::Core::String(128, "%d", score).CString());
-}
-
-void Game::SetLives(int lives)
-{
-	defender_lives = lives;
-
-	Rocket::Core::Element* score_element = context->GetDocument("game_window")->GetElementById("lives");
-	if (score_element != NULL)
-		score_element->SetInnerRML(Rocket::Core::String(128, "%d", defender_lives).CString());
-}
-
-void Game::SetWave(int wave)
-{
-	GameDetails::SetWave(wave);
-
-	Rocket::Core::Element* waves_element = context->GetDocument("game_window")->GetElementById("waves");
-	if (waves_element != NULL)
-		waves_element->SetInnerRML(Rocket::Core::String(128, "%d", wave).CString());
-}
-
-void Game::RemoveLife()
-{	
-	if (defender_lives > 0)
-	{
-		SetLives(defender_lives - 1);
-
-		if (defender_lives == 0)
-		{
-			OnGameOver();
-		}
-	}
-}
-
-bool Game::IsGameOver() const
-{
-	return game_over;
-}
-
-const Rocket::Core::Vector2f Game::GetWindowDimensions()
-{
-	return Rocket::Core::Vector2f((float) WINDOW_WIDTH, (float) WINDOW_HEIGHT);
-}
-
-void Game::MoveInvaders()
-{
-	Rocket::Core::Vector2f new_positions[NUM_INVADERS];
-
-	// We loop through all invaders, calculating their new positions, if any of them go over the screen bounds,
-	// then we switch direction, move the invaders down and start at 0 again
-	for (int i = 0; i < NUM_INVADERS; i++)
-	{
-		if (invaders[i]->GetState() == Invader::DEAD)
-			continue;
-
-		new_positions[i] = invaders[i]->GetPosition();
-		new_positions[i].x += INVADER_MOVEMENT * current_invader_direction;
-		if (new_positions[i].x < 0 || new_positions[i].x + INVADER_SPACING_X > WINDOW_WIDTH)
-		{
-			// Switch direction and start back at 0 (-1 as the for loop increments)
-			current_invader_direction *= -1.0f;
-			i = -1;
-
-			// Move all invaders down
-			for (int j = 0; j < NUM_INVADERS; j++)
-			{
-				if (invaders[j]->GetState() == Invader::DEAD)
-					continue;
-
-				Rocket::Core::Vector2f position = invaders[j]->GetPosition();
-				position.y += INVADER_SPACING_Y;
-				invaders[j]->SetPosition(position);
-			}
-
-			// Increase speed of invaders
-			invader_move_freq *= INVADER_UPDATE_MODIFIER;			
-		}
-	}
-
-	// Assign invaders their new position and advance their animation frame
-	bool invaders_alive = false;
-
-	for (int i = 0; i < NUM_INVADERS; i++)
-	{
-		if (invaders[i]->GetState() == Invader::DEAD)
-			continue;
-
-		invaders[i]->SetPosition(new_positions[i]);
-		invaders[i]->UpdateAnimation();
-
-		// If an invader hits the bottom, instant death
-		if (new_positions[i].y >= GetWindowDimensions().y - INVADER_SPACING_Y)
-		{
-			OnGameOver();
-			return;
-		}
-
-		invaders_alive = true;
-	}
-
-	if (!invaders_alive)
-	{
-		SetWave(GameDetails::GetWave() + 1);
-		InitialiseWave();
-	}
-}
-
-void Game::OnGameOver()
-{
-	// Set lives to zero and continue to the high scores
-	defender_lives = 0;
-	game_over = true;
-}
-
-void Game::InitialiseShields()
-{
-	Rocket::Core::Vector2f shield_array_start_position((float) SHIELD_START_X, (float) SHIELD_START_Y);
-
-	for (int x = 0; x < NUM_SHIELD_ARRAYS; x++)
-	{
-		// Top row (row of 4)
-		for (int i = 0; i < 4; i++)
-		{
-			Shield::ShieldType type = Shield::REGULAR;
-			if (i == 0)
-				type = Shield::TOP_LEFT;
-			else if (i == 3)
-			{
-				type = Shield::TOP_RIGHT;
-			}
-
-			shields[(x * NUM_SHIELDS_PER_ARRAY) + i] = new Shield(this, type);
-			shields[(x * NUM_SHIELDS_PER_ARRAY) + i]->SetPosition(shield_array_start_position + Rocket::Core::Vector2f((float) SHIELD_SIZE * i, 0));
-		}
-
-		// Middle row (row of 4)
-		for (int i = 0; i < 4; i++)
-		{
-			
-			Shield::ShieldType type = Shield::REGULAR;
-			if (i == 1)
-				type = Shield::BOTTOM_RIGHT;
-			else if (i == 2)
-			{
-				type = Shield::BOTTOM_LEFT;
-			}
-
-			shields[(x * NUM_SHIELDS_PER_ARRAY) + 4 + i] = new Shield(this, type);
-			shields[(x * NUM_SHIELDS_PER_ARRAY) + 4 + i]->SetPosition(shield_array_start_position + Rocket::Core::Vector2f((float) SHIELD_SIZE * i, (float) SHIELD_SIZE));
-		}
-
-		// Bottom row (2, one on each end)
-		shields[(x * NUM_SHIELDS_PER_ARRAY) + 8] = new Shield(this, Shield::REGULAR);
-		shields[(x * NUM_SHIELDS_PER_ARRAY) + 8]->SetPosition(shield_array_start_position + Rocket::Core::Vector2f(0, (float) SHIELD_SIZE * 2));
-
-		shields[(x * NUM_SHIELDS_PER_ARRAY) + 9] = new Shield(this, Shield::REGULAR);
-		shields[(x * NUM_SHIELDS_PER_ARRAY) + 9]->SetPosition(shield_array_start_position + Rocket::Core::Vector2f((float) SHIELD_SIZE * 3, (float) SHIELD_SIZE * 2));
-
-		shield_array_start_position.x += SHIELD_SPACING_X;
-	}
-}
-
-void Game::InitialiseWave()
-{
-	// Set up the rows
-	for (int y = 0; y < NUM_INVADER_ROWS; y++)
-	{
-		// Determine invader type
-		Invader::InvaderType type = Invader::UNKNOWN;
-		switch (y)
-		{
-		case 0:
-			type = Invader::RANK3; break;
-		case 1:
-		case 2:		
-			type = Invader::RANK2; break;
-		default:
-			type = Invader::RANK1; break;
-		}
-
-		// Determine position of top left invader
-		Rocket::Core::Vector2f invader_position((float) (WINDOW_WIDTH - (NUM_INVADERS_PER_ROW * INVADER_SPACING_X)) / 2, (float) (INVADER_START_Y + (y * INVADER_SPACING_Y)));
-	
-		for (int x = 0; x < NUM_INVADERS_PER_ROW; x++)
-		{
-			// Determine invader type based on row position
-			int index = (y * NUM_INVADERS_PER_ROW) + x;
-
-			delete invaders[index];
-			invaders[index] = new Invader(this, type, (y * NUM_INVADERS_PER_ROW) + x);			
-			invaders[index]->SetPosition(invader_position);			
-
-			// Increase invader position
-			invader_position.x += INVADER_SPACING_X;
-		}
-	}
-
-	// Reset mother ship
-	delete invaders[MOTHERSHIP];
-	invaders[MOTHERSHIP] = new Mothership(this, MOTHERSHIP);
-
-	// Update the move frequency	
-	invader_move_freq = ((((float)GameDetails::GetWave())-100.0f)/140.0f);
-	invader_move_freq *= invader_move_freq;
-}

+ 0 - 128
Samples/pyinvaders/src/Game.h

@@ -1,128 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSGAME_H
-#define ROCKETINVADERSGAME_H
-
-#include <Rocket/Core/Types.h>
-#include <Rocket/Core/Texture.h>
-
-class Shield;
-class Invader;
-class Defender;
-class Mothership;
-
-/**
-	Runs the game.
-	- Updates the Invader positions, animations and bombs.
-	- Updates the player position and bullets
-
-	@author Lloyd Weehuizen
- */
-
-class Game
-{
-public:
-	Game();
-	~Game();
-
-	/// Initialise a new game
-	void Initialise();
-
-	/// Update the game
-	void Update();
-
-	/// Render the game
-	void Render();
-
-	/// Access the defender
-	Defender* GetDefender();
-	/// Access the invaders
-	Invader* GetInvader(int index);
-	/// Get the total number of invaders
-	int GetNumInvaders();
-
-	/// Returns true if the given invader can drop bomb
-	bool CanDropBomb(int invader_index);
-
-	/// Access the shields.
-	Shield* GetShield(int index);
-	/// Get the total number of shields
-	int GetNumShields();
-
-	/// Adds a score onto the player's score.
-	void AddScore(int score);
-	/// Sets the player's score.
-	void SetScore(int score);
-	/// Sets the player's high-score.
-	void SetHighScore(int score);
-	/// Set the number of defender lives.
-	void SetLives(int lives);
-	/// Set the current wave
-	void SetWave(int wave);
-	/// Remove a defender life
-	void RemoveLife();
-	/// Checks if the game is over
-	bool IsGameOver() const;
-
-	/// Get the dimensions of the game window.
-	const Rocket::Core::Vector2f GetWindowDimensions();	
-
-private:
-
-	// The current invaders
-	Invader** invaders;
-	// The direction they're moving
-	float current_invader_direction;
-	// Time of the last invader update
-	Rocket::Core::Time invader_frame_start;
-	// How often the invaders move
-	Rocket::Core::Time invader_move_freq;
-	// Is the game over
-	bool game_over;
-
-	// Helper function to move the invaders
-	void MoveInvaders();
-
-	// Our current defener
-	Defender* defender;
-
-	// Number of lives the defender has left
-	int defender_lives;
-
-	// The current shields
-	Shield** shields;
-
-	// Texture that contains the sprites
-	Rocket::Core::TextureHandle texture;
-
-	void InitialiseShields();
-	void InitialiseWave();
-	void OnGameOver();
-};
-
-#endif

+ 0 - 148
Samples/pyinvaders/src/GameDetails.cpp

@@ -1,148 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "GameDetails.h"
-
-static GameDetails::Difficulty difficulty = GameDetails::EASY;
-static Rocket::Core::Colourb colour = Rocket::Core::Colourb(255, 0, 0);
-static int score = -1;
-static int wave = 0;
-static bool paused = false;
-
-static GameDetails::GraphicsQuality graphics_quality = GameDetails::OK;
-static bool reverb = true;
-static bool spatialisation = false;
-
-GameDetails::GameDetails()
-{
-}
-
-GameDetails::~GameDetails()
-{
-}
-
-// Sets the game difficulty.
-void GameDetails::SetDifficulty(Difficulty _difficulty)
-{
-	difficulty = _difficulty;
-}
-
-// Returns the game difficulty.
-GameDetails::Difficulty GameDetails::GetDifficulty()
-{
-	return difficulty;
-}
-
-// Sets the colour of the player's ship.
-void GameDetails::SetDefenderColour(const Rocket::Core::Colourb& _colour)
-{
-	colour = _colour;
-}
-
-// Returns the player's ship colour.
-const Rocket::Core::Colourb& GameDetails::GetDefenderColour()
-{
-	return colour;
-}
-
-// Sets the score the player achieved in the last game.
-void GameDetails::SetScore(int _score)
-{
-	score = _score;
-}
-
-// Resets the player's score.
-void GameDetails::ResetScore()
-{
-	score = -1;
-}
-
-// Returns the score the player achieved in the last game.
-int GameDetails::GetScore()
-{
-	return score;
-}
-
-// Set the current wave number
-void GameDetails::SetWave(int _wave)
-{
-	wave = _wave;
-}
-
-// Get the current wave number
-int GameDetails::GetWave()
-{
-	return wave;
-}
-
-// Sets the pauses state of the game
-void GameDetails::SetPaused(bool _paused)
-{
-	paused = _paused;
-}
-
-// Gets if the game is paused or not
-bool GameDetails::GetPaused()
-{
-	return paused;
-}
-
-// Sets the quality of the graphics used in-game.
-void GameDetails::SetGraphicsQuality(GraphicsQuality quality)
-{
-	graphics_quality = quality;
-}
-
-// Returns the quality of the graphics to use in-game.
-GameDetails::GraphicsQuality GameDetails::GetGraphicsQuality()
-{
-	return graphics_quality;
-}
-
-// Enables or disables reverb.
-void GameDetails::SetReverb(bool enabled)
-{
-	reverb = enabled;
-}
-
-// Returns the current state of reverb.
-bool GameDetails::GetReverb()
-{
-	return reverb;
-}
-
-// Enables or disables 3D spatialisation in the audio engine.
-void GameDetails::Set3DSpatialisation(bool enabled)
-{
-	spatialisation = enabled;
-}
-
-// Returns the current state of audio spatialisation.
-bool GameDetails::Get3DSpatialisation()
-{
-	return spatialisation;
-}

+ 0 - 107
Samples/pyinvaders/src/GameDetails.h

@@ -1,107 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSGAMEDETAILS_H
-#define ROCKETINVADERSGAMEDETAILS_H
-
-#include <Rocket/Core/Types.h>
-
-/**
-	@author Peter Curry
- */
-
-class GameDetails
-{
-public:
-	enum Difficulty { EASY, HARD };
-
-	/// Sets the game difficulty.
-	/// @param[in] difficulty The new game difficulty.
-	static void SetDifficulty(Difficulty difficulty);
-	/// Returns the game difficulty.
-	/// @return The current game difficulty.
-	static Difficulty GetDifficulty();
-
-	/// Sets the colour of the player's ship.
-	/// @param[in] colour The new ship colour.
-	static void SetDefenderColour(const Rocket::Core::Colourb& colour);
-	/// Returns the player's ship colour.
-	/// @return The colour of the player's ship.
-	static const Rocket::Core::Colourb& GetDefenderColour();
-
-	/// Sets the score the player achieved in the last game.
-	/// @param[in] score The player's score.
-	static void SetScore(int score);
-	/// Resets the player's score.
-	static void ResetScore();
-	/// Returns the score the player achieved in the last game.
-	/// @return The player's score.
-	static int GetScore();
-
-	/// Sets the current wave number
-	/// @param[in] wave The wave number
-	static void SetWave(int wave);
-	/// Get the current wave number
-	/// @return The wave number
-	static int GetWave();
-
-	/// Sets the pauses state of the game
-	/// @param[in] paused Whether the game is paused or not
-	static void SetPaused(bool paused);
-	/// Gets if the game is paused or not
-	/// @return True if the game is paused, false otherwise.
-	static bool GetPaused();
-
-	enum GraphicsQuality { GOOD, OK, BAD };
-
-	/// Sets the quality of the graphics used in-game.
-	/// @param[in] quality The new graphics quality.
-	static void SetGraphicsQuality(GraphicsQuality quality);
-	/// Returns the quality of the graphics to use in-game.
-	/// @return The currently-set graphical quality.
-	static GraphicsQuality GetGraphicsQuality();
-
-	/// Enables or disables reverb.
-	/// @param[in] enabled True to enable reverb, false to disable.
-	static void SetReverb(bool enabled);
-	/// Returns the current state of reverb.
-	/// @return The current reverb state.
-	static bool GetReverb();
-
-	/// Enables or disables 3D spatialisation in the audio engine.
-	/// @param[in] enabled True to enable spatialisation, false to disable.
-	static void Set3DSpatialisation(bool enabled);
-	/// Returns the current state of audio spatialisation.
-	/// @return The current audio spatialisation state.
-	static bool Get3DSpatialisation();
-
-private:
-	GameDetails();
-	~GameDetails();
-};
-
-#endif

+ 0 - 236
Samples/pyinvaders/src/HighScores.cpp

@@ -1,236 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "HighScores.h"
-#include <Rocket/Core/TypeConverter.h>
-#include <stdio.h>
-
-HighScores* HighScores::instance = NULL;
-
-HighScores::HighScores() : Rocket::Controls::DataSource("high_scores")
-{
-	ROCKET_ASSERT(instance == NULL);
-	instance = this;
-
-	for (int i = 0; i < NUM_SCORES; i++)
-	{
-		scores[i].score = -1;
-	}
-
-	LoadScores();
-}
-
-HighScores::~HighScores()
-{
-	ROCKET_ASSERT(instance == this);
-
-	SaveScores();
-
-	instance = NULL;
-}
-
-void HighScores::Initialise()
-{
-	new HighScores();
-}
-
-void HighScores::Shutdown()
-{
-	delete instance;
-}
-
-void HighScores::GetRow(Rocket::Core::StringList& row, const Rocket::Core::String& table, int row_index, const Rocket::Core::StringList& columns)
-{
-	if (table == "scores")
-	{
-		for (size_t i = 0; i < columns.size(); i++)
-		{
-			if (columns[i] == "name")
-			{
-				row.push_back(scores[row_index].name);
-			}
-			else if (columns[i] == "name_required")
-			{
-				row.push_back(Rocket::Core::String(4, "%d", scores[row_index].name_required));
-			}
-			else if (columns[i] == "score")
-			{
-				row.push_back(Rocket::Core::String(32, "%d", scores[row_index].score));
-			}
-			else if (columns[i] == "colour")
-			{
-				Rocket::Core::String colour_string;
-				Rocket::Core::TypeConverter< Rocket::Core::Colourb, Rocket::Core::String >::Convert(scores[row_index].colour, colour_string);
-				row.push_back(colour_string);
-			}
-			else if (columns[i] == "wave")
-			{
-				row.push_back(Rocket::Core::String(8, "%d", scores[row_index].wave));
-			}
-		}
-	}
-}
-
-int HighScores::GetNumRows(const Rocket::Core::String& table)
-{
-	if (table == "scores")
-	{
-		for (int i = 0; i < NUM_SCORES; i++)
-		{
-			if (scores[i].score == -1)
-			{
-				return i;
-			}
-		}
-
-		return NUM_SCORES;
-	}
-
-	return 0;
-}
-
-int HighScores::GetHighScore()
-{
-	if (instance->GetNumRows("scores") == 0)
-	{
-		return 0;
-	}
-
-	return instance->scores[0].score;
-}
-
-void HighScores::SubmitScore(const Rocket::Core::String& name, const Rocket::Core::Colourb& colour, int wave, int score)
-{
-	instance->SubmitScore(name, colour, wave, score, false);
-}
-
-void HighScores::SubmitScore(const Rocket::Core::Colourb& colour, int wave, int score)
-{
-	instance->SubmitScore("", colour, wave, score, true);
-}
-
-// Sets the name of the last player to submit their score.
-void HighScores::SubmitName(const Rocket::Core::String& name)
-{
-	for (int i = 0; i < instance->GetNumRows("scores"); i++)
-	{
-		if (instance->scores[i].name_required)
-		{
-			instance->scores[i].name = name;
-			instance->scores[i].name_required = false;
-			instance->NotifyRowChange("scores", i, 1);
-		}
-	}
-}
-
-void HighScores::SubmitScore(const Rocket::Core::String& name, const Rocket::Core::Colourb& colour, int wave, int score, bool name_required)
-{
-	for (int i = 0; i < NUM_SCORES; i++)
-	{
-		if (score > scores[i].score)
-		{
-			// If we've already got the maximum number of scores, then we have
-			// to send a RowsRemoved message as we're going to delete the last
-			// row from the data source.
-			bool max_rows = scores[NUM_SCORES - 1].score != -1;
-
-			// Push down all the other scores.
-			for (int j = NUM_SCORES - 1; j > i; j--)
-			{
-				scores[j] = scores[j - 1];
-			}
-
-			// Insert our new score.
-			scores[i].name = name;
-			scores[i].colour = colour;
-			scores[i].wave = wave;
-			scores[i].score = score;
-			scores[i].name_required = name_required;
-
-			// Send the row removal message (if necessary).
-			if (max_rows)
-			{
-				NotifyRowRemove("scores", NUM_SCORES - 1, 1);
-			}
-
-			// Then send the rows added message.
-			NotifyRowAdd("scores", i, 1);
-
-			return;
-		}
-	}
-}
-
-void HighScores::LoadScores()
-{
-	// Open and read the high score file.
-	FILE* scores_file = fopen("scores.txt", "rt");
-
-	if (scores_file)
-	{
-		char buffer[1024];
-		while (fgets(buffer, 1024, scores_file))
-		{
-			Rocket::Core::StringList score_parts;
-			Rocket::Core::StringUtilities::ExpandString(score_parts, Rocket::Core::String(buffer), '\t');
-			if (score_parts.size() == 4)
-			{
-				Rocket::Core::Colourb colour;
-				int wave;
-				int score;
-
-				if (Rocket::Core::TypeConverter< Rocket::Core::String , Rocket::Core::Colourb >::Convert(score_parts[1], colour) &&
-					Rocket::Core::TypeConverter< Rocket::Core::String, int >::Convert(score_parts[2], wave) &&
-					Rocket::Core::TypeConverter< Rocket::Core::String, int >::Convert(score_parts[3], score))
-				{
-					SubmitScore(score_parts[0], colour, wave, score);
-				}
-			}
-		}
-
-		fclose(scores_file);
-	}
-}
-
-void HighScores::SaveScores()
-{
-	FILE* scores_file = fopen("scores.txt", "wt");
-
-	if (scores_file)
-	{
-		for (int i = 0; i < GetNumRows("scores"); i++)
-		{
-			Rocket::Core::String colour_string;
-			Rocket::Core::TypeConverter< Rocket::Core::Colourb, Rocket::Core::String >::Convert(scores[i].colour, colour_string);
-
-			Rocket::Core::String score(1024, "%s\t%s\t%d\t%d\n", scores[i].name.CString(), colour_string.CString(), scores[i].wave, scores[i].score);
-			fputs(score.CString(), scores_file);		
-		}
-
-		fclose(scores_file);
-	}
-}

+ 0 - 77
Samples/pyinvaders/src/HighScores.h

@@ -1,77 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSHIGHSCORES_H
-#define ROCKETINVADERSHIGHSCORES_H
-
-#include <Rocket/Controls/DataSource.h>
-#include <Rocket/Core/Types.h>
-
-const int NUM_SCORES = 10;
-
-class HighScores : public Rocket::Controls::DataSource
-{
-public:
-	static void Initialise();
-	static void Shutdown();
-
-	void GetRow(Rocket::Core::StringList& row, const Rocket::Core::String& table, int row_index, const Rocket::Core::StringList& columns);
-	int GetNumRows(const Rocket::Core::String& table);
-
-	static int GetHighScore();
-
-	/// Two functions to add a score to the chart.
-	/// Adds a full score, including a name. This won't prompt the user to enter their name.
-	static void SubmitScore(const Rocket::Core::String& name, const Rocket::Core::Colourb& colour, int wave, int score);
-	/// Adds a score, and causes an input field to appear to request the user for their name.
-	static void SubmitScore(const Rocket::Core::Colourb& colour, int wave, int score);
-	/// Sets the name of the last player to submit their score.
-	static void SubmitName(const Rocket::Core::String& name);
-
-private:
-	HighScores();
-	~HighScores();
-
-	static HighScores* instance;
-
-	void SubmitScore(const Rocket::Core::String& name, const Rocket::Core::Colourb& colour, int wave, int score, bool name_required);
-	void LoadScores();
-	void SaveScores();
-
-	struct Score
-	{
-		Rocket::Core::String name;
-		bool name_required;
-		Rocket::Core::Colourb colour;
-		int score;
-		int wave;
-	};
-
-	Score scores[NUM_SCORES];
-};
-
-#endif

+ 0 - 269
Samples/pyinvaders/src/Invader.cpp

@@ -1,269 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "Invader.h"
-#include <Rocket/Core/Math.h>
-#include <Shell.h>
-#include <ShellOpenGL.h>
-#include "Defender.h"
-#include "Game.h"
-#include "GameDetails.h"
-#include "Shield.h"
-#include "Sprite.h"
-
-const float BOMB_UPDATE_FREQ = 0.04f;
-const float BOMB_RAY_SPEED = 10;
-const float BOMB_MISSILE_SPEED = 7;
-const float BOMB_PROBABILITY_EASY = 0.002f;
-const float BOMB_PROBABILITY_HARD = 0.005f;
-const float EXPLOSION_TIME = 0.25f;
-const Rocket::Core::Colourb MOTHERSHIP_COLOUR = Rocket::Core::Colourb(255, 0, 0, 255);
-
-Sprite invader_sprites[] =
-{
-	// Rank 1
-	Sprite(Rocket::Core::Vector2f(48, 32), Rocket::Core::Vector2f(0.609375f, 0), Rocket::Core::Vector2f(0.796875f, 0.5f)),
-	Sprite(Rocket::Core::Vector2f(48, 32), Rocket::Core::Vector2f(0.80078125f, 0), Rocket::Core::Vector2f(0.98828125f, 0.5f)),
-	// Rank 2
-	Sprite(Rocket::Core::Vector2f(44, 32), Rocket::Core::Vector2f(0.2578125f, 0), Rocket::Core::Vector2f(0.4296875f, 0.5f)),
-	Sprite(Rocket::Core::Vector2f(44, 32), Rocket::Core::Vector2f(0.43359375f, 0), Rocket::Core::Vector2f(0.60546875f, 0.5f)),
-	// Rank 3
-	Sprite(Rocket::Core::Vector2f(32, 32), Rocket::Core::Vector2f(0, 0), Rocket::Core::Vector2f(0.125f, 0.5f)),
-	Sprite(Rocket::Core::Vector2f(32, 32), Rocket::Core::Vector2f(0.12890625f, 0), Rocket::Core::Vector2f(0.25390625f, 0.5f)),
-	// Mothership
-	Sprite(Rocket::Core::Vector2f(64, 28), Rocket::Core::Vector2f(0.23828125f, 0.515625f), Rocket::Core::Vector2f(0.48828125f, 0.953125f)),
-	// Explosion
-	Sprite(Rocket::Core::Vector2f(52, 28), Rocket::Core::Vector2f(0.71484375f, 0.51562500f), Rocket::Core::Vector2f(0.91796875f, 0.95312500f))	
-};
-
-Sprite bomb_sprites[] =
-{
-	// Ray
-	Sprite(Rocket::Core::Vector2f(12, 20), Rocket::Core::Vector2f(0.51171875f, 0.51562500f), Rocket::Core::Vector2f(0.55859375f, 0.82812500f)),
-	Sprite(Rocket::Core::Vector2f(12, 20), Rocket::Core::Vector2f(0.56250000, 0.51562500), Rocket::Core::Vector2f(0.60937500, 0.82812500)),
-	Sprite(Rocket::Core::Vector2f(12, 20), Rocket::Core::Vector2f(0.61328125, 0.51562500), Rocket::Core::Vector2f(0.66015625, 0.82812500)),
-	Sprite(Rocket::Core::Vector2f(12, 20), Rocket::Core::Vector2f(0.66406250, 0.51562500), Rocket::Core::Vector2f(0.71093750, 0.82812500)),
-	// Missile
-	Sprite(Rocket::Core::Vector2f(12, 20), Rocket::Core::Vector2f(0.92578125, 0.51562500), Rocket::Core::Vector2f(0.97265625, 0.82812500))
-};
-
-Invader::Invader(Game* _game, InvaderType _type, int _index) : position(0,0)
-{
-	type = UNKNOWN;
-	animation_frame = 0;
-	bomb_animation_frame = 0;
-	bomb_frame_start = 0;
-	death_time = 0;
-	state = ALIVE;
-	bomb = NONE;
-	game = _game;
-	type = _type;
-	death_time = 0;
-	invader_index = _index;
-
-	bomb_probability = GameDetails::GetDifficulty() == GameDetails::EASY ? BOMB_PROBABILITY_EASY : BOMB_PROBABILITY_HARD;
-	bomb_probability *= type;
-}
-
-Invader::~Invader()
-{
-}
-
-void Invader::SetPosition(const Rocket::Core::Vector2f& _position)
-{
-	position = _position;
-}
-
-const Rocket::Core::Vector2f& Invader::GetPosition() const
-{
-	return position;
-}
-
-void Invader::Update()
-{
-	// Update the bombs
-	if (Shell::GetElapsedTime() - bomb_frame_start > BOMB_UPDATE_FREQ)
-	{	
-
-		// Update the bomb position if its in flight, or check if we should drop one
-		if (bomb != NONE)
-		{
-			if (bomb == RAY)
-			{
-				bomb_animation_frame++;
-				if (bomb_animation_frame > 3)
-					bomb_animation_frame = 0;
-
-				bomb_position.y += BOMB_RAY_SPEED;
-			}
-			else
-			{
-				bomb_position.y += BOMB_MISSILE_SPEED;
-			}
-			
-			if (bomb_position.y > game->GetWindowDimensions().y)
-				bomb = NONE;
-
-			// Check if we hit the shields
-			for (int i = 0; i < game->GetNumShields(); i++)
-			{
-				if (game->GetShield(i)->CheckHit(bomb_position))
-				{
-					bomb = NONE;
-					break;
-				}
-			}
-
-			// Check if we hit the defender
-			if (bomb != NONE)
-			{
-				if (game->GetDefender()->CheckHit(bomb_position))
-					bomb = NONE;
-			}
-		}
-		else if (state == ALIVE &&
-				 Rocket::Core::Math::RandomReal(1.0f) < bomb_probability &&
-				 game->CanDropBomb(invader_index))
-		{
-			bomb = Rocket::Core::Math::RandomInteger(2) == 0 ? RAY : MISSILE;
-			bomb_position = position;
-			bomb_position.x += invader_sprites[GetSpriteIndex()].dimensions.x / 2;
-
-			if (bomb == RAY)
-				bomb_animation_frame = 0;
-			else
-				bomb_animation_frame = 4;
-		}	
-
-		bomb_frame_start = Shell::GetElapsedTime();
-	}
-
-	if (state == EXPLODING && Shell::GetElapsedTime() > death_time)
-		state = DEAD;
-}
-
-void Invader::UpdateAnimation()
-{
-	switch (state)
-	{
-	case ALIVE:
-		animation_frame++;
-		if (animation_frame > 1)
-			animation_frame = 0;
-		break;
-
-	default:
-		break;
-	}
-}
-
-void Invader::Render()
-{
-	if (type == MOTHERSHIP)
-	{
-		glColor4ubv(MOTHERSHIP_COLOUR);
-	}
-	int sprite_index = GetSpriteIndex();
-	int sprite_offset = Rocket::Core::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2);
-
-	if (state != DEAD)
-		invader_sprites[sprite_index].Render(Rocket::Core::Vector2f(position.x - sprite_offset, position.y));
-	
-	if (bomb != NONE)
-	{
-		bomb_sprites[bomb_animation_frame].Render(bomb_position);
-	}
-
-	if (type == MOTHERSHIP)
-	{
-		glColor4ub(255, 255, 255, 255);
-	}
-}
-
-Invader::InvaderState Invader::GetState()
-{
-	return state;
-}
-
-bool Invader::CheckHit(const Rocket::Core::Vector2f& check_position)
-{
-	// Get the sprite index we're currently using for collision detection
-	int sprite_index = GetSpriteIndex();
-	int sprite_offset = Rocket::Core::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2);
-	float sprite_width = invader_sprites[sprite_index].dimensions.x;
-	float sprite_height = invader_sprites[sprite_index].dimensions.y;
-
-	// If we're alive and the position is within our bounds, set ourselves
-	// as exploding and return a valid hit
-	if (state == ALIVE
-		&& check_position.x >= position.x - sprite_offset
-		&& check_position.x <= position.x - sprite_offset + sprite_width
-		&& check_position.y >= position.y
-		&& check_position.y <= position.y + sprite_height)
-	{
-		int score = 0;
-		switch (type)
-		{
-			ROCKET_UNUSED_SWITCH_ENUM(UNKNOWN);
-			case MOTHERSHIP: score = (Rocket::Core::Math::RandomInteger(6) + 1) * 50; break;	// 50 -> 300
-			case RANK3: score = 40; break;
-			case RANK2: score = 20; break;
-			case RANK1: score = 10; break;
-		}
-
-		// Add the number of points
-		game->AddScore(score);
-
-		// Set our state to exploding and start the timer to our doom
-		state = EXPLODING;
-		death_time = Shell::GetElapsedTime() + EXPLOSION_TIME;	
-
-		return true;
-	}
-
-	return false;
-}
-
-int Invader::GetSpriteIndex() const
-{
-	// Calculate our sprite index based on animation and type
-	int index = animation_frame;
-	switch (type)
-	{
-		ROCKET_UNUSED_SWITCH_ENUM(UNKNOWN);
-		case RANK1: break;	// animation_frame is the right index already
-		case RANK2:	index += 2; break;
-		case RANK3:	index += 4; break;
-		case MOTHERSHIP: index = 6; break;
-	}
-
-	// If we're in exploding state, use the exploding sprite
-	if (state == EXPLODING)
-		index = 7;
-
-	return index;
-}

+ 0 - 114
Samples/pyinvaders/src/Invader.h

@@ -1,114 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSINVADER_H
-#define ROCKETINVADERSINVADER_H
-
-#include <Rocket/Core/Types.h>
-
-class Game;
-
-/**
-	An alien invader.
-
-	@author Lloyd Weehuizen
- */
-
-class Invader
-{
-public:	
-	enum InvaderType { UNKNOWN, RANK1, RANK2, RANK3, MOTHERSHIP };
-	enum BombType { NONE, RAY, MISSILE };
-
-	/// Construct the invader
-	Invader(Game* game, InvaderType type, int index);
-	~Invader();	
-
-	/// Set the invaders screen position
-	/// @param position Position in screen space
-	void SetPosition(const Rocket::Core::Vector2f& position);
-	/// Get the current invader position
-	/// @returns The invaders position in screen space
-	const Rocket::Core::Vector2f& GetPosition() const;
-
-	/// Update the invader
-	virtual void Update();	
-
-	/// Render the invader
-	void Render();
-
-	/// Update the invaders animation
-	void UpdateAnimation();
-
-	/// The current invaders state
-	enum InvaderState { ALIVE, EXPLODING, DEAD };
-	/// Get the current invader state
-	/// @returns Invader state
-	InvaderState GetState();
-
-	/// Returns true if the position hits the invader
-	/// If a hit is detected, will explode and start the death timer
-	/// @param position Position to do the hit check at
-	/// @returns If the invader was hit
-	bool CheckHit(const Rocket::Core::Vector2f& position);
-
-protected:
-	// Game this invader is in
-	Game* game;
-	// The index/id of this invader
-	int invader_index;
-
-	// The invader type we represent
-	InvaderType type;
-	// The current position in screen space of the invader
-	Rocket::Core::Vector2f position;
-	// Our current animation frame
-	int animation_frame;
-
-	// Our current state
-	InvaderState state;
-
-	// Our current in-flight bomb, or none. (may be not none if we're dead.)
-	BombType bomb;
-	// The current position of the bomb in screen space
-	Rocket::Core::Vector2f bomb_position;
-	// The animation frame the bomb is on
-	int bomb_animation_frame;
-	// When the last bomb update occured
-	float bomb_frame_start;
-	// Probability of us dropping a bomb - this is calculated
-	// at construction time and based on our rank and the game
-	// difficulty level
-	float bomb_probability;
-
-	// Time when we should die - 0, until we're hit
-	float death_time;	
-
-	int GetSpriteIndex() const;
-};
-
-#endif

+ 0 - 83
Samples/pyinvaders/src/Mothership.cpp

@@ -1,83 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "Mothership.h"
-#include <Rocket/Core/Math.h>
-#include "Shell.h"
-#include "Game.h"
-#include "Sprite.h"
-
-const int SPRITE_WIDTH = 64;
-
-const float APPEARANCE_PROBABILITY = 0.001f;
-const float UPDATE_FREQ = 0.025f;
-const float MOVEMENT_SPEED = 5;
-
-Mothership::Mothership(Game* game, int index) : Invader(game, Invader::MOTHERSHIP, index)
-{
-	// Start off dead, and set up our position
-	state = DEAD;
-	update_frame_start = 0;
-	position = Rocket::Core::Vector2f(-SPRITE_WIDTH, 64.0f);
-}
-
-Mothership::~Mothership()
-{
-}
-
-void Mothership::Update()
-{
-	// Generic Invader update
-	Invader::Update();
-
-	if (Shell::GetElapsedTime() - update_frame_start < UPDATE_FREQ)
-		return;
-
-	// We're alive, keep moving!
-	if (state == ALIVE)
-	{
-		position.x += (direction * MOVEMENT_SPEED);
-
-		if ((direction < 0.0f && position.x < -SPRITE_WIDTH)
-			|| (direction > 0.0f && position.x > game->GetWindowDimensions().x))
-			state = DEAD;
-
-		update_frame_start = Shell::GetElapsedTime();
-	}
-	// Determine if we should come out of hiding
-	else if (Rocket::Core::Math::RandomReal(1.0f) < APPEARANCE_PROBABILITY)
-	{
-		direction = Rocket::Core::Math::RandomReal(1.0f) < 0.5 ? -1.0f : 1.0f;
-
-		if (direction < 0)
-			position.x = game->GetWindowDimensions().x + SPRITE_WIDTH;
-		else
-			position.x = -SPRITE_WIDTH;
-
-		state = ALIVE;
-	}
-}

+ 0 - 53
Samples/pyinvaders/src/Mothership.h

@@ -1,53 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSMOTHERSHIP_H
-#define ROCKETINVADERSMOTHERSHIP_H
-
-#include "Invader.h"
-
-/**
- */
-
-class Mothership : public Invader
-{
-public:
-	Mothership(Game* game, int index);
-	~Mothership();
-
-	/// Update the mothership
-	virtual void Update();	
-
-private:
-	// Time of the last update
-	float update_frame_start;
-
-	// Direction mothership is flying in
-	float direction;
-};
-
-#endif

+ 0 - 124
Samples/pyinvaders/src/PythonInterface.cpp

@@ -1,124 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "PythonInterface.h"
-#include <Shell.h>
-#include "GameDetails.h"
-#include "ElementGame.h"
-#include "HighScores.h"
-
-void SubmitHighScore()
-{
-	int score = GameDetails::GetScore();
-	if (score > 0)
-	{
-		// Submit the score the player just got to the high scores chart.
-		HighScores::SubmitScore(GameDetails::GetDefenderColour(), GameDetails::GetWave(), GameDetails::GetScore());
-		// Reset the score so the chart won't get confused next time we enter.
-		GameDetails::ResetScore();
-	}
-}
-
-BOOST_PYTHON_MODULE(game)
-{
-	python::def("Shutdown", &Shell::RequestExit);
-	python::def("SetPaused", &GameDetails::SetPaused);
-	python::def("SetDifficulty", &GameDetails::SetDifficulty);
-	python::def("SetDefenderColour", &GameDetails::SetDefenderColour);
-	python::def("SubmitHighScore", &SubmitHighScore);
-	python::def("SetHighScoreName", &HighScores::SubmitName);
-
-	python::enum_<GameDetails::Difficulty>("difficulty")
-		.value("HARD", GameDetails::HARD)
-		.value("EASY", GameDetails::EASY)
-	;
-
-	ElementGame::InitialisePythonInterface();
-}
-
-PythonInterface::PythonInterface()
-{
-}
-
-PythonInterface::~PythonInterface()
-{
-}
-
-bool PythonInterface::Initialise(const char* path)
-{
-	// Initialise Python.
-	Py_Initialize();
-
-	// Setup the Python search path.
-	const char* python_path = Py_GetPath();
-	char buffer[1024];
-	snprintf(buffer, 1024, "%s%s%s", path, PATH_SEPARATOR, python_path);
-	buffer[1023] = '\0';
-	PySys_SetPath(buffer);
-
-	// Import Rocket.
-	if (!Import("rocket"))
-		return false;
-
-	// Define our game specific interface.
-	initgame();
-
-	return true;
-}
-
-void PythonInterface::Shutdown()
-{
-	Py_Finalize();
-}
-
-bool PythonInterface::Import(const Rocket::Core::String& name)
-{
-	PyObject* module = PyImport_ImportModule(name.CString());
-	if (!module)
-	{
-		PrintError(true);
-		return false;
-	}
-
-	Py_DECREF(module);
-	return true;
-}
-
-// Print the pending python error to stderr, optionally clearing it
-void PythonInterface::PrintError(bool clear_error)
-{
-	// Print the error and restore it to the caller
-	PyObject *type, *value, *traceback;
-	PyErr_Fetch(&type, &value, &traceback);
-	Py_XINCREF(type);
-	Py_XINCREF(value);
-	Py_XINCREF(traceback);
-	PyErr_Restore(type, value, traceback);	
-	PyErr_Print();
-	if (!clear_error)
-		PyErr_Restore(type, value, traceback);
-}

+ 0 - 58
Samples/pyinvaders/src/PythonInterface.h

@@ -1,58 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef PYTHONINTERFACE_H
-#define PYTHONINTERFACE_H
-
-#include <Rocket/Core/Python/Python.h>
-
-#include <Rocket/Core/String.h>
-
-/**
-	Creates and maintains the python interface to Invaders.
-
-	@author Lloyd Weehuizen
- */
-
-class PythonInterface
-{
-public:
-	static bool Initialise(const char* python_path);
-	static void Shutdown();
-
-	/// Import a python module
-	static bool Import(const Rocket::Core::String& name);
-
-	/// Print out current errors
-	static void PrintError(bool clear_error = false);
-
-private:
-	PythonInterface();
-	~PythonInterface();
-};
-
-#endif

+ 0 - 188
Samples/pyinvaders/src/Shield.cpp

@@ -1,188 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "Shield.h"
-#include <Rocket/Core/Math.h>
-#include <ShellOpenGL.h>
-#include "Game.h"
-#include "GameDetails.h"
-#include "Sprite.h"
-
-const int MAX_HEALTH = 4;
-
-Shield::Shield(Game* _game, ShieldType _type) : position(0,0)
-{
-	game = _game;
-	type = _type;
-	health = MAX_HEALTH;
-
-	InitialiseCells();
-}
-
-Shield::~Shield()
-{
-}
-
-void Shield::InitialiseCells()
-{
-	if (type == REGULAR || type == TOP_LEFT || type == TOP_RIGHT)
-	{
-		for (int i = 0; i < NUM_SHIELD_CELLS; i++)
-		{
-			for (int j = 0; j < NUM_SHIELD_CELLS; j++)
-			{
-				shield_cells[i][j] = ON;
-			}
-		}
-
-		// Take the bites out of the cells if they're a corner cell:
-		if (type == TOP_LEFT)
-		{
-			for (int x = 0; x < NUM_SHIELD_CELLS - 1; x++)
-			{
-				for (int y = 0; y < (NUM_SHIELD_CELLS - 1) - x; y++)
-					shield_cells[x][y] = OFF;
-			}
-		}
-
-		else if (type == TOP_RIGHT)
-		{
-			for (int x = 0; x < NUM_SHIELD_CELLS - 1; x++)
-			{
-				for (int y = 0; y < (NUM_SHIELD_CELLS - 1) - x; y++)
-					shield_cells[(NUM_SHIELD_CELLS - 1) - x][y] = OFF;
-			}
-		}
-	}
-	else
-	{
-		for (int i = 0; i < NUM_SHIELD_CELLS; i++)
-		{
-			for (int j = 0; j < NUM_SHIELD_CELLS; j++)
-			{
-				shield_cells[i][j] = OFF;
-			}
-		}
-
-		if (type == BOTTOM_LEFT)
-		{
-			for (int x = 0; x < NUM_SHIELD_CELLS - 1; x++)
-			{
-				for (int y = 0; y < (NUM_SHIELD_CELLS - 1) - x; y++)
-					shield_cells[(NUM_SHIELD_CELLS - 1) - x][y] = ON;
-			}
-		}
-
-		else if (type == BOTTOM_RIGHT)
-		{
-			for (int x = 0; x < NUM_SHIELD_CELLS - 1; x++)
-			{
-				for (int y = 0; y < (NUM_SHIELD_CELLS - 1) - x; y++)
-					shield_cells[x][y] = ON;
-			}
-		}
-	}
-}
-
-void Shield::SetPosition(const Rocket::Core::Vector2f& _position)
-{
-	position = _position;
-}
-
-const Rocket::Core::Vector2f& Shield::GetPosition() const
-{
-	return position;
-}
-
-void Shield::Render()
-{
-	if (health > 0)
-	{
-		glPointSize((GLfloat) PIXEL_SIZE);
-		glDisable(GL_TEXTURE_2D);
-		glColor4ubv(GameDetails::GetDefenderColour());
-
-		glBegin(GL_POINTS);
-
-		for (int i = 0; i < NUM_SHIELD_CELLS; i++)
-		{
-			for (int j = 0; j < NUM_SHIELD_CELLS; j++)
-			{
-				if (shield_cells[i][j] == ON)
-				{
-					Rocket::Core::Vector2f cell_position = position + Rocket::Core::Vector2f((float) (PIXEL_SIZE * i), (float) (PIXEL_SIZE * j));
-					glVertex2f(cell_position.x, cell_position.y);
-				}
-			}
-		}
-
-		glEnd();
-
-		glEnable(GL_TEXTURE_2D);
-	}
-}
-
-bool Shield::CheckHit(const Rocket::Core::Vector2f& check_position)
-{
-	float sprite_size = PIXEL_SIZE * NUM_SHIELD_CELLS;
-
-	// If we're alive and the position is within our bounds, set ourselves
-	// as exploding and return a valid hit
-	if (health > 0
-		&& check_position.x >= position.x
-		&& check_position.x <= position.x + sprite_size
-		&& check_position.y >= position.y
-		&& check_position.y <= position.y + sprite_size)
-	{
-		// Take damage.
-		SustainDamage();
-
-		return true;
-	}
-
-	return false;
-}
-
-void Shield::SustainDamage()
-{
-	health--;
-
-	if (health > 0)
-	{
-		int num_shields_to_lose = (NUM_SHIELD_CELLS * NUM_SHIELD_CELLS) / MAX_HEALTH;
-		while (num_shields_to_lose > 0)
-		{
-			int x = Rocket::Core::Math::RandomInteger(NUM_SHIELD_CELLS);
-			int y = Rocket::Core::Math::RandomInteger(NUM_SHIELD_CELLS);
-			if (shield_cells[x][y] != DESTROYED)
-			{
-				shield_cells[x][y] = DESTROYED;
-				num_shields_to_lose--;
-			}
-		}
-	}
-}

+ 0 - 90
Samples/pyinvaders/src/Shield.h

@@ -1,90 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSSHIELD_H
-#define ROCKETINVADERSSHIELD_H
-
-#include <Rocket/Core/Types.h>
-
-class Game;
-
-const int NUM_SHIELD_CELLS = 6;
-const int PIXEL_SIZE = 4;
-
-/**
-	A shield, protecting the player.
-
-	@author Robert Curry
- */
-
-class Shield
-{
-public:
-	enum ShieldType { REGULAR, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT };
-
-	/// Construct the invader
-	Shield(Game* game, ShieldType type);
-	~Shield();
-
-	/// Sets up which cells are on and off, based on the type.
-	void InitialiseCells();
-
-	/// Set the shield's screen position
-	/// @param position Position in screen space
-	void SetPosition(const Rocket::Core::Vector2f& position);
-	/// Get the current shield position
-	/// @returns The shield's position in screen space
-	const Rocket::Core::Vector2f& GetPosition() const;
-
-	/// Render the shield.
-	void Render();
-
-	/// Returns true if the position hits the shield
-	/// If a hit is detected, will degrade the shield.
-	/// @param position Position to do the hit check at
-	/// @returns If the shield was hit
-	bool CheckHit(const Rocket::Core::Vector2f& position);
-
-protected:
-	void SustainDamage();
-
-	// Game this shield is in
-	Game* game;
-
-	// The invader type we represent
-	ShieldType type;
-	// The current position in screen space of the shield
-	Rocket::Core::Vector2f position;
-
-	// Our current state - starts at 4, degrades once per hit.
-	int health;
-
-	enum ShieldCellState { ON, OFF, DESTROYED };
-	ShieldCellState shield_cells[NUM_SHIELD_CELLS][NUM_SHIELD_CELLS];
-};
-
-#endif

+ 0 - 52
Samples/pyinvaders/src/Sprite.cpp

@@ -1,52 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "Sprite.h"
-#include <ShellOpenGL.h>
-
-Sprite::Sprite(const Rocket::Core::Vector2f& dimensions, const Rocket::Core::Vector2f& top_left_texcoord, const Rocket::Core::Vector2f& bottom_right_texcoord) : dimensions(dimensions), top_left_texcoord(top_left_texcoord), bottom_right_texcoord(bottom_right_texcoord)
-{
-}
-
-Sprite::~Sprite()
-{
-}
-
-void Sprite::Render(const Rocket::Core::Vector2f& position)
-{
-	glTexCoord2f(top_left_texcoord.x, top_left_texcoord.y);
-	glVertex2f(position.x, position.y);
-
-	glTexCoord2f(top_left_texcoord.x, bottom_right_texcoord.y);
-	glVertex2f(position.x, position.y + dimensions.y);
-
-	glTexCoord2f(bottom_right_texcoord.x, bottom_right_texcoord.y);
-	glVertex2f(position.x + dimensions.x, position.y + dimensions.y);
-
-	glTexCoord2f(bottom_right_texcoord.x, top_left_texcoord.y);
-	glVertex2f(position.x + dimensions.x, position.y);
-}

+ 0 - 50
Samples/pyinvaders/src/Sprite.h

@@ -1,50 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETINVADERSSPRITE_H
-#define ROCKETINVADERSSPRITE_H
-
-#include <Rocket/Core/Types.h>
-
-/**
-	@author Peter Curry
- */
-
-class Sprite
-{
-public:
-	Sprite(const Rocket::Core::Vector2f& dimensions, const Rocket::Core::Vector2f& top_left_texcoord, const Rocket::Core::Vector2f& bottom_right_texcoord);
-	~Sprite();
-
-	void Render(const Rocket::Core::Vector2f& position);
-
-	Rocket::Core::Vector2f dimensions;
-	Rocket::Core::Vector2f top_left_texcoord;
-	Rocket::Core::Vector2f bottom_right_texcoord;
-};
-
-#endif

+ 0 - 215
Samples/pyinvaders/src/main.cpp

@@ -1,215 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#define _WIN32_WINNT 0x0500
-#include "PythonInterface.h"
-
-#include <Rocket/Core.h>
-#include <Rocket/Controls.h>
-#include <Rocket/Debugger.h>
-
-#include <Input.h>
-#include <Shell.h>
-#include "DecoratorInstancerDefender.h"
-#include "DecoratorInstancerStarfield.h"
-#include "ElementGame.h"
-#include "HighScores.h"
-
-Rocket::Core::Context* context = NULL;
-
-void DoAllocConsole();
-
-ShellRenderInterfaceExtensions *shell_renderer;
-
-void GameLoop()
-{
-	context->Update();
-
-	shell_renderer->PrepareRenderBuffer();
-	context->Render();
-	shell_renderer->PresentRenderBuffer();
-}
-
-#if defined ROCKET_PLATFORM_WIN32
-#include <windows.h>
-int APIENTRY WinMain(HINSTANCE ROCKET_UNUSED_PARAMETER(instance_handle), HINSTANCE ROCKET_UNUSED_PARAMETER(previous_instance_handle), char* ROCKET_UNUSED_PARAMETER(command_line), int ROCKET_UNUSED_PARAMETER(command_show))
-#else
-int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv))
-#endif
-{
-#ifdef ROCKET_PLATFORM_WIN32
-	ROCKET_UNUSED(instance_handle);
-	ROCKET_UNUSED(previous_instance_handle);
-	ROCKET_UNUSED(command_line);
-	ROCKET_UNUSED(command_show);
-#else
-	ROCKET_UNUSED(argc);
-	ROCKET_UNUSED(argv);
-#endif
-
-// @TODO Make these lookup at runtime rather than using hard coded paths
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/pyinvaders/"
-#define ROCKET_PATH ""
-#else
-#define APP_PATH "../../Samples/pyinvaders/"
-#define ROCKET_PATH "."
-#endif
-
-#ifdef ROCKET_PLATFORM_WIN32
-	DoAllocConsole();
-#endif
-
-	int window_width = 1024;
-	int window_height = 768;
-
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
-
-	// @TODO switch to using variable for window sizes
-	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
-		!Shell::OpenWindow("Rocket Invaders from Mars (Python Powered)", shell_renderer, window_width, window_height, false))
-	{
-		Shell::Shutdown();
-		return -1;
-	}
-
-	// Rocket initialisation.
-	Rocket::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(window_width, window_height);
-
-	ShellSystemInterface system_interface;
-	Rocket::Core::SetSystemInterface(&system_interface);
-
-	Rocket::Core::Initialise();
-	// Initialise the Rocket Controls library.
-	Rocket::Controls::Initialise();
-
-	// Initialise the Python interface.
-	PythonInterface::Initialise((Shell::GetExecutablePath() + (APP_PATH "python") + PATH_SEPARATOR + Shell::GetExecutablePath() + ROCKET_PATH).CString());
-
-	// Create the main Rocket context and set it on the shell's input layer.
-	context = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(window_width, window_height));
-	if (context == NULL)
-	{
-		Rocket::Core::Shutdown();
-		Shell::Shutdown();
-		return -1;
-	}
-
-	Rocket::Debugger::Initialise(context);
-	Input::SetContext(context);
-	shell_renderer->SetContext(context);
-
-	// Load the font faces required for Invaders.
-	Shell::LoadFonts("../assets/");
-
-	// Register Invader's custom decorator instancers.
-	Rocket::Core::DecoratorInstancer* decorator_instancer = new DecoratorInstancerStarfield();
-	Rocket::Core::Factory::RegisterDecoratorInstancer("starfield", decorator_instancer);
-	decorator_instancer->RemoveReference();
-
-	decorator_instancer = new DecoratorInstancerDefender();
-	Rocket::Core::Factory::RegisterDecoratorInstancer("defender", decorator_instancer);
-	decorator_instancer->RemoveReference();	
-
-	// Construct the game singletons.
-	HighScores::Initialise();
-
-	// Fire off the startup script.
-	PythonInterface::Import("autoexec");
-
-	Shell::EventLoop(GameLoop);	
-
-	// Shutdown the Rocket contexts.	
-	context->RemoveReference();
-	
-	// Shutdown Python before we shut down Rocket.
-	PythonInterface::Shutdown();
-
-	// Shut down the game singletons.
-	HighScores::Shutdown();
-
-	// Shutdown Rocket.
-	Rocket::Core::Shutdown();
-
-	Shell::CloseWindow();
-	Shell::Shutdown();
-
-	return 0;
-}
-
-#ifdef ROCKET_PLATFORM_WIN32
-
-#include <windows.h>
-#include <fcntl.h>
-#include <io.h>
-#include <process.h>
-
-void DoAllocConsole()
-{
-	static const WORD MAX_CONSOLE_LINES = 500;
-	int hConHandle;
-	long lStdHandle;
-	CONSOLE_SCREEN_BUFFER_INFO coninfo;
-	FILE *fp;
-
-	// allocate a console for this app
-	AllocConsole();
-
-	// set the screen buffer to be big enough to let us scroll text
-	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
-	coninfo.dwSize.Y = MAX_CONSOLE_LINES;
-	SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
-
-	// redirect unbuffered STDOUT to the console
-	lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
-	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-	fp = _fdopen( hConHandle, "w" );
-
-	*stdout = *fp;
-	setvbuf( stdout, NULL, _IONBF, 0 );
-
-	// redirect unbuffered STDIN to the console
-	lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
-	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-	fp = _fdopen( hConHandle, "r" );
-
-	*stdin = *fp;
-	setvbuf( stdin, NULL, _IONBF, 0 );
-
-	// redirect unbuffered STDERR to the console
-	lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
-	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-	fp = _fdopen( hConHandle, "w" );
-	*stderr = *fp;
-
-	setvbuf( stderr, NULL, _IONBF, 0 );
-	ShowWindow(GetConsoleWindow(), SW_SHOW);
-}
-#endif

+ 0 - 84
Source/Controls/Python/DataFormatterWrapper.cpp

@@ -1,84 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "DataFormatterWrapper.h"
-
-namespace Rocket {
-namespace Controls {
-namespace Python {
-
-DataFormatterWrapper::DataFormatterWrapper(PyObject* _self, const char* name) : DataFormatter(name)
-{
-	self = _self;
-}
-
-DataFormatterWrapper::~DataFormatterWrapper()
-{
-}
-
-void DataFormatterWrapper::InitialisePythonInterface()
-{
-	python::class_<DataFormatter, DataFormatterWrapper, boost::noncopyable>("DataFormatter", python::init<const char*>());
-}
-
-void DataFormatterWrapper::FormatData(Rocket::Core::String& formatted_data, const Rocket::Core::StringList& raw_data)
-{
-	PyObject* callable = PyObject_GetAttrString(self, "FormatData");
-	if (!callable)
-	{
-		PyObject* name = PyObject_GetAttrString(self, "__name__");
-		Rocket::Core::Log::Message(Rocket::Core::Log::LT_WARNING, "Function \"FormatData\" not found on python data formatter %s.", PyString_AsString(name));
-		Py_DECREF(name);
-		return;
-	}
-
-	python::tuple t = python::make_tuple(raw_data);
-	PyObject* result = PyObject_CallObject(callable, t.ptr());
-	Py_DECREF(callable);
-
-	// If it's a string, then just return it.
-	if (result && PyString_Check(result))
-	{
-		formatted_data = PyString_AsString(result);
-	}
-	else
-	{
-		Rocket::Core::Log::Message(Rocket::Core::Log::LT_ERROR, "Failed to get valid string from data formatter %s.", GetDataFormatterName().CString());
-		if (!result)
-		{
-			python::throw_error_already_set();
-		}
-	}
-
-	if (result)
-		Py_DECREF(result);
-}
-
-}
-}
-}

+ 0 - 61
Source/Controls/Python/DataFormatterWrapper.h

@@ -1,61 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCONTROLSPYTHONDATAFORMATTERWRAPPER_H
-#define ROCKETCONTROLSPYTHONDATAFORMATTERWRAPPER_H
-
-#include "../../../Include/Rocket/Controls/DataFormatter.h"
-
-namespace Rocket {
-namespace Controls {
-namespace Python {
-
-/**
-	Python DataFormatter wrapper
-
-	@author Robert Curry
- */
-
-class DataFormatterWrapper : public DataFormatter
-{
-public:
-	DataFormatterWrapper(PyObject* self, const char* name);
-	~DataFormatterWrapper();
-
-	static void InitialisePythonInterface();
-
-	virtual void FormatData(Rocket::Core::String& formatted_data, const Rocket::Core::StringList& raw_data);
-
-private:
-	PyObject* self;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 70
Source/Controls/Python/DataGridRowProxy.cpp

@@ -1,70 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "DataGridRowProxy.h"
-#include "../../../Include/Rocket/Core/Python/NameIndexInterface.h"
-#include "../../../Include/Rocket/Core/Python/Utilities.h"
-#include "../../../Include/Rocket/Core.h"
-
-namespace Rocket {
-namespace Controls {
-namespace Python {
-
-class DataGridRowLenAccessor
-{
-public:
-	int operator()(DataGridRowProxy& proxy)
-	{
-		return proxy.datagrid->GetNumRows();
-	}
-};
-
-class DataGridRowIndexAccessor
-{
-public:
-	ElementDataGridRow* operator()(DataGridRowProxy& proxy, int index)
-	{
-		return proxy.datagrid->GetRow(index);
-	}
-};
-
-DataGridRowProxy::DataGridRowProxy(ElementDataGrid* _datagrid)
-{
-	datagrid = _datagrid;
-}
-
-void DataGridRowProxy::InitialisePythonInterface()
-{
-	python::class_< DataGridRowProxy >("DataGridRowProxy", python::no_init)
-		.def(Rocket::Core::Python::NameIndexInterface< DataGridRowProxy, DataGridRowLenAccessor, DataGridRowIndexAccessor >())
-		;
-}
-
-}
-}
-}

+ 0 - 59
Source/Controls/Python/DataGridRowProxy.h

@@ -1,59 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONDATAGRIDROWPROXY_H
-#define ROCKETCOREPYTHONDATAGRIDROWPROXY_H
-
-namespace Rocket {
-namespace Controls {
-
-class ElementDataGrid;
-
-namespace Python {
-
-/**
-	Thin, lightweight proxy object for providing array-style context lookups.
-
-	@author Peter Curry
- */
-
-class DataGridRowProxy
-{
-public:
-	DataGridRowProxy(ElementDataGrid* datagrid);
-
-	/// Initialise the interface.
-	static void InitialisePythonInterface();
-
-	ElementDataGrid* datagrid;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 238
Source/Controls/Python/DataSourceWrapper.cpp

@@ -1,238 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "DataSourceWrapper.h"
-#include "../../../Include/Rocket/Core/Log.h"
-#include "../../../Include/Rocket/Core/Python/Utilities.h"
-
-namespace Rocket {
-namespace Controls {
-namespace Python {
-
-// Returns the string representation of a python class name
-static Core::String GetPythonClassName(PyObject* object)
-{
-	Core::String full_name;
-
-	// Check if the object is a class; either a standard Python class or a Boost Python class metatype. If so, we can
-	// query the name of the class object directly; otherwise, it is an object that we have to query the class type
-	// from.
-	bool is_class = PyClass_Check(object) ||
-					object->ob_type == python::objects::class_metatype().get();
-	PyObject* py_class = NULL;
-	if (!is_class)
-	{
-		py_class = PyObject_GetAttrString(object, "__class__");
-		object = py_class;
-		if (!object)
-		{
-			PyErr_Clear();
-			return full_name;
-		}
-	}
-
-	PyObject* py_class_name = PyObject_GetAttrString(object, "__name__");
-	if (py_class_name != NULL)
-	{
-		const char* class_name = PyString_AsString(py_class_name);
-
-		PyObject* py_module_name = PyObject_GetAttrString(object, "__module__");
-		const char* module_name = PyString_AsString(py_module_name);
-
-		full_name.FormatString(128, "%s.%s", module_name, class_name);
-
-		Py_DECREF(py_module_name);
-		Py_DECREF(py_class_name);
-	}
-	else
-	{
-		PyErr_Clear();
-	}
-
-	if (py_class != NULL)
-		Py_DECREF(py_class);
-
-	return full_name;
-}
-
-
-DataSourceWrapper::DataSourceWrapper(PyObject* _self, const char* name) : DataSource(name)
-{
-	self = _self;
-}
-
-DataSourceWrapper::~DataSourceWrapper()
-{
-}
-
-void DataSourceWrapper::InitialisePythonInterface()
-{
-	void (DataSourceWrapper::*NotifyRowChange)(const Core::String&) = &DataSourceWrapper::NotifyRowChange;
-	void (DataSourceWrapper::*NotifyRowChangeParams)(const Core::String&, int, int) = &DataSourceWrapper::NotifyRowChange;
-
-	python::scope datasource_scope = python::class_<DataSource, DataSourceWrapper, boost::noncopyable>("DataSource", python::init< const char* >())
-		.def("NotifyRowAdd", &DataSourceWrapper::NotifyRowAdd)
-		.def("NotifyRowRemove", &DataSourceWrapper::NotifyRowRemove)
-		.def("NotifyRowChange", NotifyRowChange)
-		.def("NotifyRowChange", NotifyRowChangeParams)		
-		;
-
-	// Register the column names for use in python
-	python::scope().attr("COLUMN_CHILD_SOURCE") = DataSource::CHILD_SOURCE;
-	python::scope().attr("COLUMN_DEPTH") = DataSource::DEPTH;
-	python::scope().attr("COLUMN_NUM_CHILDREN") = DataSource::NUM_CHILDREN;
-}
-
-void DataSourceWrapper::GetRow(Core::StringList& row, const Core::String& table, int row_index, const Core::StringList& columns)
-{
-	PyObject* callable = PyObject_GetAttrString(self, "GetRow");
-	if (!callable)
-	{
-		Core::String error_message(128, "Function \"GetRow\" not found on python data source %s.", GetPythonClassName(self).CString());
-		Core::Log::Message(Core::Log::LT_WARNING, "%s", error_message.CString());
-		PyErr_SetString(PyExc_RuntimeError, error_message.CString());
-		python::throw_error_already_set();
-		return;
-	}
-
-	python::tuple t = python::make_tuple(table.CString(), row_index, columns);
-	PyObject* result = PyObject_CallObject(callable, t.ptr());
-	Py_DECREF(callable);	
-
-	// If it's a list, then just get the entries out of it
-	if (result && PyList_Check(result))
-	{
-		int num_entries = PyList_Size(result);
-		for (int i = 0; i < num_entries; i++)
-		{
-			Core::String entry;
-
-			PyObject* entry_object = PyList_GetItem(result, i);
-			if (PyString_Check(entry_object))
-			{
-				entry = PyString_AS_STRING(entry_object);
-			}
-			else if (PyInt_Check(entry_object))
-			{
-				int entry_int = (int)PyInt_AS_LONG(entry_object);
-				Core::TypeConverter< int, Core::String >::Convert(entry_int, entry);
-			}
-			else if (PyFloat_Check(entry_object))
-			{
-				float entry_float = (float)PyFloat_AS_DOUBLE(entry_object);
-				Core::TypeConverter< float, Core::String >::Convert(entry_float, entry);
-			}
-			else
-			{
-				Core::String error_message(128, "Failed to convert row %d entry %d on data source %s.", row_index, i, GetPythonClassName(self).CString());
-				Core::Log::Message(Core::Log::LT_WARNING, "%s", error_message.CString());
-				PyErr_SetString(PyExc_RuntimeError, error_message.CString());
-				python::throw_error_already_set();
-			}
-
-			row.push_back(entry);
-		}
-	}
-	else
-	{
-		// Print the error and restore it to the caller
-		PyObject *type, *value, *traceback;
-		PyErr_Fetch(&type, &value, &traceback);
-		Py_XINCREF(type);
-		Py_XINCREF(value);
-		Py_XINCREF(traceback);
-
-		Core::String error_message(128, "Failed to get entries for table %s row %d from python data source %s.", table.CString(), row_index, GetPythonClassName(self).CString());
-		Core::Log::Message(Core::Log::LT_WARNING, "%s", error_message.CString());
-		if (type == NULL)
-			PyErr_SetString(PyExc_RuntimeError, error_message.CString());
-		else
-			PyErr_Restore(type, value, traceback);
-
-		python::throw_error_already_set();
-	}
-
-	if (result)
-		Py_DECREF(result);
-}
-
-int DataSourceWrapper::GetNumRows(const Core::String& table)
-{
-	int num_rows = 0;
-
-	PyObject* callable = PyObject_GetAttrString(self, "GetNumRows");
-	if (!callable)
-	{
-		Core::String error_message(128, "Function \"GetNumRows\" not found on python data source %s.", GetPythonClassName(self).CString());
-		Core::Log::Message(Core::Log::LT_WARNING, "%s", error_message.CString());
-		PyErr_SetString(PyExc_RuntimeError, error_message.CString());
-		python::throw_error_already_set();
-
-		return 0;
-	}
-
-	PyObject* result = PyObject_CallObject(callable, python::make_tuple(table.CString()).ptr());
-	Py_DECREF(callable);
-
-	if (result && PyInt_Check(result))
-	{
-		num_rows = PyInt_AsLong(result);
-	}
-	else
-	{
-		// Print the error and restore it to the caller
-		PyObject *type, *value, *traceback;
-		PyErr_Fetch(&type, &value, &traceback);
-		Py_XINCREF(type);
-		Py_XINCREF(value);
-		Py_XINCREF(traceback);
-
-		Core::String error_message(128, "Failed to get number of rows from python data source %s.", GetPythonClassName(self).CString());
-		Core::Log::Message(Core::Log::LT_WARNING, "%s", error_message.CString());
-		if (type == NULL)
-			PyErr_SetString(PyExc_RuntimeError, error_message.CString());
-		else
-			PyErr_Restore(type, value, traceback);
-
-		python::throw_error_already_set();
-	}
-	
-	if (result)
-		Py_DECREF(result);
-
-	return num_rows;	
-}
-
-Core::ScriptObject DataSourceWrapper::GetScriptObject() const
-{
-	return self;
-}
-
-}
-}
-}

+ 0 - 68
Source/Controls/Python/DataSourceWrapper.h

@@ -1,68 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONDATASOURCEWRAPPER_H
-#define ROCKETCOREPYTHONDATASOURCEWRAPPER_H
-
-#include "../../../Include/Rocket/Core/Python/Python.h"
-#include "../../../Include/Rocket/Core/Types.h"
-#include "../../../Include/Rocket/Controls/DataSource.h"
-
-namespace Rocket {
-namespace Controls {
-namespace Python {
-
-/**
-	Python DataSource Wrapper
-
-	Exposes a DataSource to python.
-
-	@author Lloyd Weehuizen
- */
-
-class DataSourceWrapper : public DataSource
-{
-	public:
-		DataSourceWrapper(PyObject* self, const char* name);
-		~DataSourceWrapper();
-
-		static void InitialisePythonInterface();
-
-		void GetRow(Core::StringList& row, const Core::String& table, int row_index, const Core::StringList& columns);
-		int GetNumRows(const Core::String& table);
-
-		virtual Core::ScriptObject GetScriptObject() const;
-
-	private:
-		PyObject* self;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 255
Source/Controls/Python/ElementInterface.cpp

@@ -1,255 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "ElementInterface.h"
-#include "../../../Include/Rocket/Core/Python/ConverterScriptObject.h"
-#include "../../../Include/Rocket/Core/Factory.h"
-#include "../../../Include/Rocket/Core/Python/ElementInstancer.h"
-#include "../../../Include/Rocket/Core/Python/ElementWrapper.h"
-#include "../../../Include/Rocket/Controls/ElementDataGrid.h"
-#include "../../../Include/Rocket/Controls/ElementDataGridCell.h"
-#include "../../../Include/Rocket/Controls/ElementDataGridRow.h"
-#include "../../../Include/Rocket/Controls/ElementDataGridExpandButton.h"
-#include "../../../Include/Rocket/Controls/ElementForm.h"
-#include "../../../Include/Rocket/Controls/ElementFormControlDataSelect.h"
-#include "../../../Include/Rocket/Controls/ElementFormControlInput.h"
-#include "../../../Include/Rocket/Controls/ElementFormControlSelect.h"
-#include "../../../Include/Rocket/Controls/ElementFormControlTextArea.h"
-#include "../../../Include/Rocket/Controls/ElementTabSet.h"
-#include "SelectOptionProxy.h"
-#include "DataGridRowProxy.h"
-
-namespace Rocket {
-namespace Controls {
-namespace Python {
-
-typedef std::map< Rocket::Core::String, PyObject* > ClassDefinitions;
-ClassDefinitions class_definitions;
-
-void ElementInterface::InitialisePythonInterface()
-{
-	// ElementDataGrid.
-	bool (ElementDataGrid::*AddColumn)(const Rocket::Core::String&, const Rocket::Core::String&, float, const Rocket::Core::String&) = &ElementDataGrid::AddColumn;
-	class_definitions["DataGrid"] = python::class_< ElementDataGrid, Core::Python::ElementWrapper< ElementDataGrid >, boost::noncopyable, python::bases< Core::Element > >("ElementDataGrid", python::init< const char* >())
-		.def("AddColumn", AddColumn)
-		.def("SetDataSource", &ElementDataGrid::SetDataSource)
-		.add_property("rows", &ElementInterface::GetRows)
-		.ptr();
-
-	Rocket::Core::Python::ConverterScriptObject< ElementDataGrid > datagrid_converter;
-
-	// ElementDataGridRow.
-	class_definitions["DataGridRow"] = python::class_< ElementDataGridRow, Core::Python::ElementWrapper< ElementDataGridRow >, boost::noncopyable, python::bases< Core::Element > >("ElementDataGridRow", python::init< const char* >())
-		.add_property("row_expanded", &ElementDataGridRow::IsRowExpanded, &ElementInterface::SetRowExpanded)
-		.add_property("parent_grid", python::make_function(&ElementDataGridRow::GetParentGrid, python::return_value_policy< python::return_by_value >()))
-		.add_property("parent_row", python::make_function(&ElementDataGridRow::GetParentRow, python::return_value_policy< python::return_by_value >()))
-		.add_property("parent_relative_index", &ElementDataGridRow::GetParentRelativeIndex)
-		.add_property("table_relative_index", &ElementDataGridRow::GetTableRelativeIndex)
-		.ptr();
-
-	DataGridRowProxy::InitialisePythonInterface();
-	Rocket::Core::Python::ConverterScriptObject< ElementDataGridRow > datagridrow_converter;
-
-	// ElementDataGridCell.
-	class_definitions["DataGridCell"] = python::class_< ElementDataGridCell, Core::Python::ElementWrapper< ElementDataGridCell >, boost::noncopyable, python::bases< Core::Element > >("ElementDataGridCell", python::init< const char* >())
-		.ptr();
-
-	// ElementDataGridCell.
-	class_definitions["DataGridExpand"] = python::class_< ElementDataGridExpandButton, Core::Python::ElementWrapper< ElementDataGridExpandButton >, boost::noncopyable, python::bases< Core::Element > >("ElementDataGridExpand", python::init< const char* >())
-		.ptr();
-
-	// ElementForm.
-	class_definitions["Form"] = python::class_< ElementForm,Core::Python::ElementWrapper< ElementForm >, boost::noncopyable, python::bases< Core::Element > >("Form", python::init< const char* >())
-		.def("Submit", &ElementForm::Submit)
-		.def("Submit", &ElementInterface::Submit)
-		.ptr();
-
-	// ElementFormControl.
-	python::class_< ElementFormControl, Core::Python::ElementWrapper< ElementFormControl >, boost::noncopyable, python::bases< Core::Element > >("IElementFormControl", python::no_init)
-		.add_property("name", &ElementFormControl::GetName, &ElementFormControl::SetName)
-		.add_property("value", &ElementFormControl::GetValue, &ElementFormControl::SetValue)
-		.add_property("disabled", &ElementFormControl::IsDisabled, &ElementFormControl::SetDisabled)
-		.ptr();
-
-	// ElementFormControlInput.
-	class_definitions["FormControlInput"] = python::class_< ElementFormControlInput, Core::Python::ElementWrapper< ElementFormControlInput >, boost::noncopyable, python::bases< ElementFormControl > >("ElementFormControlInput", python::init< const char* >())
-		.add_property("checked", &ElementInterface::GetChecked, &ElementInterface::SetChecked)
-		.add_property("maxlength", &ElementInterface::GetMaxLength, &ElementInterface::SetMaxLength)
-		.add_property("size", &ElementInterface::GetSize, &ElementInterface::SetSize)
-		.add_property("max", &ElementInterface::GetMax, &ElementInterface::SetMax)
-		.add_property("min", &ElementInterface::GetMin, &ElementInterface::SetMin)
-		.add_property("step", &ElementInterface::GetStep, &ElementInterface::SetStep)
-		.ptr();
-
-	// ElementFormControlTextArea.
-	class_definitions["FormControlTextArea"] = python::class_< ElementFormControlTextArea,Core::Python::ElementWrapper< ElementFormControlTextArea >, boost::noncopyable, python::bases< ElementFormControl > >("ElementFormControlTextArea", python::init< const char* >())
-		.add_property("cols", &ElementFormControlTextArea::GetNumColumns, &ElementFormControlTextArea::SetNumColumns)
-		.add_property("rows", &ElementFormControlTextArea::GetNumRows, &ElementFormControlTextArea::SetNumRows)
-		.add_property("wordwrap", &ElementFormControlTextArea::GetWordWrap, &ElementFormControlTextArea::SetWordWrap)
-		.add_property("maxlength", &ElementFormControlTextArea::GetMaxLength, &ElementFormControlTextArea::SetMaxLength)
-		.ptr();
-	
-	// ElementFormControlSelect.
-	SelectOptionProxy::InitialisePythonInterface();
-	class_definitions["FormControlSelect"] = python::class_< ElementFormControlSelect, Core::Python::ElementWrapper< ElementFormControlSelect >, boost::noncopyable, python::bases< ElementFormControl > >("ElementFormControlSelect", python::init< const char* >())
-		.def("Add", &ElementFormControlSelect::Add)
-		.def("Add", &ElementInterface::Add)
-		.def("Remove", &ElementFormControlSelect::Remove)
-		.add_property("options", &ElementInterface::GetOptions)
-		.add_property("selection", &ElementFormControlSelect::GetSelection, &ElementFormControlSelect::SetSelection)
-		.ptr();
-
-	// ElementFormControlDataSelect.
-	class_definitions["FormControlDataSelect"] = python::class_< ElementFormControlDataSelect, Core::Python::ElementWrapper< ElementFormControlDataSelect >, boost::noncopyable, python::bases< ElementFormControlSelect > >("ElementFormControlDataSelect", python::init< const char* >())
-		.def("SetDataSource", &ElementFormControlDataSelect::SetDataSource)
-		.ptr();
-
-	// ElementTabSet.
-	void (ElementTabSet::*SetTab)(int, const Rocket::Core::String&) = &ElementTabSet::SetTab;
-	void (ElementTabSet::*SetPanel)(int, const Rocket::Core::String&) = &ElementTabSet::SetPanel;
-	class_definitions["TabSet"] = python::class_< ElementTabSet, Core::Python::ElementWrapper< ElementTabSet >, boost::noncopyable, python::bases< Core::Element > >("ElementTabSet", python::init< const char* >())
-		.add_property("num_tabs", &ElementTabSet::GetNumTabs)
-		.def("SetTab", SetTab)
-		.def("SetPanel", SetPanel)
-		.add_property("active_tab", &ElementTabSet::GetActiveTab, &ElementTabSet::SetActiveTab)
-		.ptr();
-}
-
-void ElementInterface::InitialiseRocketInterface()
-{	
-	Core::Factory::RegisterElementInstancer("datagrid", new Core::Python::ElementInstancer( (*class_definitions.find("DataGrid")).second))->RemoveReference();
-	Core::Factory::RegisterElementInstancer("datagridexpand", new Core::Python::ElementInstancer( (*class_definitions.find("DataGridExpand")).second))->RemoveReference();
-	Core::Factory::RegisterElementInstancer("#rktctl_datagridrow", new Core::Python::ElementInstancer( (*class_definitions.find("DataGridRow")).second))->RemoveReference();
-	Core::Factory::RegisterElementInstancer("#rktctl_datagridcell", new Core::Python::ElementInstancer( (*class_definitions.find("DataGridCell")).second))->RemoveReference();	
-	
-	Core::Factory::RegisterElementInstancer("form", new Core::Python::ElementInstancer((*class_definitions.find("Form")).second ))->RemoveReference();	
-	Core::Factory::RegisterElementInstancer("input", new Core::Python::ElementInstancer((*class_definitions.find("FormControlInput")).second ))->RemoveReference();	
-	Core::Factory::RegisterElementInstancer("textarea", new Core::Python::ElementInstancer((*class_definitions.find("FormControlTextArea")).second ))->RemoveReference();
-	Core::Factory::RegisterElementInstancer("dataselect", new Core::Python::ElementInstancer((*class_definitions.find("FormControlDataSelect")).second ))->RemoveReference();
-	Core::Factory::RegisterElementInstancer("select", new Core::Python::ElementInstancer((*class_definitions.find("FormControlSelect")).second ))->RemoveReference();
-	Core::Factory::RegisterElementInstancer("tabset", new Core::Python::ElementInstancer((*class_definitions.find("TabSet")).second ))->RemoveReference();
-}
-
-// Sets the expanded state of a data grid row.
-void ElementInterface::SetRowExpanded(ElementDataGridRow* element, bool row_expanded)
-{
-	if (row_expanded)
-		element->ExpandRow();
-	else
-		element->CollapseRow();
-}
-
-// Returns the options proxy for a select element.
-SelectOptionProxy ElementInterface::GetOptions(ElementFormControlSelect* element)
-{
-	return SelectOptionProxy(element);
-}
-
-// Override for ElementFormControlSelect's Add() without the last parameter.
-int ElementInterface::Add(ElementFormControlSelect* element, const Rocket::Core::String& rml, const Rocket::Core::String& value)
-{
-	return element->Add(rml, value);
-}
-
-// Default parameter submit for forms
-void ElementInterface::Submit(ElementForm* element)
-{
-	element->Submit();
-}
-
-bool ElementInterface::GetChecked(ElementFormControlInput* element)
-{
-	return element->HasAttribute("checked");
-}
-
-void ElementInterface::SetChecked(ElementFormControlInput* element, bool checked)
-{
-	if (checked)
-		element->SetAttribute("checked", true);
-	else
-		element->RemoveAttribute("checked");
-}
-
-int ElementInterface::GetMaxLength(ElementFormControlInput* element)
-{
-	return element->GetAttribute<int>("maxlength", -1);
-}
-
-void ElementInterface::SetMaxLength(ElementFormControlInput* element, int max_length)
-{
-	element->SetAttribute("maxlength", max_length);
-}
-
-int ElementInterface::GetSize(ElementFormControlInput* element)
-{
-	return element->GetAttribute<int>("size", 20);
-}
-
-void ElementInterface::SetSize(ElementFormControlInput* element, int size)
-{
-	element->SetAttribute("size", size);
-}
-
-int ElementInterface::GetMin(ElementFormControlInput* element)
-{
-	return element->GetAttribute<int>("min", 0);
-}
-
-void ElementInterface::SetMin(ElementFormControlInput* element, int min)
-{
-	element->SetAttribute("min", min);
-}
-
-int ElementInterface::GetMax(ElementFormControlInput* element)
-{
-	return element->GetAttribute<int>("max", 100);
-}
-
-void ElementInterface::SetMax(ElementFormControlInput* element, int max)
-{
-	element->SetAttribute("max", max);
-}
-
-int ElementInterface::GetStep(ElementFormControlInput* element)
-{
-	return element->GetAttribute<int>("step", 1);
-}
-
-void ElementInterface::SetStep(ElementFormControlInput* element, int step)
-{
-	element->SetAttribute("step", step);
-}
-
-DataGridRowProxy ElementInterface::GetRows(ElementDataGrid* element)
-{
-	return DataGridRowProxy(element);
-}
-
-}
-}
-}

+ 0 - 94
Source/Controls/Python/ElementInterface.h

@@ -1,94 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCONTROLSPYTHONELEMENTINTERFACE_H
-#define ROCKETCONTROLSPYTHONELEMENTINTERFACE_H
-
-#include "SelectOptionProxy.h"
-#include "DataGridRowProxy.h"
-
-namespace Rocket {
-namespace Controls {
-
-class ElementDataGridRow;
-class ElementFormControlSelect;
-
-namespace Python {
-
-/**
-	Python interface to the element classes
-	defined in the Rocket Controls library
-
-	@author Lloyd Weehuizen
- */
-
-class ElementInterface
-{
-public:
-	/// Initialises the python element interface
-	static void InitialisePythonInterface();
-	/// Initialise the rocket element interface
-	static void InitialiseRocketInterface();
-
-private:
-	// Sets the expanded state of a data grid row.
-	static void SetRowExpanded(ElementDataGridRow* element, bool row_expanded);
-	// Returns the options proxy for a select element.
-	static SelectOptionProxy GetOptions(ElementFormControlSelect* element);
-	// Override for ElementFormControlSelect's Add() without the last parameter.
-	static int Add(ElementFormControlSelect* element, const Rocket::Core::String& rml, const Rocket::Core::String& value);
-
-	// Default parameter submit for forms
-	static void Submit(ElementForm* element);
-
-	// Methods for simplyfing access to input element attributes
-	static bool GetChecked(ElementFormControlInput* element);
-	static void SetChecked(ElementFormControlInput* element, bool checked);
-	
-	static int GetMaxLength(ElementFormControlInput* element);
-	static void SetMaxLength(ElementFormControlInput* element, int max_length);
-	
-	static int GetSize(ElementFormControlInput* element);
-	static void SetSize(ElementFormControlInput* element, int size);
-	
-	static int GetMax(ElementFormControlInput* element);
-	static void SetMax(ElementFormControlInput* element, int max);
-	
-	static int GetMin(ElementFormControlInput* element);
-	static void SetMin(ElementFormControlInput* element, int min);
-
-	static int GetStep(ElementFormControlInput* element);
-	static void SetStep(ElementFormControlInput* element, int step);
-
-	static DataGridRowProxy GetRows(ElementDataGrid* element);
-};
-
-}
-}
-}
-
-#endif

+ 0 - 71
Source/Controls/Python/Module.cpp

@@ -1,71 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "Module.h"
-#include "../../../Include/Rocket/Core/Python/Python.h"
-#include "../../../Include/Rocket/Core/Python/ConverterScriptObject.h"
-#include "../../../Include/Rocket/Controls/DataSource.h"
-#include "ElementInterface.h"
-#include "DataFormatterWrapper.h"
-#include "DataSourceWrapper.h"
-
-namespace Rocket {
-namespace Controls {
-namespace Python {
-
-Module module;
-
-BOOST_PYTHON_MODULE(_rocketcontrols)
-{	
-	// Pull in the core python namespace, to make sure its loaded
-	// the boost python definitions
-	Py_XDECREF(PyImport_ImportModule("_rocketcore"));
-
-	Rocket::Core::Python::ConverterScriptObject< DataSource >();
-
-	// Initialise the python bindings
-	ElementInterface::InitialisePythonInterface();
-	DataFormatterWrapper::InitialisePythonInterface();
-	DataSourceWrapper::InitialisePythonInterface();
-
-	// Register this plugin with rocket
-	Rocket::Core::RegisterPlugin(&module);
-}
-
-void Module::OnInitialise()
-{
-	// Force initialisation of C++ interface before we register our instancers
-	Controls::Initialise();
-
-	// Load out elements into Rocket
-	ElementInterface::InitialiseRocketInterface();
-}
-
-}
-}
-}

+ 0 - 57
Source/Controls/Python/Module.h

@@ -1,57 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCONTROLSPYTHONMODULE_H
-#define ROCKETCONTROLSPYTHONMODULE_H
-
-#include "../../../Include/Rocket/Core/Plugin.h"
-
-namespace Rocket {
-namespace Controls {
-namespace Python {
-
-/**
-	Python Interfaces for the User Controls Library
-
-	When this module loads, it updates the Rocket Factory
-	with instancers for instancing all elements through python
-
-	@author Lloyd Weehuizen
- */
-
-class Module : public Core::Plugin
-{
-public:
-	/// Hook for module initialisation
-	virtual void OnInitialise();
-};
-
-}
-}
-}
-
-#endif

+ 0 - 84
Source/Controls/Python/SelectOptionProxy.cpp

@@ -1,84 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "SelectOptionProxy.h"
-#include "../../../Include/Rocket/Core/Element.h"
-
-namespace Rocket {
-namespace Controls {
-namespace Python {
-
-SelectOptionProxy::SelectOptionProxy(ElementFormControlSelect* _element)
-{
-	element = _element;
-
-	// Update the element to force it to evaluate its options if necessary.
-	element->Update();
-}
-
-SelectOptionProxy::~SelectOptionProxy()
-{
-}
-
-void SelectOptionProxy::InitialisePythonInterface()
-{
-	python::class_< SelectOption >("SelectOption", python::no_init)
-		.add_property("element", python::make_function(&SelectOption::GetElement, python::return_value_policy< python::return_by_value >()))
-		.add_property("value", python::make_function(&SelectOption::GetValue, python::return_value_policy< python::return_by_value >()))
-		;
-
-	python::class_< SelectOptionProxy >("SelectOptionProxy", python::no_init)
-		.def("__len__", &SelectOptionProxy::Len)
-		.def("__getitem__", &SelectOptionProxy::GetItem, python::return_value_policy< python::return_by_value >())
-		;
-}
-
-int SelectOptionProxy::Len()
-{
-	return element->GetNumOptions();
-}
-
-SelectOption SelectOptionProxy::GetItem(int index)
-{
-	// Support indexing from both ends.
-	if (index < 0)
-		index = element->GetNumAttributes() + index;
-
-	// Throw an exception if we're out of range. This is required to support Python iteration.
-	if (index >= element->GetNumOptions())
-	{
-		PyErr_SetString(PyExc_IndexError, "Index out of range.");
-		python::throw_error_already_set();
-	}
-
-	return *element->GetOption(index);
-}
-
-}
-}
-}

+ 0 - 69
Source/Controls/Python/SelectOptionProxy.h

@@ -1,69 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCONTROLSPYTHONSELECTOPTIONPROXY_H
-#define ROCKETCONTROLSPYTHONSELECTOPTIONPROXY_H
-
-#include "../../../Include/Rocket/Controls/SelectOption.h"
-
-namespace Rocket {
-namespace Controls {
-
-class ElementFormControlSelect;
-
-namespace Python {
-
-/**
-	Thin, lightweight proxy object for providing a select.options accessor.
-
-	@author Peter Curry
- */
-
-class SelectOptionProxy
-{
-public:
-	SelectOptionProxy(ElementFormControlSelect* element);
-	~SelectOptionProxy();
-
-	/// Initialise the interface.
-	static void InitialisePythonInterface();
-
-	/// Python __getitem__ override.
-	SelectOption GetItem(int index);
-
-	/// Python __len__ override.
-	int Len();
-
-private:
-	ElementFormControlSelect* element;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 28
Source/Controls/Python/precompiled.cpp

@@ -1,28 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"

+ 0 - 33
Source/Controls/Python/precompiled.h

@@ -1,33 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-// Python header.
-#include "../../../Include/Rocket/Core/Python/Python.h"
-
-// Rocket core and controls.
-#include "../../../Include/Rocket/Core.h"
-#include "../../../Include/Rocket/Controls.h"

+ 0 - 79
Source/Core/Python/ContextDocumentProxy.cpp

@@ -1,79 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "ContextDocumentProxy.h"
-#include "../../../Include/Rocket/Core/Python/NameIndexInterface.h"
-#include "../../../Include/Rocket/Core/Python/Utilities.h"
-#include "../../../Include/Rocket/Core/Context.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-class ContextDocumentLenAccessor
-{
-public:
-	int operator()(ContextDocumentProxy& proxy)
-	{
-		return proxy.context->GetNumDocuments();
-	}
-};
-
-class ContextDocumentIndexAccessor
-{
-public:
-	ElementDocument* operator()(ContextDocumentProxy& proxy, int index)
-	{
-		return proxy.context->GetDocument(index);
-	}
-};
-
-class ContextDocumentNameAccessor
-{
-public:
-	ElementDocument* operator()(ContextDocumentProxy& proxy, const Rocket::Core::String& name)
-	{
-		return proxy.context->GetDocument(name);
-	}
-};
-
-ContextDocumentProxy::ContextDocumentProxy(Context* _context)
-{
-	context = _context;
-}
-
-void ContextDocumentProxy::InitialisePythonInterface()
-{
-	python::class_< ContextDocumentProxy >("documentproxy", python::no_init)
-		.def(Rocket::Core::Python::NameIndexInterface< ContextDocumentProxy, ContextDocumentLenAccessor, ContextDocumentIndexAccessor, ContextDocumentNameAccessor >())
-		;
-}
-
-}
-}
-}

+ 0 - 59
Source/Core/Python/ContextDocumentProxy.h

@@ -1,59 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONCONTEXTDOCUMENTPROXY_H
-#define ROCKETCOREPYTHONCONTEXTDOCUMENTPROXY_H
-
-namespace Rocket {
-namespace Core {
-
-class Context;
-
-namespace Python {
-
-/**
-	Thin, lightweight proxy object for providing array-style document lookups on a context.
-
-	@author Peter Curry
- */
-
-class ContextDocumentProxy
-{
-public:
-	ContextDocumentProxy(Context* context);
-
-	/// Initialise the interface.
-	static void InitialisePythonInterface();
-
-	Context* context;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 85
Source/Core/Python/ContextInstancer.cpp

@@ -1,85 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "ContextInstancer.h"
-#include "../../../Include/Rocket/Core/Python/Utilities.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-ContextInstancer::ContextInstancer(PyObject* _instancer)
-{
-	instancer = _instancer;
-	Py_INCREF(instancer);
-}
-
-ContextInstancer::~ContextInstancer()
-{
-	Py_DECREF(instancer);
-}
-
-// Instances a context.
-Context* ContextInstancer::InstanceContext(const Rocket::Core::String& name)
-{
-	// Put the arguments into a tuple.
-	PyObject* args = PyTuple_New(1);	
-	PyTuple_SetItem(args, 0, PyString_FromString(name.CString()));
-
-	// Instance the context.
-	PyObject* instance = PyObject_CallObject(instancer, args);
-	Py_DECREF(args);
-
-	// Rebind the target element.
-	Context* context = python::extract< Context* >(Rocket::Core::Python::Utilities::MakeObject(instance));
-	if (context != NULL)
-	{
-		// The wrapper will remove the initial C++ reference (as the object may have been made in Python), so we have
-		// to add the reference back again ... and remove the Python reference this will add!
-		context->AddReference();
-		Py_DECREF(instance);
-	}
-
-	return context;
-}
-
-// Releases a context previously created by this context.
-void ContextInstancer::ReleaseContext(Context* ROCKET_UNUSED_PARAMETER(context))
-{
-	ROCKET_UNUSED(context);
-}
-
-// Releases this context instancer
-void ContextInstancer::Release()
-{
-	delete this;
-}
-}
-}
-
-}

+ 0 - 69
Source/Core/Python/ContextInstancer.h

@@ -1,69 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONCONTEXTINSTANCER_H
-#define ROCKETCOREPYTHONCONTEXTINSTANCER_H
-
-#include "../../../Include/Rocket/Core/ContextInstancer.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-/**
-	Instancer for Python contexts.
-
-	@author Peter Curry
- */
-
-class ContextInstancer : public Rocket::Core::ContextInstancer
-{
-public:
-	ContextInstancer(PyObject* instancer);
-	virtual ~ContextInstancer();
-
-	/// Instances a context.
-	/// @param[in] name Name of this context.
-	/// @return The instanced context.
-	virtual Context* InstanceContext(const Rocket::Core::String& name);
-
-	/// Releases a context previously created by this context.
-	/// @param[in] context The context to release.
-	virtual void ReleaseContext(Context* context);
-
-	/// Releases this context instancer
-	virtual void Release();
-
-private:
-	PyObject* instancer;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 151
Source/Core/Python/ContextInterface.cpp

@@ -1,151 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "ContextInterface.h"
-
-#include "../../../Include/Rocket/Core/Python/Utilities.h"
-#include "../../../Include/Rocket/Core/Python/Wrapper.h"
-#include "../../../Include/Rocket/Core/Context.h"
-#include "../../../Include/Rocket/Core/Factory.h"
-
-#include "EventListener.h"
-#include "ContextInstancer.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-static PyObject* py_context = NULL;
-
-// Initialises the Python interface.
-bool ContextInterface::InitialisePythonInterface()
-{
-	ContextDocumentProxy::InitialisePythonInterface();
-
-	py_context = python::class_< Context, Rocket::Core::Python::Wrapper< Context, const Rocket::Core::String& >, boost::noncopyable>("Context", python::init< const Rocket::Core::String& >())
-		.def("AddEventListener", &ContextInterface::AddEventListener)
-		.def("AddMouseCursor", &Context::AddMouseCursor, python::return_value_policy< python::return_by_value >())
-		.def("CreateDocument", &ContextInterface::CreateDocument)
-		.def("LoadDocument", &ContextInterface::LoadDocument)
-		.def("LoadDocumentFromMemory", &ContextInterface::LoadDocumentFromMemory)
-		.def("LoadMouseCursor", &ContextInterface::LoadMouseCursor)
-		.def("Render", &Context::Render)
-		.def("ShowMouseCursor", &Context::ShowMouseCursor)
-		.def("UnloadAllDocuments", &Context::UnloadAllDocuments)
-		.def("UnloadAllMouseCursors", &Context::UnloadAllMouseCursors)
-		.def("UnloadDocument", &Context::UnloadDocument)
-		.def("UnloadMouseCursor", &Context::UnloadMouseCursor)
-		.def("Update", &Context::Update)
-		.add_property("dimensions", python::make_function(&Context::GetDimensions, python::return_value_policy< python::return_by_value >()), &Context::SetDimensions)
-		.add_property("documents", &ContextInterface::GetDocuments)
-		.add_property("focus_element", python::make_function(&Context::GetFocusElement, python::return_value_policy< python::return_by_value >()))
-		.add_property("hover_element", python::make_function(&Context::GetHoverElement, python::return_value_policy< python::return_by_value >()))
-		.add_property("root_element", python::make_function(&Context::GetRootElement, python::return_value_policy< python::return_by_value >()))
-		.add_property("name", python::make_function(&Context::GetName, python::return_value_policy< python::return_by_value >()))
-		.ptr();
-
-	return true;
-}
-
-// Initialise the Rocket element interface.
-void ContextInterface::InitialiseRocketInterface()
-{
-	Factory::RegisterContextInstancer(new ContextInstancer(py_context))->RemoveReference();
-}
-
-// The "AddEventListener" function bound into Python context objects instead of the C++ function.
-void ContextInterface::AddEventListener(Context* self, const char* event, const char* script, bool in_capture_phase)
-{
-	self->AddEventListener(event, new EventListener(script, self->GetRootElement()), in_capture_phase);
-}
-
-// The "CreateDocument" function bound into Python context objects instead of the C++ function.
-python::object ContextInterface::CreateDocument(Context* self, const char* tag)
-{
-	Rocket::Core::ElementDocument* document = self->CreateDocument(tag);
-	if (document == NULL)
-		return python::object();
-
-	// Remove the C++ caller reference and add a Python one to replace it.
-	python::object py_document = Rocket::Core::Python::Utilities::MakeObject(document);
-	document->RemoveReference();
-
-	return py_document;
-}
-
-// The "LoadDocument" function bound into Python context objects instead of the C++ function.
-python::object ContextInterface::LoadDocument(Context* self, const char* document_path)
-{
-	Rocket::Core::ElementDocument* document = self->LoadDocument(document_path);
-	if (document == NULL)
-		return python::object();
-
-	// Remove the C++ caller reference and return the python::object
-	python::object py_document = Rocket::Core::Python::Utilities::MakeObject(document);
-	document->RemoveReference();
-
-	return py_document;
-}
-
-// The "LoadDocument" function bound into Python context objects instead of the C++ function.
-python::object ContextInterface::LoadDocumentFromMemory(Context* self, const char* stream)
-{
-	Rocket::Core::ElementDocument* document = self->LoadDocumentFromMemory(stream);
-	if (document == NULL)
-		return python::object();
-
-	// Remove the C++ caller reference and return the python::object
-	python::object py_document = Rocket::Core::Python::Utilities::MakeObject(document);
-	document->RemoveReference();
-
-	return py_document;
-}
-
-// The "LoadMouseCursor" function bound into Python context objects instead of the C++ function.
-python::object ContextInterface::LoadMouseCursor(Context* self, const char* document_path)
-{
-	Rocket::Core::ElementDocument* document = self->LoadMouseCursor(document_path);
-	if (document == NULL)
-		return python::object();
-
-	// Remove the C++ caller reference and add a Python one to replace it.
-	python::object py_document = Rocket::Core::Python::Utilities::MakeObject(document);
-	document->RemoveReference();
-
-	return py_document;
-}
-
-// Returns the document proxy object for the 'document' property.
-ContextDocumentProxy ContextInterface::GetDocuments(Context* self)
-{
-	return ContextDocumentProxy(self);
-}
-
-}
-}
-}

+ 0 - 90
Source/Core/Python/ContextInterface.h

@@ -1,90 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONCONTEXTINTERFACE_H
-#define ROCKETCOREPYTHONCONTEXTINTERFACE_H
-
-#include "ContextDocumentProxy.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-/**
-	Installs and manages the Python interface for libRocket Context objects.
-
-	@author Peter Curry
- */
-
-class ContextInterface
-{
-public:
-	/// Initialises the Python context interface.
-	static bool InitialisePythonInterface();
-	/// Initialise the Rocket context interface.
-	static void InitialiseRocketInterface();
-
-	/// The "AddEventListener" function bound into Python context objects instead of the C++
-	/// function.
-	/// @param[in] self The calling context.
-	/// @param[in] event The event to bind to.
-	/// @param[in] script The script fragment to execute.
-	/// @param[in] in_capture_phase True if binding on the capture phase, false if the bubble phase.
-	static void AddEventListener(Context* self, const char* event, const char* script, bool in_capture_phase);
-	/// The "CreateDocument" function bound into Python context objects instead of the C++
-	/// function.
-	/// @param[in] self The calling context.
-	/// @param[in] tag The tag name for the instanced document.
-	/// @return The new document.
-	static python::object CreateDocument(Context* self, const char* tag);
-	/// The "LoadDocument" function bound into Python context objects instead of the C++ function.
-	/// @param[in] self The calling context.
-	/// @param[in] document_path The path to load the document from.
-	/// @return The loaded document.
-	static python::object LoadDocument(Context* self, const char* document_path);
-	/// The "LoadDocument" function bound into Python context objects instead of the C++ function.
-	/// @param[in] self The calling context.
-	/// @param[in] stream The document stream
-	/// @return The loaded document.
-	static python::object LoadDocumentFromMemory(Context* self, const char* stream);
-	/// The "LoadMouseCursor" function bound into Python context objects instead of the C++
-	/// function.
-	/// @param[in] self The calling context.
-	/// @param[in] document_path The path to load the cursor from.
-	/// @return The loaded cursor.
-	static python::object LoadMouseCursor(Context* self, const char* document_path);
-	/// Returns the document proxy object for the 'document' property.
-	/// @param[in] self The calling context.
-	/// @return The proxy object.
-	static ContextDocumentProxy GetDocuments(Context* self);
-};
-
-}
-}
-}
-
-#endif

+ 0 - 80
Source/Core/Python/ContextProxy.cpp

@@ -1,80 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "ContextProxy.h"
-#include "../../../Include/Rocket/Core/Python/NameIndexInterface.h"
-#include "../../../Include/Rocket/Core/Python/Utilities.h"
-#include "../../../Include/Rocket/Core.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-class ContextLenAccessor
-{
-public:
-	int operator()(ContextProxy& ROCKET_UNUSED_PARAMETER(proxy))
-	{
-		ROCKET_UNUSED(proxy);
-
-		return GetNumContexts();
-	}
-};
-
-class ContextIndexAccessor
-{
-public:
-	Context* operator()(ContextProxy& ROCKET_UNUSED_PARAMETER(proxy), int index)
-	{
-		ROCKET_UNUSED(proxy);
-
-		return GetContext(index);
-	}
-};
-
-class ContextNameAccessor
-{
-public:
-	Context* operator()(ContextProxy& ROCKET_UNUSED_PARAMETER(proxy), const Rocket::Core::String& name)
-	{
-		ROCKET_UNUSED(proxy);
-
-		return GetContext(name);
-	}
-};
-
-void ContextProxy::InitialisePythonInterface()
-{
-	python::class_< ContextProxy >("contextproxy", python::no_init)
-		.def(Rocket::Core::Python::NameIndexInterface< ContextProxy, ContextLenAccessor, ContextIndexAccessor, ContextNameAccessor >())
-		;
-}
-
-}
-}
-}

+ 0 - 52
Source/Core/Python/ContextProxy.h

@@ -1,52 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONCONTEXTPROXY_H
-#define ROCKETCOREPYTHONCONTEXTPROXY_H
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-/**
-	Thin, lightweight proxy object for providing array-style context lookups.
-
-	@author Peter Curry
- */
-
-class ContextProxy
-{
-public:
-	/// Initialise the interface.
-	static void InitialisePythonInterface();
-};
-
-}
-}
-}
-
-#endif

+ 0 - 219
Source/Core/Python/Converters.cpp

@@ -1,219 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-
-#include "../../../Include/Rocket/Core/Variant.h"
-#include "../../../Include/Rocket/Core/Dictionary.h"
-#include "../../../Include/Rocket/Core/Python/ConverterScriptObject.h"
-#include "../../../Include/Rocket/Core/ElementDocument.h"
-
-#include "EventListener.h"
-
-#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-// Boost helper class for converting from Variant to a python object
-struct VariantConverter
-{
-	VariantConverter()
-	{
-		// Register custom Variant to python converter
-		boost::python::to_python_converter< Variant, VariantConverter >();
-		boost::python::to_python_converter< Variant*, VariantConverter >();
-
-		// Register the python to variant converter
-		boost::python::converter::registry::push_back(&Convertible, &Construct, boost::python::type_id< Variant >());
-	}
-
-	static PyObject* convert(Variant* variant)
-	{
-		if (!variant)
-		{
-			Py_INCREF(Py_None);
-			return Py_None;
-		}
-		return convert(*variant);
-	}
-
-	static PyObject* convert(const Variant& variant)
-	{
-		PyObject* object = NULL;
-
-		switch (variant.GetType())
-		{
-			case Variant::STRING:
-			{
-				object = PyString_FromString(variant.Get< String >().CString());
-			}
-			break;
-
-			case Variant::INT:
-			{
-				object = PyInt_FromLong(variant.Get< int >());
-			}
-			break;
-
-			case Variant::WORD:
-			{
-				object = PyInt_FromLong(variant.Get< word >());
-			}
-			break;
-
-			case Variant::FLOAT:
-			{
-				object = PyFloat_FromDouble(variant.Get< float >());
-			}
-			break;
-
-			case Variant::VECTOR2:
-			{
-				python::object o(variant.Get< Vector2f >());
-				object = o.ptr();
-				Py_INCREF( object );
-			}
-			break;
-
-			case Variant::SCRIPTINTERFACE:
-			{				
-				object = (PyObject*)(variant.Get< ScriptInterface* >())->GetScriptObject();
-				Py_INCREF(object);
-			}
-			break;
-
-			default:
-			{
-				object = Py_None;
-				Py_INCREF(object);
-			}
-			break;
-		}
-		
-		return object;
-	}
-
-	static void* Convertible(PyObject* object)
-	{
-		if (!PyString_Check(object) && !PyInt_Check(object) && !PyFloat_Check(object))
-			return 0;
-		return object;
-	}
-
-	static void Construct(PyObject* object, boost::python::converter::rvalue_from_python_stage1_data* data)
-	{
-		void* storage = ((boost::python::converter::rvalue_from_python_storage< Variant >*)data)->storage.bytes;
-		Variant* variant = new (storage) Variant();
-
-		if (PyString_Check(object))
-		{
-			variant->Set(String(PyString_AsString(object)));
-		}
-		else if (PyInt_Check(object))
-		{
-			variant->Set((int)PyInt_AsLong(object));
-		}
-		else if (PyFloat_Check(object))
-		{
-			variant->Set((float)PyFloat_AsDouble(object));
-		}
-		else 
-		{
-			boost::python::throw_error_already_set();
-			return;
-		}		
-		
-		data->convertible = storage;
-	}
-};
-
-// String Converter
-struct StringConverter
-{
-	StringConverter()
-	{
-		boost::python::to_python_converter< String, StringConverter >();
-
-		boost::python::converter::registry::push_back( &Convertible, &Construct, boost::python::type_id< String >() );
-	}
-
-	static PyObject* convert(const String& s)
-	{
-		return boost::python::incref(boost::python::object(s.CString()).ptr());
-	}
-
-	static void* Convertible(PyObject* obj_ptr)
-	{
-		if (!PyString_Check(obj_ptr))
-			return 0;
-		return obj_ptr;
-	}
-
-	static void Construct(PyObject* obj_ptr, boost::python::converter::rvalue_from_python_stage1_data* data)
-	{
-		const char* value = PyString_AsString(obj_ptr);
-		if (value == 0) 
-			boost::python::throw_error_already_set();
-		void* storage = ((boost::python::converter::rvalue_from_python_storage< String >*)data)->storage.bytes;
-		new (storage) String(value);
-		data->convertible = storage;
-	}
-};
-
-// Helper class for converting from python to an event listener
-struct EventListenerFromPython
-{
-	EventListenerFromPython()
-	{
-		python::converter::registry::insert( &Convert, python::type_id<EventListener>() );
-	}
-
-	static void* Convert( PyObject* object )
-	{
-		return new EventListener( object );	
-	}
-};
-
-void RegisterPythonConverters()
-{
-	StringConverter();
-	VariantConverter();	
-
-	ConverterScriptObject< ScriptInterface >();	
-
-	EventListenerFromPython();
-
-	ConverterScriptObject< Context >();
-	ConverterScriptObject< Element >();
-	ConverterScriptObject< ElementDocument >();
-}
-
-}
-}
-}

+ 0 - 38
Source/Core/Python/Converters.h

@@ -1,38 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONCONVERTERS_H
-#define ROCKETCOREPYTHONCONVERTERS_H
-
-/// Registers the to/from python converters with boost
-void RegisterPyConverters();
-
-}
-}
-}
-
-#endif

+ 0 - 87
Source/Core/Python/ElementAttributeProxy.cpp

@@ -1,87 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "ElementAttributeProxy.h"
-#include "../../../Include/Rocket/Core/Property.h"
-#include "../../../Include/Rocket/Core/Element.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-ElementAttributeProxy::ElementAttributeProxy(Element* _element)
-{
-	element = _element;
-}
-
-ElementAttributeProxy::~ElementAttributeProxy()
-{
-}
-
-void ElementAttributeProxy::InitialisePythonInterface()
-{
-	python::class_<AttributeProxy>("AttributeProxy", python::no_init)
-		.def_readonly("name", &AttributeProxy::GetName)
-		.add_property("value", &AttributeProxy::GetValue)
-		;
-
-	python::class_<ElementAttributeProxy>("ElementAttributesProxy", python::no_init)
-		.def("__len__", &ElementAttributeProxy::Len )
-		.def("__getitem__", &ElementAttributeProxy::GetItem, python::return_value_policy< python::return_by_value >())		
-		;
-}
-
-int ElementAttributeProxy::Len()
-{
-	return element->GetNumAttributes();
-}
-
-ElementAttributeProxy::AttributeProxy ElementAttributeProxy::GetItem(int index)
-{
-	// Support indexing from both ends
-	if (index < 0)
-	{
-		index = element->GetNumAttributes() + index;
-	}
-
-	Rocket::Core::String name;
-	Rocket::Core::String value;
-
-	// Throw exception if we're out of range, this is required to support python iteration
-	if (!element->IterateAttributes(index, name, value))
-	{
-		PyErr_SetString(PyExc_IndexError, "Index out of range");
-		python::throw_error_already_set();
-	}
-
-	return AttributeProxy(name, value);
-}
-
-}
-}
-}

+ 0 - 79
Source/Core/Python/ElementAttributeProxy.h

@@ -1,79 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONELEMENTATTRIBUTEPROXY_H
-#define ROCKETCOREPYTHONELEMENTATTRIBUTEPROXY_H
-
-namespace Rocket {
-namespace Core {
-
-class Element;
-
-namespace Python {
-
-/**
-	Thin lightweight proxy object for providing
-	a DOM-like element.children accessor.
-
-	@author Lloyd Weehuizen
- */
-
-class ElementAttributeProxy
-{
-public:
-	ElementAttributeProxy(Element* element);
-	~ElementAttributeProxy();
-
-	/// Initialise the interface
-	static void InitialisePythonInterface();
-
-	// Class that contains a single attribute instance
-	class AttributeProxy
-	{
-	public:
-		AttributeProxy(const Rocket::Core::String& _name, const Rocket::Core::String& _value) : name(_name), value(_value) {}
-		const char* GetName() { return name.CString(); }
-		const char* GetValue() { return value.CString(); }
-		Rocket::Core::String name;
-		Rocket::Core::String value;
-	};
-	
-	/// Python __getitem__ override
-	AttributeProxy GetItem(int index);
-
-	/// Python __len__ override
-	int Len();
-	
-private:
-	Element* element;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 79
Source/Core/Python/ElementChildrenProxy.cpp

@@ -1,79 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#include "precompiled.h"
-#include "ElementChildrenProxy.h"
-#include "../../../Include/Rocket/Core/Property.h"
-#include "../../../Include/Rocket/Core/Element.h"
-
-namespace Rocket {
-namespace Core {
-namespace Python {
-
-ElementChildrenProxy::ElementChildrenProxy(Element* _element)
-{
-	element = _element;
-}
-
-ElementChildrenProxy::~ElementChildrenProxy()
-{
-}
-
-void ElementChildrenProxy::InitialisePythonInterface()
-{
-	python::class_<ElementChildrenProxy>("childrenproxy", python::no_init)
-		.def("__len__", &ElementChildrenProxy::Len )
-		.def("__getitem__", &ElementChildrenProxy::GetItem, python::return_value_policy< python::return_by_value >())
-		;
-}
-
-int ElementChildrenProxy::Len()
-{
-	return element->GetNumChildren();
-}
-
-Element* ElementChildrenProxy::GetItem(int index)
-{
-	// Support indexing from both ends
-	if (index < 0)
-	{
-		index = element->GetNumChildren() + index;
-	}
-
-	// Throw exception if we're out of range, this is required to support python iteration
-	if (index >= element->GetNumChildren())
-	{
-		PyErr_SetString(PyExc_IndexError, "Index out of range");
-		python::throw_error_already_set();
-	}
-
-	return element->GetChild(index);
-}
-
-}
-}
-}

+ 0 - 68
Source/Core/Python/ElementChildrenProxy.h

@@ -1,68 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * 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 OR COPYRIGHT HOLDERS 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.
- *
- */
-
-#ifndef ROCKETCOREPYTHONELEMENTCHILDRENPROXY_H
-#define ROCKETCOREPYTHONELEMENTCHILDRENPROXY_H
-
-namespace Rocket {
-namespace Core {
-
-class Element;
-
-namespace Python {
-
-/**
-	Thin lightweight proxy object for providing
-	a DOM-like element.children accessor.
-
-	@author Lloyd Weehuizen
- */
-
-class ElementChildrenProxy
-{
-public:
-	ElementChildrenProxy(Element* element);
-	~ElementChildrenProxy();
-
-	/// Initialise the interface
-	static void InitialisePythonInterface();
-
-	/// Python __len__ override
-	int Len();
-
-	/// Python __getitem__ override
-	Element* GetItem(int index);
-	
-private:
-	Element* element;
-};
-
-}
-}
-}
-
-#endif

Some files were not shown because too many files changed in this diff