mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-05-10 10:51:39 +00:00
new options
This commit is contained in:
parent
b00e12aa3b
commit
1b5ca52394
17 changed files with 155 additions and 25 deletions
|
|
@ -331,6 +331,7 @@ R_BUTTON = "Tlačítko R - Možnosti"
|
|||
L_BUTTON = "Tlačítko L - Znovu načíst aktivní mody"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "Použít ovládání chatu Terminal/CMD"
|
||||
CHAT_WIDTH = "Šířka chatu"
|
||||
CHAT_HEIGHT = "Výška chatu"
|
||||
|
|
@ -345,6 +346,9 @@ CHAT_SIZE_VERY_BIG = "Velmi velká"
|
|||
CHAT_SIZE_HUGE = "Obrovská"
|
||||
CHAT_SIZE_VERY_HUGE = "Obří"
|
||||
CHAT_SIZE_MAXIMUM = "Maximum"
|
||||
CHAT_TEXT_SCALE = "Velikost textu chatu"
|
||||
CHAT_OPACITY = "Průhlednost chatu"
|
||||
CHAT_LIFETIME = "Doba zobrazení zpráv (s)"
|
||||
CHAT_CHAR_COUNTER = "Zobrazit počitadlo znaků chatu"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Skrýt chat, když je zavřený"
|
||||
|
||||
|
|
|
|||
|
|
@ -331,6 +331,7 @@ R_BUTTON = "R-knop - Opties"
|
|||
L_BUTTON = "L-knop - Actieve mods opnieuw laden"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "Terminal/CMD Chatbox besturingen gebruiken"
|
||||
CHAT_WIDTH = "Chatbreedte"
|
||||
CHAT_HEIGHT = "Chathoogte"
|
||||
|
|
@ -345,6 +346,9 @@ CHAT_SIZE_VERY_BIG = "Zeer groot"
|
|||
CHAT_SIZE_HUGE = "Enorm"
|
||||
CHAT_SIZE_VERY_HUGE = "Gigantisch"
|
||||
CHAT_SIZE_MAXIMUM = "Maximum"
|
||||
CHAT_TEXT_SCALE = "Chat-tekstgrootte"
|
||||
CHAT_OPACITY = "Chat-transparantie"
|
||||
CHAT_LIFETIME = "Weergaveduur berichten (s)"
|
||||
CHAT_CHAR_COUNTER = "Chat-tekensteller weergeven"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Chat verbergen wanneer gesloten"
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ UNRECOGNIZED = "Unrecognized chat command."
|
|||
MOD_GRANTED = "\\#fff982\\You are now a Moderator."
|
||||
ALL_COMMANDS = "All commands"
|
||||
TAB_COMPLETE_INFO = "Press TAB to autocomplete commands, use Shift+TAB to navigate backwards"
|
||||
|
||||
[MENU]
|
||||
BACK = "Back"
|
||||
CANCEL = "Cancel"
|
||||
|
|
@ -331,6 +330,7 @@ R_BUTTON = "R Button - Options"
|
|||
L_BUTTON = "L Button - Reload Active Mods"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "Use Terminal/CMD Chatbox Controls"
|
||||
CHAT_WIDTH = "Chat Width"
|
||||
CHAT_HEIGHT = "Chat Height"
|
||||
|
|
@ -345,6 +345,9 @@ CHAT_SIZE_VERY_BIG = "Very Big"
|
|||
CHAT_SIZE_HUGE = "Huge"
|
||||
CHAT_SIZE_VERY_HUGE = "Very Huge"
|
||||
CHAT_SIZE_MAXIMUM = "Maximum"
|
||||
CHAT_TEXT_SCALE = "Chat Text Size"
|
||||
CHAT_OPACITY = "Chat Opacity"
|
||||
CHAT_LIFETIME = "Chat Message Lifetime (s)"
|
||||
CHAT_CHAR_COUNTER = "Show Chat Character Counter"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Hide Chat When Closed"
|
||||
|
||||
|
|
|
|||
|
|
@ -331,6 +331,7 @@ R_BUTTON = "Bouton R - Options"
|
|||
L_BUTTON = "Bouton L - Recharger les mods actifs"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "Utiliser les contrôles de chat Terminal/CMD"
|
||||
CHAT_WIDTH = "Largeur du chat"
|
||||
CHAT_HEIGHT = "Hauteur du chat"
|
||||
|
|
@ -345,6 +346,9 @@ CHAT_SIZE_VERY_BIG = "Très grande"
|
|||
CHAT_SIZE_HUGE = "Énorme"
|
||||
CHAT_SIZE_VERY_HUGE = "Gigantesque"
|
||||
CHAT_SIZE_MAXIMUM = "Maximum"
|
||||
CHAT_TEXT_SCALE = "Taille du texte du chat"
|
||||
CHAT_OPACITY = "Opacité du chat"
|
||||
CHAT_LIFETIME = "Durée d'affichage des messages (s)"
|
||||
CHAT_CHAR_COUNTER = "Afficher le compteur de caractères du chat"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Masquer le chat lorsqu'il est fermé"
|
||||
|
||||
|
|
|
|||
|
|
@ -331,6 +331,7 @@ R_BUTTON = "R-Taste - Optionen"
|
|||
L_BUTTON = "L-Taste - Aktive Mods neu laden"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "Terminal/CMD Chatbox-Steuerung verwenden"
|
||||
CHAT_WIDTH = "Chatbreite"
|
||||
CHAT_HEIGHT = "Chathöhe"
|
||||
|
|
@ -345,6 +346,9 @@ CHAT_SIZE_VERY_BIG = "Sehr groß"
|
|||
CHAT_SIZE_HUGE = "Riesig"
|
||||
CHAT_SIZE_VERY_HUGE = "Gigantisch"
|
||||
CHAT_SIZE_MAXIMUM = "Maximal"
|
||||
CHAT_TEXT_SCALE = "Chat-Textgröße"
|
||||
CHAT_OPACITY = "Chat-Transparenz"
|
||||
CHAT_LIFETIME = "Chat-Anzeigedauer (s)"
|
||||
CHAT_CHAR_COUNTER = "Chat-Zeichenzähler anzeigen"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Verstecke Chat wenn geschlossen"
|
||||
|
||||
|
|
|
|||
|
|
@ -329,6 +329,7 @@ R_BUTTON = "Pulsante R - Opzioni"
|
|||
L_BUTTON = "Pulsante L - Ricarica Mod Attive"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "Usa controlli chat Terminale/CMD"
|
||||
CHAT_WIDTH = "Larghezza chat"
|
||||
CHAT_HEIGHT = "Altezza chat"
|
||||
|
|
@ -343,6 +344,9 @@ CHAT_SIZE_VERY_BIG = "Molto grande"
|
|||
CHAT_SIZE_HUGE = "Enorme"
|
||||
CHAT_SIZE_VERY_HUGE = "Enormissima"
|
||||
CHAT_SIZE_MAXIMUM = "Massimo"
|
||||
CHAT_TEXT_SCALE = "Dimensione testo chat"
|
||||
CHAT_OPACITY = "Opacità chat"
|
||||
CHAT_LIFETIME = "Durata messaggi chat (s)"
|
||||
CHAT_CHAR_COUNTER = "Mostra contatore caratteri della chat"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Nascondi chat quando è chiusa"
|
||||
|
||||
|
|
|
|||
|
|
@ -332,6 +332,7 @@ R_BUTTON = "Rボタン - 設定"
|
|||
L_BUTTON = "Lボタン - アクティブなMODを再読み込み"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "ターミナル/CMDチャットボックスコントロールを使用"
|
||||
CHAT_WIDTH = "チャット幅"
|
||||
CHAT_HEIGHT = "チャットの高さ"
|
||||
|
|
@ -346,6 +347,9 @@ CHAT_SIZE_VERY_BIG = "とても大きい"
|
|||
CHAT_SIZE_HUGE = "巨大"
|
||||
CHAT_SIZE_VERY_HUGE = "超巨大"
|
||||
CHAT_SIZE_MAXIMUM = "最大"
|
||||
CHAT_TEXT_SCALE = "チャット文字サイズ"
|
||||
CHAT_OPACITY = "チャットの不透明度"
|
||||
CHAT_LIFETIME = "メッセージ表示時間 (秒)"
|
||||
CHAT_CHAR_COUNTER = "チャットの文字数カウンターを表示"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "閉じているときはチャットを隠す"
|
||||
|
||||
|
|
|
|||
|
|
@ -331,6 +331,7 @@ R_BUTTON = "Przycisk R - Opcje"
|
|||
L_BUTTON = "Przycisk L - Przeładuj aktywne mody"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "Użyj sterowania czatu Terminal/CMD"
|
||||
CHAT_WIDTH = "Szerokość czatu"
|
||||
CHAT_HEIGHT = "Wysokość czatu"
|
||||
|
|
@ -345,6 +346,9 @@ CHAT_SIZE_VERY_BIG = "Bardzo duża"
|
|||
CHAT_SIZE_HUGE = "Ogromna"
|
||||
CHAT_SIZE_VERY_HUGE = "Olbrzymia"
|
||||
CHAT_SIZE_MAXIMUM = "Maksimum"
|
||||
CHAT_TEXT_SCALE = "Rozmiar tekstu czatu"
|
||||
CHAT_OPACITY = "Przezroczystość czatu"
|
||||
CHAT_LIFETIME = "Czas wyświetlania wiadomości (s)"
|
||||
CHAT_CHAR_COUNTER = "Pokaż licznik znaków czatu"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Ukryj czat, gdy jest zamknięty"
|
||||
|
||||
|
|
|
|||
|
|
@ -331,6 +331,7 @@ R_BUTTON = "Botão R - Opções"
|
|||
L_BUTTON = "Botão L - Recarregar mods ativos"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "Usar controles de chat Terminal/CMD"
|
||||
CHAT_WIDTH = "Largura do chat"
|
||||
CHAT_HEIGHT = "Altura do chat"
|
||||
|
|
@ -345,6 +346,9 @@ CHAT_SIZE_VERY_BIG = "Muito grande"
|
|||
CHAT_SIZE_HUGE = "Enorme"
|
||||
CHAT_SIZE_VERY_HUGE = "Enorme demais"
|
||||
CHAT_SIZE_MAXIMUM = "Máximo"
|
||||
CHAT_TEXT_SCALE = "Tamanho do texto do chat"
|
||||
CHAT_OPACITY = "Opacidade do chat"
|
||||
CHAT_LIFETIME = "Duração da mensagem do chat (s)"
|
||||
CHAT_CHAR_COUNTER = "Mostrar contador de caracteres do chat"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Ocultar chat quando fechado"
|
||||
|
||||
|
|
|
|||
|
|
@ -344,6 +344,9 @@ CHAT_SIZE_VERY_BIG = "Очень большая"
|
|||
CHAT_SIZE_HUGE = "Огромная"
|
||||
CHAT_SIZE_VERY_HUGE = "Гигантская"
|
||||
CHAT_SIZE_MAXIMUM = "Максимум"
|
||||
CHAT_TEXT_SCALE = "Размер текста чата"
|
||||
CHAT_OPACITY = "Прозрачность чата"
|
||||
CHAT_LIFETIME = "Время показа сообщений (с)"
|
||||
CHAT_CHAR_COUNTER = "Показывать счётчик символов чата"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Скрывать чат, когда он закрыт"
|
||||
|
||||
|
|
|
|||
|
|
@ -331,6 +331,7 @@ R_BUTTON = "Botón R - Opciones"
|
|||
L_BUTTON = "Botón L - Recargar mods activos"
|
||||
|
||||
[CHAT_OPTIONS]
|
||||
CHAT = "CHAT"
|
||||
USE_STANDARD_KEY_BINDINGS_CHAT = "Usar controles de chat Terminal/CMD"
|
||||
CHAT_WIDTH = "Ancho del chat"
|
||||
CHAT_HEIGHT = "Altura del chat"
|
||||
|
|
@ -345,6 +346,9 @@ CHAT_SIZE_VERY_BIG = "Muy grande"
|
|||
CHAT_SIZE_HUGE = "Enorme"
|
||||
CHAT_SIZE_VERY_HUGE = "Enorme+"
|
||||
CHAT_SIZE_MAXIMUM = "Máximo"
|
||||
CHAT_TEXT_SCALE = "Tamaño de texto del chat"
|
||||
CHAT_OPACITY = "Opacidad del chat"
|
||||
CHAT_LIFETIME = "Duración del mensaje de chat (s)"
|
||||
CHAT_CHAR_COUNTER = "Mostrar contador de caracteres del chat"
|
||||
DISABLE_CHAT_WHEN_CLOSED = "Ocultar chat cuando esté cerrado"
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ bool configChatCharCounter = true;
|
|||
bool configDisableChatWhenClosed = false;
|
||||
unsigned int configChatWidth = 800;
|
||||
unsigned int configChatHeight = 400;
|
||||
unsigned int configChatTextScale = 100;
|
||||
unsigned int configChatOpacity = 70;
|
||||
unsigned int configChatMessageLifetime = 10;
|
||||
bool configSmoothScrolling = false;
|
||||
// free camera settings
|
||||
bool configEnableFreeCamera = false;
|
||||
|
|
@ -285,6 +288,9 @@ static const struct ConfigOption options[] = {
|
|||
{.name = "use_standard_key_bindings_chat", .type = CONFIG_TYPE_BOOL, .boolValue = &configUseStandardKeyBindingsChat},
|
||||
{.name = "chat_width", .type = CONFIG_TYPE_UINT, .uintValue = &configChatWidth},
|
||||
{.name = "chat_height", .type = CONFIG_TYPE_UINT, .uintValue = &configChatHeight},
|
||||
{.name = "chat_text_scale", .type = CONFIG_TYPE_UINT, .uintValue = &configChatTextScale},
|
||||
{.name = "chat_opacity", .type = CONFIG_TYPE_UINT, .uintValue = &configChatOpacity},
|
||||
{.name = "chat_message_lifetime", .type = CONFIG_TYPE_UINT, .uintValue = &configChatMessageLifetime},
|
||||
{.name = "chat_char_counter", .type = CONFIG_TYPE_BOOL, .boolValue = &configChatCharCounter},
|
||||
{.name = "disable_chat_when_closed", .type = CONFIG_TYPE_BOOL, .boolValue = &configDisableChatWhenClosed},
|
||||
{.name = "smooth_scrolling", .type = CONFIG_TYPE_BOOL, .boolValue = &configSmoothScrolling},
|
||||
|
|
|
|||
|
|
@ -100,6 +100,9 @@ extern bool configChatCharCounter;
|
|||
extern bool configDisableChatWhenClosed;
|
||||
extern unsigned int configChatWidth;
|
||||
extern unsigned int configChatHeight;
|
||||
extern unsigned int configChatTextScale;
|
||||
extern unsigned int configChatOpacity;
|
||||
extern unsigned int configChatMessageLifetime;
|
||||
extern bool configSmoothScrolling;
|
||||
// free camera settings
|
||||
extern bool configEnableFreeCamera;
|
||||
|
|
|
|||
|
|
@ -138,7 +138,10 @@ static void djui_chat_box_set_focus_style(void) {
|
|||
bool hasMessages = (gDjuiChatBox->chatFlow->base.height.value > 2.0f);
|
||||
u8 alpha = 0;
|
||||
if (hasMessages) {
|
||||
alpha = gDjuiChatBoxFocus ? 160 : 0;
|
||||
int baseAlpha = (int)(configChatOpacity * 2.55f);
|
||||
if (baseAlpha > 255) { baseAlpha = 255; }
|
||||
if (baseAlpha < 0) { baseAlpha = 0; }
|
||||
alpha = gDjuiChatBoxFocus ? (u8)baseAlpha : 0;
|
||||
}
|
||||
djui_base_set_color(&gDjuiChatBox->chatFlow->base, 0, 0, 0, alpha);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,22 @@
|
|||
#include "djui_hud_utils.h"
|
||||
#include "pc/debuglog.h"
|
||||
#include "pc/lua/smlua_hooks.h"
|
||||
#include "pc/configfile.h"
|
||||
|
||||
#define DJUI_CHAT_LIFE_TIME 10.0f
|
||||
#define DJUI_CHAT_LIFE_TIME_DEFAULT 10.0f
|
||||
|
||||
static bool djui_chat_message_render(struct DjuiBase* base) {
|
||||
struct DjuiChatMessage* chatMessage = (struct DjuiChatMessage*)base;
|
||||
struct DjuiBase* ctBase = &chatMessage->message->base;
|
||||
|
||||
f32 lifeTime = (f32)configChatMessageLifetime;
|
||||
if (lifeTime < 3.0f) lifeTime = 3.0f;
|
||||
if (lifeTime > 60.0f) lifeTime = 60.0f;
|
||||
|
||||
f32 seconds = clock_elapsed() - chatMessage->createTime;
|
||||
f32 f = 1.0f;
|
||||
if (seconds >= (DJUI_CHAT_LIFE_TIME - 1)) {
|
||||
f = fmax(1.0f - (seconds - (DJUI_CHAT_LIFE_TIME - 1)), 0.0f);
|
||||
if (seconds >= (lifeTime - 1.0f)) {
|
||||
f = fmax(1.0f - (seconds - (lifeTime - 1.0f)), 0.0f);
|
||||
f *= f;
|
||||
f *= f;
|
||||
}
|
||||
|
|
@ -33,8 +38,22 @@ static bool djui_chat_message_render(struct DjuiBase* base) {
|
|||
} else if (f <= 0.1f) {
|
||||
return false;
|
||||
} else {
|
||||
djui_base_set_color(base, 0, 0, 0, 140 * f);
|
||||
djui_base_set_color(ctBase, 255, 255, 255, 255 * f);
|
||||
int bgAlphaI = (int)(configChatOpacity * f * 2.55f);
|
||||
if (bgAlphaI > 255) { bgAlphaI = 255; }
|
||||
if (bgAlphaI < 0) { bgAlphaI = 0; }
|
||||
u8 bgAlpha = (u8)bgAlphaI;
|
||||
|
||||
// Text-Deckkraft: beim Standardwert (70) bereits voll sichtbar,
|
||||
// darunter linear bis 0 herunter, darüber weiterhin voll sichtbar.
|
||||
const f32 defaultOpacity = 70.0f;
|
||||
f32 textScale = 1.0f;
|
||||
if ((f32)configChatOpacity < defaultOpacity) {
|
||||
textScale = (f32)configChatOpacity / defaultOpacity;
|
||||
}
|
||||
u8 textAlpha = (u8)(255.0f * f * textScale);
|
||||
|
||||
djui_base_set_color(base, 0, 0, 0, bgAlpha);
|
||||
djui_base_set_color(ctBase, 255, 255, 255, textAlpha);
|
||||
djui_base_set_size_type(base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(base, chatMessage->messageWidth, chatMessage->base.height.value);
|
||||
}
|
||||
|
|
@ -71,6 +90,56 @@ void djui_chat_message_create_from(u8 globalIndex, const char* message) {
|
|||
djui_chat_message_create(chatMsg);
|
||||
}
|
||||
|
||||
static void djui_chat_message_apply_style_one(struct DjuiChatMessage* chatMessage) {
|
||||
struct DjuiBase* base = &chatMessage->base;
|
||||
|
||||
f32 maxTextWidth = gDjuiChatBox->base.width.value
|
||||
- gDjuiChatBox->base.padding.left.value - gDjuiChatBox->base.padding.right.value
|
||||
- base->padding.left.value - base->padding.right.value;
|
||||
|
||||
struct DjuiText* chatText = chatMessage->message;
|
||||
struct DjuiBase* ctBase = &chatText->base;
|
||||
djui_base_set_size_type(ctBase, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(ctBase, maxTextWidth, 1.0f);
|
||||
djui_base_set_color(ctBase, 255, 255, 255, 255);
|
||||
djui_base_set_location(ctBase, 0, 0);
|
||||
djui_text_set_alignment(chatText, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
|
||||
|
||||
// apply text scale based on config
|
||||
f32 scale = ((f32)configChatTextScale) / 100.0f;
|
||||
if (scale < 0.5f) { scale = 0.5f; }
|
||||
if (scale > 1.5f) { scale = 1.5f; }
|
||||
djui_text_set_font_scale(chatText, chatText->font->defaultFontScale * scale);
|
||||
|
||||
// figure out chat message height
|
||||
chatText->base.comp.width = maxTextWidth;
|
||||
f32 messageHeight = djui_text_count_lines(chatText, 10)
|
||||
* (chatText->font->lineHeight * chatText->font->defaultFontScale * scale) + 8;
|
||||
djui_base_set_size(base, 1.0f, messageHeight);
|
||||
|
||||
// figure out chat message width
|
||||
f32 messageWidth = djui_text_find_width(chatText, 10);
|
||||
chatMessage->messageWidth = messageWidth + 8;
|
||||
}
|
||||
|
||||
void djui_chat_messages_apply_style(void) {
|
||||
if (gDjuiChatBox == NULL || gDjuiChatBox->chatFlow == NULL) { return; }
|
||||
|
||||
gDjuiChatBox->chatFlow->base.height.value = 0;
|
||||
|
||||
struct DjuiBaseChild* child = gDjuiChatBox->chatFlow->base.child;
|
||||
while (child != NULL) {
|
||||
struct DjuiChatMessage* msg = (struct DjuiChatMessage*)child->base;
|
||||
djui_chat_message_apply_style_one(msg);
|
||||
gDjuiChatBox->chatFlow->base.height.value += msg->base.height.value + gDjuiChatBox->chatFlow->margin.value;
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
if (!gDjuiChatBox->scrolling) {
|
||||
gDjuiChatBox->chatFlow->base.y.value = gDjuiChatBox->chatContainer->base.elem.height - gDjuiChatBox->chatFlow->base.height.value;
|
||||
}
|
||||
}
|
||||
|
||||
void djui_chat_message_create(const char* message) {
|
||||
if (gDjuiChatBox == NULL || gDjuiChatBox->chatFlow == NULL) { return; }
|
||||
struct DjuiChatMessage* chatMessage = calloc(1, sizeof(struct DjuiChatMessage));
|
||||
|
|
@ -82,28 +151,14 @@ void djui_chat_message_create(const char* message) {
|
|||
djui_base_set_padding(base, 0, 4, 0, 4);
|
||||
djui_base_set_alignment(base, DJUI_HALIGN_LEFT, DJUI_VALIGN_BOTTOM);
|
||||
|
||||
f32 maxTextWidth = gDjuiChatBox->base.width.value - gDjuiChatBox->base.padding.left.value - gDjuiChatBox->base.padding.right.value - base->padding.left.value - base->padding.right.value;
|
||||
|
||||
struct DjuiText* chatText = djui_text_create(base, message);
|
||||
struct DjuiBase* ctBase = &chatText->base;
|
||||
djui_base_set_size_type(ctBase, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(ctBase, maxTextWidth, 1.0f);
|
||||
djui_base_set_color(ctBase, 255, 255, 255, 255);
|
||||
djui_base_set_location(ctBase, 0, 0);
|
||||
djui_text_set_alignment(chatText, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
|
||||
chatMessage->message = chatText;
|
||||
chatMessage->createTime = clock_elapsed();
|
||||
|
||||
// figure out chat message height
|
||||
chatText->base.comp.width = maxTextWidth;
|
||||
f32 messageHeight = djui_text_count_lines(chatText, 10) * (chatText->font->lineHeight * chatText->font->defaultFontScale) + 8;
|
||||
djui_base_set_size(base, 1.0f, messageHeight);
|
||||
gDjuiChatBox->chatFlow->base.height.value += messageHeight + gDjuiChatBox->chatFlow->margin.value;
|
||||
djui_chat_message_apply_style_one(chatMessage);
|
||||
|
||||
gDjuiChatBox->chatFlow->base.height.value += chatMessage->base.height.value + gDjuiChatBox->chatFlow->margin.value;
|
||||
if (!gDjuiChatBox->scrolling) {
|
||||
gDjuiChatBox->chatFlow->base.y.value = gDjuiChatBox->chatContainer->base.elem.height - gDjuiChatBox->chatFlow->base.height.value;
|
||||
}
|
||||
|
||||
// figure out chat message width
|
||||
f32 messageWidth = djui_text_find_width(chatText, 10);
|
||||
chatMessage->messageWidth = messageWidth + 8;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,3 +13,4 @@ struct DjuiChatMessage {
|
|||
void djui_chat_message_create_from(u8 globalIndex, const char* message);
|
||||
/* |description|Creates a `message` in the game's chat box|descriptionEnd| */
|
||||
void djui_chat_message_create(const char* message);
|
||||
void djui_chat_messages_apply_style(void);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "pc/configfile.h"
|
||||
|
||||
void djui_panel_chat_create(struct DjuiBase* caller) {
|
||||
struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(OPTIONS, CHAT), false);
|
||||
struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(CHAT_OPTIONS, CHAT), false);
|
||||
struct DjuiBase* body = djui_three_panel_get_body(panel);
|
||||
{
|
||||
djui_checkbox_create(body, DLANG(CHAT_OPTIONS, USE_STANDARD_KEY_BINDINGS_CHAT), &configUseStandardKeyBindingsChat, NULL);
|
||||
|
|
@ -74,9 +74,29 @@ void djui_panel_chat_create(struct DjuiBase* caller) {
|
|||
djui_base_set_size(&gDjuiChatBox->base, gDjuiChatBox->base.width.value, configChatHeight);
|
||||
}
|
||||
}
|
||||
|
||||
djui_selectionbox_create(body, DLANG(CHAT_OPTIONS, CHAT_WIDTH), chatSizeChoices, 11, &sChatWidthIndex, on_chat_width_change);
|
||||
djui_selectionbox_create(body, DLANG(CHAT_OPTIONS, CHAT_HEIGHT), chatSizeChoices, 11, &sChatHeightIndex, on_chat_height_change);
|
||||
|
||||
void on_chat_style_change(UNUSED struct DjuiBase* b) {
|
||||
djui_chat_messages_apply_style();
|
||||
if (gDjuiChatBox != NULL) {
|
||||
bool hasMessages = (gDjuiChatBox->chatFlow->base.height.value > 2.0f);
|
||||
u8 alpha = 0;
|
||||
if (hasMessages) {
|
||||
int baseAlpha = (int)(configChatOpacity * 2.55f);
|
||||
if (baseAlpha > 255) { baseAlpha = 255; }
|
||||
if (baseAlpha < 0) { baseAlpha = 0; }
|
||||
alpha = gDjuiChatBoxFocus ? (u8)baseAlpha : 0;
|
||||
}
|
||||
djui_base_set_color(&gDjuiChatBox->chatFlow->base, 0, 0, 0, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
djui_slider_create(body, DLANG(CHAT_OPTIONS, CHAT_TEXT_SCALE), &configChatTextScale, 50, 150, on_chat_style_change);
|
||||
djui_slider_create(body, DLANG(CHAT_OPTIONS, CHAT_OPACITY), &configChatOpacity, 0, 100, on_chat_style_change);
|
||||
djui_slider_create(body, DLANG(CHAT_OPTIONS, CHAT_LIFETIME), &configChatMessageLifetime, 3, 60, NULL);
|
||||
|
||||
djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue