Коммит 2d67454f создал по автору xottab-duty's avatar xottab-duty
Просмотр файлов

Allowed keyboard and gamepad input for MessageBoxEx

владелец 2ade51c9
......@@ -7,6 +7,7 @@ CUIMessageBoxEx::CUIMessageBoxEx() : CUIDialogWnd(CUIMessageBoxEx::GetDebugType(
{
m_pMessageBox = xr_new<CUIMessageBox>();
m_pMessageBox->SetWindowName("msg_box");
m_pMessageBox->AllowInputHandling(true);
// m_pMessageBox->SetAutoDelete(true);
AttachChild(m_pMessageBox);
}
......@@ -74,30 +75,6 @@ void CUIMessageBoxEx::SendMessage(CUIWindow* pWnd, s16 msg, void* pData /* = NUL
LPCSTR CUIMessageBoxEx::GetHost() { return m_pMessageBox->GetHost(); }
LPCSTR CUIMessageBoxEx::GetPassword() { return m_pMessageBox->GetPassword(); }
bool CUIMessageBoxEx::OnKeyboardAction(int dik, EUIMessages keyboard_action)
{
if (keyboard_action == WINDOW_KEY_PRESSED)
{
auto action = GetBindedAction(dik);
if (action == kENTER || action == kJUMP)
{
m_pMessageBox->OnYesOk();
return true;
/*
}else
if ( IsBinded(kQUIT, dik) )
{
CUIMessageBox::E_MESSAGEBOX_STYLE style = m_pMessageBox->GetBoxStyle();
if(style != CUIMessageBox::MESSAGEBOX_INFO)
HideDialog();
return true;
*/
}
else
return CUIDialogWnd::OnKeyboardAction(dik, keyboard_action);
}
return CUIDialogWnd::OnKeyboardAction(dik, keyboard_action);
}
void CUIMessageBoxEx::SetTextEditURL(LPCSTR text) { m_pMessageBox->SetTextEditURL(text); }
LPCSTR CUIMessageBoxEx::GetTextEditURL() { return m_pMessageBox->GetTextEditURL(); }
......@@ -25,7 +25,6 @@ public:
void OnOKClicked(CUIWindow*, void*);
void OnNOClicked(CUIWindow*, void*);
virtual bool OnKeyboardAction(int dik, EUIMessages keyboard_action);
virtual bool NeedCenterCursor() const { return false; }
CUIMessageBox* m_pMessageBox;
......
......@@ -48,6 +48,86 @@ bool CUIMessageBox::OnMouseAction(float x, float y, EUIMessages mouse_action)
return inherited::OnMouseAction(x, y, mouse_action);
}
bool CUIMessageBox::OnKeyboardAction(int dik, EUIMessages keyboard_action)
{
if (IsInputHandlingAllowed() && keyboard_action == WINDOW_KEY_PRESSED)
{
const bool quitPressed = IsBinded(kQUIT, dik);
auto action = GetBindedAction(dik, EKeyContext::UI);
switch (m_eMessageBoxStyle)
{
case MESSAGEBOX_OK:
case MESSAGEBOX_INFO:
{
if (quitPressed)
action = kUI_BACK;
switch (action)
{
case kUI_ACCEPT:
case kUI_BACK:
OnYesOk();
return true;
}
break;
}
case MESSAGEBOX_DIRECT_IP:
case MESSAGEBOX_RA_LOGIN:
case MESSAGEBOX_PASSWORD:
case MESSAGEBOX_YES_NO:
case MESSAGEBOX_QUIT_GAME:
case MESSAGEBOX_QUIT_WINDOWS:
{
switch (action)
{
case kUI_ACCEPT:
OnYesOk();
return true;
case kUI_BACK:
m_UIButtonNo->OnClick();
return true;
}
break;
}
case MESSAGEBOX_YES_NO_CANCEL:
{
switch (action)
{
case kUI_ACCEPT:
OnYesOk();
return true;
case kUI_ACTION_1:
m_UIButtonNo->OnClick();
return true;
case kUI_BACK:
m_UIButtonCancel->OnClick();
return true;
}
break;
}
case MESSAGEBOX_YES_NO_COPY:
{
switch (action)
{
case kUI_ACCEPT:
OnYesOk();
return true;
case kUI_BACK:
m_UIButtonNo->OnClick();
return true;
case kUI_ACTION_1:
m_UIButtonCopy->OnClick();
return true;
}
break;
}
default:
VERIFY(!"Unknown message box type!");
} // switch (m_eMessageBoxStyle)
}
return CUIStatic::OnKeyboardAction(dik, keyboard_action);
}
bool CUIMessageBox::InitMessageBox(LPCSTR box_template)
{
Clear();
......
......@@ -41,10 +41,15 @@ public:
LPCSTR GetTextEditURL();
virtual bool OnMouseAction(float x, float y, EUIMessages mouse_action);
bool OnKeyboardAction(int dik, EUIMessages keyboard_action) override;
virtual void SendMessage(CUIWindow* pWnd, s16 msg, void* pData);
void OnYesOk();
[[nodiscard]]
bool IsInputHandlingAllowed() const { return m_allowInputHandling; }
void AllowInputHandling(bool allow) { m_allowInputHandling = allow; }
pcstr GetDebugType() override { return "CUIMessageBox"; }
protected:
......@@ -65,4 +70,5 @@ protected:
CUIEditBox* m_UIEditURL;
E_MESSAGEBOX_STYLE m_eMessageBoxStyle;
bool m_allowInputHandling{};
};
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать