Advertisement
bitetti

LRocket.h - self LibRocket & Lua integration

Oct 26th, 2011
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.81 KB | None | 0 0
  1. /*
  2.  * LRocket.h
  3.  *
  4.  *  Created on: 19/10/2011
  5.  *      Author: bitetti
  6.  */
  7.  
  8. #ifndef LROCKET_H_
  9. #define LROCKET_H_
  10.  
  11. #include <iostream>
  12. #include <list>
  13.  
  14. #include <Ogre.h>
  15. #include "OgreKit.h"
  16. #include "Loaders/Blender2/gkBlendInternalFile.h"
  17. #include "gkTextManager.h"
  18. #include "gkCommon.h"
  19. #include "gkUtils.h"
  20.  
  21. extern "C"{
  22.     #include <lua.h>
  23.     #include <lauxlib.h>
  24.     #include <lualib.h>
  25. }
  26.  
  27. // GUI
  28. #include <Rocket/Core.h>
  29. #include <Rocket/Controls.h>
  30. #include <Rocket/Debugger.h>
  31. #include "rocket/RocketRenderListener.h"
  32. #include "rocket/RenderInterfaceOgre3D.h"
  33. #include "rocket/RocketEventListener.h"
  34. #include "rocket/SystemInterfaceOgre3D.h"
  35. #include "rocket/FileInterfaceOgre3D.h"
  36.  
  37. void installRocketFonts();
  38.  
  39. namespace WWP {
  40.  
  41. class Rocket_Document {
  42. public:
  43.         gkString name;
  44.         gkString callBack;
  45.         Rocket::Core::ElementDocument* document;
  46.  
  47.         Rocket_Document()
  48.         {
  49.  
  50.         }
  51.  
  52.         Rocket_Document( const char* _name, const char* _callBack, Rocket::Core::ElementDocument* _document)
  53.         {
  54.             name = _name;
  55.             callBack = _callBack;
  56.             document = _document;
  57.         }
  58.  
  59.         ~Rocket_Document()
  60.         {std::cout<<"-1\n";
  61.             if( document != 0)
  62.             {
  63.                 std::cout<<"0\n";document->RemoveReference();
  64.                 std::cout<<"1\n";document->Close();
  65.                 std::cout<<"2\n";delete document;
  66.                 std::cout<<"3\n";document = 0;
  67.             }
  68.             std::cout<<"finalizando: "<<name.c_str()<<"\n";
  69.             std::cout<<"4\n";name.clear();
  70.             std::cout<<"5\n";callBack.clear();
  71.         }
  72. };
  73.  
  74.  
  75. #define LROCKET_CLASS "LRocket"
  76.  
  77. class LRocket :
  78.     public Rocket::Core::EventListener
  79. {
  80. public:
  81.     virtual ~LRocket();
  82.  
  83.     static void registrarFuncoes( lua_State* L );
  84.     static void finaliza();
  85.  
  86. private:
  87.     LRocket();
  88.  
  89.     //rocket to lua
  90.     virtual void ProcessEvent(Rocket::Core::Event& event);
  91.  
  92.     //lua
  93.     static int initLibRocket( lua_State* L );
  94.     static int showCursor(lua_State* L);
  95.     static int loadDocument(lua_State* L);
  96.     static int unloadDocument(lua_State* L);
  97.     static int showDocument(lua_State* L);
  98.     static int hideDocument(lua_State* L);
  99.     static int setInnerHTML(lua_State* L);
  100.     static int getInnerHTML(lua_State* L);
  101.     static int getFormElementValue(lua_State* L);
  102.  
  103. //vars
  104. private:
  105.     static LRocket* main;
  106.     static lua_State* Lua;
  107.     static std::list<Rocket_Document*> documentos;
  108.     static Rocket::Core::ElementDocument* cursor;
  109.     gkWindow* window;
  110.     RenderInterfaceOgre3D* m_rkOgreRenderer;
  111.     SystemInterfaceOgre3D* m_rkOgreSystem;
  112.     FileInterfaceOgre3D* m_rkFileInterface;
  113.     RocketEventListener* m_rkEventListener;
  114.     RocketRenderListener* m_rkRenderListener;
  115.     Rocket::Core::Context*  m_rkContext;
  116.     Rocket::Core::ElementDocument* m_document;
  117.  
  118.  
  119.     /**
  120.      * Registros para Lua
  121.      */
  122.     static const luaL_reg meta_methods[];
  123.     static const luaL_reg class_methods[];
  124.     #define newtable(L) (lua_newtable(L), lua_gettop(L))
  125. };
  126.  
  127. }
  128.  
  129. #endif /* LROCKET_H_ */
  130.  
  131.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement