diff --git a/lang/Czech.ini b/lang/Czech.ini index 75ac7655a..8cc02ee87 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -351,7 +351,10 @@ CHAT_BACKGROUND_OPACITY = "Průhlednost pozadí chatu" CHAT_TEXT_OPACITY = "Průhlednost textu chatu" CHAT_LIFETIME = "Doba zobrazení zpráv" CHAT_CHAR_COUNTER = "Zobrazit počitadlo znaků chatu" -DISABLE_CHAT_WHEN_CLOSED = "Skrýt chat, když je zavřený" +CHAT_CLOSED_MODE = "Zobrazit historii chatu" +CHAT_CLOSED_DISABLED = "Skrytý" +CHAT_CLOSED_LIFETIME = "Skrýt po: %us" +CHAT_CLOSED_ALWAYS = "Vždy viditelný" [INFORMATION] INFORMATION_TITLE = "INFORMACE" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index 1b1be29b5..e1bf057c8 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -351,7 +351,10 @@ CHAT_BACKGROUND_OPACITY = "Transparantie van de chatachtergrond" CHAT_TEXT_OPACITY = "Transparantie van de chattekst" CHAT_LIFETIME = "Weergaveduur berichten" CHAT_CHAR_COUNTER = "Chat-tekensteller weergeven" -DISABLE_CHAT_WHEN_CLOSED = "Chat verbergen wanneer gesloten" +CHAT_CLOSED_MODE = "Chatgeschiedenis tonen" +CHAT_CLOSED_DISABLED = "Verborgen" +CHAT_CLOSED_LIFETIME = "Verbergen na: %us" +CHAT_CLOSED_ALWAYS = "Altijd zichtbaar" [INFORMATION] INFORMATION_TITLE = "INFORMATIE" diff --git a/lang/English.ini b/lang/English.ini index f6d4ec516..d416f8b7d 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -350,7 +350,10 @@ CHAT_BACKGROUND_OPACITY = "Chat Background Opacity" CHAT_TEXT_OPACITY = "Chat Text Opacity" CHAT_LIFETIME = "Chat Message Lifetime" CHAT_CHAR_COUNTER = "Show Chat Character Counter" -DISABLE_CHAT_WHEN_CLOSED = "Hide Chat When Closed" +CHAT_CLOSED_MODE = "Show chat history" +CHAT_CLOSED_DISABLED = "Hide immediately" +CHAT_CLOSED_LIFETIME = "Fade after: %us" +CHAT_CLOSED_ALWAYS = "Always visible" [INFORMATION] INFORMATION_TITLE = "INFO" diff --git a/lang/French.ini b/lang/French.ini index 1bef6dcb4..008e54c49 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -351,7 +351,10 @@ CHAT_BACKGROUND_OPACITY = "Opacité du fond du chat" CHAT_TEXT_OPACITY = "Opacité du texte du chat" CHAT_LIFETIME = "Durée d'affichage des messages" CHAT_CHAR_COUNTER = "Afficher le compteur de caractères du chat" -DISABLE_CHAT_WHEN_CLOSED = "Masquer le chat lorsqu'il est fermé" +CHAT_CLOSED_MODE = "Afficher l'historique du chat" +CHAT_CLOSED_DISABLED = "Masqué" +CHAT_CLOSED_LIFETIME = "Masquer après : %us" +CHAT_CLOSED_ALWAYS = "Toujours visible" [INFORMATION] INFORMATION_TITLE = "INFORMATION" diff --git a/lang/German.ini b/lang/German.ini index d7d1c82c4..ad416e9e1 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -351,7 +351,10 @@ CHAT_BACKGROUND_OPACITY = "Chat-Hintergrundtransparenz" CHAT_TEXT_OPACITY = "Chat-Texttransparenz" CHAT_LIFETIME = "Chat-Anzeigedauer" CHAT_CHAR_COUNTER = "Chat-Zeichenzähler anzeigen" -DISABLE_CHAT_WHEN_CLOSED = "Verstecke Chat wenn geschlossen" +CHAT_CLOSED_MODE = "Chatverlauf anzeigen" +CHAT_CLOSED_DISABLED = "Sofort ausblenden" +CHAT_CLOSED_LIFETIME = "Ausblenden nach: %us" +CHAT_CLOSED_ALWAYS = "Dauerhaft anzeigen" [INFORMATION] INFORMATION_TITLE = "INFORMATION" diff --git a/lang/Italian.ini b/lang/Italian.ini index 8d2f54455..adb7cc196 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -349,7 +349,10 @@ CHAT_BACKGROUND_OPACITY = "Opacità sfondo chat" CHAT_TEXT_OPACITY = "Opacità testo chat" CHAT_LIFETIME = "Durata messaggi chat" CHAT_CHAR_COUNTER = "Mostra contatore caratteri della chat" -DISABLE_CHAT_WHEN_CLOSED = "Nascondi chat quando è chiusa" +CHAT_CLOSED_MODE = "Mostrare la cronologia della chat" +CHAT_CLOSED_DISABLED = "Disattivata" +CHAT_CLOSED_LIFETIME = "Nascondi dopo: %us" +CHAT_CLOSED_ALWAYS = "Sempre visibile" [INFORMATION] INFORMATION_TITLE = "INFO" diff --git a/lang/Japanese.ini b/lang/Japanese.ini index 82ef1ccd0..4def7bdff 100644 --- a/lang/Japanese.ini +++ b/lang/Japanese.ini @@ -352,7 +352,10 @@ CHAT_BACKGROUND_OPACITY = "チャット背景の不透明度" CHAT_TEXT_OPACITY = "チャット文字の不透明度" CHAT_LIFETIME = "メッセージ表示時間" CHAT_CHAR_COUNTER = "チャットの文字数カウンターを表示" -DISABLE_CHAT_WHEN_CLOSED = "閉じているときはチャットを隠す" +CHAT_CLOSED_MODE = "チャット履歴の表示" +CHAT_CLOSED_DISABLED = "非表示" +CHAT_CLOSED_LIFETIME = "非表示まで: %us" +CHAT_CLOSED_ALWAYS = "常に表示" [INFORMATION] INFORMATION_TITLE = "INFO" diff --git a/lang/Polish.ini b/lang/Polish.ini index 0562dc7df..44d3c57a7 100644 --- a/lang/Polish.ini +++ b/lang/Polish.ini @@ -351,7 +351,10 @@ CHAT_BACKGROUND_OPACITY = "Przezroczystość tła czatu" CHAT_TEXT_OPACITY = "Przezroczystość tekstu czatu" CHAT_LIFETIME = "Czas wyświetlania wiadomości" CHAT_CHAR_COUNTER = "Pokaż licznik znaków czatu" -DISABLE_CHAT_WHEN_CLOSED = "Ukryj czat, gdy jest zamknięty" +CHAT_CLOSED_MODE = "Wyświetlanie historii czatu" +CHAT_CLOSED_DISABLED = "Wyłączony" +CHAT_CLOSED_LIFETIME = "Ukryj po: %us" +CHAT_CLOSED_ALWAYS = "Zawsze widoczny" [INFORMATION] INFORMATION_TITLE = "INFORMACJA" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index 134576f58..bd0fb35ec 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -351,7 +351,10 @@ CHAT_BACKGROUND_OPACITY = "Opacidade do fundo do chat" CHAT_TEXT_OPACITY = "Opacidade do texto do chat" CHAT_LIFETIME = "Duração da mensagem do chat" CHAT_CHAR_COUNTER = "Mostrar contador de caracteres do chat" -DISABLE_CHAT_WHEN_CLOSED = "Ocultar chat quando fechado" +CHAT_CLOSED_MODE = "Exibir histórico do chat" +CHAT_CLOSED_DISABLED = "Oculto" +CHAT_CLOSED_LIFETIME = "Ocultar após: %us" +CHAT_CLOSED_ALWAYS = "Sempre visível" [INFORMATION] INFORMATION_TITLE = "INFORMAÇÃO" diff --git a/lang/Russian.ini b/lang/Russian.ini index f86da4f3a..a3d8d8066 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -349,7 +349,10 @@ CHAT_BACKGROUND_OPACITY = "Прозрачность фона чата" CHAT_TEXT_OPACITY = "Прозрачность текста чата" CHAT_LIFETIME = "Время показа сообщений" CHAT_CHAR_COUNTER = "Показывать счётчик символов чата" -DISABLE_CHAT_WHEN_CLOSED = "Скрывать чат, когда он закрыт" +CHAT_CLOSED_MODE = "Показывать историю чата" +CHAT_CLOSED_DISABLED = "Скрыт" +CHAT_CLOSED_LIFETIME = "Скрывать через: %us" +CHAT_CLOSED_ALWAYS = "Всегда виден" [INFORMATION] INFORMATION_TITLE = "INFORMATION" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index 6f581991d..65f34a14f 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -351,7 +351,10 @@ CHAT_BACKGROUND_OPACITY = "Opacidad del fondo del chat" CHAT_TEXT_OPACITY = "Opacidad del texto del chat" CHAT_LIFETIME = "Duración del mensaje de chat" CHAT_CHAR_COUNTER = "Mostrar contador de caracteres del chat" -DISABLE_CHAT_WHEN_CLOSED = "Ocultar chat cuando esté cerrado" +CHAT_CLOSED_MODE = "Mostrar historial de chat" +CHAT_CLOSED_DISABLED = "Oculto" +CHAT_CLOSED_LIFETIME = "Ocultar tras: %us" +CHAT_CLOSED_ALWAYS = "Siempre visible" [INFORMATION] INFORMATION_TITLE = "INFORMACIÓN" diff --git a/src/pc/configfile.c b/src/pc/configfile.c index e69a1d7fe..6b6a41dd2 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -134,7 +134,7 @@ bool configBackgroundGamepad = true; bool configDisableGamepads = false; bool configUseStandardKeyBindingsChat = true; bool configChatCharCounter = true; -bool configDisableChatWhenClosed = false; +unsigned int configChatClosedMode = 1; unsigned int configChatWidth = 800; unsigned int configChatHeight = 400; unsigned int configChatTextScale = 100; @@ -293,8 +293,8 @@ static const struct ConfigOption options[] = { {.name = "chat_background_opacity", .type = CONFIG_TYPE_UINT, .uintValue = &configChatBackgroundOpacity}, {.name = "chat_text_opacity", .type = CONFIG_TYPE_UINT, .uintValue = &configChatTextOpacity}, {.name = "chat_message_lifetime", .type = CONFIG_TYPE_UINT, .uintValue = &configChatMessageLifetime}, + {.name = "chat_closed_mode", .type = CONFIG_TYPE_UINT, .uintValue = &configChatClosedMode}, {.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}, {.name = "stick_rotate_left", .type = CONFIG_TYPE_BOOL, .boolValue = &configStick.rotateLeft}, {.name = "stick_invert_left_x", .type = CONFIG_TYPE_BOOL, .boolValue = &configStick.invertLeftX}, diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 29ae79188..369c7f05e 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -97,7 +97,7 @@ extern bool configBackgroundGamepad; extern bool configDisableGamepads; extern bool configUseStandardKeyBindingsChat; extern bool configChatCharCounter; -extern bool configDisableChatWhenClosed; +extern unsigned int configChatClosedMode; extern unsigned int configChatWidth; extern unsigned int configChatHeight; extern unsigned int configChatTextScale; diff --git a/src/pc/djui/djui_chat_message.c b/src/pc/djui/djui_chat_message.c index 26179ee1b..b6f738780 100644 --- a/src/pc/djui/djui_chat_message.c +++ b/src/pc/djui/djui_chat_message.c @@ -16,28 +16,39 @@ 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 < 1.0f) lifeTime = 1.0f; - if (lifeTime > 120.0f) lifeTime = 120.0f; - - f32 seconds = clock_elapsed() - chatMessage->createTime; f32 f = 1.0f; - if (seconds >= (lifeTime - 1.0f)) { - f = fmax(1.0f - (seconds - (lifeTime - 1.0f)), 0.0f); - f *= f; - f *= f; - } if (gDjuiChatBoxFocus) { djui_base_set_color(base, 0, 0, 0, 0); djui_base_set_color(ctBase, 255, 255, 255, 255); djui_base_set_size_type(base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(base, 1.0f, chatMessage->base.height.value); - } else if (configDisableChatWhenClosed) { - return false; - } else if (f <= 0.1f) { - return false; } else { + u32 mode = configChatClosedMode; + if (mode > 2) { mode = 1; } + + if (mode == 0) { + return false; + } + + if (mode == 1) { + f32 lifeTime = (f32)configChatMessageLifetime; + if (lifeTime < 1.0f) lifeTime = 1.0f; + if (lifeTime > 120.0f) lifeTime = 120.0f; + + f32 seconds = clock_elapsed() - chatMessage->createTime; + if (seconds >= (lifeTime - 1.0f)) { + f = fmax(1.0f - (seconds - (lifeTime - 1.0f)), 0.0f); + f *= f; + f *= f; + } + if (f <= 0.1f) { + return false; + } + } else { + f = 1.0f; + } + int bgAlphaI = (int)(configChatBackgroundOpacity * f * 2.55f); if (bgAlphaI > 255) { bgAlphaI = 255; } if (bgAlphaI < 0) { bgAlphaI = 0; } diff --git a/src/pc/djui/djui_panel_chat.c b/src/pc/djui/djui_panel_chat.c index a01d158aa..2ff09448b 100644 --- a/src/pc/djui/djui_panel_chat.c +++ b/src/pc/djui/djui_panel_chat.c @@ -1,15 +1,19 @@ #include "djui.h" #include "djui_panel.h" #include "djui_panel_menu.h" +#include "djui_selectionbox.h" #include "pc/utils/misc.h" #include "pc/configfile.h" -#define CHAT_WIDTH_DEFAULT 800 -#define CHAT_HEIGHT_DEFAULT 400 -#define CHAT_TEXT_SCALE_DEFAULT 100 -#define CHAT_BG_OPACITY_DEFAULT 70 -#define CHAT_TEXT_OPACITY_DEFAULT 100 -#define CHAT_LIFETIME_DEFAULT 10 +#define CHAT_WIDTH_DEFAULT 800 +#define CHAT_HEIGHT_DEFAULT 400 +#define CHAT_TEXT_SCALE_DEFAULT 100 +#define CHAT_BG_OPACITY_DEFAULT 70 +#define CHAT_TEXT_OPACITY_DEFAULT 100 +#define CHAT_LIFETIME_DEFAULT 10 +#define CHAT_USE_STD_KEY_BINDINGS_DEFAULT true +#define CHAT_CHAR_COUNTER_DEFAULT true +#define CHAT_CLOSED_MODE_DEFAULT 1 static const u8 CHAT_LABEL_LOW_RGB[3] = { 32, 64, 255 }; static const u8 CHAT_LABEL_DEFAULT_RGB[3] = { 32, 224, 32 }; @@ -29,12 +33,23 @@ static struct DjuiSlider* sSliderBgOpacity = NULL; static struct DjuiSlider* sSliderTextOpacity = NULL; static struct DjuiSlider* sSliderLifetime = NULL; +static struct DjuiCheckbox* sCheckboxUseStdChat = NULL; +static struct DjuiCheckbox* sCheckboxCharCounter = NULL; + static struct DjuiButton* sResetWidthButton = NULL; static struct DjuiButton* sResetHeightButton = NULL; static struct DjuiButton* sResetTextScaleButton = NULL; static struct DjuiButton* sResetBgOpacityButton = NULL; static struct DjuiButton* sResetTextOpacityButton = NULL; static struct DjuiButton* sResetLifetimeButton = NULL; +static struct DjuiButton* sResetUseStdChatButton = NULL; +static struct DjuiButton* sResetCharCounterButton = NULL; +static struct DjuiButton* sResetClosedModeButton = NULL; + +static void djui_panel_chat_update_lifetime_slider_enabled(void); +static void djui_panel_chat_update_closed_mode_lifetime_label(void); + +static struct DjuiSelectionbox* sChatClosedModeSelection = NULL; static void djui_panel_chat_apply_chatbox_style(void) { djui_chat_messages_apply_style(); @@ -127,27 +142,36 @@ static void djui_panel_chat_update_value_labels(void) { snprintf(buf, sizeof(buf), "%us", configChatMessageLifetime); djui_text_set_text(sChatLifetimeLabel, buf); struct DjuiBase* base = &sChatLifetimeLabel->base; - if (configChatMessageLifetime < 10) { - djui_base_set_color(base, CHAT_LABEL_LOW_RGB[0], CHAT_LABEL_LOW_RGB[1], CHAT_LABEL_LOW_RGB[2], 255); - } else if (configChatMessageLifetime == 10) { - djui_base_set_color(base, CHAT_LABEL_DEFAULT_RGB[0], CHAT_LABEL_DEFAULT_RGB[1], CHAT_LABEL_DEFAULT_RGB[2], 255); + + if (configChatClosedMode != 1) { + // Deaktivierter Modus: Wert grau darstellen + djui_base_set_color(base, 160, 160, 160, 255); } else { - djui_base_set_color(base, CHAT_LABEL_HIGH_RGB[0], CHAT_LABEL_HIGH_RGB[1], CHAT_LABEL_HIGH_RGB[2], 255); + if (configChatMessageLifetime < CHAT_LIFETIME_DEFAULT) { + djui_base_set_color(base, CHAT_LABEL_LOW_RGB[0], CHAT_LABEL_LOW_RGB[1], CHAT_LABEL_LOW_RGB[2], 255); + } else if (configChatMessageLifetime == CHAT_LIFETIME_DEFAULT) { + djui_base_set_color(base, CHAT_LABEL_DEFAULT_RGB[0], CHAT_LABEL_DEFAULT_RGB[1], CHAT_LABEL_DEFAULT_RGB[2], 255); + } else { + djui_base_set_color(base, CHAT_LABEL_HIGH_RGB[0], CHAT_LABEL_HIGH_RGB[1], CHAT_LABEL_HIGH_RGB[2], 255); + } } } } static void djui_panel_chat_update_reset_buttons(void) { const struct { struct DjuiButton** btn; bool active; } entries[] = { + { &sResetUseStdChatButton, configUseStandardKeyBindingsChat != CHAT_USE_STD_KEY_BINDINGS_DEFAULT }, + { &sResetCharCounterButton, configChatCharCounter != CHAT_CHAR_COUNTER_DEFAULT }, + { &sResetClosedModeButton, configChatClosedMode != CHAT_CLOSED_MODE_DEFAULT }, { &sResetWidthButton, configChatWidth != CHAT_WIDTH_DEFAULT }, { &sResetHeightButton, configChatHeight != CHAT_HEIGHT_DEFAULT }, { &sResetTextScaleButton, configChatTextScale != CHAT_TEXT_SCALE_DEFAULT }, { &sResetBgOpacityButton, configChatBackgroundOpacity != CHAT_BG_OPACITY_DEFAULT }, { &sResetTextOpacityButton, configChatTextOpacity != CHAT_TEXT_OPACITY_DEFAULT }, - { &sResetLifetimeButton, configChatMessageLifetime != CHAT_LIFETIME_DEFAULT }, + { &sResetLifetimeButton, (configChatClosedMode == 1) && (configChatMessageLifetime != CHAT_LIFETIME_DEFAULT) }, }; - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 9; i++) { struct DjuiButton* btn = *entries[i].btn; if (btn == NULL) { continue; } @@ -164,6 +188,12 @@ static void djui_panel_chat_update_reset_buttons(void) { } } +static void djui_panel_chat_update_lifetime_slider_enabled(void) { + if (sSliderLifetime == NULL) { return; } + bool lifetimeActive = (configChatClosedMode == 1); + djui_base_set_enabled(&sSliderLifetime->base, lifetimeActive); +} + static void djui_panel_chat_slider_on_cursor_down(struct DjuiBase* base) { struct DjuiSlider* slider = (struct DjuiSlider*)base; u32 min = slider->min; @@ -243,6 +273,24 @@ static void djui_panel_chat_on_style_change(UNUSED struct DjuiBase* b) { static void djui_panel_chat_on_lifetime_change(UNUSED struct DjuiBase* b) { djui_panel_chat_update_value_labels(); djui_panel_chat_update_reset_buttons(); + djui_panel_chat_update_closed_mode_lifetime_label(); +} + +static void djui_panel_chat_on_closed_mode_change(UNUSED struct DjuiBase* b) { + if (configChatClosedMode > 2) { + configChatClosedMode = 1; + } + djui_panel_chat_update_lifetime_slider_enabled(); + djui_panel_chat_update_reset_buttons(); + djui_panel_chat_update_value_labels(); + djui_panel_chat_update_closed_mode_lifetime_label(); +} + +static void djui_panel_chat_update_closed_mode_lifetime_label(void) { + if (sChatClosedModeSelection == NULL) { return; } + char buf[64]; + snprintf(buf, sizeof(buf), DLANG(CHAT_OPTIONS, CHAT_CLOSED_LIFETIME), configChatMessageLifetime); + djui_selectionbox_set_choice_text(sChatClosedModeSelection, 1, buf); } static void djui_panel_chat_on_reset_width(UNUSED struct DjuiBase* b) { @@ -308,16 +356,58 @@ static void djui_panel_chat_on_reset_lifetime(UNUSED struct DjuiBase* b) { } djui_panel_chat_update_value_labels(); djui_panel_chat_update_reset_buttons(); + djui_panel_chat_update_closed_mode_lifetime_label(); +} + +static void djui_panel_chat_on_reset_use_std_chat(UNUSED struct DjuiBase* b) { + configUseStandardKeyBindingsChat = CHAT_USE_STD_KEY_BINDINGS_DEFAULT; + if (sCheckboxUseStdChat != NULL && sCheckboxUseStdChat->rectValue != NULL) { + djui_base_set_visible(&sCheckboxUseStdChat->rectValue->base, configUseStandardKeyBindingsChat); + } + djui_panel_chat_update_reset_buttons(); +} + +static void djui_panel_chat_on_reset_char_counter(UNUSED struct DjuiBase* b) { + configChatCharCounter = CHAT_CHAR_COUNTER_DEFAULT; + if (sCheckboxCharCounter != NULL && sCheckboxCharCounter->rectValue != NULL) { + djui_base_set_visible(&sCheckboxCharCounter->rectValue->base, configChatCharCounter); + } + djui_panel_chat_update_reset_buttons(); +} + +static void djui_panel_chat_on_reset_closed_mode(UNUSED struct DjuiBase* b) { + configChatClosedMode = CHAT_CLOSED_MODE_DEFAULT; + if (sChatClosedModeSelection != NULL) { + djui_selectionbox_update_value(&sChatClosedModeSelection->base); + djui_panel_chat_on_closed_mode_change(&sChatClosedModeSelection->base); + } else { + djui_panel_chat_on_closed_mode_change(NULL); + } +} + +static void djui_panel_chat_on_checkbox_change(UNUSED struct DjuiBase* b) { + djui_panel_chat_update_reset_buttons(); } void djui_panel_chat_create(struct DjuiBase* caller) { 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); + struct DjuiRect* rowUseStdChat = djui_rect_container_create(body, 32); + struct DjuiRect* rowCharCounter = djui_rect_container_create(body, 32); + struct DjuiRect* rowClosedMode = djui_rect_container_create(body, 32); - djui_checkbox_create(body, DLANG(CHAT_OPTIONS, CHAT_CHAR_COUNTER), &configChatCharCounter, NULL); - djui_checkbox_create(body, DLANG(CHAT_OPTIONS, DISABLE_CHAT_WHEN_CLOSED), &configDisableChatWhenClosed, NULL); + sCheckboxUseStdChat = djui_checkbox_create(&rowUseStdChat->base, DLANG(CHAT_OPTIONS, USE_STANDARD_KEY_BINDINGS_CHAT), &configUseStandardKeyBindingsChat, djui_panel_chat_on_checkbox_change); + sCheckboxCharCounter = djui_checkbox_create(&rowCharCounter->base, DLANG(CHAT_OPTIONS, CHAT_CHAR_COUNTER), &configChatCharCounter, djui_panel_chat_on_checkbox_change); + + char lifetimeChoice[64]; + snprintf(lifetimeChoice, sizeof(lifetimeChoice), DLANG(CHAT_OPTIONS, CHAT_CLOSED_LIFETIME), configChatMessageLifetime); + char* chatClosedModeChoices[] = { + DLANG(CHAT_OPTIONS, CHAT_CLOSED_DISABLED), + lifetimeChoice, + DLANG(CHAT_OPTIONS, CHAT_CLOSED_ALWAYS), + }; + sChatClosedModeSelection = djui_selectionbox_create(&rowClosedMode->base, DLANG(CHAT_OPTIONS, CHAT_CLOSED_MODE), chatClosedModeChoices, 3, &configChatClosedMode, djui_panel_chat_on_closed_mode_change); char* chatSizeChoices[] = { DLANG(CHAT_OPTIONS, CHAT_SIZE_MINIMUM), @@ -334,19 +424,33 @@ void djui_panel_chat_create(struct DjuiBase* caller) { }; (void)chatSizeChoices; + // Checkbox- / Selection-Basis und -Track an Sliderbreite anpassen + if (sCheckboxUseStdChat != NULL) { + djui_base_set_size(&sCheckboxUseStdChat->base, 0.94f, 32.0f); + } + if (sCheckboxCharCounter != NULL) { + djui_base_set_size(&sCheckboxCharCounter->base, 0.94f, 32.0f); + } + if (sChatClosedModeSelection != NULL) { + djui_base_set_size(&sChatClosedModeSelection->base, 0.94f, 32.0f); + if (sChatClosedModeSelection->rect != NULL) { + djui_base_set_size(&sChatClosedModeSelection->rect->base, 0.46f, 1.0f); + } + } + + struct DjuiRect* rowLifetime = djui_rect_container_create(body, 32); struct DjuiRect* rowWidth = djui_rect_container_create(body, 32); struct DjuiRect* rowHeight = djui_rect_container_create(body, 32); struct DjuiRect* rowTextScale = djui_rect_container_create(body, 32); struct DjuiRect* rowBgOpacity = djui_rect_container_create(body, 32); struct DjuiRect* rowTextOpacity= djui_rect_container_create(body, 32); - struct DjuiRect* rowLifetime = djui_rect_container_create(body, 32); + sSliderLifetime = djui_slider_create(&rowLifetime->base, DLANG(CHAT_OPTIONS, CHAT_LIFETIME), &configChatMessageLifetime, 1, 120, djui_panel_chat_on_lifetime_change); sSliderWidth = djui_slider_create(&rowWidth->base, DLANG(CHAT_OPTIONS, CHAT_WIDTH), &configChatWidth, 200, 2000, djui_panel_chat_on_width_slider_change); sSliderHeight = djui_slider_create(&rowHeight->base, DLANG(CHAT_OPTIONS, CHAT_HEIGHT), &configChatHeight, 100, 1000, djui_panel_chat_on_height_slider_change); sSliderTextScale = djui_slider_create(&rowTextScale->base, DLANG(CHAT_OPTIONS, CHAT_TEXT_SCALE), &configChatTextScale, 50, 200, djui_panel_chat_on_style_change); sSliderBgOpacity = djui_slider_create(&rowBgOpacity->base, DLANG(CHAT_OPTIONS, CHAT_BACKGROUND_OPACITY), &configChatBackgroundOpacity, 0, 100, djui_panel_chat_on_style_change); sSliderTextOpacity = djui_slider_create(&rowTextOpacity->base, DLANG(CHAT_OPTIONS, CHAT_TEXT_OPACITY), &configChatTextOpacity, 0, 100, djui_panel_chat_on_style_change); - sSliderLifetime = djui_slider_create(&rowLifetime->base, DLANG(CHAT_OPTIONS, CHAT_LIFETIME), &configChatMessageLifetime, 1, 120, djui_panel_chat_on_lifetime_change); { struct DjuiSlider* slidersForCursor[] = { @@ -429,6 +533,9 @@ void djui_panel_chat_create(struct DjuiBase* caller) { djui_text_set_alignment(sChatLifetimeLabel, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER); djui_text_set_drop_shadow(sChatLifetimeLabel, 64, 64, 64, 100); + sResetUseStdChatButton = djui_button_create(&rowUseStdChat->base, "X", DJUI_BUTTON_STYLE_NORMAL, djui_panel_chat_on_reset_use_std_chat); + sResetCharCounterButton = djui_button_create(&rowCharCounter->base, "X", DJUI_BUTTON_STYLE_NORMAL, djui_panel_chat_on_reset_char_counter); + sResetClosedModeButton = djui_button_create(&rowClosedMode->base, "X", DJUI_BUTTON_STYLE_NORMAL, djui_panel_chat_on_reset_closed_mode); sResetWidthButton = djui_button_create(&rowWidth->base, "X", DJUI_BUTTON_STYLE_NORMAL, djui_panel_chat_on_reset_width); sResetHeightButton = djui_button_create(&rowHeight->base, "X", DJUI_BUTTON_STYLE_NORMAL, djui_panel_chat_on_reset_height); sResetTextScaleButton = djui_button_create(&rowTextScale->base, "X", DJUI_BUTTON_STYLE_NORMAL, djui_panel_chat_on_reset_text_scale); @@ -437,6 +544,9 @@ void djui_panel_chat_create(struct DjuiBase* caller) { sResetLifetimeButton = djui_button_create(&rowLifetime->base, "X", DJUI_BUTTON_STYLE_NORMAL, djui_panel_chat_on_reset_lifetime); struct DjuiButton* buttons[] = { + sResetUseStdChatButton, + sResetCharCounterButton, + sResetClosedModeButton, sResetWidthButton, sResetHeightButton, sResetTextScaleButton, @@ -444,7 +554,7 @@ void djui_panel_chat_create(struct DjuiBase* caller) { sResetTextOpacityButton, sResetLifetimeButton, }; - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 9; i++) { struct DjuiButton* btn = buttons[i]; if (btn == NULL) { continue; } djui_base_set_alignment(&btn->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_CENTER); @@ -453,6 +563,7 @@ void djui_panel_chat_create(struct DjuiBase* caller) { } djui_panel_chat_update_value_labels(); + djui_panel_chat_update_lifetime_slider_enabled(); djui_panel_chat_update_reset_buttons(); djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back); diff --git a/src/pc/djui/djui_selectionbox.c b/src/pc/djui/djui_selectionbox.c index addb888ef..f47c73c9b 100644 --- a/src/pc/djui/djui_selectionbox.c +++ b/src/pc/djui/djui_selectionbox.c @@ -167,3 +167,20 @@ struct DjuiSelectionbox* djui_selectionbox_create(struct DjuiBase* parent, const return selectionbox; } + +void djui_selectionbox_set_choice_text(struct DjuiSelectionbox* selectionbox, u8 index, const char* text) { + if (selectionbox == NULL) { return; } + if (index >= selectionbox->choiceCount) { return; } + + if (selectionbox->choices[index] != NULL) { + free(selectionbox->choices[index]); + } + + u32 length = strlen(text); + selectionbox->choices[index] = calloc(length + 1, sizeof(char)); + sprintf(selectionbox->choices[index], "%s", text); + + if (*selectionbox->value == index && selectionbox->rectText != NULL) { + djui_text_set_text(selectionbox->rectText, selectionbox->choices[index]); + } +} \ No newline at end of file diff --git a/src/pc/djui/djui_selectionbox.h b/src/pc/djui/djui_selectionbox.h index c79e224e6..9cca82cd0 100644 --- a/src/pc/djui/djui_selectionbox.h +++ b/src/pc/djui/djui_selectionbox.h @@ -14,4 +14,5 @@ struct DjuiSelectionbox { }; struct DjuiSelectionbox* djui_selectionbox_create(struct DjuiBase* parent, const char* message, char* choices[], u8 choiceCount, unsigned int* value, void (*on_value_change)(struct DjuiBase*)); -void djui_selectionbox_update_value(struct DjuiBase* base); \ No newline at end of file +void djui_selectionbox_update_value(struct DjuiBase* base); +void djui_selectionbox_set_choice_text(struct DjuiSelectionbox* selectionbox, u8 index, const char* text); \ No newline at end of file