Pārlūkot izejas kodu

Adding tutorials back to libRocket samples

This initial commit returns the tutorials back to the source tree and
updates the CMake build to generate appropriate Make targets.

The next step in the process is replacing the 'EMP' references with
'Rocket' and testing the tutorials.
Noam Chitayat 13 gadi atpakaļ
vecāks
revīzija
4ddc7f4c67
59 mainītis faili ar 3391 papildinājumiem un 89 dzēšanām
  1. 29 4
      Build/CMakeLists.txt
  2. 128 84
      Build/cmake/SampleFileList.cmake
  3. 3 1
      Build/cmake/gen_samplelists.sh
  4. 29 0
      Samples/tutorial/datagrid/Datagrid.sln
  5. 191 0
      Samples/tutorial/datagrid/Datagrid.vcproj
  6. 65 0
      Samples/tutorial/datagrid/Datagrid.vcproj.user
  7. 64 0
      Samples/tutorial/datagrid/SConstruct
  8. BIN
      Samples/tutorial/datagrid/data/high_scores_defender.png
  9. 15 0
      Samples/tutorial/datagrid/data/template.rml
  10. BIN
      Samples/tutorial/datagrid/data/tutorial.png
  11. 128 0
      Samples/tutorial/datagrid/data/tutorial.rcss
  12. 28 0
      Samples/tutorial/datagrid/data/tutorial.rml
  13. 10 0
      Samples/tutorial/datagrid/high_score.txt
  14. 70 0
      Samples/tutorial/datagrid/src/DecoratorDefender.cpp
  15. 46 0
      Samples/tutorial/datagrid/src/DecoratorDefender.h
  16. 51 0
      Samples/tutorial/datagrid/src/DecoratorInstancerDefender.cpp
  17. 41 0
      Samples/tutorial/datagrid/src/DecoratorInstancerDefender.h
  18. 115 0
      Samples/tutorial/datagrid/src/HighScores.cpp
  19. 50 0
      Samples/tutorial/datagrid/src/HighScores.h
  20. 101 0
      Samples/tutorial/datagrid/src/main.cpp
  21. 28 0
      Samples/tutorial/datagrid_tree/DatagridTree.sln
  22. 199 0
      Samples/tutorial/datagrid_tree/DatagridTree.vcproj
  23. 65 0
      Samples/tutorial/datagrid_tree/DatagridTree.vcproj.user
  24. 64 0
      Samples/tutorial/datagrid_tree/SConstruct
  25. BIN
      Samples/tutorial/datagrid_tree/data/high_scores_alien_1.png
  26. BIN
      Samples/tutorial/datagrid_tree/data/high_scores_alien_2.png
  27. BIN
      Samples/tutorial/datagrid_tree/data/high_scores_alien_3.png
  28. BIN
      Samples/tutorial/datagrid_tree/data/high_scores_defender.png
  29. 15 0
      Samples/tutorial/datagrid_tree/data/template.rml
  30. BIN
      Samples/tutorial/datagrid_tree/data/tutorial.png
  31. 128 0
      Samples/tutorial/datagrid_tree/data/tutorial.rcss
  32. 112 0
      Samples/tutorial/datagrid_tree/data/tutorial.rml
  33. 10 0
      Samples/tutorial/datagrid_tree/high_score.txt
  34. 70 0
      Samples/tutorial/datagrid_tree/src/DecoratorDefender.cpp
  35. 46 0
      Samples/tutorial/datagrid_tree/src/DecoratorDefender.h
  36. 51 0
      Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.cpp
  37. 41 0
      Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.h
  38. 180 0
      Samples/tutorial/datagrid_tree/src/HighScores.cpp
  39. 57 0
      Samples/tutorial/datagrid_tree/src/HighScores.h
  40. 34 0
      Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.cpp
  41. 31 0
      Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.h
  42. 105 0
      Samples/tutorial/datagrid_tree/src/main.cpp
  43. 63 0
      Samples/tutorial/template/SConstruct
  44. 29 0
      Samples/tutorial/template/Template.sln
  45. 167 0
      Samples/tutorial/template/Template.vcproj
  46. 65 0
      Samples/tutorial/template/Template.vcproj.user
  47. BIN
      Samples/tutorial/template/data/tutorial.png
  48. 26 0
      Samples/tutorial/template/data/tutorial.rcss
  49. 17 0
      Samples/tutorial/template/data/tutorial.rml
  50. 85 0
      Samples/tutorial/template/src/main.cpp
  51. 29 0
      Samples/tutorial/tutorial_drag/Drag.sln
  52. 175 0
      Samples/tutorial/tutorial_drag/Drag.vcproj
  53. 65 0
      Samples/tutorial/tutorial_drag/Drag.vcproj.user
  54. 63 0
      Samples/tutorial/tutorial_drag/SConstruct
  55. 16 0
      Samples/tutorial/tutorial_drag/data/inventory.rml
  56. 25 0
      Samples/tutorial/tutorial_drag/data/tutorial.rcss
  57. 44 0
      Samples/tutorial/tutorial_drag/src/Inventory.cpp
  58. 31 0
      Samples/tutorial/tutorial_drag/src/Inventory.h
  59. 91 0
      Samples/tutorial/tutorial_drag/src/main.cpp

+ 29 - 4
Build/CMakeLists.txt

@@ -204,7 +204,9 @@ endmacro()
 
 if(BUILD_SAMPLES)
     include(SampleFileList)
-	set(samples treeview customlog drag loaddocument)
+
+    set(samples treeview customlog drag loaddocument)
+    set(tutorials template datagrid datagrid_tree tutorial_drag)
     
     set(sample_LIBRARIES
     	shell 
@@ -217,8 +219,8 @@ if(BUILD_SAMPLES)
 	find_package(OpenGL REQUIRED)
     	   
     if(OPENGL_FOUND)
-    	include_directories(${OPENGL_INCLUDE_DIR})
-        list(APPEND sample_LIBRARIES ${OPENGL_LIBRARIES})
+	include_directories(${OPENGL_INCLUDE_DIR})
+	list(APPEND sample_LIBRARIES ${OPENGL_LIBRARIES})
     endif()
     
     # Set up required system libraries
@@ -242,7 +244,7 @@ if(BUILD_SAMPLES)
    
     set(SAMPLES_DIR opt/Rocket/Samples)
 
-    # The samples use the shell library
+    # The samples and tutorials use the shell library
     include_directories(${PROJECT_SOURCE_DIR}/Samples/shell/include)
 
     # Build and install sample shell library
@@ -268,6 +270,17 @@ if(BUILD_SAMPLES)
         	BUNDLE DESTINATION ${SAMPLES_DIR})
     endforeach()
 
+    # Build and install the tutorials
+    foreach(tutorial ${tutorials})
+        bl_sample(${tutorial} ${sample_LIBRARIES})
+
+        # The tutorials always set this as their current working directory
+        install(DIRECTORY DESTINATION ${SAMPLES_DIR}/tutorial/${tutorial})
+        install(TARGETS ${tutorial}
+                RUNTIME DESTINATION ${SAMPLES_DIR}/${tutorial}
+                BUNDLE DESTINATION ${SAMPLES_DIR})
+    endforeach()
+
     # Build and install invaders sample
     bl_sample(invaders ${sample_LIBRARIES})
     install(DIRECTORY DESTINATION ${SAMPLES_DIR}/invaders)
@@ -296,6 +309,18 @@ else()
 endif()
 
 if(BUILD_SAMPLES)
+    install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/template/data
+            DESTINATION ${SAMPLES_DIR}/tutorial/template
+    )
+    install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid/data
+            DESTINATION ${SAMPLES_DIR}/tutorial/datagrid
+    )
+    install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/data
+            DESTINATION ${SAMPLES_DIR}/tutorial/datagrid_tree
+    )
+    install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/tutorial_drag/data
+            DESTINATION ${SAMPLES_DIR}/tutorial/tutorial_drag
+    )
     install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/data
             DESTINATION ${SAMPLES_DIR}/basic/treeview
     )

+ 128 - 84
Build/cmake/SampleFileList.cmake

