Mobile: Make menu input overlay clearer and make it actually stay onscreen on an ipad (Thanks Isabella)

This commit is contained in:
UnknownShadow200 2020-11-17 21:11:44 +11:00
parent c8e6fb0b56
commit 0643c90f3a
4 changed files with 26 additions and 8 deletions

View File

@ -2043,8 +2043,12 @@ static void MenuInputOverlay_Init(void* screen) {
s->maxVertices = MENUINPUT_MAX_VERTICES;
TextInputWidget_Create(&s->input, 400, &s->value, s->desc);
ButtonWidget_Init(&s->ok, 40, MenuInputOverlay_OK);
ButtonWidget_Init(&s->Default, 200, MenuInputOverlay_Default);
#ifdef CC_BUILD_TOUCH
ButtonWidget_Init(&s->ok, Input_TouchMode ? 200 : 40, MenuInputOverlay_OK);
#else
ButtonWidget_Init(&s->ok, 40, MenuInputOverlay_OK);
#endif
Window_OpenKeyboard(&s->value,
(s->desc->VTABLE == &IntInput_VTABLE || s->desc->VTABLE == &FloatInput_VTABLE)
@ -2078,6 +2082,19 @@ static void MenuInputOverlay_Layout(void* screen) {
Widget_SetLocation(&s->input, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 110);
Widget_SetLocation(&s->ok, ANCHOR_CENTRE, ANCHOR_CENTRE, 240, 110);
Widget_SetLocation(&s->Default, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 150);
#ifdef CC_BUILD_TOUCH
if (!Input_TouchMode) return;
if (WindowInfo.SoftKeyboard == SOFT_KEYBOARD_SHIFT) {
Widget_SetLocation(&s->input, ANCHOR_CENTRE, ANCHOR_MAX, 0, 65);
Widget_SetLocation(&s->ok, ANCHOR_CENTRE, ANCHOR_MAX, 120, 25);
Widget_SetLocation(&s->Default, ANCHOR_CENTRE, ANCHOR_MAX, -120, 25);
} else {
Widget_SetLocation(&s->input, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 110);
Widget_SetLocation(&s->ok, ANCHOR_CENTRE, ANCHOR_CENTRE, 120, 150);
Widget_SetLocation(&s->Default, ANCHOR_CENTRE, ANCHOR_CENTRE, -120, 150);
}
#endif
}
static void MenuInputOverlay_ContextLost(void* screen) {
@ -2306,7 +2323,7 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
String_InitArray(value, valueBuffer);
btn->GetValue(&value);
desc = &s->descs[s->activeI];
MenuInputOverlay_Show(desc, &value, MenuOptionsScreen_OnDone, false);
MenuInputOverlay_Show(desc, &value, MenuOptionsScreen_OnDone, Input_TouchMode);
}
static void MenuOptionsScreen_OnHacksChanged(void* screen) {

View File

@ -1073,7 +1073,7 @@ static void ChatScreen_Layout(void* screen) {
#ifdef CC_BUILD_TOUCH
if (!Input_TouchMode) return;
if (WindowInfo._preferBottom) {
if (WindowInfo.SoftKeyboard == SOFT_KEYBOARD_SHIFT) {
Widget_SetLocation(&s->send, ANCHOR_MAX, ANCHOR_MAX, 10, 60);
Widget_SetLocation(&s->cancel, ANCHOR_MAX, ANCHOR_MAX, 10, 10);
} else {

View File

@ -3424,7 +3424,8 @@ void Window_Init(void) {
/* as the chat/send butons are positioned at the top of the canvas - they */
/* get pushed offscreen and can't be used at all anymore. So handle this */
/* case specially by positioning them at the bottom instead for iOS. */
WindowInfo._preferBottom = EM_ASM_INT_V({ return /iPhone|iPad|iPod/i.test(navigator.userAgent); });
WindowInfo.SoftKeyboard = EM_ASM_INT_V({ return /iPhone|iPad|iPod/i.test(navigator.userAgent); })
? SOFT_KEYBOARD_SHIFT : SOFT_KEYBOARD_RESIZE;
}
void Window_Create(int width, int height) {
@ -3911,7 +3912,7 @@ void Window_Init(void) {
JavaGetCurrentEnv(env);
JavaRegisterNatives(env, methods);
WindowInfo.SoftKeyboard = true;
WindowInfo.SoftKeyboard = SOFT_KEYBOARD_RESIZE;
Input_TouchMode = true;
DisplayInfo.Depth = 32;
DisplayInfo.ScaleX = JavaCallFloat(env, "getDpiX", "()F", NULL);

View File

@ -35,6 +35,7 @@ struct DynamicLibSym;
/* The states the window can be in. */
enum WindowState { WINDOW_STATE_NORMAL, WINDOW_STATE_FULLSCREEN, WINDOW_STATE_MINIMISED };
enum KeyboardType { KEYBOARD_TYPE_TEXT, KEYBOARD_TYPE_NUMBER, KEYBOARD_TYPE_PASSWORD };
enum SoftKeyboard { SOFT_KEYBOARD_NONE, SOFT_KEYBOARD_RESIZE, SOFT_KEYBOARD_SHIFT };
/* Can't name these structs Window/Display, because it conflicts with X11's Window/Display typedef */
/* Data for the display monitor. */
@ -70,9 +71,8 @@ CC_VAR extern struct _WinData {
cc_bool Exists;
/* Whether the user is interacting with the window. */
cc_bool Focused;
/* Whether the platform only supports on-screen keyboard. */
cc_bool SoftKeyboard;
cc_bool _preferBottom;
/* The type of on-screen keyboard this platform supports. (usually SOFT_KEYBOARD_NONE) */
cc_uint8 SoftKeyboard;
} WindowInfo;
/* Initialises state for window. Also sets Display_ members. */