PDA

View Full Version : Disabling all input for modal dialog



BigBMan
10-05-2011, 08:53 AM
I know you have a few handy functions for part of this, but what if I wanted to *temporarily* disable all buttons and text input and present a dialog box or user prompt (think tutorials, storytelling, pause menus, etc). On clicking an entity in the dialog, I'd like to remove the dialog and re-enable all Entities/Components on the screen. Ideas? I would like to grey-out all entities when they are disabled.

Seth
10-07-2011, 05:14 AM
Well, I think DisableAllButtonsEntity(Entity *pEnt, bool bRecursive) (from EntityUtils.cpp) would do the job.. except if you look in the function, it only handles "Button2D" components. I should have it also check for the name "InputTextRender" because the same "disabled" parm is recognized by that too.

EnableAllButtonsEntity() is the reverse.

BigBMan
10-07-2011, 06:01 AM
That's where I was headed. I run into issues where some buttons (i.e. radio buttons) are on/off which currently use the enabled/disabled variant. You function turns all on/off together.

Guess I need to create some more custom components!

BigBMan
10-13-2011, 08:27 AM
Well, this works for now, though alpha doesn't seem to be affected with InputTextRenderComponent.


//
// Disables all input entities
//
void SetInputDisabled( Entity* pEnt, bool bDisabled, bool bRecursive )
{
if(bDisabled)
{
pEnt->GetVar("alpha")->Set(0.5f);
}
else
{
pEnt->GetVar("alpha")->Set(1.0f);
}

// go through all components
ComponentList* pComponents = pEnt->GetComponents();
ComponentList::iterator componentItor = pComponents->begin();
while (componentItor != pComponents->end())
{
EntityComponent* pComp = ((EntityComponent*)*componentItor);

if( pComp->GetName() == "Button2D")
{
pComp->GetVar("disabled")->Set(uint32(bDisabled));
}
else if( pComp->GetName() == "InputTextRender")
{
pComp->GetVar("disabled")->Set(uint32(bDisabled));
}

componentItor++;
}

if (!bRecursive) return;

//also run this on all children
EntityList *pChildren = pEnt->GetChildren();

EntityList::iterator itor = pChildren->begin();
while (itor != pChildren->end())
{
SetInputDisabled(*itor, bDisabled);
itor++;
}
}