@@ -19,14 +19,14 @@ set(directx_SRC_FILES
 )
 
 set(drag_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/basic/drag/src/Inventory.h
     ${PROJECT_SOURCE_DIR}/Samples/basic/drag/src/DragListener.h
+    ${PROJECT_SOURCE_DIR}/Samples/basic/drag/src/Inventory.h
 )
 
 set(drag_SRC_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/basic/drag/src/main.cpp
     ${PROJECT_SOURCE_DIR}/Samples/basic/drag/src/DragListener.cpp
     ${PROJECT_SOURCE_DIR}/Samples/basic/drag/src/Inventory.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/basic/drag/src/main.cpp
 )
 
 set(loaddocument_HDR_FILES
@@ -37,158 +37,202 @@ set(loaddocument_SRC_FILES
 )
 
 set(ogre3d_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/RocketApplication.h
     ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/RenderInterfaceOgre3D.h
+    ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/RocketApplication.h
     ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/RocketFrameListener.h
     ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/SystemInterfaceOgre3D.h
 )
 
 set(ogre3d_SRC_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/RenderInterfaceOgre3D.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/SystemInterfaceOgre3D.cpp
     ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/main.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/RocketFrameListener.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/RenderInterfaceOgre3D.cpp
     ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/RocketApplication.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/RocketFrameListener.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/basic/ogre3d/src/SystemInterfaceOgre3D.cpp
 )
 
 set(treeview_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/src/FileSystem.h
     ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/src/FileFormatter.h
+    ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/src/FileSystem.h
 )
 
 set(treeview_SRC_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/src/main.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/src/FileSystem.cpp
     ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/src/FileFormatter.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/src/FileSystem.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/src/main.cpp
 )
 
 set(invaders_HDR_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorDefender.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorInstancerDefender.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorInstancerStarfield.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorStarfield.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Defender.h
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/ElementGame.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Event.h
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandler.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Invader.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Shield.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorInstancerStarfield.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Mothership.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventManager.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerHighScore.h
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerOptions.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorInstancerDefender.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Defender.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorStarfield.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerStartGame.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventInstancer.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventManager.h
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Game.h
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/GameDetails.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScoresNameFormatter.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Event.h
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScores.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventInstancer.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorDefender.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerStartGame.h
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerHighScore.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScoresNameFormatter.h
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScoresShipFormatter.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Invader.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Mothership.h
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Shield.h
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Sprite.h
 )
 
 set(invaders_SRC_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorDefender.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorInstancerDefender.cpp
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorInstancerStarfield.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/main.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Invader.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScoresShipFormatter.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerOptions.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorStarfield.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Defender.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/ElementGame.cpp
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Event.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Sprite.cpp
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandler.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScoresNameFormatter.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerHighScore.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerOptions.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerStartGame.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventInstancer.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventManager.cpp
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Game.cpp
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/GameDetails.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorInstancerDefender.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorStarfield.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventInstancer.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScores.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScoresNameFormatter.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScoresShipFormatter.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Invader.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/main.cpp
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Mothership.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerHighScore.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/DecoratorDefender.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/ElementGame.cpp
     ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Shield.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventManager.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/HighScores.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/EventHandlerStartGame.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Defender.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/invaders/src/Sprite.cpp
 )
 
 set(pyinvaders_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/ElementGame.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Invader.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Shield.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorInstancerStarfield.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Mothership.h
+    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorDefender.h
     ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorInstancerDefender.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Defender.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/PythonInterface.h
     ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/HighScores.h
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorDefender.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/main.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Invader.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Sprite.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/DecoratorInstancerDefender.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/DecoratorStarfield.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/PythonInterface.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/DecoratorDefender.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/ElementGame.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/PythonInterface.cpp
     ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Shield.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/HighScores.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Defender.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/pyinvaders/src/Sprite.cpp
 )
 
 set(shell_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellSystemInterface.h
-    ${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellFileInterface.h
-    ${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellRenderInterfaceOpenGL.h
-    ${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellOpenGL.h
     ${PROJECT_SOURCE_DIR}/Samples/shell/include/Input.h
     ${PROJECT_SOURCE_DIR}/Samples/shell/include/Shell.h
+    ${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellFileInterface.h
+    ${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellOpenGL.h
+    ${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellRenderInterfaceOpenGL.h
+    ${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellSystemInterface.h
 )
 
 set(shell_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Samples/shell/src/Input.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/shell/src/Shell.cpp
     ${PROJECT_SOURCE_DIR}/Samples/shell/src/ShellFileInterface.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/shell/src/ShellSystemInterface.cpp
     ${PROJECT_SOURCE_DIR}/Samples/shell/src/ShellRenderInterfaceOpenGL.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/shell/src/Shell.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/shell/src/ShellSystemInterface.cpp
+)
+
+set(template_HDR_FILES
+)
+
+set(template_SRC_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/template/src/main.cpp
+)
+
+set(datagrid_HDR_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid/src/DecoratorDefender.h
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.h
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid/src/HighScores.h
+)
+
+set(datagrid_SRC_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid/src/DecoratorDefender.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid/src/HighScores.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid/src/main.cpp
+)
+
+set(datagrid_tree_HDR_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/src/DecoratorDefender.h
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.h
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/src/HighScores.h
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.h
+)
+
+set(datagrid_tree_SRC_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/src/DecoratorDefender.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/src/HighScores.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/datagrid_tree/src/main.cpp
+)
+
+set(tutorial_drag_HDR_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/tutorial_drag/src/Inventory.h
+)
+
+set(tutorial_drag_SRC_FILES
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/tutorial_drag/src/Inventory.cpp
+    ${PROJECT_SOURCE_DIR}/Samples/tutorial/tutorial_drag/src/main.cpp
 )
 
 # Deal with platform specific sources for sample shell
 if(WIN32)
-	list(APPEND shell_SRC_FILES
-		${PROJECT_SOURCE_DIR}/Samples/shell/src/win32/ShellWin32.cpp
-		${PROJECT_SOURCE_DIR}/Samples/shell/src/win32/InputWin32.cpp
-	)
-	list(APPEND shell_HDR_FILES
-		${PROJECT_SOURCE_DIR}/Samples/shell/include/win32/InputWin32.h
-	)
+       list(APPEND shell_SRC_FILES
+               ${PROJECT_SOURCE_DIR}/Samples/shell/src/win32/ShellWin32.cpp
+               ${PROJECT_SOURCE_DIR}/Samples/shell/src/win32/InputWin32.cpp
+       )
+       list(APPEND shell_HDR_FILES
+               ${PROJECT_SOURCE_DIR}/Samples/shell/include/win32/InputWin32.h
+       )
 elseif(APPLE)
-	list(APPEND shell_SRC_FILES
-		${PROJECT_SOURCE_DIR}/Samples/shell/src/macosx/ShellMacOSX.cpp
-		${PROJECT_SOURCE_DIR}/Samples/shell/src/macosx/InputMacOSX.cpp
-	)
-	list(APPEND shell_HDR_FILES
-		${PROJECT_SOURCE_DIR}/Samples/shell/include/macosx/InputMacOSX.h
-	)
+       list(APPEND shell_SRC_FILES
+               ${PROJECT_SOURCE_DIR}/Samples/shell/src/macosx/ShellMacOSX.cpp
+               ${PROJECT_SOURCE_DIR}/Samples/shell/src/macosx/InputMacOSX.cpp
+       )
+       list(APPEND shell_HDR_FILES
+               ${PROJECT_SOURCE_DIR}/Samples/shell/include/macosx/InputMacOSX.h
+       )
 else()
-	list(APPEND shell_SRC_FILES
-		${PROJECT_SOURCE_DIR}/Samples/shell/src/x11/ShellX11.cpp
-		${PROJECT_SOURCE_DIR}/Samples/shell/src/x11/InputX11.cpp
-	)
-	list(APPEND shell_HDR_FILES
-		${PROJECT_SOURCE_DIR}/Samples/shell/include/x11/InputX11.h
-	)
+       list(APPEND shell_SRC_FILES
+               ${PROJECT_SOURCE_DIR}/Samples/shell/src/x11/ShellX11.cpp
+               ${PROJECT_SOURCE_DIR}/Samples/shell/src/x11/InputX11.cpp
+       )
+       list(APPEND shell_HDR_FILES
+               ${PROJECT_SOURCE_DIR}/Samples/shell/include/x11/InputX11.h
+       )
 endif()
 

+ 3 - 1
Build/cmake/gen_samplelists.sh

@@ -8,11 +8,13 @@ srcdir='${PROJECT_SOURCE_DIR}'
 srcpath=Samples
 samples=('basic/customlog' 'basic/directx' 'basic/drag' 'basic/loaddocument'
         'basic/ogre3d' 'basic/treeview' 'invaders' 'pyinvaders' 'shell'
+	'tutorial/template' 'tutorial/datagrid' 'tutorial/datagrid_tree' 'tutorial/tutorial_drag'
 )
 
 printfiles() {
     # Print headers
-    name=${1/'basic/'/} #substitute basic/ for nothing
+    name=${1//basic\//} #substitute basic/ for nothing
+    name=${name//tutorial\/} #substitute tutorial/ for nothing
     echo ${hdr/sample/$name} >>$file
     find  $srcpath/$1/src -maxdepth 1 -iname "*.h" -exec echo '    '$srcdir/{} \; >>$file
     find  $srcpath/$1/include -maxdepth 1 -iname "*.h" -exec echo '    '$srcdir/{} \; >>$file 2>/dev/null

+ 29 - 0
Samples/tutorial/datagrid/Datagrid.sln

@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Datagrid", "datagrid.vcproj", "{3C58D3B5-9478-4221-954A-01E3C4F1FA89}"
+	ProjectSection(ProjectDependencies) = postProject
+		{AF4FF882-AFD9-457B-979E-A5B482388D46} = {AF4FF882-AFD9-457B-979E-A5B482388D46}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shell", "..\..\shell\shell.vcproj", "{AF4FF882-AFD9-457B-979E-A5B482388D46}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Debug|Win32.ActiveCfg = Debug|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Debug|Win32.Build.0 = Debug|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Release|Win32.ActiveCfg = Release|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Release|Win32.Build.0 = Release|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Debug|Win32.ActiveCfg = Debug|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Debug|Win32.Build.0 = Debug|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Release|Win32.ActiveCfg = Release|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 191 - 0
Samples/tutorial/datagrid/Datagrid.vcproj

@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="Datagrid"
+	ProjectGUID="{3C58D3B5-9478-4221-954A-01E3C4F1FA89}"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\..\shell\include;..\..\..\..\..\packages\include"
+				PreprocessorDefinitions="WIN32"
+				RuntimeLibrary="3"
+				WarningLevel="4"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="EMPCore_d.lib RocketCore_d.lib RocketControls_d.lib RocketDebugger_d.lib libpng_d.lib zlib_d.lib opengl32.lib"
+				OutputFile="..\..\..\..\..\packages\bin\$(ProjectName)_d.exe"
+				AdditionalLibraryDirectories="..\..\shell\libpng;..\..\..\..\..\packages\bin"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="..\..\shell\include;..\..\..\..\..\packages\include"
+				PreprocessorDefinitions="WIN32"
+				RuntimeLibrary="2"
+				WarningLevel="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="EMPCore.lib RocketCore.lib RocketControls.lib RocketDebugger.lib libpng.lib zlib.lib opengl32.lib"
+				OutputFile="..\..\..\..\..\packages\bin\$(ProjectName).exe"
+				AdditionalLibraryDirectories="..\..\shell\libpng;..\..\..\..\..\packages\bin"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\src\DecoratorDefender.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\src\DecoratorDefender.h"
+			>
+		</File>
+		<File
+			RelativePath=".\src\DecoratorInstancerDefender.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\src\DecoratorInstancerDefender.h"
+			>
+		</File>
+		<File
+			RelativePath=".\src\HighScores.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\src\HighScores.h"
+			>
+		</File>
+		<File
+			RelativePath=".\src\main.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 65 - 0
Samples/tutorial/datagrid/Datagrid.vcproj.user

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="8.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="..\..\..\..\..\packages\bin"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine=""
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="..\..\..\..\..\packages\bin"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine=""
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>

+ 64 - 0
Samples/tutorial/datagrid/SConstruct

@@ -0,0 +1,64 @@
+#
+# DataGrid Construction File
+# 
+import os
+import sys
+sys.path += [ "../../../../../build" ]
+import wmsconstruct
+
+FILES = Split( """
+	src/
+	""" )
+
+INCLUDE = Split( """
+	../../../../../packages/include/
+	../../shell/include/
+	""" )
+
+LIBS = Split( """
+	RocketControls
+	RocketDebugger
+	RocketCore
+	EMPCore
+	Shell
+	""" )
+
+LIBPATHS = Split( """
+	../../../../../packages/bin
+	""" )
+
+DEPENDENCIES = []
+
+if sys.platform == "win32":
+	LIBS += Split( """
+		opengl32
+		user32
+		gdi32
+		libpng
+		zlib
+		""" )
+	LIBPATHS += Split( """
+		../../shell/libpng
+		""" )
+elif sys.platform == "darwin":
+	LIBS += Split( """
+		png
+		z
+		""" )
+	LIBPATHS += Split( """
+		../../shell/libpng
+		""" )
+	DEPENDENCIES += ["AGL", "Carbon", "OpenGL"]
+elif sys.platform == "linux2":
+	LIBS += Split( """
+		GL
+		png
+		""" )
+
+wmsconstruct.Program("Rocket Datagrid Tutorial",
+	"../../../../../packages/bin/datagrid",
+	FILES,
+	INCLUDE,
+	LIBS,
+	LIBPATHS,
+	DEPENDENCIES)

BIN
Samples/tutorial/datagrid/data/high_scores_defender.png


+ 15 - 0
Samples/tutorial/datagrid/data/template.rml

@@ -0,0 +1,15 @@
+<template name="window" content="content">
+<head>
+	<link type="text/css" href="../../../assets/rkt.rcss"/>
+	<link type="text/css" href="tutorial.rcss"/>
+</head>
+<body class="window">
+	<div id="title-bar">
+		<handle move_target="#document">
+			<span id="title">Dummy Title</span>
+		</handle>
+	</div>
+	<div id="content">
+	</div>
+</body>
+</template>

BIN
Samples/tutorial/datagrid/data/tutorial.png


+ 128 - 0
Samples/tutorial/datagrid/data/tutorial.rcss

@@ -0,0 +1,128 @@
+body
+{
+	font-family: Delicious;
+	font-weight: normal;
+	font-style: normal;
+	font-size: 15;
+	color: white;
+}
+
+body.window
+{
+	background-decorator: tiled-box;
+	background-top-left-image: tutorial.png 0px 0px 133px 140px;
+	background-top-right-image: tutorial.png 136px 0px 146px 140px;
+	background-top-image: tutorial.png stretch 134px 0px 135px 140px;
+	background-bottom-left-image: tutorial.png 0px 140px 11px 151px;
+	background-bottom-right-image: tutorial.png 136px 140px 146px 151px;
+	background-bottom-image: tutorial.png stretch 11px 140px 12px 151px;
+	background-left-image: tutorial.png stretch 0px 139px 10px 140px;
+	background-center-image: tutorial.png stretch 11px 139px 12px 140px;
+	
+	padding: 10px 15px;
+}
+
+div#title-bar
+{
+	position: absolute;
+	top: -43px;
+}
+
+div#title-bar span
+{
+	padding-left: 85px;
+	padding-right: 25px;
+	padding-top: 17px;
+	padding-bottom: 48px;
+
+	font-size: 22;
+	font-weight: bold;
+
+	text-shadow: 2px 2px black;
+
+	background-decorator: tiled-horizontal;
+	background-left-image: tutorial.png 147px 0px 229px 85px;
+	background-center-image: tutorial.png stretch 229px 0px 230px 85px;
+	background-right-image: tutorial.png 231px 0px 246px 85px;
+}
+
+div#content
+{
+	height: 100%;
+	overflow: auto;
+
+	z-index: 1;
+}
+
+scrollbarvertical
+{
+	width: 27px;
+	margin-top: -6px;
+	margin-bottom: -6px;
+	margin-right: -11px;
+}
+
+scrollbarvertical slidertrack
+{
+	background-decorator: tiled-vertical;
+	background-top-image: tutorial.png 56px 199px 83px 201px;
+	background-center-image: tutorial.png stretch 56px 201px 83px 202px;
+	background-bottom-image: tutorial.png 56px 203px 83px 204px;
+}
+
+scrollbarvertical sliderbar
+{
+	margin-left: 4px;
+	width: 23px;
+	min-height: 46px;
+
+	background-decorator: tiled-vertical;
+	background-top-image: tutorial.png 56px 152px 79px 175px;
+	background-center-image: tutorial.png stretch 56px 175px 79px 175px;
+	background-bottom-image: tutorial.png 56px 176px 79px 198px;
+}
+
+scrollbarvertical sliderbar:hover
+{
+	background-top-image-s: 80px 103px;
+	background-center-image-s: 80px 103px;
+	background-bottom-image-s: 80px 103px;
+}
+
+scrollbarvertical sliderbar:active
+{
+	background-top-image-s: 104px 127px;
+	background-center-image-s: 104px 127px;
+	background-bottom-image-s: 104px 127px;
+}
+
+scrollbarvertical sliderarrowdec,
+scrollbarvertical sliderarrowinc
+{
+	width: 27px;
+	height: 24px;
+}
+
+scrollbarvertical sliderarrowdec
+{
+	icon-decorator: image;
+	icon-image: tutorial.png 0px 152px 27px 176px;
+}
+
+scrollbarvertical sliderarrowinc
+{
+	icon-decorator: image;
+	icon-image: tutorial.png 28px 152px 55px 176px;
+}
+
+scrollbarvertical sliderarrowdec:hover,
+scrollbarvertical sliderarrowinc:hover
+{
+	icon-image-t: 177px 201px;
+}
+
+scrollbarvertical sliderarrowdec:active,
+scrollbarvertical sliderarrowinc:active
+{
+	icon-image-t: 202px 226px;
+}

+ 28 - 0
Samples/tutorial/datagrid/data/tutorial.rml

@@ -0,0 +1,28 @@
+<rml>
+<head>
+	<link type="text/template" href="template.rml"/>
+	<title>Datagrid Tutorial</title>
+	<style>
+		body
+		{
+			width: 400px;
+			height: 300px;
+
+			margin: auto;
+		}
+        
+        defender
+        {
+            display: block;
+            width: 64px;
+            height: 16px;
+
+            defender-decorator: defender;
+            defender-image-src: high_scores_defender.png;
+        }
+	</style>
+</head>
+<body template="window">
+	Insert high scores here.
+</body>
+</rml>

+ 10 - 0
Samples/tutorial/datagrid/high_score.txt

@@ -0,0 +1,10 @@
+Rocket	233, 116, 81, 255	1	1000
+UI	127, 255, 0, 255	1	900
+middleware	21, 96, 189, 255	1	800
+for	246, 74, 138, 255	1	700
+all	255, 0, 255, 255	1	600
+your	218, 165, 32, 255	1	500
+game	255, 255, 240, 255	1	400
+interface	233, 116, 81, 255	1	300
+needs	127, 255, 0, 255	1	200
+:)	21, 96, 189, 255	1	100

+ 70 - 0
Samples/tutorial/datagrid/src/DecoratorDefender.cpp

@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include "DecoratorDefender.h"
+#include <EMP/Core/Math.h>
+#include <Rocket/Core/Element.h>
+#include <Rocket/Core/Texture.h>
+#include <ShellOpenGL.h>
+
+DecoratorDefender::~DecoratorDefender()
+{
+}
+
+bool DecoratorDefender::Initialise(const EMP::Core::String& image_source, const EMP::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* EMP_UNUSED(element))
+{
+	return NULL;
+}
+
+// Called to release element data generated by this decorator.
+void DecoratorDefender::ReleaseElementData(Rocket::Core::DecoratorDataHandle EMP_UNUSED(element_data))
+{
+}
+
+// Called to render the decorator on an element.
+void DecoratorDefender::RenderElement(Rocket::Core::Element* element, Rocket::Core::DecoratorDataHandle EMP_UNUSED(element_data))
+{
+	EMP::Core::Vector2f position = element->GetAbsoluteOffset(Rocket::Core::Box::PADDING);
+	EMP::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()));
+	EMP::Core::Colourb colour = element->GetProperty< EMP::Core::Colourb >("color");
+	glColor4ubv(element->GetProperty< EMP::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);
+}

+ 46 - 0
Samples/tutorial/datagrid/src/DecoratorDefender.h

@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#ifndef DECORATORDEFENDER_H
+#define DECORATORDEFENDER_H
+
+#include <Rocket/Core/Decorator.h>
+
+/**
+	A decorator that displays the defender in the colour of its "colour" property.
+	@author Robert Curry
+ */
+
+class DecoratorDefender : public Rocket::Core::Decorator
+{
+public:
+	virtual ~DecoratorDefender();
+
+	bool Initialise(const EMP::Core::String& image_source, const EMP::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

+ 51 - 0
Samples/tutorial/datagrid/src/DecoratorInstancerDefender.cpp

@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include "DecoratorInstancerDefender.h"
+#include <EMP/Core/Math.h>
+#include <EMP/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 EMP::Core::String& EMP_UNUSED(name), const Rocket::Core::PropertyDictionary& properties)
+{
+	const Rocket::Core::Property* image_source_property = properties.GetProperty("image-src");
+	EMP::Core::String image_source = image_source_property->Get< EMP::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;
+}

+ 41 - 0
Samples/tutorial/datagrid/src/DecoratorInstancerDefender.h

@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#ifndef DECORATORINSTANCERDEFENDER_H
+#define DECORATORINSTANCERDEFENDER_H
+
+#include <Rocket/Core/DecoratorInstancer.h>
+
+/**
+	Decorator instancer for the Defender decorator.
+	@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 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 EMP::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

+ 115 - 0
Samples/tutorial/datagrid/src/HighScores.cpp

@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include "HighScores.h"
+#include <EMP/Core/StringUtilities.h>
+#include <EMP/Core/TypeConverter.h>
+#include <Rocket/Core.h>
+#include <stdio.h>
+
+HighScores* HighScores::instance = NULL;
+
+HighScores::HighScores()
+{
+	EMP_ASSERT(instance == NULL);
+	instance = this;
+
+	for (int i = 0; i < NUM_SCORES; i++)
+	{
+		scores[i].score = -1;
+	}
+
+	LoadScores();
+}
+
+HighScores::~HighScores()
+{
+	EMP_ASSERT(instance == this);
+	instance = NULL;
+}
+
+void HighScores::Initialise()
+{
+	new HighScores();
+}
+
+void HighScores::Shutdown()
+{
+	delete instance;
+}
+
+void HighScores::SubmitScore(const EMP::Core::String& name, const EMP::Core::Colourb& colour, int wave, int score)
+{
+	for (size_t i = 0; i < NUM_SCORES; i++)
+	{
+		if (score > scores[i].score)
+		{
+			// Push down all the other scores.
+			for (size_t 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;
+
+			return;
+		}
+	}
+}
+
+void HighScores::LoadScores()
+{
+	// Open and read the high score file.
+	Rocket::Core::FileInterface* file_interface = Rocket::Core::GetFileInterface();
+	Rocket::Core::FileHandle scores_file = file_interface->Open("high_score.txt");
+	
+	if (scores_file)
+	{
+		file_interface->Seek(scores_file, 0, SEEK_END);
+		size_t scores_length = file_interface->Tell(scores_file);
+		file_interface->Seek(scores_file, 0, SEEK_SET);
+
+		if (scores_length > 0)
+		{
+			char* buffer = new char[scores_length + 1];
+			file_interface->Read(buffer, scores_length, scores_file);
+			file_interface->Close(scores_file);
+			buffer[scores_length] = 0;
+
+			EMP::Core::StringList score_lines;
+			EMP::Core::StringUtilities::ExpandString(score_lines, buffer, '\n');
+			delete[] buffer;
+			
+			for (size_t i = 0; i < score_lines.size(); i++)
+			{
+				EMP::Core::StringList score_parts;
+				EMP::Core::StringUtilities::ExpandString(score_parts, score_lines[i], '\t');
+				if (score_parts.size() == 4)
+				{
+					EMP::Core::Colourb colour;
+					int wave;
+					int score;
+
+					if (EMP::Core::TypeConverter< EMP::Core::String , EMP::Core::Colourb >::Convert(score_parts[1], colour) &&
+						EMP::Core::TypeConverter< EMP::Core::String, int >::Convert(score_parts[2], wave) &&
+						EMP::Core::TypeConverter< EMP::Core::String, int >::Convert(score_parts[3], score))
+					{
+						SubmitScore(score_parts[0], colour, wave, score);
+					}
+				}
+			}
+		}
+	}
+}

+ 50 - 0
Samples/tutorial/datagrid/src/HighScores.h

@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#ifndef HIGHSCORES_H
+#define HIGHSCORES_H
+
+#include <EMP/Core/Types.h>
+
+const int NUM_SCORES = 10;
+
+/**
+	This class stores a list of high scores, and loads the high scores list from a file upon initialisation.
+	@author Robert Curry
+ */
+
+class HighScores
+{
+public:
+	static void Initialise();
+	static void Shutdown();
+
+private:
+	HighScores();
+	~HighScores();
+
+	static HighScores* instance;
+
+	void SubmitScore(const EMP::Core::String& name, const EMP::Core::Colourb& colour, int wave, int score);
+	void LoadScores();
+
+	struct Score
+	{
+		EMP::Core::String name;
+		EMP::Core::Colourb colour;
+		int score;
+		int wave;
+	};
+
+	Score scores[NUM_SCORES];
+};
+
+#endif

+ 101 - 0
Samples/tutorial/datagrid/src/main.cpp

@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include <Rocket/Core.h>
+#include <Rocket/Controls.h>
+#include <Rocket/Debugger.h>
+#include <Input.h>
+#include <Shell.h>
+#include "DecoratorInstancerDefender.h"
+#include "HighScores.h"
+
+Rocket::Core::Context* context = NULL;
+
+void GameLoop()
+{
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	context->Update();
+	context->Render();
+
+	Shell::FlipBuffers();
+}
+
+#if defined EMP_PLATFORM_WIN32
+#include <windows.h>
+int APIENTRY WinMain(HINSTANCE EMP_UNUSED(instance_handle), HINSTANCE EMP_UNUSED(previous_instance_handle), char* EMP_UNUSED(command_line), int EMP_UNUSED(command_show))
+#else
+int main(int EMP_UNUSED(argc), char** EMP_UNUSED(argv))
+#endif
+{
+	// Generic OS initialisation, creates a window and attaches OpenGL.
+	if (!Shell::Initialise("../../projects/Rocket/samples/tutorials/datagrid/") ||
+		!Shell::OpenWindow("Datagrid Tutorial", true))
+	{
+		Shell::Shutdown();
+		return -1;
+	}
+
+	// Rocket initialisation.
+	ShellRenderInterfaceOpenGL opengl_renderer;
+	Rocket::Core::SetRenderInterface(&opengl_renderer);
+
+	ShellSystemInterface system_interface;
+	Rocket::Core::SetSystemInterface(&system_interface);
+
+	Rocket::Core::Initialise();
+	Rocket::Controls::Initialise();
+
+	// Create the main Rocket context and set it on the shell's input layer.
+	context = Rocket::Core::CreateContext("main", EMP::Core::Vector2i(1024, 768));
+	if (context == NULL)
+	{
+		Rocket::Core::Shutdown();
+		Shell::Shutdown();
+		return -1;
+	}
+
+	Rocket::Debugger::Initialise(context);
+	Input::SetContext(context);
+
+	Shell::LoadFonts("../../assets/");
+
+	// Load the defender decorator.
+	Rocket::Core::DecoratorInstancer* decorator_instancer = Rocket::Core::Factory::RegisterDecoratorInstancer("defender", new DecoratorInstancerDefender());
+	if (decorator_instancer != NULL)
+		decorator_instancer->RemoveReference();
+
+	// Construct the high scores.
+	HighScores::Initialise();
+
+	// Load and show the tutorial document.
+	Rocket::Core::ElementDocument* document = context->LoadDocument("data/tutorial.rml");
+	document->GetElementById("title")->SetInnerRML(document->GetTitle());
+	if (document != NULL)
+	{
+		document->Show();
+		document->RemoveReference();
+	}
+
+	Shell::EventLoop(GameLoop);
+
+	// Shut down the high scores.
+	HighScores::Shutdown();
+
+	// Shutdown Rocket.
+	context->RemoveReference();
+	Rocket::Core::Shutdown();
+
+	Shell::CloseWindow();
+	Shell::Shutdown();
+
+	return 0;
+}

+ 28 - 0
Samples/tutorial/datagrid_tree/DatagridTree.sln

@@ -0,0 +1,28 @@
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shell", "..\..\shell\shell.vcproj", "{AF4FF882-AFD9-457B-979E-A5B482388D46}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DatagridTree", "DatagridTree.vcproj", "{3C58D3B5-9478-4221-954A-01E3C4F1FA89}"
+	ProjectSection(ProjectDependencies) = postProject
+		{AF4FF882-AFD9-457B-979E-A5B482388D46} = {AF4FF882-AFD9-457B-979E-A5B482388D46}
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Debug|Win32.ActiveCfg = Debug|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Debug|Win32.Build.0 = Debug|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Release|Win32.ActiveCfg = Release|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Release|Win32.Build.0 = Release|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Debug|Win32.ActiveCfg = Debug|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Debug|Win32.Build.0 = Debug|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Release|Win32.ActiveCfg = Release|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 199 - 0
Samples/tutorial/datagrid_tree/DatagridTree.vcproj

@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="DatagridTree"
+	ProjectGUID="{3C58D3B5-9478-4221-954A-01E3C4F1FA89}"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\..\shell\include;..\..\..\..\..\packages\include"
+				PreprocessorDefinitions="WIN32"
+				RuntimeLibrary="3"
+				WarningLevel="4"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="EMPCore_d.lib RocketCore_d.lib RocketControls_d.lib RocketDebugger_d.lib libpng_d.lib zlib_d.lib opengl32.lib"
+				OutputFile="..\..\..\..\..\packages\bin\$(ProjectName)_d.exe"
+				AdditionalLibraryDirectories="..\..\shell\libpng;..\..\..\..\..\packages\bin"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="..\..\shell\include;..\..\..\..\..\packages\include"
+				PreprocessorDefinitions="WIN32"
+				RuntimeLibrary="2"
+				WarningLevel="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="EMPCore.lib RocketCore.lib RocketControls.lib RocketDebugger.lib libpng.lib zlib.lib opengl32.lib"
+				OutputFile="..\..\..\..\..\packages\bin\$(ProjectName).exe"
+				AdditionalLibraryDirectories="..\..\shell\libpng;..\..\..\..\..\packages\bin"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\src\DecoratorDefender.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\src\DecoratorDefender.h"
+			>
+		</File>
+		<File
+			RelativePath=".\src\DecoratorInstancerDefender.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\src\DecoratorInstancerDefender.h"
+			>
+		</File>
+		<File
+			RelativePath=".\src\HighScores.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\src\HighScores.h"
+			>
+		</File>
+		<File
+			RelativePath=".\src\HighScoresShipFormatter.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\src\HighScoresShipFormatter.h"
+			>
+		</File>
+		<File
+			RelativePath=".\src\main.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 65 - 0
Samples/tutorial/datagrid_tree/DatagridTree.vcproj.user

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="8.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="..\..\..\..\..\packages\bin"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine=""
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="..\..\..\..\..\packages\bin"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine=""
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>

+ 64 - 0
Samples/tutorial/datagrid_tree/SConstruct

@@ -0,0 +1,64 @@
+#
+# DataGrid Tree Construction File
+# 
+import os
+import sys
+sys.path += [ "../../../../../build" ]
+import wmsconstruct
+
+FILES = Split( """
+	src/
+	""" )
+
+INCLUDE = Split( """
+	../../../../../packages/include/
+	../../shell/include/
+	""" )
+
+LIBS = Split( """
+	RocketControls
+	RocketDebugger
+	RocketCore
+	EMPCore
+	Shell
+	""" )
+
+LIBPATHS = Split( """
+	../../../../../packages/bin
+	""" )
+
+DEPENDENCIES = []
+
+if sys.platform == "win32":
+	LIBS += Split( """
+		opengl32
+		user32
+		gdi32
+		libpng
+		zlib
+		""" )
+	LIBPATHS += Split( """
+		../../shell/libpng
+		""" )
+elif sys.platform == "darwin":
+	LIBS += Split( """
+		png
+		z
+		""" )
+	LIBPATHS += Split( """
+		../../shell/libpng
+		""" )
+	DEPENDENCIES += ["AGL", "Carbon", "OpenGL"]
+elif sys.platform == "linux2":
+	LIBS += Split( """
+		GL
+		png
+		""" )
+
+wmsconstruct.Program("Rocket Datagrid Tree Tutorial",
+	"../../../../../packages/bin/datagridtree",
+	FILES,
+	INCLUDE,
+	LIBS,
+	LIBPATHS,
+	DEPENDENCIES)

BIN
Samples/tutorial/datagrid_tree/data/high_scores_alien_1.png


BIN
Samples/tutorial/datagrid_tree/data/high_scores_alien_2.png


BIN
Samples/tutorial/datagrid_tree/data/high_scores_alien_3.png


BIN
Samples/tutorial/datagrid_tree/data/high_scores_defender.png


+ 15 - 0
Samples/tutorial/datagrid_tree/data/template.rml

@@ -0,0 +1,15 @@
+<template name="window" content="content">
+<head>
+	<link type="text/css" href="../../../assets/rkt.rcss"/>
+	<link type="text/css" href="tutorial.rcss"/>
+</head>
+<body class="window">
+	<div id="title-bar">
+		<handle move_target="#document">
+			<span id="title">Dummy Title</span>
+		</handle>
+	</div>
+	<div id="content">
+	</div>
+</body>
+</template>

BIN
Samples/tutorial/datagrid_tree/data/tutorial.png


+ 128 - 0
Samples/tutorial/datagrid_tree/data/tutorial.rcss

@@ -0,0 +1,128 @@
+body
+{
+	font-family: Delicious;
+	font-weight: normal;
+	font-style: normal;
+	font-size: 15;
+	color: white;
+}
+
+body.window
+{
+	background-decorator: tiled-box;
+	background-top-left-image: tutorial.png 0px 0px 133px 140px;
+	background-top-right-image: tutorial.png 136px 0px 146px 140px;
+	background-top-image: tutorial.png stretch 134px 0px 135px 140px;
+	background-bottom-left-image: tutorial.png 0px 140px 11px 151px;
+	background-bottom-right-image: tutorial.png 136px 140px 146px 151px;
+	background-bottom-image: tutorial.png stretch 11px 140px 12px 151px;
+	background-left-image: tutorial.png stretch 0px 139px 10px 140px;
+	background-center-image: tutorial.png stretch 11px 139px 12px 140px;
+	
+	padding: 10px 15px;
+}
+
+div#title-bar
+{
+	position: absolute;
+	top: -43px;
+}
+
+div#title-bar span
+{
+	padding-left: 85px;
+	padding-right: 25px;
+	padding-top: 17px;
+	padding-bottom: 48px;
+
+	font-size: 22;
+	font-weight: bold;
+
+	text-shadow: 2px 2px black;
+
+	background-decorator: tiled-horizontal;
+	background-left-image: tutorial.png 147px 0px 229px 85px;
+	background-center-image: tutorial.png stretch 229px 0px 230px 85px;
+	background-right-image: tutorial.png 231px 0px 246px 85px;
+}
+
+div#content
+{
+	height: 100%;
+	overflow: auto;
+
+	z-index: 1;
+}
+
+scrollbarvertical
+{
+	width: 27px;
+	margin-top: -6px;
+	margin-bottom: -6px;
+	margin-right: -11px;
+}
+
+scrollbarvertical slidertrack
+{
+	background-decorator: tiled-vertical;
+	background-top-image: tutorial.png 56px 199px 83px 201px;
+	background-center-image: tutorial.png stretch 56px 201px 83px 202px;
+	background-bottom-image: tutorial.png 56px 203px 83px 204px;
+}
+
+scrollbarvertical sliderbar
+{
+	margin-left: 4px;
+	width: 23px;
+	min-height: 46px;
+
+	background-decorator: tiled-vertical;
+	background-top-image: tutorial.png 56px 152px 79px 175px;
+	background-center-image: tutorial.png stretch 56px 175px 79px 175px;
+	background-bottom-image: tutorial.png 56px 176px 79px 198px;
+}
+
+scrollbarvertical sliderbar:hover
+{
+	background-top-image-s: 80px 103px;
+	background-center-image-s: 80px 103px;
+	background-bottom-image-s: 80px 103px;
+}
+
+scrollbarvertical sliderbar:active
+{
+	background-top-image-s: 104px 127px;
+	background-center-image-s: 104px 127px;
+	background-bottom-image-s: 104px 127px;
+}
+
+scrollbarvertical sliderarrowdec,
+scrollbarvertical sliderarrowinc
+{
+	width: 27px;
+	height: 24px;
+}
+
+scrollbarvertical sliderarrowdec
+{
+	icon-decorator: image;
+	icon-image: tutorial.png 0px 152px 27px 176px;
+}
+
+scrollbarvertical sliderarrowinc
+{
+	icon-decorator: image;
+	icon-image: tutorial.png 28px 152px 55px 176px;
+}
+
+scrollbarvertical sliderarrowdec:hover,
+scrollbarvertical sliderarrowinc:hover
+{
+	icon-image-t: 177px 201px;
+}
+
+scrollbarvertical sliderarrowdec:active,
+scrollbarvertical sliderarrowinc:active
+{
+	icon-image-t: 202px 226px;
+}

+ 112 - 0
Samples/tutorial/datagrid_tree/data/tutorial.rml

@@ -0,0 +1,112 @@
+<rml>
+<head>
+	<link type="text/template" href="template.rml"/>
+	<title>Datagrid Tutorial</title>
+	<style>
+		body
+		{
+			width: 400px;
+			height: 300px;
+
+			margin: auto;
+		}
+		
+		defender
+		{
+			display: block;
+			width: 64px;
+			height: 16px;
+			
+			defender-decorator: defender;
+			defender-image-src: high_scores_defender.png;
+		}
+		
+		defender.alien_1
+		{
+			defender-image-src: high_scores_alien_1.png;
+		}
+		
+		defender.alien_2
+		{
+			defender-image-src: high_scores_alien_2.png;
+		}
+		
+		defender.alien_3
+		{
+			defender-image-src: high_scores_alien_3.png;
+		}
+		
+		datagridheader
+		{
+			width: auto;
+			height: 25px;
+			padding: 5px 10px 0px 10px;
+		
+			background-decorator: tiled-horizontal;
+			background-left-image: ../../../assets/invader.png 127px 192px 143px 223px;
+			background-center-image: ../../../assets/invader.png stretch 143px 192px 145px 223px;
+			background-right-image: ../../../assets/invader.png 145px 192px 160px 223px;
+		}
+		
+		datagridbody
+		{
+			color: black;
+			text-align: center;
+			
+			margin-left: 4px;
+			margin-right: 3px;
+			padding: 0px 4px 4px 4px;
+			
+			background-decorator: tiled-box;
+			background-top-left-image: ../../../assets/invader.png 281px 275px 292px 284px;
+			background-top-right-image: ../../../assets/invader.png 294px 275px 305px 284px;
+			background-top-image: ../../../assets/invader.png stretch 292px 275px 293px 284px;
+			background-bottom-left-image: ../../../assets/invader.png 281px 285px 292px 296px;
+			background-bottom-right-image: ../../../assets/invader.png 294px 285px 305px 296px;
+			background-bottom-image: ../../../assets/invader.png stretch 292px 285px 293px 296px;
+			background-left-image: ../../../assets/invader.png stretch 281px 283px 292px 284px;
+			background-center-image: ../../../assets/invader.png stretch 292px 283px 293px 284px;
+		}
+		
+		datagrid datagridrow:nth-child(even)
+		{
+			background: #FFFFFFA0;
+		}
+		
+		datagridexpand
+		{
+			display: block;
+			
+			margin: 1px 0px 1px 5px;
+			height: 17px;
+			width: 17px;
+			
+			icon-decorator: image;
+			icon-image: ../../../assets/invader.png 3px 232px 20px 249px;
+		}
+		
+		datagridexpand:hover
+		{
+			icon-image-s: 21px 38px;
+		}
+		
+		datagridexpand:active
+		{
+			icon-image-s: 39px 56px;
+		}
+		
+		datagridexpand.collapsed
+		{
+			icon-image-t: 250px 267px;
+		}
+	</style>
+</head>
+<body template="window">
+	<datagrid source="high_scores.scores">
+		<col fields="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>
+</body>
+</rml>

+ 10 - 0
Samples/tutorial/datagrid_tree/high_score.txt

@@ -0,0 +1,10 @@
+Rocket	233, 116, 81, 255	1	1000	36	12	10
+UI	127, 255, 0, 255	1	900	30	12	9
+middleware	21, 96, 189, 255	1	800	28	10	8
+for	246, 74, 138, 255	1	700	26	10	7
+all	255, 0, 255, 255	1	600	24	10	5
+your	218, 165, 32, 255	1	500	30	6	2
+game	255, 255, 240, 255	1	400	24	4	2
+interface	233, 116, 81, 255	1	300	12	3	3
+needs	127, 255, 0, 255	1	200	8	2	2
+:)	21, 96, 189, 255	1	100	4	3	0

+ 70 - 0
Samples/tutorial/datagrid_tree/src/DecoratorDefender.cpp

@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include "DecoratorDefender.h"
+#include <EMP/Core/Math.h>
+#include <Rocket/Core/Element.h>
+#include <Rocket/Core/Texture.h>
+#include <ShellOpenGL.h>
+
+DecoratorDefender::~DecoratorDefender()
+{
+}
+
+bool DecoratorDefender::Initialise(const EMP::Core::String& image_source, const EMP::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* EMP_UNUSED(element))
+{
+	return NULL;
+}
+
+// Called to release element data generated by this decorator.
+void DecoratorDefender::ReleaseElementData(Rocket::Core::DecoratorDataHandle EMP_UNUSED(element_data))
+{
+}
+
+// Called to render the decorator on an element.
+void DecoratorDefender::RenderElement(Rocket::Core::Element* element, Rocket::Core::DecoratorDataHandle EMP_UNUSED(element_data))
+{
+	EMP::Core::Vector2f position = element->GetAbsoluteOffset(Rocket::Core::Box::PADDING);
+	EMP::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()));
+	EMP::Core::Colourb colour = element->GetProperty< EMP::Core::Colourb >("color");
+	glColor4ubv(element->GetProperty< EMP::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);
+}

+ 46 - 0
Samples/tutorial/datagrid_tree/src/DecoratorDefender.h

@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#ifndef DECORATORDEFENDER_H
+#define DECORATORDEFENDER_H
+
+#include <Rocket/Core/Decorator.h>
+
+/**
+	A decorator that displays the defender in the colour of its "colour" property.
+	@author Robert Curry
+ */
+
+class DecoratorDefender : public Rocket::Core::Decorator
+{
+public:
+	virtual ~DecoratorDefender();
+
+	bool Initialise(const EMP::Core::String& image_source, const EMP::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

+ 51 - 0
Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.cpp

@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include "DecoratorInstancerDefender.h"
+#include <EMP/Core/Math.h>
+#include <EMP/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 EMP::Core::String& EMP_UNUSED(name), const Rocket::Core::PropertyDictionary& properties)
+{
+	const Rocket::Core::Property* image_source_property = properties.GetProperty("image-src");
+	EMP::Core::String image_source = image_source_property->Get< EMP::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;
+}

+ 41 - 0
Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.h

@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#ifndef DECORATORINSTANCERDEFENDER_H
+#define DECORATORINSTANCERDEFENDER_H
+
+#include <Rocket/Core/DecoratorInstancer.h>
+
+/**
+	Decorator instancer for the Defender decorator.
+	@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 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 EMP::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

+ 180 - 0
Samples/tutorial/datagrid_tree/src/HighScores.cpp

@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include "HighScores.h"
+#include <EMP/Core/StringUtilities.h>
+#include <EMP/Core/TypeConverter.h>
+#include <Rocket/Core.h>
+#include <stdio.h>
+
+static const char* ALIEN_NAMES[] = { "Drone", "Beserker", "Death-droid" };
+static int ALIEN_SCORES[] = { 10, 20, 40 };
+
+HighScores* HighScores::instance = NULL;
+
+HighScores::HighScores() : EMP::Core::DataSource("high_scores")
+{
+	EMP_ASSERT(instance == NULL);
+	instance = this;
+
+	for (int i = 0; i < NUM_SCORES; i++)
+	{
+		scores[i].score = -1;
+	}
+
+	LoadScores();
+}
+
+HighScores::~HighScores()
+{
+	EMP_ASSERT(instance == this);
+	instance = NULL;
+}
+
+void HighScores::Initialise()
+{
+	new HighScores();
+}
+
+void HighScores::Shutdown()
+{
+	delete instance;
+}
+
+void HighScores::GetRow(EMP::Core::StringList& row, const EMP::Core::String& table, int row_index, const EMP::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] == "score")
+			{
+				row.push_back(EMP::Core::String(32, "%d", scores[row_index].score));
+			}
+			else if (columns[i] == "colour")
+			{
+				EMP::Core::String colour_string;
+				EMP::Core::TypeConverter< EMP::Core::Colourb, EMP::Core::String >::Convert(scores[row_index].colour, colour_string);
+				row.push_back(colour_string);
+			}
+			else if (columns[i] == "wave")
+			{
+				row.push_back(EMP::Core::String(8, "%d", scores[row_index].wave));
+			}
+		}
+	}
+}
+
+int HighScores::GetNumRows(const EMP::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;
+}
+
+void HighScores::SubmitScore(const EMP::Core::String& name, const EMP::Core::Colourb& colour, int wave, int score, int alien_kills[])
+{
+	for (size_t i = 0; i < NUM_SCORES; i++)
+	{
+		if (score > scores[i].score)
+		{
+			// Push down all the other scores.
+			for (size_t 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;
+
+			for (int j = 0; j < NUM_ALIEN_TYPES; j++)
+			{
+				scores[i].alien_kills[j] = alien_kills[j];
+			}
+
+			NotifyRowAdd("scores", i, 1);
+
+			return;
+		}
+	}
+}
+
+void HighScores::LoadScores()
+{
+	// Open and read the high score file.
+	Rocket::Core::FileInterface* file_interface = Rocket::Core::GetFileInterface();
+	Rocket::Core::FileHandle scores_file = file_interface->Open("high_score.txt");
+	
+	if (scores_file)
+	{
+		file_interface->Seek(scores_file, 0, SEEK_END);
+		size_t scores_length = file_interface->Tell(scores_file);
+		file_interface->Seek(scores_file, 0, SEEK_SET);
+
+		if (scores_length > 0)
+		{
+			char* buffer = new char[scores_length + 1];
+			file_interface->Read(buffer, scores_length, scores_file);
+			file_interface->Close(scores_file);
+			buffer[scores_length] = 0;
+
+			EMP::Core::StringList score_lines;
+			EMP::Core::StringUtilities::ExpandString(score_lines, buffer, '\n');
+			delete[] buffer;
+
+			for (size_t i = 0; i < score_lines.size(); i++)
+			{
+				EMP::Core::StringList score_parts;
+				EMP::Core::StringUtilities::ExpandString(score_parts, score_lines[i], '\t');
+				if (score_parts.size() == 4 + NUM_ALIEN_TYPES)
+				{
+					EMP::Core::Colourb colour;
+					int wave;
+					int score;
+					int alien_kills[NUM_ALIEN_TYPES];
+
+					if (EMP::Core::TypeConverter< EMP::Core::String , EMP::Core::Colourb >::Convert(score_parts[1], colour) &&
+						EMP::Core::TypeConverter< EMP::Core::String, int >::Convert(score_parts[2], wave) &&
+						EMP::Core::TypeConverter< EMP::Core::String, int >::Convert(score_parts[3], score))
+					{
+						for (int j = 0; j < NUM_ALIEN_TYPES; j++)
+						{
+							if (!EMP::Core::TypeConverter< EMP::Core::String, int >::Convert(score_parts[4 + j], alien_kills[j]))
+							{
+								break;
+							}
+						}
+
+						SubmitScore(score_parts[0], colour, wave, score, alien_kills);
+					}
+				}
+			}
+		}
+	}
+}

+ 57 - 0
Samples/tutorial/datagrid_tree/src/HighScores.h

@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#ifndef HIGHSCORES_H
+#define HIGHSCORES_H
+
+#include <EMP/Core/Types.h>
+#include <EMP/Core/DataSource.h>
+
+const int NUM_SCORES = 10;
+const int NUM_ALIEN_TYPES = 3;
+
+/**
+	This class stores a list of high scores, and loads the high scores list from a file upon initialisation.
+	@author Robert Curry
+ */
+
+class HighScores : public EMP::Core::DataSource
+{
+public:
+	static void Initialise();
+	static void Shutdown();
+
+	void GetRow(EMP::Core::StringList& row, const EMP::Core::String& table, int row_index, const EMP::Core::StringList& columns);
+	int GetNumRows(const EMP::Core::String& table);
+
+private:
+	HighScores();
+	~HighScores();
+
+	static HighScores* instance;
+
+	void SubmitScore(const EMP::Core::String& name, const EMP::Core::Colourb& colour, int wave, int score, int alien_kills[]);
+	void LoadScores();
+
+	struct Score
+	{
+		EMP::Core::String name;
+		EMP::Core::Colourb colour;
+		int score;
+		int wave;
+
+		int alien_kills[NUM_ALIEN_TYPES];
+	};
+
+	Score scores[NUM_SCORES];
+};
+
+#endif

+ 34 - 0
Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.cpp

@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include "HighScoresShipFormatter.h"
+#include <EMP/Core/TypeConverter.h>
+
+HighScoresShipFormatter::HighScoresShipFormatter() : Rocket::Controls::DataFormatter("ship")
+{
+}
+
+HighScoresShipFormatter::~HighScoresShipFormatter()
+{
+}
+
+void HighScoresShipFormatter::FormatData(EMP::Core::String& formatted_data, const EMP::Core::StringList& raw_data)
+{
+	// Data format:
+	// raw_data[0] is the colour, in "%d, %d, %d, %d" format.
+
+	EMP::Core::Colourb ship_colour;
+	EMP::Core::TypeConverter< EMP::Core::String, EMP::Core::Colourb >::Convert(raw_data[0], ship_colour);
+
+	EMP::Core::String colour_string(32, "%d,%d,%d", ship_colour.red, ship_colour.green, ship_colour.blue);
+
+	formatted_data = "<defender style=\"color: rgb(" + colour_string + ");\" />";
+}

+ 31 - 0
Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.h

@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#ifndef HIGHSCORESSHIPFORMATTER_H
+#define HIGHSCORESSHIPFORMATTER_H
+
+#include <Rocket/Controls/DataFormatter.h>
+
+/**
+	Formats the colour of the player's ship to a <defender> tag, which is linked to the defender decorator.
+	@author Robert Curry
+ */
+
+class HighScoresShipFormatter : public Rocket::Controls::DataFormatter
+{
+	public:
+		HighScoresShipFormatter();
+		~HighScoresShipFormatter();
+
+		void FormatData(EMP::Core::String& formatted_data, const EMP::Core::StringList& raw_data);
+};
+
+#endif

+ 105 - 0
Samples/tutorial/datagrid_tree/src/main.cpp

@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include <Rocket/Core.h>
+#include <Rocket/Controls.h>
+#include <Rocket/Debugger.h>
+#include <Input.h>
+#include <Shell.h>
+#include "DecoratorInstancerDefender.h"
+#include "HighScores.h"
+#include "HighScoresShipFormatter.h"
+
+Rocket::Core::Context* context = NULL;
+
+void GameLoop()
+{
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	context->Update();
+	context->Render();
+
+	Shell::FlipBuffers();
+}
+
+#if defined EMP_PLATFORM_WIN32
+#include <windows.h>
+int APIENTRY WinMain(HINSTANCE EMP_UNUSED(instance_handle), HINSTANCE EMP_UNUSED(previous_instance_handle), char* EMP_UNUSED(command_line), int EMP_UNUSED(command_show))
+#else
+int main(int EMP_UNUSED(argc), char** EMP_UNUSED(argv))
+#endif
+{
+	// Generic OS initialisation, creates a window and attaches OpenGL.
+	if (!Shell::Initialise("../../projects/Rocket/samples/tutorials/datagrid_tree/") ||
+		!Shell::OpenWindow("Datagrid Tree Tutorial", true))
+	{
+		Shell::Shutdown();
+		return -1;
+	}
+
+	// Rocket initialisation.
+	ShellRenderInterfaceOpenGL opengl_renderer;
+	Rocket::Core::SetRenderInterface(&opengl_renderer);
+
+	ShellSystemInterface system_interface;
+	Rocket::Core::SetSystemInterface(&system_interface);
+
+	Rocket::Core::Initialise();
+	Rocket::Controls::Initialise();
+
+	// Create the main Rocket context and set it on the shell's input layer.
+	context = Rocket::Core::CreateContext("main", EMP::Core::Vector2i(1024, 768));
+	if (context == NULL)
+	{
+		Rocket::Core::Shutdown();
+		Shell::Shutdown();
+		return -1;
+	}
+
+	Rocket::Debugger::Initialise(context);
+	Input::SetContext(context);
+
+	Shell::LoadFonts("../../assets/");
+
+	// Load the defender decorator.
+	Rocket::Core::DecoratorInstancer* decorator_instancer = Rocket::Core::Factory::RegisterDecoratorInstancer("defender", new DecoratorInstancerDefender());
+	if (decorator_instancer != NULL)
+		decorator_instancer->RemoveReference();
+
+	// Add the ship formatter.
+	HighScoresShipFormatter ship_formatter;
+
+	// Construct the high scores.
+	HighScores::Initialise();
+
+	// Load and show the tutorial document.
+	Rocket::Core::ElementDocument* document = context->LoadDocument("data/tutorial.rml");
+	document->GetElementById("title")->SetInnerRML(document->GetTitle());
+	if (document != NULL)
+	{
+		document->Show();
+		document->RemoveReference();
+	}
+
+	Shell::EventLoop(GameLoop);
+
+	// Shut down the high scores.
+	HighScores::Shutdown();
+
+	// Shutdown Rocket.
+	context->RemoveReference();
+	Rocket::Core::Shutdown();
+
+	Shell::CloseWindow();
+	Shell::Shutdown();
+
+	return 0;
+}

+ 63 - 0
Samples/tutorial/template/SConstruct

@@ -0,0 +1,63 @@
+#
+# Template Construction File
+# 
+import os
+import sys
+sys.path += [ "../../../../../build" ]
+import wmsconstruct
+
+FILES = Split( """
+	src/
+	""" )
+
+INCLUDE = Split( """
+	../../../../../packages/include/
+	../../shell/include/
+	""" )
+
+LIBS = Split( """
+	RocketDebugger
+	RocketCore
+	EMPCore
+	Shell
+	""" )
+
+LIBPATHS = Split( """
+	../../../../../packages/bin
+	""" )
+
+DEPENDENCIES = []
+
+if sys.platform == "win32":
+	LIBS += Split( """
+		opengl32
+		user32
+		gdi32
+		libpng
+		zlib
+		""" )
+	LIBPATHS += Split( """
+		../../shell/libpng
+		""" )
+elif sys.platform == "darwin":
+	LIBS += Split( """
+		png
+		z
+		""" )
+	LIBPATHS += Split( """
+		../../shell/libpng
+		""" )
+	DEPENDENCIES += ["AGL", "Carbon", "OpenGL"]
+elif sys.platform == "linux2":
+	LIBS += Split( """
+		GL
+		png
+		""" )
+
+wmsconstruct.Program("Rocket Template Tutorial",
+	"../../../../../packages/bin/template",
+	FILES,
+	INCLUDE,
+	LIBS,
+	LIBPATHS,
+	DEPENDENCIES)

+ 29 - 0
Samples/tutorial/template/Template.sln

@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template", "Template.vcproj", "{3C58D3B5-9478-4221-954A-01E3C4F1FA89}"
+	ProjectSection(ProjectDependencies) = postProject
+		{AF4FF882-AFD9-457B-979E-A5B482388D46} = {AF4FF882-AFD9-457B-979E-A5B482388D46}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shell", "..\..\shell\shell.vcproj", "{AF4FF882-AFD9-457B-979E-A5B482388D46}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Debug|Win32.ActiveCfg = Debug|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Debug|Win32.Build.0 = Debug|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Release|Win32.ActiveCfg = Release|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Release|Win32.Build.0 = Release|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Debug|Win32.ActiveCfg = Debug|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Debug|Win32.Build.0 = Debug|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Release|Win32.ActiveCfg = Release|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 167 - 0
Samples/tutorial/template/Template.vcproj

@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="Template"
+	ProjectGUID="{3C58D3B5-9478-4221-954A-01E3C4F1FA89}"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\..\shell\include;..\..\..\..\..\packages\include"
+				PreprocessorDefinitions="WIN32"
+				RuntimeLibrary="3"
+				WarningLevel="4"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="EMPCore_d.lib RocketCore_d.lib RocketControls_d.lib RocketDebugger_d.lib libpng_d.lib zlib_d.lib opengl32.lib"
+				OutputFile="..\..\..\..\..\packages\bin\$(ProjectName)_d.exe"
+				AdditionalLibraryDirectories="..\..\shell\libpng;..\..\..\..\..\packages\bin"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="..\..\shell\include;..\..\..\..\..\packages\include"
+				PreprocessorDefinitions="WIN32"
+				RuntimeLibrary="2"
+				WarningLevel="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="EMPCore.lib RocketCore.lib RocketControls.lib RocketDebugger.lib libpng.lib zlib.lib opengl32.lib"
+				OutputFile="..\..\..\..\..\packages\bin\$(ProjectName).exe"
+				AdditionalLibraryDirectories="..\..\shell\libpng;..\..\..\..\..\packages\bin"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\src\main.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 65 - 0
Samples/tutorial/template/Template.vcproj.user

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="8.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="..\..\..\..\..\packages\bin"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine=""
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="..\..\..\..\..\packages\bin"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine=""
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>

BIN
Samples/tutorial/template/data/tutorial.png


+ 26 - 0
Samples/tutorial/template/data/tutorial.rcss

@@ -0,0 +1,26 @@
+body
+{
+	font-family: Delicious;
+	font-weight: normal;
+	font-style: normal;
+	font-size: 15;
+	color: white;
+}
+
+body.window
+{
+	background-decorator: tiled-box;
+	background-top-left-image: tutorial.png 0px 0px 133px 140px;
+	background-top-right-image: tutorial.png 136px 0px 146px 140px;
+	background-top-image: tutorial.png stretch 134px 0px 135px 140px;
+	background-bottom-left-image: tutorial.png 0px 140px 11px 151px;
+	background-bottom-right-image: tutorial.png 136px 140px 146px 151px;
+	background-bottom-image: tutorial.png stretch 11px 140px 12px 151px;
+	background-left-image: tutorial.png stretch 0px 139px 10px 140px;
+	background-center-image: tutorial.png stretch 11px 139px 12px 140px;
+}
+
+div
+{
+    display: block;
+}

+ 17 - 0
Samples/tutorial/template/data/tutorial.rml

@@ -0,0 +1,17 @@
+<rml>
+<head>
+	<link type="text/css" href="tutorial.rcss"/>
+	<title>Window</title>
+	<style>
+		body
+		{
+			width: 400px;
+			height: 300px;
+
+			margin: auto;
+		}
+	</style>
+</head>
+<body class="window">
+</body>
+</rml>

+ 85 - 0
Samples/tutorial/template/src/main.cpp

@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include <Rocket/Core.h>
+#include <Rocket/Debugger.h>
+#include <Input.h>
+#include <Shell.h>
+
+Rocket::Core::Context* context = NULL;
+
+void GameLoop()
+{
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	context->Update();
+	context->Render();
+
+	Shell::FlipBuffers();
+}
+
+#if defined EMP_PLATFORM_WIN32
+#include <windows.h>
+int APIENTRY WinMain(HINSTANCE EMP_UNUSED(instance_handle), HINSTANCE EMP_UNUSED(previous_instance_handle), char* EMP_UNUSED(command_line), int EMP_UNUSED(command_show))
+#else
+int main(int EMP_UNUSED(argc), char** EMP_UNUSED(argv))
+#endif
+{
+	// Generic OS initialisation, creates a window and attaches OpenGL.
+	if (!Shell::Initialise("../../projects/Rocket/samples/tutorials/template/") ||
+		!Shell::OpenWindow("Template Tutorial", true))
+	{
+		Shell::Shutdown();
+		return -1;
+	}
+
+	// Rocket initialisation.
+	ShellRenderInterfaceOpenGL opengl_renderer;
+	Rocket::Core::SetRenderInterface(&opengl_renderer);
+
+	ShellSystemInterface system_interface;
+	Rocket::Core::SetSystemInterface(&system_interface);
+
+	Rocket::Core::Initialise();
+
+	// Create the main Rocket context and set it on the shell's input layer.
+	context = Rocket::Core::CreateContext("main", EMP::Core::Vector2i(1024, 768));
+	if (context == NULL)
+	{
+		Rocket::Core::Shutdown();
+		Shell::Shutdown();
+		return -1;
+	}
+
+	Rocket::Debugger::Initialise(context);
+	Input::SetContext(context);
+
+	Shell::LoadFonts("../../assets/");
+
+	// Load and show the tutorial document.
+	Rocket::Core::ElementDocument* document = context->LoadDocument("data/tutorial.rml");
+	if (document != NULL)
+	{
+		document->Show();
+		document->RemoveReference();
+	}
+
+	Shell::EventLoop(GameLoop);
+
+	// Shutdown Rocket.
+	context->RemoveReference();
+	Rocket::Core::Shutdown();
+
+	Shell::CloseWindow();
+	Shell::Shutdown();
+
+	return 0;
+}

+ 29 - 0
Samples/tutorial/tutorial_drag/Drag.sln

@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Drag", "Drag.vcproj", "{3C58D3B5-9478-4221-954A-01E3C4F1FA89}"
+	ProjectSection(ProjectDependencies) = postProject
+		{AF4FF882-AFD9-457B-979E-A5B482388D46} = {AF4FF882-AFD9-457B-979E-A5B482388D46}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shell", "..\..\shell\shell.vcproj", "{AF4FF882-AFD9-457B-979E-A5B482388D46}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Debug|Win32.ActiveCfg = Debug|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Debug|Win32.Build.0 = Debug|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Release|Win32.ActiveCfg = Release|Win32
+		{3C58D3B5-9478-4221-954A-01E3C4F1FA89}.Release|Win32.Build.0 = Release|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Debug|Win32.ActiveCfg = Debug|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Debug|Win32.Build.0 = Debug|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Release|Win32.ActiveCfg = Release|Win32
+		{AF4FF882-AFD9-457B-979E-A5B482388D46}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 175 - 0
Samples/tutorial/tutorial_drag/Drag.vcproj

@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="Drag"
+	ProjectGUID="{3C58D3B5-9478-4221-954A-01E3C4F1FA89}"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\..\shell\include;..\..\..\..\..\packages\include"
+				PreprocessorDefinitions="WIN32"
+				RuntimeLibrary="3"
+				WarningLevel="4"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="EMPCore_d.lib RocketCore_d.lib RocketControls_d.lib RocketDebugger_d.lib libpng_d.lib zlib_d.lib opengl32.lib"
+				OutputFile="..\..\..\..\..\packages\bin\$(ProjectName)_d.exe"
+				AdditionalLibraryDirectories="..\..\shell\libpng;..\..\..\..\..\packages\bin"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="..\..\shell\include;..\..\..\..\..\packages\include"
+				PreprocessorDefinitions="WIN32"
+				RuntimeLibrary="2"
+				WarningLevel="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="EMPCore.lib RocketCore.lib RocketControls.lib RocketDebugger.lib libpng.lib zlib.lib opengl32.lib"
+				OutputFile="..\..\..\..\..\packages\bin\$(ProjectName).exe"
+				AdditionalLibraryDirectories="..\..\shell\libpng;..\..\..\..\..\packages\bin"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\src\Inventory.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\src\Inventory.h"
+			>
+		</File>
+		<File
+			RelativePath=".\src\main.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 65 - 0
Samples/tutorial/tutorial_drag/Drag.vcproj.user

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="8.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="..\..\..\..\..\packages\bin"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine=""
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="..\..\..\..\..\packages\bin"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine=""
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>

+ 63 - 0
Samples/tutorial/tutorial_drag/SConstruct

@@ -0,0 +1,63 @@
+#
+# Drag Construction File
+# 
+import os
+import sys
+sys.path += [ "../../../../../build" ]
+import wmsconstruct
+
+FILES = Split( """
+	src/
+	""" )
+
+INCLUDE = Split( """
+	../../../../../packages/include/
+	../../shell/include/
+	""" )
+
+LIBS = Split( """
+	RocketDebugger
+	RocketCore
+	EMPCore
+	Shell
+	""" )
+
+LIBPATHS = Split( """
+	../../../../../packages/bin
+	""" )
+
+DEPENDENCIES = []
+
+if sys.platform == "win32":
+	LIBS += Split( """
+		opengl32
+		user32
+		gdi32
+		libpng
+		zlib
+		""" )
+	LIBPATHS += Split( """
+		../../shell/libpng
+		""" )
+elif sys.platform == "darwin":
+	LIBS += Split( """
+		png
+		z
+		""" )
+	LIBPATHS += Split( """
+		../../shell/libpng
+		""" )
+	DEPENDENCIES += ["AGL", "Carbon", "OpenGL"]
+elif sys.platform == "linux2":
+	LIBS += Split( """
+		GL
+		png
+		""" )
+
+wmsconstruct.Program("Rocket Drag Tutorial",
+	"../../../../../packages/bin/drag",
+	FILES,
+	INCLUDE,
+	LIBS,
+	LIBPATHS,
+	DEPENDENCIES)

+ 16 - 0
Samples/tutorial/tutorial_drag/data/inventory.rml

@@ -0,0 +1,16 @@
+<rml>
+<head>
+	<link type="text/template" href="../../../assets/window.rml"/>
+	<link type="text/css" href="tutorial.rcss"/>
+	<title>Inventory</title>
+	<style>
+		body
+		{
+			width: 400px;
+			height: 300px;
+		}
+	</style>
+</head>
+<body template="window">
+</body>
+</rml>

+ 25 - 0
Samples/tutorial/tutorial_drag/data/tutorial.rcss

@@ -0,0 +1,25 @@
+/* Hide the window icon. */
+div#title_bar div#icon
+{
+    display: none;
+}
+
+icon
+{
+    /* The icons are floated left so they appear left-to-right. */
+    float: left;
+    
+    /* The padding is added to push the text down to the bottom of the element. The inner dimensions plus the
+       padding come to 100px square. */
+    width: 80px;
+    height: 40px;
+    padding: 60px 10px 0px 10px;
+    margin: 10px;
+    
+    background-decorator: image;
+    background-image: ../../../assets/present.png 0px 0px 100px 100px;
+    
+    font-size: 12;
+    text-align: center;
+    text-shadow: 1px 1px black;
+}

+ 44 - 0
Samples/tutorial/tutorial_drag/src/Inventory.cpp

@@ -0,0 +1,44 @@
+#include "Inventory.h"
+#include <Rocket/Core/Factory.h>
+
+// Constructs a new inventory and opens its window.
+Inventory::Inventory(const EMP::Core::String& title, const EMP::Core::Vector2f& position, Rocket::Core::Context* context)
+{
+	document = context->LoadDocument("data/inventory.rml");
+	if (document != NULL)
+	{
+		document->GetElementById("title")->SetInnerRML(title);
+		document->SetProperty("left", Rocket::Core::Property(position.x, Rocket::Core::Property::PX));
+		document->SetProperty("top", Rocket::Core::Property(position.y, Rocket::Core::Property::PX));
+		document->Show();
+	}
+}
+
+// Destroys the inventory and closes its window.
+Inventory::~Inventory()
+{
+	if (document != NULL)
+	{
+		document->RemoveReference();
+		document->Close();
+	}
+}
+
+// Adds a brand-new item into this inventory.
+void Inventory::AddItem(const EMP::Core::String& name)
+{
+	if (document == NULL)
+		return;
+
+	Rocket::Core::Element* content = document->GetElementById("content");
+	if (content == NULL)
+		return;
+
+	// Create the new 'icon' element.
+	Rocket::Core::Element* icon = Rocket::Core::Factory::InstanceElement(content, "icon", "icon", EMP::Core::XMLAttributes());
+	icon->SetInnerRML(name);
+	content->AppendChild(icon);
+
+	// Release the initial reference on the element now that the document has it.
+	icon->RemoveReference();
+}

+ 31 - 0
Samples/tutorial/tutorial_drag/src/Inventory.h

@@ -0,0 +1,31 @@
+#ifndef INVENTORY_H
+#define INVENTORY_H
+
+#include <EMP/Core/String.h>
+#include <Rocket/Core/Context.h>
+#include <Rocket/Core/ElementDocument.h>
+
+/**
+	@author Peter Curry
+ */
+
+class Inventory
+{
+public:
+	/// Constructs a new inventory and opens its window.
+	/// @param[in] title The title of the new inventory.
+	/// @param[in] position The position of the inventory window.
+	/// @param[in] context The context to open the inventory window in.
+	Inventory(const EMP::Core::String& title, const EMP::Core::Vector2f& position, Rocket::Core::Context* context);
+	/// Destroys the inventory and closes its window.
+	~Inventory();
+
+	/// Adds a brand-new item into this inventory.
+	/// @param[in] name The name of this item.
+	void AddItem(const EMP::Core::String& name);
+
+private:
+	Rocket::Core::ElementDocument* document;
+};
+
+#endif

+ 91 - 0
Samples/tutorial/tutorial_drag/src/main.cpp

@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2006 - 2008
+ * Wandering Monster Studios Limited
+ *
+ * Any use of this program is governed by the terms of Wandering Monster
+ * Studios Limited's Licence Agreement included with this program, a copy
+ * of which can be obtained by contacting Wandering Monster Studios
+ * Limited at [email protected].
+ *
+ */
+
+#include <Rocket/Core.h>
+#include <Rocket/Debugger.h>
+#include <Input.h>
+#include <Shell.h>
+#include "Inventory.h"
+
+Rocket::Core::Context* context = NULL;
+
+void GameLoop()
+{
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	context->Update();
+	context->Render();
+
+	Shell::FlipBuffers();
+}
+
+#if defined EMP_PLATFORM_WIN32
+#include <windows.h>
+int APIENTRY WinMain(HINSTANCE EMP_UNUSED(instance_handle), HINSTANCE EMP_UNUSED(previous_instance_handle), char* EMP_UNUSED(command_line), int EMP_UNUSED(command_show))
+#else
+int main(int EMP_UNUSED(argc), char** EMP_UNUSED(argv))
+#endif
+{
+	// Generic OS initialisation, creates a window and attaches OpenGL.
+	if (!Shell::Initialise("../../projects/Rocket/samples/tutorials/drag/") ||
+		!Shell::OpenWindow("Drag Tutorial", true))
+	{
+		Shell::Shutdown();
+		return -1;
+	}
+
+	// Rocket initialisation.
+	ShellRenderInterfaceOpenGL opengl_renderer;
+	Rocket::Core::SetRenderInterface(&opengl_renderer);
+
+	ShellSystemInterface system_interface;
+	Rocket::Core::SetSystemInterface(&system_interface);
+
+	Rocket::Core::Initialise();
+
+	// Create the main Rocket context and set it on the shell's input layer.
+	context = Rocket::Core::CreateContext("main", EMP::Core::Vector2i(1024, 768));
+	if (context == NULL)
+	{
+		Rocket::Core::Shutdown();
+		Shell::Shutdown();
+		return -1;
+	}
+
+	Rocket::Debugger::Initialise(context);
+	Input::SetContext(context);
+
+	Shell::LoadFonts("../../assets/");
+
+	// Load and show the inventory document.
+	Inventory* inventory_1 = new Inventory("Inventory 1", EMP::Core::Vector2f(50, 200), context);
+	Inventory* inventory_2 = new Inventory("Inventory 2", EMP::Core::Vector2f(540, 240), context);
+
+	// Add items into the inventory.
+	inventory_1->AddItem("Mk III L.A.S.E.R.");
+	inventory_1->AddItem("Gravity Descender");
+	inventory_1->AddItem("Closed-Loop Ion Beam");
+	inventory_1->AddItem("5kT Mega-Bomb");
+
+	Shell::EventLoop(GameLoop);
+
+	delete inventory_1;
+	delete inventory_2;
+
+	// Shutdown Rocket.
+	context->RemoveReference();
+	Rocket::Core::Shutdown();
+
+	Shell::CloseWindow();
+	Shell::Shutdown();
+
+	return 0;
+}