mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 15:28:21 -04:00
Web mobile: Make text input dark instead of light, and don't render chat input behind it at all
This commit is contained in:
parent
e287e8db26
commit
3e34665941
@ -1376,6 +1376,7 @@ void ChatScreen_OpenInput(const cc_string* text) {
|
|||||||
OpenKeyboardArgs_Init(&args, text, KEYBOARD_TYPE_TEXT | KEYBOARD_FLAG_SEND);
|
OpenKeyboardArgs_Init(&args, text, KEYBOARD_TYPE_TEXT | KEYBOARD_FLAG_SEND);
|
||||||
args.placeholder = "Enter chat";
|
args.placeholder = "Enter chat";
|
||||||
Window_OpenKeyboard(&args);
|
Window_OpenKeyboard(&args);
|
||||||
|
s->input.base.disabled = args.opaque;
|
||||||
|
|
||||||
String_Copy(&s->input.base.text, text);
|
String_Copy(&s->input.base.text, text);
|
||||||
InputWidget_UpdateText(&s->input.base);
|
InputWidget_UpdateText(&s->input.base);
|
||||||
|
@ -1658,23 +1658,13 @@ void TextInputWidget_SetFont(struct TextInputWidget* w, struct FontDesc* font) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static const cc_string chatInputPrefix = String_FromConst("> ");
|
static const cc_string chatInputPrefix = String_FromConst("> ");
|
||||||
|
|
||||||
static void ChatInputWidget_RemakeTexture(void* widget) {
|
static void ChatInputWidget_MakeTexture(struct InputWidget* w, int width, int height) {
|
||||||
cc_string line; char lineBuffer[STRING_SIZE + 2];
|
cc_string line; char lineBuffer[STRING_SIZE + 2];
|
||||||
struct InputWidget* w = (struct InputWidget*)widget;
|
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
int width = 0, height = 0;
|
|
||||||
struct Context2D ctx;
|
struct Context2D ctx;
|
||||||
char lastCol;
|
char lastCol;
|
||||||
int i, x, y;
|
int i, x, y;
|
||||||
|
|
||||||
for (i = 0; i < w->GetMaxLines(); i++) {
|
|
||||||
if (!w->lines[i].length) break;
|
|
||||||
height += w->lineHeight;
|
|
||||||
width = max(width, w->lineWidths[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!width) width = w->prefixWidth;
|
|
||||||
if (!height) height = w->lineHeight;
|
|
||||||
Context2D_Alloc(&ctx, width, height);
|
Context2D_Alloc(&ctx, width, height);
|
||||||
|
|
||||||
DrawTextArgs_Make(&args, &chatInputPrefix, w->font, true);
|
DrawTextArgs_Make(&args, &chatInputPrefix, w->font, true);
|
||||||
@ -1701,6 +1691,27 @@ static void ChatInputWidget_RemakeTexture(void* widget) {
|
|||||||
|
|
||||||
Context2D_MakeTexture(&w->inputTex, &ctx);
|
Context2D_MakeTexture(&w->inputTex, &ctx);
|
||||||
Context2D_Free(&ctx);
|
Context2D_Free(&ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ChatInputWidget_RemakeTexture(void* widget) {
|
||||||
|
struct InputWidget* w = (struct InputWidget*)widget;
|
||||||
|
int width = 0, height = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < w->GetMaxLines(); i++) {
|
||||||
|
if (!w->lines[i].length) break;
|
||||||
|
height += w->lineHeight;
|
||||||
|
width = max(width, w->lineWidths[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!width) width = w->prefixWidth;
|
||||||
|
if (!height) height = w->lineHeight;
|
||||||
|
|
||||||
|
if (w->disabled) {
|
||||||
|
Gfx_DeleteTexture(&w->inputTex.ID);
|
||||||
|
} else {
|
||||||
|
ChatInputWidget_MakeTexture(w, width, height);
|
||||||
|
}
|
||||||
w->caretAccumulator = 0;
|
w->caretAccumulator = 0;
|
||||||
|
|
||||||
w->width = width;
|
w->width = width;
|
||||||
@ -1716,8 +1727,8 @@ static void ChatInputWidget_Render(void* widget, double delta) {
|
|||||||
int x = w->x, y = w->y;
|
int x = w->x, y = w->y;
|
||||||
cc_bool caretAtEnd;
|
cc_bool caretAtEnd;
|
||||||
int i, width;
|
int i, width;
|
||||||
|
if (w->disabled) return;
|
||||||
|
|
||||||
Gfx_SetTexturing(false);
|
|
||||||
for (i = 0; i < INPUTWIDGET_MAX_LINES; i++) {
|
for (i = 0; i < INPUTWIDGET_MAX_LINES; i++) {
|
||||||
if (i > 0 && !w->lines[i].length) break;
|
if (i > 0 && !w->lines[i].length) break;
|
||||||
|
|
||||||
|
@ -144,11 +144,11 @@ void Window_DrawFramebuffer(Rect2D r);
|
|||||||
/* Frees the previously allocated framebuffer. */
|
/* Frees the previously allocated framebuffer. */
|
||||||
void Window_FreeFramebuffer(struct Bitmap* bmp);
|
void Window_FreeFramebuffer(struct Bitmap* bmp);
|
||||||
|
|
||||||
struct OpenKeyboardArgs { const cc_string* text; int type; const char* placeholder; };
|
struct OpenKeyboardArgs { const cc_string* text; int type; const char* placeholder; cc_bool opaque; };
|
||||||
void OpenKeyboardArgs_Init(struct OpenKeyboardArgs* args, STRING_REF const cc_string* text, int type);
|
void OpenKeyboardArgs_Init(struct OpenKeyboardArgs* args, STRING_REF const cc_string* text, int type);
|
||||||
/* Displays on-screen keyboard for platforms that lack physical keyboard input. */
|
/* Displays on-screen keyboard for platforms that lack physical keyboard input. */
|
||||||
/* NOTE: On desktop platforms, this won't do anything. */
|
/* NOTE: On desktop platforms, this won't do anything. */
|
||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args);
|
void Window_OpenKeyboard(struct OpenKeyboardArgs* args);
|
||||||
/* Sets the text used for keyboard input. */
|
/* Sets the text used for keyboard input. */
|
||||||
/* NOTE: This is only used for mobile on-screen keyboard input with the web client, */
|
/* NOTE: This is only used for mobile on-screen keyboard input with the web client, */
|
||||||
/* because it is backed by a HTML input, rather than true keyboard input events. */
|
/* because it is backed by a HTML input, rather than true keyboard input events. */
|
||||||
|
@ -407,7 +407,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
|||||||
Mem_Free(bmp->scan0);
|
Mem_Free(bmp->scan0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* kArgs) {
|
void Window_OpenKeyboard(struct OpenKeyboardArgs* kArgs) {
|
||||||
JNIEnv* env;
|
JNIEnv* env;
|
||||||
jvalue args[2];
|
jvalue args[2];
|
||||||
JavaGetCurrentEnv(env);
|
JavaGetCurrentEnv(env);
|
||||||
|
@ -646,7 +646,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
|||||||
CGColorSpaceRelease(colorSpace);
|
CGColorSpaceRelease(colorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { }
|
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { }
|
||||||
void Window_SetKeyboardText(const cc_string* text) { }
|
void Window_SetKeyboardText(const cc_string* text) { }
|
||||||
void Window_CloseKeyboard(void) { }
|
void Window_CloseKeyboard(void) { }
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
|||||||
/* TODO: Do we still need to unlock it though? */
|
/* TODO: Do we still need to unlock it though? */
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { SDL_StartTextInput(); }
|
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { SDL_StartTextInput(); }
|
||||||
void Window_SetKeyboardText(const cc_string* text) { }
|
void Window_SetKeyboardText(const cc_string* text) { }
|
||||||
void Window_CloseKeyboard(void) { SDL_StopTextInput(); }
|
void Window_CloseKeyboard(void) { SDL_StopTextInput(); }
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ EMSCRIPTEN_KEEPALIVE void Window_OnTextChanged(const char* src) {
|
|||||||
Event_RaiseString(&InputEvents.TextChanged, &str);
|
Event_RaiseString(&InputEvents.TextChanged, &str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) {
|
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
keyboardOpen = true;
|
keyboardOpen = true;
|
||||||
if (!Input_TouchMode) return;
|
if (!Input_TouchMode) return;
|
||||||
@ -589,6 +589,7 @@ void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) {
|
|||||||
Platform_EncodeUtf8(str, args->text);
|
Platform_EncodeUtf8(str, args->text);
|
||||||
Platform_LogConst("OPEN SESAME");
|
Platform_LogConst("OPEN SESAME");
|
||||||
interop_OpenKeyboard(str, args->type, args->placeholder);
|
interop_OpenKeyboard(str, args->type, args->placeholder);
|
||||||
|
args->opaque = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_SetKeyboardText(const cc_string* text) {
|
void Window_SetKeyboardText(const cc_string* text) {
|
||||||
|
@ -642,7 +642,7 @@ static void InitRawMouse(void) {
|
|||||||
rawMouseSupported = false;
|
rawMouseSupported = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { }
|
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { }
|
||||||
void Window_SetKeyboardText(const cc_string* text) { }
|
void Window_SetKeyboardText(const cc_string* text) { }
|
||||||
void Window_CloseKeyboard(void) { }
|
void Window_CloseKeyboard(void) { }
|
||||||
|
|
||||||
|
@ -1085,7 +1085,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
|||||||
if (bmp->scan0 != fb_data) Mem_Free(fb_data);
|
if (bmp->scan0 != fb_data) Mem_Free(fb_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { }
|
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { }
|
||||||
void Window_SetKeyboardText(const cc_string* text) { }
|
void Window_SetKeyboardText(const cc_string* text) { }
|
||||||
void Window_CloseKeyboard(void) { }
|
void Window_CloseKeyboard(void) { }
|
||||||
|
|
||||||
|
@ -68,9 +68,10 @@ void Window_ShowDialog(const char* title, const char* msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OpenKeyboardArgs_Init(struct OpenKeyboardArgs* args, STRING_REF const cc_string* text, int type) {
|
void OpenKeyboardArgs_Init(struct OpenKeyboardArgs* args, STRING_REF const cc_string* text, int type) {
|
||||||
args->text = text;
|
args->text = text;
|
||||||
args->type = type;
|
args->type = type;
|
||||||
args->placeholder = "";
|
args->placeholder = "";
|
||||||
|
args->opaque = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
|||||||
Mem_Free(bmp->scan0);
|
Mem_Free(bmp->scan0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { }
|
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { }
|
||||||
void Window_SetKeyboardText(const cc_string* text) { }
|
void Window_SetKeyboardText(const cc_string* text) { }
|
||||||
void Window_CloseKeyboard(void) { }
|
void Window_CloseKeyboard(void) { }
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ static void LInput_SetPlaceholder(UITextField* fld, const char* placeholder);
|
|||||||
static UITextField* text_input;
|
static UITextField* text_input;
|
||||||
static CCKBController* kb_controller;
|
static CCKBController* kb_controller;
|
||||||
|
|
||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) {
|
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) {
|
||||||
if (!kb_controller) {
|
if (!kb_controller) {
|
||||||
kb_controller = [[CCKBController alloc] init];
|
kb_controller = [[CCKBController alloc] init];
|
||||||
CFBridgingRetain(kb_controller); // prevent GC TODO even needed?
|
CFBridgingRetain(kb_controller); // prevent GC TODO even needed?
|
||||||
|
@ -794,7 +794,8 @@ mergeInto(LibraryManager.library, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & 0x100) { elem.setAttribute('enterkeyhint', 'send'); }
|
if (flags & 0x100) { elem.setAttribute('enterkeyhint', 'send'); }
|
||||||
elem.setAttribute('style', 'position:absolute; left:0; bottom:0; margin: 0px; width: 100%');
|
//elem.setAttribute('style', 'position:absolute; left:0.5%; bottom:1%; margin: 0px; width: 99%; background-color: #080808; border: none; color: white; opacity: 0.7');
|
||||||
|
elem.setAttribute('style', 'position:absolute; left:0; bottom:0; margin: 0px; width: 100%; background-color: #222222; border: none; color: white;');
|
||||||
elem.setAttribute('placeholder', UTF8ToString(placeholder));
|
elem.setAttribute('placeholder', UTF8ToString(placeholder));
|
||||||
elem.value = UTF8ToString(text);
|
elem.value = UTF8ToString(text);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user