mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Fix Chat Scrolling (#822)
* stupid oversight and more * Fix macOS compilation
This commit is contained in:
parent
c856188ab2
commit
b79960e42c
1 changed files with 16 additions and 17 deletions
|
|
@ -111,7 +111,6 @@ bool djui_chat_box_render(struct DjuiBase* base) {
|
||||||
}
|
}
|
||||||
} else { chatBox->scrollY = chatBox->chatFlow->base.y.value; }
|
} else { chatBox->scrollY = chatBox->chatFlow->base.y.value; }
|
||||||
|
|
||||||
printf("%f\n", chatBox->chatFlow->base.y.value);
|
|
||||||
if (sDjuiChatBoxClearText) {
|
if (sDjuiChatBoxClearText) {
|
||||||
sDjuiChatBoxClearText = false;
|
sDjuiChatBoxClearText = false;
|
||||||
djui_inputbox_set_text(gDjuiChatBox->chatInput, "");
|
djui_inputbox_set_text(gDjuiChatBox->chatInput, "");
|
||||||
|
|
@ -418,7 +417,6 @@ static bool djui_chat_box_input_on_key_down(UNUSED struct DjuiBase* base, int sc
|
||||||
sent_history_init(&sentHistory);
|
sent_history_init(&sentHistory);
|
||||||
|
|
||||||
if (gDjuiChatBox == NULL) { return false; }
|
if (gDjuiChatBox == NULL) { return false; }
|
||||||
f32 yMax = gDjuiChatBox->chatContainer->base.elem.height - gDjuiChatBox->chatFlow->base.height.value;
|
|
||||||
|
|
||||||
f32 pageAmount = gDjuiChatBox->chatContainer->base.elem.height * 3.0f / 4.0f;
|
f32 pageAmount = gDjuiChatBox->chatContainer->base.elem.height * 3.0f / 4.0f;
|
||||||
|
|
||||||
|
|
@ -429,21 +427,23 @@ static bool djui_chat_box_input_on_key_down(UNUSED struct DjuiBase* base, int sc
|
||||||
case SCANCODE_UP:
|
case SCANCODE_UP:
|
||||||
if (!configUseStandardKeyBindingsChat && (gDjuiChatBox->chatInput && gDjuiChatBox->chatInput->buffer && gDjuiChatBox->chatInput->buffer[0] != '/')) {
|
if (!configUseStandardKeyBindingsChat && (gDjuiChatBox->chatInput && gDjuiChatBox->chatInput->buffer && gDjuiChatBox->chatInput->buffer[0] != '/')) {
|
||||||
gDjuiChatBox->scrollY += 15;
|
gDjuiChatBox->scrollY += 15;
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
sent_history_update_current_message(&sentHistory, gDjuiChatBox->chatInput->buffer);
|
sent_history_update_current_message(&sentHistory, gDjuiChatBox->chatInput->buffer);
|
||||||
sent_history_navigate(&sentHistory, true);
|
sent_history_navigate(&sentHistory, true);
|
||||||
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) { reset_tab_completion_all(); }
|
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) { reset_tab_completion_all(); }
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case SCANCODE_DOWN:
|
case SCANCODE_DOWN:
|
||||||
if (!configUseStandardKeyBindingsChat && (gDjuiChatBox->chatInput && gDjuiChatBox->chatInput->buffer && gDjuiChatBox->chatInput->buffer[0] != '/')) {
|
if (!configUseStandardKeyBindingsChat && (gDjuiChatBox->chatInput && gDjuiChatBox->chatInput->buffer && gDjuiChatBox->chatInput->buffer[0] != '/')) {
|
||||||
gDjuiChatBox->scrollY -= 15;
|
gDjuiChatBox->scrollY -= 15;
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
sent_history_update_current_message(&sentHistory, gDjuiChatBox->chatInput->buffer);
|
sent_history_update_current_message(&sentHistory, gDjuiChatBox->chatInput->buffer);
|
||||||
sent_history_navigate(&sentHistory, false);
|
sent_history_navigate(&sentHistory, false);
|
||||||
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) { reset_tab_completion_all(); }
|
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) { reset_tab_completion_all(); }
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case SCANCODE_PAGE_UP:
|
case SCANCODE_PAGE_UP:
|
||||||
gDjuiChatBox->scrollY += configUseStandardKeyBindingsChat ? 15 : pageAmount;
|
gDjuiChatBox->scrollY += configUseStandardKeyBindingsChat ? 15 : pageAmount;
|
||||||
break;
|
break;
|
||||||
|
|
@ -458,28 +458,29 @@ static bool djui_chat_box_input_on_key_down(UNUSED struct DjuiBase* base, int sc
|
||||||
break;
|
break;
|
||||||
case SCANCODE_TAB:
|
case SCANCODE_TAB:
|
||||||
handle_tab_completion();
|
handle_tab_completion();
|
||||||
break;
|
return true;
|
||||||
case SCANCODE_ENTER:
|
case SCANCODE_ENTER:
|
||||||
reset_tab_completion_all();
|
reset_tab_completion_all();
|
||||||
sent_history_reset_navigation(&sentHistory);
|
sent_history_reset_navigation(&sentHistory);
|
||||||
djui_chat_box_input_enter(gDjuiChatBox->chatInput);
|
djui_chat_box_input_enter(gDjuiChatBox->chatInput);
|
||||||
break;
|
return true;
|
||||||
case SCANCODE_ESCAPE:
|
case SCANCODE_ESCAPE:
|
||||||
reset_tab_completion_all();
|
reset_tab_completion_all();
|
||||||
sent_history_reset_navigation(&sentHistory);
|
sent_history_reset_navigation(&sentHistory);
|
||||||
djui_chat_box_input_escape(gDjuiChatBox->chatInput);
|
djui_chat_box_input_escape(gDjuiChatBox->chatInput);
|
||||||
break;
|
return true;
|
||||||
default: {
|
default: {
|
||||||
bool returnValueOnOtherKeyDown = djui_inputbox_on_key_down(base, scancode);
|
bool returnValueOnOtherKeyDown = djui_inputbox_on_key_down(base, scancode);
|
||||||
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) {
|
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) {
|
||||||
reset_tab_completion_all();
|
reset_tab_completion_all();
|
||||||
|
}
|
||||||
|
return returnValueOnOtherKeyDown;
|
||||||
}
|
}
|
||||||
return returnValueOnOtherKeyDown;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gDjuiConsole->scrolling) {
|
if (!gDjuiChatBox->scrolling) {
|
||||||
gDjuiConsole->scrolling = gDjuiConsole->scrollY < 0 && gDjuiConsole->scrollY > yMax;
|
gDjuiChatBox->scrolling = gDjuiChatBox->scrollY < 0.f;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -500,16 +501,14 @@ static void djui_chat_box_input_on_text_editing(struct DjuiBase *base, char* tex
|
||||||
static void djui_chat_box_input_on_scroll(UNUSED struct DjuiBase *base, UNUSED float x, float y) {
|
static void djui_chat_box_input_on_scroll(UNUSED struct DjuiBase *base, UNUSED float x, float y) {
|
||||||
if (gDjuiChatBox == NULL) { return; }
|
if (gDjuiChatBox == NULL) { return; }
|
||||||
|
|
||||||
f32 yMax = gDjuiChatBox->chatContainer->base.elem.height - gDjuiChatBox->chatFlow->base.height.value;
|
|
||||||
|
|
||||||
y *= 24.f;
|
y *= 24.f;
|
||||||
if (gDjuiInputHeldControl) { y /= 2; }
|
if (gDjuiInputHeldControl) { y /= 2; }
|
||||||
if (gDjuiInputHeldShift) { y *= 3; }
|
if (gDjuiInputHeldShift) { y *= 3; }
|
||||||
|
|
||||||
gDjuiChatBox->scrollY += y;
|
gDjuiChatBox->scrollY += y;
|
||||||
|
|
||||||
if (!gDjuiConsole->scrolling) {
|
if (!gDjuiChatBox->scrolling) {
|
||||||
gDjuiConsole->scrolling = gDjuiConsole->scrollY < 0 && gDjuiConsole->scrollY > yMax;
|
gDjuiChatBox->scrolling = gDjuiChatBox->scrollY < 0.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue