Ejemplo n.º 1
0
    void DoWork(Threading::DefaultThreadSpecificStorage::Type& CurrentThreadStorage)
    {
        /*RigidDebris* Deb1 = TheEntresol->GetActorManager()->GetActor("RobotWayUpFrontLeft");
        RigidDebris* Deb2 = TheEntresol->GetActorManager()->GetActor("RobotWayUpFrontRight");
        if( Deb1->IsAnimated() )
        {
            Deb1->AdvanceAnimation((Real)0.001 * TheEntresol->GetLastFrameTimeMilliseconds() );
        }

        if( Deb2->IsAnimated() )
        {
            Deb2->AdvanceAnimation((Real)0.0001 * TheEntresol->GetLastFrameTimeMilliseconds() );
        }// */

        // Update Stat information
        Graphics::GameWindow* MainWindow = static_cast<Graphics::GraphicsManager*>( TheEntresol->GetManager(ManagerBase::MT_GraphicsManager) )->GetGameWindow(0);
        UI::Screen* DScreen = static_cast<UI::UIManager*>( TheEntresol->GetManager(ManagerBase::MT_UIManager) )->GetScreen("DefaultScreen");
        UI::Widget* CurFPS = static_cast<UI::Widget*>(DScreen->GetWidget("D_CurFPS"));
        UI::Widget* AvFPS = static_cast<UI::Widget*>(DScreen->GetWidget("D_AvFPS"));
        StringStream CFPSstream;
        StringStream AFPSstream;
        CFPSstream << MainWindow->GetLastFPS();
        AFPSstream << MainWindow->GetAverageFPS();
        String CFPS = CFPSstream.str();
        String AFPS = AFPSstream.str();
        static_cast<UI::SingleLineTextLayer*>(CurFPS->GetRenderLayer(0))->SetText(CFPS);
        static_cast<UI::SingleLineTextLayer*>(AvFPS->GetRenderLayer(0))->SetText(AFPS);
    }
Ejemplo n.º 2
0
	static int l_set_font_size(lua_State *l) {
		UI::Widget *w = LuaObject<UI::Widget>::CheckFromLua(1);
		UI::Widget::Font font = static_cast<UI::Widget::Font>(LuaConstants::GetConstantFromArg(l, "UIFont", 2));
		w->SetFont(font);
		lua_pushvalue(l, 1);
		return 1;
	}
Ejemplo n.º 3
0
	static int l_bind(lua_State *l) {
		UI::Widget *w = LuaObject<UI::Widget>::CheckFromLua(1);
		const std::string bindName(luaL_checkstring(l, 2));
		PropertiedObject *po = LuaObject<PropertiedObject>::CheckFromLua(3);
		const std::string propertyName(luaL_checkstring(l, 4));
		w->Bind(bindName, po, propertyName);
		return 0;
	}
Ejemplo n.º 4
0
	static int l_set_enabled(lua_State *l) {
		UI::Widget *w = LuaObject<UI::Widget>::CheckFromLua(1);
		const bool enable = lua_toboolean(l, 2);
		if (enable) {
			w->Enable();
		} else {
			w->Disable();
		}
		return 0;
	}
Ejemplo n.º 5
0
static void dialog_button_callback( ui::Widget widget, gpointer data ){
	int *loop, *ret;

	auto parent = widget.window();
	loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
	ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );

	*loop = 0;
	*ret = gpointer_to_int( data );
}
Ejemplo n.º 6
0
	void on_touch_event(ui::TouchEvent event) {
		/* TODO: Capture widget receiving the Start event, send Move and
		 * End events to the same widget.
		 */
		/* Capture Start widget.
		 * If touch is over Start widget at Move event, then the widget
		 * should be highlighted. If the touch is not over the Start
		 * widget at Move event, widget should un-highlight.
		 * If touch is over Start widget at End event, then the widget
		 * action should occur.
		 */
		if( event.type == ui::TouchEvent::Type::Start ) {
			captured_widget = touch_widget(this->top_widget, event);
		}

		if( captured_widget ) {
			captured_widget->on_touch(event);
		}
	}
Ejemplo n.º 7
0
/**
 * @brief destroy widget if destroy signal is passed to widget
 */
