Missing button in grand prix editor name dialog #1765
This commit is contained in:
parent
68db893e84
commit
107e434fe9
@ -11,10 +11,13 @@
|
|||||||
<textbox id="textfield" width="75%" I18N="In the 'add new grand prix' dialog" align="center"/>
|
<textbox id="textfield" width="75%" I18N="In the 'add new grand prix' dialog" align="center"/>
|
||||||
|
|
||||||
<spacer height="20" width="20" />
|
<spacer height="20" width="20" />
|
||||||
|
|
||||||
<button id="cancel" I18N="In the 'add new grand prix' dialog" text="Press ESC to cancel" align="center"/>
|
<div width="100%" height="60" layout="horizontal-row">
|
||||||
|
<button id="accept" I18N="In the 'add new grand prix' dialog" text="Create" align="center" proportion="1"/>
|
||||||
<spacer height="15" width="20" />
|
<spacer height="15" width="20" />
|
||||||
|
<button id="cancel" I18N="In the 'add new grand prix' dialog" text="Cancel" align="center" proportion="1"/>
|
||||||
|
<spacer height="15" width="20" />
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</stkgui>
|
</stkgui>
|
||||||
|
@ -62,6 +62,10 @@ GUIEngine::EventPropagation EnterGPNameDialog::processEvent(const std::string& e
|
|||||||
dismiss();
|
dismiss();
|
||||||
return GUIEngine::EVENT_BLOCK;
|
return GUIEngine::EVENT_BLOCK;
|
||||||
}
|
}
|
||||||
|
else if (eventSource == "accept")
|
||||||
|
{
|
||||||
|
validateName();
|
||||||
|
}
|
||||||
return GUIEngine::EVENT_LET;
|
return GUIEngine::EVENT_LET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +81,39 @@ void EnterGPNameDialog::onEnterPressedInternal()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Otherwise, see if we can accept the new name
|
//Otherwise, see if we can accept the new name and create the grand prix
|
||||||
|
validateName();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
void EnterGPNameDialog::onUpdate(float dt)
|
||||||
|
{
|
||||||
|
// It's unsafe to delete from inside the event handler so we do it here
|
||||||
|
if (m_self_destroy)
|
||||||
|
{
|
||||||
|
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
|
||||||
|
stringw name = textCtrl->getText().trim();
|
||||||
|
|
||||||
|
// irrLicht is too stupid to remove focus from deleted widgets
|
||||||
|
// so do it by hand
|
||||||
|
GUIEngine::getGUIEnv()->removeFocus( textCtrl->getIrrlichtElement() );
|
||||||
|
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
||||||
|
|
||||||
|
// we will destroy the dialog before notifying the listener to be safer.
|
||||||
|
// but in order not to crash we must make a local copy of the listern
|
||||||
|
// otherwise we will crash
|
||||||
|
INewGPListener* listener = m_listener;
|
||||||
|
|
||||||
|
ModalDialog::dismiss();
|
||||||
|
|
||||||
|
if (listener != NULL)
|
||||||
|
listener->onNewGPWithName(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void EnterGPNameDialog::validateName()
|
||||||
|
{
|
||||||
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
|
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
|
||||||
assert(textCtrl != NULL);
|
assert(textCtrl != NULL);
|
||||||
LabelWidget* label = getWidget<LabelWidget>("title");
|
LabelWidget* label = getWidget<LabelWidget>("title");
|
||||||
@ -106,30 +142,5 @@ void EnterGPNameDialog::onEnterPressedInternal()
|
|||||||
// in onUpdate (which checks for m_self_destroy)
|
// in onUpdate (which checks for m_self_destroy)
|
||||||
m_self_destroy = true;
|
m_self_destroy = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
}
|
||||||
void EnterGPNameDialog::onUpdate(float dt)
|
|
||||||
{
|
|
||||||
// It's unsafe to delete from inside the event handler so we do it here
|
|
||||||
if (m_self_destroy)
|
|
||||||
{
|
|
||||||
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
|
|
||||||
stringw name = textCtrl->getText().trim();
|
|
||||||
|
|
||||||
// irrLicht is too stupid to remove focus from deleted widgets
|
|
||||||
// so do it by hand
|
|
||||||
GUIEngine::getGUIEnv()->removeFocus( textCtrl->getIrrlichtElement() );
|
|
||||||
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
|
||||||
|
|
||||||
// we will destroy the dialog before notifying the listener to be safer.
|
|
||||||
// but in order not to crash we must make a local copy of the listern
|
|
||||||
// otherwise we will crash
|
|
||||||
INewGPListener* listener = m_listener;
|
|
||||||
|
|
||||||
ModalDialog::dismiss();
|
|
||||||
|
|
||||||
if (listener != NULL)
|
|
||||||
listener->onNewGPWithName(name);
|
|
||||||
}
|
|
||||||
}
|
|
@ -62,8 +62,8 @@ public:
|
|||||||
~EnterGPNameDialog();
|
~EnterGPNameDialog();
|
||||||
|
|
||||||
void onEnterPressedInternal();
|
void onEnterPressedInternal();
|
||||||
|
void validateName();
|
||||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||||
|
|
||||||
virtual void onUpdate(float dt);
|
virtual void onUpdate(float dt);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user