mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 00:56:40 -04:00
Merge pull request #1155 from ClassiCube/ChatScaleImprovements
Chat scale improvements
This commit is contained in:
commit
02d35e96c8
@ -58,7 +58,8 @@ float Gui_GetInventoryScale(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float Gui_GetChatScale(void) {
|
float Gui_GetChatScale(void) {
|
||||||
return Gui_Scale(GetWindowScale() * Gui.RawChatScale);
|
if (Gui.AutoScaleChat) return Gui_Scale(GetWindowScale() * Gui.RawChatScale);
|
||||||
|
return Gui.RawChatScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui_MakeTitleFont(struct FontDesc* font) { Font_Make(font, 16, FONT_FLAGS_BOLD); }
|
void Gui_MakeTitleFont(struct FontDesc* font) { Font_Make(font, 16, FONT_FLAGS_BOLD); }
|
||||||
@ -119,6 +120,8 @@ static void LoadOptions(void) {
|
|||||||
Gui.RawHotbarScale = Options_GetFloat(OPT_HOTBAR_SCALE, 0.25f, 5.0f, 1.0f);
|
Gui.RawHotbarScale = Options_GetFloat(OPT_HOTBAR_SCALE, 0.25f, 5.0f, 1.0f);
|
||||||
Gui.RawChatScale = Options_GetFloat(OPT_CHAT_SCALE, 0.25f, 5.0f, 1.0f);
|
Gui.RawChatScale = Options_GetFloat(OPT_CHAT_SCALE, 0.25f, 5.0f, 1.0f);
|
||||||
Gui.RawTouchScale = Options_GetFloat(OPT_TOUCH_SCALE, 0.25f, 5.0f, 1.0f);
|
Gui.RawTouchScale = Options_GetFloat(OPT_TOUCH_SCALE, 0.25f, 5.0f, 1.0f);
|
||||||
|
|
||||||
|
Gui.AutoScaleChat = Options_GetBool(OPT_CHAT_AUTO_SCALE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoseAllScreens(void) {
|
static void LoseAllScreens(void) {
|
||||||
|
@ -50,6 +50,8 @@ CC_VAR extern struct _GuiData {
|
|||||||
float RawTouchScale;
|
float RawTouchScale;
|
||||||
/* The highest priority screen that has grabbed input. */
|
/* The highest priority screen that has grabbed input. */
|
||||||
struct Screen* InputGrab;
|
struct Screen* InputGrab;
|
||||||
|
/* Whether chat automatically scales based on window size. */
|
||||||
|
cc_bool AutoScaleChat;
|
||||||
/* Whether the touch UI is currently being displayed */
|
/* Whether the touch UI is currently being displayed */
|
||||||
cc_bool TouchUI;
|
cc_bool TouchUI;
|
||||||
} Gui;
|
} Gui;
|
||||||
|
17
src/Menus.c
17
src/Menus.c
@ -2995,6 +2995,12 @@ static void ChatOptionsScreen_SetScale(const cc_string* v, float* target, const
|
|||||||
Gui_LayoutAll();
|
Gui_LayoutAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ChatOptionsScreen_GetAutoScaleChat(cc_string* v) { Menu_GetBool(v, Gui.AutoScaleChat); }
|
||||||
|
static void ChatOptionsScreen_SetAutoScaleChat(const cc_string* v) {
|
||||||
|
Gui.AutoScaleChat = Menu_SetBool(v, OPT_CHAT_AUTO_SCALE);
|
||||||
|
Gui_LayoutAll();
|
||||||
|
}
|
||||||
|
|
||||||
static void ChatOptionsScreen_GetChatScale(cc_string* v) { String_AppendFloat(v, Gui.RawChatScale, 1); }
|
static void ChatOptionsScreen_GetChatScale(cc_string* v) { String_AppendFloat(v, Gui.RawChatScale, 1); }
|
||||||
static void ChatOptionsScreen_SetChatScale(const cc_string* v) { ChatOptionsScreen_SetScale(v, &Gui.RawChatScale, OPT_CHAT_SCALE); }
|
static void ChatOptionsScreen_SetChatScale(const cc_string* v) { ChatOptionsScreen_SetScale(v, &Gui.RawChatScale, OPT_CHAT_SCALE); }
|
||||||
|
|
||||||
@ -3024,16 +3030,19 @@ static void ChatOptionsScreen_InitWidgets(struct MenuOptionsScreen* s) {
|
|||||||
{ 1, 0, "Log to disk", MenuOptionsScreen_Bool,
|
{ 1, 0, "Log to disk", MenuOptionsScreen_Bool,
|
||||||
ChatOptionsScreen_GetLogging, ChatOptionsScreen_SetLogging },
|
ChatOptionsScreen_GetLogging, ChatOptionsScreen_SetLogging },
|
||||||
{ 1, 50, "Clickable chat", MenuOptionsScreen_Bool,
|
{ 1, 50, "Clickable chat", MenuOptionsScreen_Bool,
|
||||||
ChatOptionsScreen_GetClickable, ChatOptionsScreen_SetClickable }
|
ChatOptionsScreen_GetClickable, ChatOptionsScreen_SetClickable },
|
||||||
|
|
||||||
|
{ -1,-50, "Scale with window", MenuOptionsScreen_Bool,
|
||||||
|
ChatOptionsScreen_GetAutoScaleChat, ChatOptionsScreen_SetAutoScaleChat }
|
||||||
};
|
};
|
||||||
|
|
||||||
s->numCore = 4;
|
s->numCore = 5;
|
||||||
s->maxVertices += 4 * BUTTONWIDGET_MAX;
|
s->maxVertices += 5 * BUTTONWIDGET_MAX;
|
||||||
MenuOptionsScreen_InitButtons(s, buttons, Array_Elems(buttons), Menu_SwitchOptions);
|
MenuOptionsScreen_InitButtons(s, buttons, Array_Elems(buttons), Menu_SwitchOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatOptionsScreen_Show(void) {
|
void ChatOptionsScreen_Show(void) {
|
||||||
static struct MenuInputDesc descs[5];
|
static struct MenuInputDesc descs[6];
|
||||||
MenuInput_Float(descs[0], 0.25f, 4.00f, 1);
|
MenuInput_Float(descs[0], 0.25f, 4.00f, 1);
|
||||||
MenuInput_Int(descs[1], 0, 30, Gui.DefaultLines);
|
MenuInput_Int(descs[1], 0, 30, Gui.DefaultLines);
|
||||||
MenuOptionsScreen_Show(descs, ChatOptionsScreen_InitWidgets);
|
MenuOptionsScreen_Show(descs, ChatOptionsScreen_InitWidgets);
|
||||||
|
@ -48,6 +48,7 @@ Copyright 2014-2023 ClassiCube | Licensed under BSD-3
|
|||||||
#define OPT_HOTBAR_SCALE "gui-hotbarscale"
|
#define OPT_HOTBAR_SCALE "gui-hotbarscale"
|
||||||
#define OPT_INVENTORY_SCALE "gui-inventoryscale"
|
#define OPT_INVENTORY_SCALE "gui-inventoryscale"
|
||||||
#define OPT_CHAT_SCALE "gui-chatscale"
|
#define OPT_CHAT_SCALE "gui-chatscale"
|
||||||
|
#define OPT_CHAT_AUTO_SCALE "gui-autoscalechat"
|
||||||
#define OPT_SHOW_FPS "gui-showfps"
|
#define OPT_SHOW_FPS "gui-showfps"
|
||||||
#define OPT_FONT_NAME "gui-fontname"
|
#define OPT_FONT_NAME "gui-fontname"
|
||||||
#define OPT_BLACK_TEXT "gui-blacktextshadows"
|
#define OPT_BLACK_TEXT "gui-blacktextshadows"
|
||||||
|
@ -943,7 +943,7 @@ static void ChatScreen_FreeChatFonts(struct ChatScreen* s) {
|
|||||||
|
|
||||||
static cc_bool ChatScreen_ChatUpdateFont(struct ChatScreen* s) {
|
static cc_bool ChatScreen_ChatUpdateFont(struct ChatScreen* s) {
|
||||||
int size = (int)(8 * Gui_GetChatScale());
|
int size = (int)(8 * Gui_GetChatScale());
|
||||||
Math_Clamp(size, 8, 60);
|
Math_Clamp(size, 8, 64);
|
||||||
|
|
||||||
/* don't recreate font if possible */
|
/* don't recreate font if possible */
|
||||||
/* TODO: Add function for this, don't use Display_ScaleY (Drawer2D_SameFontSize ??) */
|
/* TODO: Add function for this, don't use Display_ScaleY (Drawer2D_SameFontSize ??) */
|
||||||
@ -952,10 +952,14 @@ static cc_bool ChatScreen_ChatUpdateFont(struct ChatScreen* s) {
|
|||||||
Font_Make(&s->chatFont, size, FONT_FLAGS_PADDING);
|
Font_Make(&s->chatFont, size, FONT_FLAGS_PADDING);
|
||||||
|
|
||||||
size = (int)(16 * Gui_GetChatScale());
|
size = (int)(16 * Gui_GetChatScale());
|
||||||
Math_Clamp(size, 8, 60);
|
Math_Clamp(size, 8, 64);
|
||||||
Font_Make(&s->announcementFont, size, FONT_FLAGS_NONE);
|
Font_Make(&s->announcementFont, size, FONT_FLAGS_NONE);
|
||||||
Font_Make(&s->bigAnnouncementFont, size * 1.33, FONT_FLAGS_NONE);
|
size = (int)(24 * Gui_GetChatScale());
|
||||||
Font_Make(&s->smallAnnouncementFont, size * 0.67, FONT_FLAGS_NONE);
|
Math_Clamp(size, 8, 64);
|
||||||
|
Font_Make(&s->bigAnnouncementFont, size, FONT_FLAGS_NONE);
|
||||||
|
size = (int)(8 * Gui_GetChatScale());
|
||||||
|
Math_Clamp(size, 8, 64);
|
||||||
|
Font_Make(&s->smallAnnouncementFont, size, FONT_FLAGS_NONE);
|
||||||
|
|
||||||
ChatInputWidget_SetFont(&s->input, &s->chatFont);
|
ChatInputWidget_SetFont(&s->input, &s->chatFont);
|
||||||
TextGroupWidget_SetFont(&s->status, &s->chatFont);
|
TextGroupWidget_SetFont(&s->status, &s->chatFont);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user