Beispiel #1
0
Rocket::Core::ElementDocument *RocketModule::loadDocument( const char *filename, bool show )
{
	Rocket::Core::ElementDocument *document;

	// YES I really had to make a function for this!
	document = context->LoadDocument( filename );

	if( show && document )
	{
		// load documents with autofocus disabled
		document->Show( Rocket::Core::ElementDocument::NONE );
		document->Focus();

		// reference counting may bog on us if we cache documents!
		document->RemoveReference();

		// optional element specific eventlisteners here

		// only for UI documents! FIXME: we are already doing this in NavigationStack
		Rocket::Core::EventListener *listener = UI_GetMainListener();
		document->AddEventListener( "keydown", listener );
		document->AddEventListener( "change", listener );
	}

	return document;
}
Beispiel #2
0
Rocket::Core::ElementDocument* UIContext::load_mouse_cursor_file( const std::string& filename )
{
  Rocket::Core::ElementDocument* cursor = nullptr;

  if( this->context_ )
  {
    cursor = this->context_->LoadMouseCursor( filename.c_str() );

    if( cursor )
    {
      cursor->RemoveReference();
      cursor->Show();
    }
    else // cursor == nullptr
    {
      NOM_LOG_ERR( NOM_LOG_CATEGORY_APPLICATION, "Could not load mouse cursor from file:", filename );
    }
  }
  else
  {
    NOM_LOG_CRIT( NOM_LOG_CATEGORY_APPLICATION, "Could not load mouse cursor: invalid context with file:", filename );
  }

  return cursor;
}
Beispiel #3
0
// Loads a window and binds the event handler for it.
bool EventManager::LoadWindow(const Rocket::Core::String& window_name)
{
    // Set the event handler for the new screen, if one has been registered.
    EventHandler* old_event_handler = event_handler;
    EventHandlerMap::iterator iterator = event_handlers.find(window_name);
    if (iterator != event_handlers.end())
        event_handler = (*iterator).second;
    else
        event_handler = NULL;

    // Attempt to load the referenced RML document.

    char path[1024];
    GetMmoResourcePath(path, 1024, (window_name + ".rml").CString());

    Rocket::Core::ElementDocument* document = gContext->LoadDocument(path);
    if (document == NULL)
    {
        event_handler = old_event_handler;
        return false;
    }

    // Set the element's title on the title; IDd 'title' in the RML.
    Rocket::Core::Element* title = document->GetElementById("title");
    if (title != NULL)
        title->SetInnerRML(document->GetTitle());

    document->Focus();
    document->Show();

    // Remove the caller's reference.
    document->RemoveReference();

    return true;
}
void HelloWorld::Start()
{
    helloScene_ = new Scene(context_);
    CreateObjects();
    CreateText();
    SubscribeToEvents();
    
    
    //Rocket stuff
    Rocket::Core::SetRenderInterface(&rocketRenderer);
    Rocket::Core::SetSystemInterface(&rocketSystemInterface);
    
    Rocket::Core::Initialise();
    int w = GetSubsystem<Graphics>()->GetWidth();
    int h = GetSubsystem<Graphics>()->GetHeight();
    rocketContext = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(w, h));
    if(rocketContext == NULL)
    {
        Rocket::Core::Shutdown();
        throw "Dead in the water";
    }
    
    Rocket::Core::FontDatabase::LoadFontFace("Data/Fonts/Delicious-Bold.otf");
    Rocket::Core::FontDatabase::LoadFontFace("Data/Fonts/Delicious-BoldItalic.otf");
    Rocket::Core::FontDatabase::LoadFontFace("Data/Fonts/Delicious-Italic.otf");
    Rocket::Core::FontDatabase::LoadFontFace("Data/Fonts/Delicious-Roman.otf");
    
    Rocket::Core::ElementDocument *Document = rocketContext->LoadDocument("Data/UI/rocketDemo.html");
    
    if(Document)
    {
        Document->Show();
        Document->RemoveReference();
    };
}
Beispiel #5
0
void Phobos::Game::Gui::LevelSelector::Open()
{
	m_fCloseRequested = false;

	m_upDataSource.reset( PH_NEW LevelFileDataSource(m_lstLevelPaths));
	m_upDataGridController.reset(PH_NEW(DataGridController));

	m_spGuiContext = Engine::Gui::Manager::GetInstance().CreateContext("LevelSelector");

	Rocket::Core::ElementDocument* cursor = m_spGuiContext->LoadMouseCursor("resources/gui/LevelSelector/cursor.rml");
	if (cursor)
		cursor->RemoveReference();

	Rocket::Core::ElementDocument* document = m_spGuiContext->LoadDocument("resources/gui/LevelSelector/main.rml");
	if (document)
	{
		document->SetTitle(Rocket::Core::String("Select Level"));
		document->Show();		

		document->RemoveReference();

		Rocket::Controls::ElementDataGrid *dataGrid = dynamic_cast<Rocket::Controls::ElementDataGrid*>(document->GetElementById("datagrid"));				

		int numRows = dataGrid->GetNumRows();

		dataGrid->AddEventListener("rowadd", m_upDataGridController.get());
		dataGrid->AddEventListener("keydown", m_upDataGridController.get());

		document->GetElementById("loadForm")->AddEventListener("submit", &clLevelSelectorEventListener_gl);
		document->GetElementById("quitForm")->AddEventListener("submit", &clLevelSelectorEventListener_gl);
	}
}
bool
CFormBackendImp::LoadLayout( GUCEF::CORE::CIOAccess& layoutStorage )
{GUCEF_TRACE;
    
    CRocketStreamAdapter streamAdapter( layoutStorage );

    // Load and show the document.
    Rocket::Core::ElementDocument* document = m_context->GetRocketContext()->LoadDocument( &streamAdapter );
    if ( NULL != document )
    {
        document->Show();
        document->RemoveReference();
        return true;
    }
    return false;
}
void GuiDemo::initRocket()
{
	GK_ASSERT(m_scene && !m_rkContext);

	gkWindow* window = m_scene->getDisplayWindow();
	// Rocket initialisation.
	m_rkOgreRenderer = new RenderInterfaceOgre3D(window->getWidth(), window->getHeight());
	Rocket::Core::SetRenderInterface(m_rkOgreRenderer);

	m_rkOgreSystem = new SystemInterfaceOgre3D();
	Rocket::Core::SetSystemInterface(m_rkOgreSystem);

	Rocket::Core::Initialise();
	Rocket::Controls::Initialise();


	installRocketFonts();

	m_rkContext = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(window->getWidth(), window->getHeight()));
	Rocket::Debugger::Initialise(m_rkContext);

	m_rkFileInterface = new FileInterfaceOgre3D();
	Rocket::Core::SetFileInterface(m_rkFileInterface);


	// Load the mouse cursor and release the caller's reference.
	Rocket::Core::ElementDocument* cursor = m_rkContext->LoadMouseCursor(ROCKET_CURSOR_PAGE);
	if (cursor)
		cursor->RemoveReference();

	m_document = m_rkContext->LoadDocument(ROCKET_DEMO_PAGE);
	if (m_document)
	{
		Rocket::Core::Element* button = m_document->GetElementById(DEMO_PAGE_BUTTON_ID);
		if (button)
			button->AddEventListener("click", this);
		m_document->Show();		
	}

	m_rkEventListener  = new RocketEventListener(window, m_rkContext);
	m_rkRenderListener = new RocketRenderListener(window->getRenderWindow(), m_scene->getManager(), m_rkContext);
}
Beispiel #8
0
/*
* Create Application
*/
Application::Application()
    : window_(sf::VideoMode(1024, 768), "SpaceG", sf::Style::Titlebar | sf::Style::Close ),
      currentState_(nullptr)
{
	//Handle the view seperate from rendertexture and window 
	
    //setting up sfml render stuff
    window_.setFramerateLimit(60);
    auto size = window_.getSize();
    renderTexture_.create(size.x, size.y);
    view_ = renderTexture_.getView();
    renderTexture_.setView(view_);
    
    //glew init
    glewInit();
    
    //logging:
    auto cs = window_.getSettings();
    cul::Log::Source().verbose("OpenGL Context: %d.%d", cs.majorVersion, cs.minorVersion);
    //depthBits, stencilBits, antialiasingLevel
    
    //GUI Init
    //Getting directly rendered to window not to render texture
    uiRenderInterface_ = new SfmlRenderInterface(&window_);
    Rocket::Core::SetRenderInterface(uiRenderInterface_);
    Rocket::Core::SetSystemInterface(&uiSysInterface_);
    Rocket::Core::Initialise();
    
    uiCtx_ = Rocket::Core::CreateContext("default", Rocket::Core::Vector2i(size.x, size.y));
    
    //Load Fonts
    Rocket::Core::FontDatabase::LoadFontFace("data/font/LinLibertine_Rah.ttf", "Libertine", Rocket::Core::Font::STYLE_NORMAL, Rocket::Core::Font::WEIGHT_NORMAL);
    
    //test
    Rocket::Core::ElementDocument* document = uiCtx_->LoadDocument("data/ui_test.rml");
    if (document != NULL)
        document->Show();
    
    
    Rocket::Debugger::Initialise(uiCtx_);
}
void RocketApplication::createScene()
{
	Ogre::ResourceGroupManager::getSingleton().createResourceGroup("Rocket");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(rocket_path.Replace("\\", "/").CString(), "FileSystem", "Rocket");

	// Rocket initialisation.
	ogre_renderer = new RenderInterfaceOgre3D(mWindow->getWidth(), mWindow->getHeight());
	Rocket::Core::SetRenderInterface(ogre_renderer);

	ogre_system = new SystemInterfaceOgre3D();
	Rocket::Core::SetSystemInterface(ogre_system);

	Rocket::Core::Initialise();
	Rocket::Controls::Initialise();

	// Load the fonts from the path to the sample directory.
	Rocket::Core::FontDatabase::LoadFontFace(sample_path + "../../assets/Delicious-Roman.otf");
	Rocket::Core::FontDatabase::LoadFontFace(sample_path + "../../assets/Delicious-Bold.otf");
	Rocket::Core::FontDatabase::LoadFontFace(sample_path + "../../assets/Delicious-Italic.otf");
	Rocket::Core::FontDatabase::LoadFontFace(sample_path + "../../assets/Delicious-BoldItalic.otf");

	context = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(mWindow->getWidth(), mWindow->getHeight()));
	Rocket::Debugger::Initialise(context);

	// Load the mouse cursor and release the caller's reference.
	Rocket::Core::ElementDocument* cursor = context->LoadMouseCursor(sample_path + "../../assets/cursor.rml");
	if (cursor)
		cursor->RemoveReference();

	Rocket::Core::ElementDocument* document = context->LoadDocument(sample_path + "../../assets/demo.rml");
	if (document)
	{
		document->Show();
		document->RemoveReference();
	}

	// Add the application as a listener to Ogre's render queue so we can render during the overlay.
	mSceneMgr->addRenderQueueListener(this);
}
// Loads a window and binds the event handler for it.
Rocket::Core::ElementDocument* EventManager::LoadWindow(const Rocket::Core::String& window_name)
{
    // Set the event handler for the new screen, if one has been registered.
    EventHandler* old_event_handler = event_handler;
    EventHandlerMap::iterator iterator = event_handlers.find(window_name);
    if (iterator != event_handlers.end())
    {
        event_handler = iterator->second;
        //Rocket::Core::Log::Message(Rocket::Core::Log::LT_INFO, "%s", window_name.CString());
    }
    else
        event_handler = NULL;

    // Attempt to load the referenced RML document.
    Rocket::Core::String document_path = Rocket::Core::String("data/") + window_name + Rocket::Core::String(".rml");
    Rocket::Core::ElementDocument* document = Context->LoadDocument(document_path.CString());
    if (document == nullptr)
    {
        event_handler = old_event_handler;
        return nullptr;
    }

    document->SetId(window_name);

    // Set the element's title on the title; IDd 'title' in the RML.
    Rocket::Core::Element* title = document->GetElementById("title");
    if (title != NULL)
        title->SetInnerRML(document->GetTitle());

    document->Focus();
    document->Show();

    // Remove the caller's reference.
    document->RemoveReference();

    return document;
}
Beispiel #11
0
void GuiDemo::loadGUI()
{
	GK_ASSERT(m_scene);

	// Install fonts
	gkGUIManager *gm = gkGUIManager::getSingletonPtr();
	gm->loadFont("Delicious-Roman");
	gm->loadFont("Delicious-Bold");
	gm->loadFont("Delicious-Italic");
	gm->loadFont("Delicious-BoldItalic");

	// Initialise the Lua interface
    Rocket::Core::Lua::Interpreter::Initialise();
    Rocket::Controls::Lua::RegisterTypes(Rocket::Core::Lua::Interpreter::GetLuaState());
	//Rocket::Core::Vector2f v; v.Normalise();


	// Create context
	gkGUI *gui = m_scene->getDisplayWindow()->getGUI();
	
	// Enable debugger (shift+~)
	gm->setDebug(gui);

	// Load the mouse cursor and release the caller's reference.
	Rocket::Core::ElementDocument* cursor = gui->getContext()->LoadMouseCursor(ROCKET_CURSOR_PAGE);
	if (cursor)
		cursor->RemoveReference();

	m_document = gui->getContext()->LoadDocument(ROCKET_DEMO_PAGE);
	if (m_document)
	{
		Rocket::Core::Element* button = m_document->GetElementById(DEMO_PAGE_BUTTON_ID);
		if (button)
			button->AddEventListener("click", this);
		m_document->Show();		
	}
}
Beispiel #12
0
GameMenu::GameMenu(WindowFramework* window, Rocket::Core::Context* context) : UiBase(window, context)
{
  Rocket::Core::ElementDocument* doc     = context->LoadDocument("data/main_menu.rml");

  root = doc;
  if (doc)
  {
    doc->Show();

    ToggleEventListener(true, "continue", "click", _continueClicked);
    ToggleEventListener(true, "options",  "click", _optionsClicked);
    ToggleEventListener(true, "exit",     "click", _exitClicked);
    ToggleEventListener(true, "save",     "click", _saveClicked);
    ToggleEventListener(true, "load",     "click", _loadClicked);

    _continueClicked.EventReceived.Connect(*this, &GameMenu::MenuEventContinue);
    _exitClicked.EventReceived.Connect(ExitClicked, &Sync::Signal<void (Rocket::Core::Event&)>::Emit);
    _saveClicked.EventReceived.Connect(SaveClicked, &Sync::Signal<void (Rocket::Core::Event&)>::Emit);
    _loadClicked.EventReceived.Connect(LoadClicked, &Sync::Signal<void (Rocket::Core::Event&)>::Emit);
    _optionsClicked.EventReceived.Connect(OptionsClicked, &Sync::Signal<void (Rocket::Core::Event&)>::Emit);

    Translate();
  }
}
 Handle<Value> EDShow(const Arguments& args)
 {  
    Rocket::Core::ElementDocument* v = UnwrapElementDocument(args.This());
    v->Show();   
    return Undefined();      
 }
Beispiel #14
0
int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
#endif
{
    // Generic OS initialisation, creates a window and does not attach OpenGL.
    if (!Shell::Initialise("../Samples/basic/directx/") ||
            !Shell::OpenWindow("DirectX Sample", false))
    {
        Shell::Shutdown();
        return -1;
    }

    // DirectX initialisation.
    if (!InitialiseDirectX())
    {
        Shell::CloseWindow();
        Shell::Shutdown();

        return -1;
    }

    // Install our DirectX render interface into Rocket.
    RenderInterfaceDirectX directx_renderer(g_pD3D, g_pd3dDevice);
    Rocket::Core::SetRenderInterface(&directx_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", Rocket::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("../../assets/demo.rml");
    if (document != NULL)
    {
        document->Show();
        document->RemoveReference();
    }

    Shell::EventLoop(GameLoop);

    // Shutdown Rocket.
    context->RemoveReference();
    Rocket::Core::Shutdown();

    ShutdownDirectX();

    Shell::CloseWindow();
    Shell::Shutdown();

    return 0;
}
Beispiel #15
0
int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv))
#endif
{
#ifdef ROCKET_PLATFORM_WIN32
	ROCKET_UNUSED(instance_handle);
	ROCKET_UNUSED(previous_instance_handle);
	ROCKET_UNUSED(command_line);
	ROCKET_UNUSED(command_show);
#else
	ROCKET_UNUSED(argc);
	ROCKET_UNUSED(argv);
#endif

	// Generic OS initialisation, creates a window and attaches OpenGL.
	if (!Shell::Initialise("../Samples/tutorial/template/") ||
		!Shell::OpenWindow("Template Tutorial", true))
	{
		Shell::Shutdown();
		return -1;
	}

	// Rocket initialisation.
	ShellRenderInterfaceOpenGL opengl_renderer;
	Rocket::Core::SetRenderInterface(&opengl_renderer);
    opengl_renderer.SetViewport(1024, 768);

	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", Rocket::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;
}
Beispiel #16
0
int main(int argc, char *argv[])
{
    Options& options = Options::GetInstance();
    options.LoadFromCommandLine(argc, argv);
	options.LoadFromIniFile("gravity.ini");

    GRAVITY_LOG(info, "Client started.");

    sf::ContextSettings settings;
	settings.depthBits = 0;
	settings.stencilBits = 8;
	settings.antialiasingLevel = options.msaa;
	int style = options.fullscreen ? sf::Style::Fullscreen : sf::Style::Default;

    sf::RenderWindow window(sf::VideoMode(options.hres, options.vres, options.bitdepth), "Gravity", style, settings);
    ::Gravity::Game::Game game;
	
    game.Start();
    
	BoundingCamera camera(Vec2f(400, 300), Vec2f());


    // ROCKET

    RocketRendererInterfaceImpl rendererInterface;
    RocketSystemInterfaceImpl systemInterface;
    RocketShellInterfaceImpl shellInterface("../data/gui/");

    rendererInterface.target =  &window;
    rendererInterface.states = (sf::RenderStates *) &sf::RenderStates::Default;

    Rocket::Core::SetFileInterface(&shellInterface);
    Rocket::Core::SetRenderInterface(&rendererInterface);
    Rocket::Core::SetSystemInterface(&systemInterface);

    if(!Rocket::Core::Initialise())
        return 0;

	Rocket::Controls::Initialise();

    Rocket::Core::FontDatabase::LoadFontFace("Delicious-Bold.otf");
    Rocket::Core::FontDatabase::LoadFontFace("Delicious-BoldItalic.otf");
    Rocket::Core::FontDatabase::LoadFontFace("Delicious-Italic.otf");
    Rocket::Core::FontDatabase::LoadFontFace("Delicious-Roman.otf");
    Rocket::Core::FontDatabase::LoadFontFace("DejaVuSans-Bold.ttf");
    Rocket::Core::FontDatabase::LoadFontFace("DejaVuSans-BoldOblique.ttf");
    Rocket::Core::FontDatabase::LoadFontFace("DejaVuSans-Oblique.ttf");
    Rocket::Core::FontDatabase::LoadFontFace("DejaVuSans.ttf");

    Rocket::Core::Context *Context = Rocket::Core::CreateContext("default",
        Rocket::Core::Vector2i(window.getSize().x, window.getSize().y));
    
    Rocket::Debugger::Initialise(Context);
	//Rocket::Debugger::SetVisible(true);
    
    Rocket::Core::ElementDocument *document = Context->LoadDocument("my.rml");

    if(document)
    {
        document->Show();
        document->RemoveReference();
    };

    // END ROCKET


    //Rocket::Core::ElementDocument* document;

	std::cout << "OpenGL Version" << window.getSettings().ContextSettings::majorVersion << "." << window.getSettings().ContextSettings::minorVersion << std::endl;
    sf::ContextSettings settingz = window.getSettings();
    std::cout << settingz.majorVersion << "." << settingz.minorVersion << std::endl;

    while(window.isOpen()) {
    	sf::Event event;
        Entity* ship = game.GetWorld().GetEntities()[0];

		while (window.pollEvent(event)) {
        //window.PollEvent(event);
			if (event.type == sf::Event::Closed)
				window.close();

			if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
				return 0;

			if ((event.type == sf::Event::MouseWheelMoved)) {
				options.renderscale += event.mouseWheel.delta*.1f;
			}

			if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) {
                Shape* bombShape = Shape::CreateBombShape();
				Entity* bomb = new Entity(game.GetWorld(), *bombShape, ship->GetPos() + Vec2f(1, 1));
                bomb->SetVel(ship->GetVel());
                bomb->SetMass(0.01f);
                game.GetWorld().AddEntity(*bomb);
                
			}
            
            switch(event.type)
            {
                case sf::Event::Resized:
                    //rendererInterface.Resize();
                    break;
                case sf::Event::MouseMoved:
                    Context->ProcessMouseMove(event.mouseMove.x, event.mouseMove.y,
                                              systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::MouseButtonPressed:
                    Context->ProcessMouseButtonDown(event.mouseButton.button,
                            systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::MouseButtonReleased:
                    Context->ProcessMouseButtonUp(event.mouseButton.button,
                            systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::MouseWheelMoved:
                    Context->ProcessMouseWheel(event.mouseWheel.delta,
                                               systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::TextEntered:
                    if (event.text.unicode > 32)
                        Context->ProcessTextInput(event.text.unicode);
                    break;
                case sf::Event::KeyPressed:
                    Context->ProcessKeyDown(systemInterface.TranslateKey(event.key.code),
                                            systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::KeyReleased:
                    if(event.key.code == sf::Keyboard::F8)
                    {
                        Rocket::Debugger::SetVisible(!Rocket::Debugger::IsVisible());
                    };

                    Context->ProcessKeyUp(systemInterface.TranslateKey(event.key.code),
                                          systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::Closed:
                    return 1;
                    break;
            };
		}       
        
        int rotate = sf::Keyboard::isKeyPressed(sf::Keyboard::Right) - sf::Keyboard::isKeyPressed(sf::Keyboard::Left);
		bool forward = sf::Keyboard::isKeyPressed(sf::Keyboard::Up);



		sf::View nView(Vec2f(options.hres, options.vres), Vec2f(options.hres, options.vres));
		camera.Update(ship->GetPos() * options.renderscale);
		nView.move(camera.GetPos() - Vec2f(options.hres, options.vres));

        ship->Rotate(rotate*2);
		if (forward)
			ship->ApplyForce(Vec2f(0.f, 2.f).Rotate(ship->GetAngle()));

        window.clear();
        window.setView(nView);
        DrawWorld(window, game.GetWorld(), 0.f);

        sf::View viewEmpty = window.getDefaultView();
        window.setView(viewEmpty);
        Context->Update();
        Context->Render();
        window.setFramerateLimit(60);
        window.display();

        
        game.Step();

    }

    game.Stop();
    return 0;
}
Beispiel #17
0
int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv))
#endif
{
#ifdef ROCKET_PLATFORM_WIN32
	ROCKET_UNUSED(instance_handle);
	ROCKET_UNUSED(previous_instance_handle);
	ROCKET_UNUSED(command_line);
	ROCKET_UNUSED(command_show);
#else
	ROCKET_UNUSED(argc);
	ROCKET_UNUSED(argv);
#endif

#ifdef ROCKET_PLATFORM_LINUX
#define APP_PATH "../Samples/tutorial/datagrid_tree/"
#else
#define APP_PATH "../../Samples/tutorial/datagrid_tree/"
#endif

#ifdef ROCKET_PLATFORM_WIN32
        DoAllocConsole();
#endif

	int window_width = 1024;
	int window_height = 768;

	ShellRenderInterfaceOpenGL opengl_renderer;
	shell_renderer = &opengl_renderer;

	// Generic OS initialisation, creates a window and attaches OpenGL.
	if (!Shell::Initialise(APP_PATH) ||
		!Shell::OpenWindow("Datagrid Tree Tutorial", shell_renderer, window_width, window_height, true))
	{
		Shell::Shutdown();
		return -1;
	}

	// Rocket initialisation.
	Rocket::Core::SetRenderInterface(&opengl_renderer);
	opengl_renderer.SetViewport(window_width, window_height);

	ShellSystemInterface system_interface;
	Rocket::Core::SetSystemInterface(&system_interface);

	Rocket::Core::Initialise();
	Rocket::Controls::Initialise();

	// Create the main Rocket context and set it on the shell's input layer.
	context = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(window_width, window_height));
	if (context == NULL)
	{
		Rocket::Core::Shutdown();
		Shell::Shutdown();
		return -1;
	}

	Rocket::Debugger::Initialise(context);
	Input::SetContext(context);
	shell_renderer->SetContext(context);

	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;
}
Beispiel #18
0
void Rocket_DocumentAction(const char* name, const char* action) {
    if (!Q_stricmp(action, "show") || !Q_stricmp(action, "open")) {
        Rocket::Core::ElementDocument* document = menuContext->GetDocument(name);
        if (document) {
            document->Show();
        }
    } else if (!Q_stricmp("close", action)) {
        if (!*name) // If name is empty, hide active
        {
            if (menuContext->GetFocusElement() &&
                menuContext->GetFocusElement()->GetOwnerDocument()) {
                menuContext->GetFocusElement()->GetOwnerDocument()->Close();
            }

            return;
        }

        Rocket::Core::ElementDocument* document = menuContext->GetDocument(name);
        if (document) {
            document->Close();
        }
    } else if (!Q_stricmp("goto", action)) {
        Rocket::Core::ElementDocument* document = menuContext->GetDocument(name);
        if (document) {
            Rocket::Core::ElementDocument* owner =
                    menuContext->GetFocusElement()->GetOwnerDocument();
            if (owner) {
                owner->Close();
            }
            document->Show();
        }
    } else if (!Q_stricmp("load", action)) {
        Rocket_LoadDocument(name);
    } else if (!Q_stricmp("blur", action) || !Q_stricmp("hide", action)) {
        Rocket::Core::ElementDocument* document = nullptr;

        if (!*name) // If name is empty, hide active
        {
            if (menuContext->GetFocusElement() &&
                menuContext->GetFocusElement()->GetOwnerDocument()) {
                document = menuContext->GetFocusElement()->GetOwnerDocument();
            }
        } else {
            document = menuContext->GetDocument(name);
        }

        if (document) {
            document->Hide();
        }
    } else if (!Q_stricmp("blurall", action)) {
        for (int i = 0; i < menuContext->GetNumDocuments(); ++i) {
            menuContext->GetDocument(i)->Hide();
        }
    } else if (!Q_stricmp("reload", action)) {
        Rocket::Core::ElementDocument* document = nullptr;

        if (!*name) // If name is empty, hide active
        {
            if (menuContext->GetFocusElement() &&
                menuContext->GetFocusElement()->GetOwnerDocument()) {
                document = menuContext->GetFocusElement()->GetOwnerDocument();
            }
        } else {
            document = menuContext->GetDocument(name);
        }

        if (document) {
            Rocket::Core::String url = document->GetSourceURL();
            document->Close();
            document = menuContext->LoadDocument(url);
            document->Show();
        }
    }
}
Beispiel #19
0
int main(int argc, char **argv)
{
#ifdef ROCKET_PLATFORM_WIN32
        DoAllocConsole();
#endif

        int window_width = 1024;
        int window_height = 768;

	sf::RenderWindow MyWindow(sf::VideoMode(window_width, window_height), "libRocket with SFML");

	RocketSFMLRenderer Renderer;
	RocketSFMLSystemInterface SystemInterface;
	ShellFileInterface FileInterface("../Samples/assets/");

	if(!MyWindow.IsOpened())
		return 1;

	Renderer.SetWindow(&MyWindow);

	Rocket::Core::SetFileInterface(&FileInterface);
	Rocket::Core::SetRenderInterface(&Renderer);
	Rocket::Core::SetSystemInterface(&SystemInterface);

	if(!Rocket::Core::Initialise())
		return 1;

	Rocket::Core::FontDatabase::LoadFontFace("Delicious-Bold.otf");
	Rocket::Core::FontDatabase::LoadFontFace("Delicious-BoldItalic.otf");
	Rocket::Core::FontDatabase::LoadFontFace("Delicious-Italic.otf");
	Rocket::Core::FontDatabase::LoadFontFace("Delicious-Roman.otf");

	Rocket::Core::Context *Context = Rocket::Core::CreateContext("default",
		Rocket::Core::Vector2i(MyWindow.GetWidth(), MyWindow.GetHeight()));

	Rocket::Debugger::Initialise(Context);

	Rocket::Core::ElementDocument *Document = Context->LoadDocument("demo.rml");

	if(Document)
	{
		Document->Show();
		Document->RemoveReference();
	};

	while(MyWindow.IsOpened())
	{
		static sf::Event event;

		MyWindow.Clear();
		Context->Render();
		MyWindow.Display();

		while(MyWindow.GetEvent(event))
		{
			switch(event.Type)
			{
			case sf::Event::Resized:
				Renderer.Resize();
				break;
			case sf::Event::MouseMoved:
				Context->ProcessMouseMove(event.MouseMove.X, event.MouseMove.Y,
					SystemInterface.GetKeyModifiers(&MyWindow));
				break;
			case sf::Event::MouseButtonPressed:
				Context->ProcessMouseButtonDown(event.MouseButton.Button,
					SystemInterface.GetKeyModifiers(&MyWindow));
				break;
			case sf::Event::MouseButtonReleased:
				Context->ProcessMouseButtonUp(event.MouseButton.Button,
					SystemInterface.GetKeyModifiers(&MyWindow));
				break;
			case sf::Event::MouseWheelMoved:
				Context->ProcessMouseWheel(event.MouseWheel.Delta,
					SystemInterface.GetKeyModifiers(&MyWindow));
				break;
			case sf::Event::TextEntered:
				if (event.Text.Unicode > 32)
					Context->ProcessTextInput(event.Text.Unicode);
				break;
			case sf::Event::KeyPressed:
				Context->ProcessKeyDown(SystemInterface.TranslateKey(event.Key.Code),
					SystemInterface.GetKeyModifiers(&MyWindow));
				break;
			case sf::Event::KeyReleased:
				if(event.Key.Code == sf::Key::F8)
				{
					Rocket::Debugger::SetVisible(!Rocket::Debugger::IsVisible());
				};

				Context->ProcessKeyUp(SystemInterface.TranslateKey(event.Key.Code),
					SystemInterface.GetKeyModifiers(&MyWindow));
				break;
			case sf::Event::Closed:
				return 1;
				break;
			};
		};

		Context->Update();
	};

	return 0;
};
Beispiel #20
0
int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
#endif
{
	// Generic OS initialisation, creates a window and attaches OpenGL.
	if (!Shell::Initialise("../Samples/basic/customlog/") ||
		!Shell::OpenWindow("Custom File Handler Sample", true))
	{
		Shell::Shutdown();
		return -1;
	}

	// Rocket initialisation.
	ShellRenderInterfaceOpenGL opengl_renderer;
	Rocket::Core::SetRenderInterface(&opengl_renderer);
    opengl_renderer.SetViewport(1024,768);


	// Initialise our system interface to write the log messages to file.
	SystemInterface 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", Rocket::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 a non-existent document to spawn an error message.
	Rocket::Core::ElementDocument* invalid_document = context->LoadDocument("../../assets/invalid.rml");
	ROCKET_ASSERTMSG(invalid_document != NULL, "Testing ASSERT logging.");
	if (invalid_document != NULL)
	{
		invalid_document->RemoveReference();
		invalid_document->Close();
	}

	// Load and show the demo document.
	Rocket::Core::ElementDocument* document = context->LoadDocument("../../assets/demo.rml");
	if (document != NULL)
	{
		document->Show();
		document->RemoveReference();
	}

	Shell::EventLoop(GameLoop);

	// Shutdown Rocket.
	context->RemoveReference();
	Rocket::Core::Shutdown();

	Shell::CloseWindow();
	Shell::Shutdown();

	return 0;
}