Пример #1
0
// Find children by id
UIWidget* UIWidget::FindChildById(const int32 nId, bool bRecursive)
{
	UIWidget* widget = NULL;
	GTGAMEOBJECT_FOREACH_CHILD(it)
	{
		// Get widget object
		widget = (UIWidget*)(*it);
		// Check if the widget is in its region
		if(widget && widget->GetId() == nId)
		{
			return widget;
		}
		if(bRecursive)
		{
			// Keep looking for the target in children
			widget = widget->FindChildById(nId, bRecursive);
			if(widget)
			{
				// Found it
				return widget;
			}
		}
	}
	return NULL;
}
Пример #2
0
void SampleSelector::HandleWidgetEvent(StringHash eventType, VariantMap& eventData)
{
    using namespace WidgetEvent;

    if (eventData[P_TYPE].GetUInt() == UI_EVENT_TYPE_CLICK)
    {
        UIWidget* target = static_cast<UIWidget*>(eventData[P_TARGET].GetPtr());
        String exampleName = target->GetId().CString();

        // Make sure we mark event handled, as we're deleting the button
        eventData[P_HANDLED] = true;

        // Goodbye UI
        FeatureExamples::GetUIView()->DeleteAllChildren();

        currentSample_ = 0;

        if (exampleName == "Hello World")
        {
            currentSample_ = new HelloWorld(context_);
        }
        else if (exampleName == "Hello GUI")
        {
            currentSample_ = new HelloGui(context_);
        }
        else if (exampleName == "2D Sprite")
        {
            currentSample_ = new Atomic2DSprite(context_);
        }
        else if (exampleName == "2D Physics")
        {
            currentSample_ = new Physics2D(context_);
        }
        else if (exampleName == "2D Constraints")
        {
            currentSample_ = new Constraints2D(context_);
        }
        else if (exampleName == "2D Spriter Animation")
        {
            currentSample_ = new SpriterAnimation(context_);
        }
        else if (exampleName == "3D Static Scene")
        {
            currentSample_ = new StaticScene(context_);
        }
        else if (exampleName == "3D Animating Scene")
        {
            currentSample_ = new AnimatingScene(context_);
        }
        else if (exampleName == "3D Physics")
        {
            currentSample_ = new Physics3D(context_);
        }
        else if (exampleName == "3D Skeletal Animation")
        {
            currentSample_ = new SkeletalAnimation(context_);
        }
        else if (exampleName == "3D Character")
        {
            currentSample_ = new CharacterDemo(context_);
        }
        else if (exampleName == "3D Ragdolls")
        {
            currentSample_ = new Ragdolls(context_);
        }
        else if (exampleName == "3D Vehicle Demo")
        {
            currentSample_ = new VehicleDemo(context_);
        }
        else if (exampleName == "3D Crowd Navigation")
        {
            currentSample_ = new CrowdNavigation(context_);
        }
        else if (exampleName == "3D Dynamic Geometry")
        {
            currentSample_ = new DynamicGeometry(context_);
        }
        else if (exampleName == "3D Water")
        {
            currentSample_ = new Water(context_);
        }
        else if (exampleName == "3D Billboards")
        {
            currentSample_ = new Billboards(context_);
        }
        else if (exampleName == "3D Multiple Viewports")
        {
            currentSample_ = new MultipleViewports(context_);
        }
        else if (exampleName == "3D Decals")
        {
            currentSample_ = new Decals(context_);
        }
        else if (exampleName == "2D Rope")
        {
            currentSample_ = new PhysicsRope2D(context_);
        }
        else if (exampleName == "Render to Texture")
        {
            currentSample_ = new RenderToTexture(context_);
        }
        else if (exampleName == "3D Light Animation")
        {
            currentSample_ = new LightAnimation(context_);
        }
        else if (exampleName == "3D Particles")
        {
            currentSample_ = new Particles3D(context_);
        }

        if (currentSample_.NotNull())
        {
            UnsubscribeFromEvent(E_KEYUP);
            currentSample_->Start();
        }

    }

}