コード例 #1
0
ファイル: LevelSelector.cpp プロジェクト: CronosTs/phobos3d
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);
	}
}
コード例 #2
0
ファイル: EventManager.cpp プロジェクト: ktj007/mmo
// 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;
}
コード例 #3
0
void GuiDemo::ProcessEvent(Rocket::Core::Event& event)
{
	GK_ASSERT(m_document);
	Rocket::Core::Element* elm = m_document->GetElementById(DEMO_PAGE_INPUT_ID);
	if (elm)
	{
		printf("button clicked: %s\n", static_cast<Rocket::Controls::ElementFormControl*>(elm)->GetValue().CString());
	}
	//printf("Processing event %s", event.GetType().CString());
}
コード例 #4
0
void Rocket_GetAttribute( const char *name, const char *id, const char *attribute, char *out, int length )
{
    if ( ( !*name || !*id ) && activeElement )
    {
        Q_strncpyz( out, activeElement->GetAttribute< Rocket::Core::String >( attribute, "" ).CString(), length );
    }

    else
    {
        Rocket::Core::ElementDocument *document = menuContext->GetDocument( name );

        if ( document )
        {
            Q_strncpyz( out, document->GetElementById( id )->GetAttribute< Rocket::Core::String >( attribute, "" ).CString(), length );
        }
    }
}
コード例 #5
0
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);
}
コード例 #6
0
void Rocket_SetPropertyById( const char *id, const char *property, const char *value )
{
    if ( *id )
    {
        Rocket::Core::ElementDocument *document = menuContext->GetFocusElement()->GetOwnerDocument();

        if ( document )
        {
            Rocket::Core::Element *element = document->GetElementById( id );

            if ( element )
            {
                element->SetProperty( property, value );
            }
        }
    }

    else if ( activeElement )
    {
        activeElement->SetProperty( property, value );
    }
}
コード例 #7
0
void Rocket_SetAttribute( const char *name, const char *id, const char *attribute, const char *value )
{
    if ( ( !*name && !*id ) && activeElement )
    {
        activeElement->SetAttribute( attribute, value );
    }

    else
    {
        Rocket::Core::ElementDocument *document = name[0] ? menuContext->GetDocument( name ) : menuContext->GetFocusElement()->GetOwnerDocument();

        if ( document )
        {
            Rocket::Core::Element *element = document->GetElementById( id );

            if ( element )
            {
                element->SetAttribute( attribute, value );
            }
        }
    }
}
コード例 #8
0
// 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;
}
コード例 #9
0
ファイル: main.cpp プロジェクト: Ali-il/gamekit
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();		
	}
}
コード例 #10
0
void Rocket_SetInnerRML( const char *name, const char *id, const char *RML, int parseFlags )
{
    Rocket::Core::String newRML = parseFlags  ? Rocket_QuakeToRML( RML, parseFlags ) : RML;

    if ( ( !*name || !*id ) && activeElement )
    {
        Rocket_SetInnerRMLGuarded( activeElement, newRML );
    }

    else
    {
        Rocket::Core::ElementDocument *document = menuContext->GetDocument( name );

        if ( document )
        {
            Rocket::Core::Element *e = document->GetElementById( id );

            if ( e )
            {
                Rocket_SetInnerRMLGuarded( e, newRML );
            }
        }
    }
}
コード例 #11
0
ファイル: main.cpp プロジェクト: Clever-Boy/qfusion
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;
}