static void destroy( ui::Widget widget, gpointer data ){
	widget.destroy();
}
Ejemplo n.º 8
0
void MakeGUI()
{
    String DefaultScreen = "DefaultScreen";
    UI::UIManager* GUI = static_cast<UI::UIManager*>( TheEntresol->GetManager(ManagerBase::MT_UIManager) );
    Graphics::Viewport* UIViewport = static_cast<Graphics::GraphicsManager*>( TheEntresol->GetManager(ManagerBase::MT_GraphicsManager) )->GetGameWindow(0)->GetViewport(0);
    GUI->LoadMTA("EngineDemo_Menu.mta","Group1");
    GUI->AddAutoRegisterCode(Input::MetaCode(Input::BUTTON_PRESSING,Input::MOUSEBUTTON_1));
    GUI->EnableButtonAutoRegister(true);
    UI::Screen* DScreen = GUI->CreateScreen(DefaultScreen, "EngineDemo_Menu", UIViewport,0);

    ColourValue Transparent(0.0,0.0,0.0,0.0);
    ColourValue Black(0.0,0.0,0.0,1.0);
    ColourValue TransBlack(0.0,0.0,0.0,0.3);

    ColourValue ButtonColour(0.6,0.2,0.2,1.0);
    ColourValue HoveredButtonColour(0.8,0.7,0.05,1.0);
    ColourValue MenuColour(0.4,0.8,0.3,1.0);

    //Build the HUD
    UI::StackButton* MenuAccess = DScreen->CreateStackButton("D_MenuAccess",UI::UnifiedRect(0.008,0.932,0.14,0.06));
    UI::SingleImageLayer* AccessBackground = MenuAccess->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Normal,0));
    AccessBackground->SetColour(ButtonColour);
    UI::SingleImageLayer* AccessHoveredBackground = MenuAccess->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Hovered,0));
    AccessHoveredBackground->SetColour(HoveredButtonColour);
    UI::SingleLineTextLayer* AccessText = MenuAccess->CreateSingleLineTextLayer(1,1);
    AccessText->HorizontallyAlign(UI::LA_Center);
    AccessText->VerticallyAlign(UI::LA_Center);
    AccessText->SetDefaultFont("Ubuntu-14");
    AccessText->SetText("Menu");
    DScreen->AddChild(MenuAccess,1);

    UI::Widget* CurFPS = DScreen->CreateWidget("D_CurFPS",UI::UnifiedRect(0.16,0.008,0.06,0.065));
    UI::SingleLineTextLayer* CurFPSText = CurFPS->CreateSingleLineTextLayer(1,1);
    CurFPSText->HorizontallyAlign(UI::LA_TopLeft);
    CurFPSText->VerticallyAlign(UI::LA_Center);
    CurFPSText->SetDefaultFont("Ubuntu-14");
    CurFPSText->SetText("0.0");
    DScreen->AddChild(CurFPS,2);

    UI::Widget* CurFPSStat = DScreen->CreateWidget("D_CurFPSStat",UI::UnifiedRect(0.008,0.008,0.15,0.065));
    UI::SingleLineTextLayer* CurFPSStatText = CurFPSStat->CreateSingleLineTextLayer(1,1);
    CurFPSStatText->HorizontallyAlign(UI::LA_TopLeft);
    CurFPSStatText->VerticallyAlign(UI::LA_Center);
    CurFPSStatText->SetDefaultFont("Ubuntu-14");
    CurFPSStatText->SetText("Current FPS: ");
    DScreen->AddChild(CurFPSStat,3);

    UI::Widget* AvFPS = DScreen->CreateWidget("D_AvFPS",UI::UnifiedRect(0.16,0.081,0.06,0.065));
    UI::SingleLineTextLayer* AvFPSText = AvFPS->CreateSingleLineTextLayer(1,1);
    AvFPSText->HorizontallyAlign(UI::LA_TopLeft);
    AvFPSText->VerticallyAlign(UI::LA_Center);
    AvFPSText->SetDefaultFont("Ubuntu-14");
    AvFPSText->SetText("0.0");
    DScreen->AddChild(AvFPS,4);

    UI::Widget* AvFPSStat = DScreen->CreateWidget("D_AvFPSStat",UI::UnifiedRect(0.008,0.081,0.15,0.065));
    UI::SingleLineTextLayer* AvFPSStatText = AvFPSStat->CreateSingleLineTextLayer(1,1);
    AvFPSStatText->HorizontallyAlign(UI::LA_TopLeft);
    AvFPSStatText->VerticallyAlign(UI::LA_Center);
    AvFPSStatText->SetDefaultFont("Ubuntu-14");
    AvFPSStatText->SetText("Average FPS: ");
    DScreen->AddChild(AvFPSStat,5);
    //End of HUD
    //Build the Menu
    UI::MenuEntry* DemoMenu = DScreen->CreateMenuEntry("D_Menu",UI::UnifiedRect(0.35,0.27,0.3,0.45));
    UI::SingleImageLayer* DemoMenuBackground = DemoMenu->CreateSingleImageLayer(1,1);
    DemoMenuBackground->SetColour(MenuColour);
    DScreen->AddChild(DemoMenu,6);

    UI::StackButton* ReturnButton = DScreen->CreateStackButton("D_Return",UI::UnifiedRect(0.10,0.56,0.80,0.16));
    UI::SingleImageLayer* ReturnBackground = ReturnButton->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Normal,0));
    ReturnBackground->SetColour(ButtonColour);
    UI::SingleImageLayer* ReturnHoveredBackground = ReturnButton->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Hovered,0));
    ReturnHoveredBackground->SetColour(HoveredButtonColour);
    UI::SingleLineTextLayer* ReturnText = ReturnButton->CreateSingleLineTextLayer(1,1);
    ReturnText->HorizontallyAlign(UI::LA_Center);
    ReturnText->VerticallyAlign(UI::LA_Center);
    ReturnText->SetDefaultFont("Ubuntu-14");
    ReturnText->SetText("Return To Demo");
    DemoMenu->AddChild(ReturnButton,1);

    UI::Button* GameExitButton = DScreen->CreateButton("D_Exit",UI::UnifiedRect(0.10,0.78,0.80,0.16));
    UI::SingleImageLayer* GameExitBackground = GameExitButton->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Normal,0));
    GameExitBackground->SetColour(ButtonColour);
    UI::SingleImageLayer* GameExitHoveredBackground = GameExitButton->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Hovered,0));
    GameExitHoveredBackground->SetColour(HoveredButtonColour);
    UI::SingleLineTextLayer* GameExitText = GameExitButton->CreateSingleLineTextLayer(1,1);
    GameExitText->HorizontallyAlign(UI::LA_Center);
    GameExitText->VerticallyAlign(UI::LA_Center);
    GameExitText->SetDefaultFont("Ubuntu-14");
    GameExitText->SetText("Exit Demo");
    DemoMenu->AddChild(GameExitButton,2);

    DemoMenu->SetPushButton(MenuAccess);
    DemoMenu->SetPopButton(ReturnButton);
    //End of Menu
}
Ejemplo n.º 9
0
inline void CHECK_RESTORE( ui::Widget w ){
	if ( gpointer_to_int( g_object_get_data( G_OBJECT( w ), "was_mapped" ) ) != 0 ) {
		w.show();
	}
}
Ejemplo n.º 10
0
inline void CHECK_MINIMIZE( ui::Widget w ){
	g_object_set_data( G_OBJECT( w ), "was_mapped", gint_to_pointer( gtk_widget_get_visible( w ) ) );
	w.hide();
}
Ejemplo n.º 11
0
		static int l_attr_disabled(lua_State *l)
		{
			UI::Widget *w = LuaObject<UI::Widget>::CheckFromLua(1);
			lua_pushboolean(l, w->IsDisabled());
			return 1;
		}
