1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Android: Add selection dialog (drop down/combo box) (#13814)

- The handling of IGUIComboBox uses the new setAndSendSelected() method.
- getDialogState() is now getInputDialogState() and returns the state of the input dialog.
- getLastDialogType() is added and returns current/last shown dialog's type.
- getInputDialogState() now returns an enum instead of int.
- getAndroidUIInput() now returns void instead of bool.
- New data types (enum) are added:
  (1) GameActivity.DialogType (Java) and porting::AndroidDialogType (C++)
  (2) GameActivity.DialogState (Java) and porting::AndroidDialogState (C++)
- When showing a text input dialog, there is no custom accept button text any more.
- showDialog()/showDialogUI() for text input is now showTextInputDialog()/showTextInputDialogUI().
- showInputDialog()/showDialogUI() for text input is now showTextInputDialog()/showTextInputDialogUI().
- getDialogValue()/getInputDialogValue() is now getDialogMessage()/getInputDialogMessage().


Co-authored-by: Gregor Parzefall <82708541+grorp@users.noreply.github.com>
This commit is contained in:
Muhammad Rifqi Priyo Susanto 2024-01-07 19:00:04 +07:00 committed by GitHub
parent bd42cc2c77
commit 171f911237
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 259 additions and 106 deletions

View file

@ -268,11 +268,34 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
if (((gui::IGUIEditBox *)hovered)->isPasswordBox())
type = 3;
porting::showInputDialog(gettext("OK"), "",
wide_to_utf8(((gui::IGUIEditBox *)hovered)->getText()), type);
porting::showTextInputDialog("",
wide_to_utf8(((gui::IGUIEditBox *) hovered)->getText()), type);
return retval;
}
}
if (event.EventType == EET_GUI_EVENT) {
if (event.GUIEvent.EventType == gui::EGET_LISTBOX_OPENED) {
gui::IGUIComboBox *dropdown = (gui::IGUIComboBox *) event.GUIEvent.Caller;
std::string field_name = getNameByID(dropdown->getID());
if (field_name.empty())
return false;
m_jni_field_name = field_name;
s32 selected_idx = dropdown->getSelected();
s32 option_size = dropdown->getItemCount();
std::string list_of_options[option_size];
for (s32 i = 0; i < option_size; i++) {
list_of_options[i] = wide_to_utf8(dropdown->getItem(i));
}
porting::showComboBoxDialog(list_of_options, option_size, selected_idx);
return true; // Prevent the Irrlicht dropdown from opening.
}
}
#endif
// Convert touch events into mouse events.
@ -347,22 +370,12 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
}
#ifdef __ANDROID__
bool GUIModalMenu::hasAndroidUIInput()
porting::AndroidDialogState GUIModalMenu::getAndroidUIInputState()
{
// no dialog shown
// No dialog is shown
if (m_jni_field_name.empty())
return false;
return porting::DIALOG_CANCELED;
// still waiting
if (porting::getInputDialogState() == -1)
return true;
// no value abort dialog processing
if (porting::getInputDialogState() != 0) {
m_jni_field_name.clear();
return false;
}
return true;
return porting::getInputDialogState();
}
#endif