Ejemplo n.º 12
0
		static int l_attr_height(lua_State *l)
		{
			UI::Widget *w = LuaObject<UI::Widget>::CheckFromLua(1);
			lua_pushnumber(l, w->GetSize().y);
			return 1;
		}
Ejemplo n.º 13
0
		static int l_enable(lua_State *l)
		{
			UI::Widget *w = LuaObject<UI::Widget>::CheckFromLua(1);
			w->Enable();
			return 0;
		}
Ejemplo n.º 14
0
		static int l_remove_shortcut(lua_State *l)
		{
			UI::Widget *w = LuaObject<UI::Widget>::CheckFromLua(1);
			w->RemoveShortcut(UI::KeySym::FromString(luaL_checkstring(l, 2)));
			return 0;
		}
Ejemplo n.º 15
0
		static int l_hide(lua_State *l)
		{
			UI::Widget *w = LuaObject<UI::Widget>::CheckFromLua(1);
			w->Hidden();
			return 0;
		}
Ejemplo n.º 16
0
static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
	widget.hide();
	int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
	*loop = 0;
	return TRUE;
}
Ejemplo n.º 17
0
/**
 * @brief function for close button to destroy the toplevel widget
 */
static void close_window( ui::Widget widget, gpointer data ){
	widget.window().destroy();
}
Ejemplo n.º 18
0
    void DoWork(Threading::DefaultThreadSpecificStorage::Type& CurrentThreadStorage)
    {
        //User Input through a WorldQueryTool
        Input::InputManager* InputMan = Input::InputManager::GetSingletonPtr();
        Input::Mouse* SysMouse = InputMan->GetSystemMouse();
        Input::Keyboard* SysKeyboard = InputMan->GetSystemKeyboard();
        Input::Controller* Controller1 = NULL;
        if( InputMan->GetNumControllers() > 0 )
            Controller1 = InputMan->GetController(0);

        if( SysKeyboard->IsButtonPressed(Input::KEY_LEFT) || (Controller1 ? Controller1->IsHatPushedInDirection(1,Input::CONTROLLERHAT_LEFT) : false) )
            { CamControl->StrafeLeft( 300 * ( TheEntresol->GetLastFrameTimeMilliseconds() * 0.001 ) ); }

        if( SysKeyboard->IsButtonPressed(Input::KEY_RIGHT) || (Controller1 ? Controller1->IsHatPushedInDirection(1,Input::CONTROLLERHAT_RIGHT) : false) )
            { CamControl->StrafeRight( 300 * ( TheEntresol->GetLastFrameTimeMilliseconds() * 0.001 ) ); }

        if( SysKeyboard->IsButtonPressed(Input::KEY_UP) || (Controller1 ? Controller1->IsHatPushedInDirection(1,Input::CONTROLLERHAT_UP) : false) )
            { CamControl->MoveForward( 300 * ( TheEntresol->GetLastFrameTimeMilliseconds() * 0.001 ) ); }

        if( SysKeyboard->IsButtonPressed(Input::KEY_DOWN)  || (Controller1 ? Controller1->IsHatPushedInDirection(1,Input::CONTROLLERHAT_DOWN) : false) )
            { CamControl->MoveBackward( 300 * ( TheEntresol->GetLastFrameTimeMilliseconds() * 0.001 ) ); }

        static bool MouseCam = false;
        if( SysKeyboard->IsButtonPressed(Input::KEY_HOME) )
            { MouseCam = true; }

        if( SysKeyboard->IsButtonPressed(Input::KEY_END))
            { MouseCam = false; }

        Physics::PhysicsManager* PhysMan = static_cast<Physics::PhysicsManager*>( this->OneWorld->GetManager(ManagerBase::MT_PhysicsManager) );

        if( SysKeyboard->IsButtonPressed(Input::KEY_BACKSLASH) )
            { PhysMan->SetTimeMultiplier(1.0); }

        if( SysKeyboard->IsButtonPressed(Input::KEY_RIGHTBRACKET) ) {
            Real Factor = PhysMan->GetTimeMultiplier() * 1.5;
            if( Factor > 2.0 )
                { Factor = 2.0; }
            PhysMan->SetTimeMultiplier(Factor);
        }

        if( SysKeyboard->IsButtonPressed(Input::KEY_LEFTBRACKET) ) {
            Real Factor = PhysMan->GetTimeMultiplier() * .75;
            if( Factor < 0.01 )
                { Factor = 0.01; }
            PhysMan->SetTimeMultiplier(Factor);
        }

        Vector2 Offset = SysMouse->GetMouseDelta();
        if( MouseCam && Vector2(0,0) != Offset )
            CamControl->Rotate(Offset.X * 0.01,Offset.Y * 0.01,0);

        if( SysKeyboard->IsButtonPressing(Input::KEY_M) || (Controller1 ? Controller1->IsButtonPressed(1) : false) ) {
            Audio::iSound* Theme = Soundtrack.at(1);
            if( !Theme->IsPlaying() ) {
                Theme->Play();
            }
        }

        if( SysKeyboard->IsButtonPressing(Input::KEY_N) || (Controller1 ? Controller1->IsButtonPressed(2) : false) ) {
            Audio::iSound* Theme = Soundtrack.at(1);
            if( Theme->IsPlaying() ) {
                Theme->Stop();
            }
        }

        // Audio test fun
        if( SysKeyboard->IsButtonPressing(Input::KEY_T) ) {
            static Boole Toggle = true;
            Audio::iSound* Welcome = ( Announcer.size() >= 2 ? ( Toggle ? Announcer[1] : Announcer[0] ) : NULL );
            if( Welcome != NULL ) {
                if( Welcome->IsPlaying() ) {
                    Welcome->Stop();
                }
                Welcome->Play();
            }
            Toggle = !Toggle;
        }

        // Make a declaration for a static constrain so it survives the function lifetime
        static Physics::Point2PointConstraint* Dragger = NULL;

        if( SysMouse->IsButtonPressed(1) ) {
            UI::UIManager* UIMan = UI::UIManager::GetSingletonPtr();
            if( UIMan->MouseIsInUISystem() ) {
                //UI::Screen* DScreen = UIMan->GetScreen("DefaultScreen");
                UI::Widget* Hover = UIMan->GetHoveredWidget();
                if(Hover) {
                    Hover = Hover->GetBottomMostHoveredWidget();
                    if( "D_Exit" == Hover->GetName() ) {
                        TheEntresol->BreakMainLoop();
                    }
                }
            }else{
                Ray MouseRay = RayQueryTool::GetMouseRay();
                RayCaster.GetFirstObjectOnRayByPolygon(MouseRay,Mezzanine::WO_RigidDebris);

                bool firstframe=false;
                if( 0 == RayCaster.LastQueryResultsObjectPtr() ) {
                    #ifdef MEZZDEBUG
                    //TheEntresol->Log("No Object Clicked on");
                    #endif
                }else{
                    #ifdef MEZZDEBUG
                    //TheEntresol->Log("Object Clicked on"); TheEntresol->Log(*ClickOnActor);
                    //TheEntresol->Log("MouseRay"); TheEntresol->Log(*MouseRay);
                    //TheEntresol->Log("PlaneOfPlay"); TheEntresol->Log(PlaneOfPlay);
                    //TheEntresol->Log("ClickOnActor"); TheEntresol->Log(*ClickOnActor);
                    #endif
                    if( !( RayCaster.LastQueryResultsObjectPtr()->IsStatic() ) ) {
                        if(!Dragger) { //If we have a dragger, then this is dragging, not clicking
                            if(RayCaster.LastQueryResultsObjectPtr()->GetType() == Mezzanine::WO_RigidDebris) { //This is Dragging let's do some checks for sanity
                                Vector3 LocalPivot = RayCaster.LastQueryResultsOffset();
                                RigidDebris* rigid = static_cast<RigidDebris*>(RayCaster.LastQueryResultsObjectPtr());
                                rigid->GetRigidProxy()->SetActivationState(Physics::AS_DisableDeactivation);
                                //Dragger = new Generic6DofConstraint(rigid, LocalPivot, Quaternion(0,0,0,1), false);
                                Dragger = PhysMan->CreatePoint2PointConstraint(rigid->GetRigidProxy(),LocalPivot);
                                Dragger->SetTAU(0.001);
                                Dragger->EnableConstraint(true);
                                Dragger->SetParam(Physics::Con_Stop_CFM,0.8,-1); Dragger->SetParam(Physics::Con_Stop_CFM,0.8,-1); Dragger->SetParam(Physics::Con_Stop_CFM,0.8,-1);
                                Dragger->SetParam(Physics::Con_Stop_ERP,0.1,-1); Dragger->SetParam(Physics::Con_Stop_ERP,0.1,-1); Dragger->SetParam(Physics::Con_Stop_ERP,0.1,-1);
                                firstframe=true;
                            }else{  // since we don't
                                #ifdef MEZZDEBUG
                                //TheEntresol->Log("Object is not an ActorRigid.  Aborting.");
                                #endif
                            }
                        }
                    }else{
                        #ifdef MEZZDEBUG
                        //TheEntresol->Log("Object is Static/Kinematic.  Aborting.");
                        #endif
                    }
                }

                // This chunk of code calculates the 3d point that the actor needs to be dragged to
                if( RayCaster.RayPlaneIntersection(MouseRay, PlaneOfPlay) ) {
                    if(Dragger&&!firstframe)
                        { Dragger->SetPivotB(RayCaster.LastQueryResultsOffset()); }
                }
            }

        }else{  //Since we are no longer clicking we need to setup for the next clicking
            if( Dragger ) {
                Physics::RigidProxy* Prox = Dragger->GetProxyA();
                PhysMan->DestroyConstraint(Dragger);
                Dragger = NULL;
                Prox->SetActivationState(Physics::AS_Active);
            }
        }
    }
Ejemplo n.º 19
0
void PressedButtons_connect( PressedButtons& pressedButtons, ui::Widget widget ){
	widget.connect( "button_press_event", G_CALLBACK( PressedButtons_button_press ), &pressedButtons );
	widget.connect( "button_release_event", G_CALLBACK( PressedButtons_button_release ), &pressedButtons );
	widget.connect( "focus_out_event", G_CALLBACK( PressedButtons_focus_out ), &pressedButtons );
}