mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Added an option to modify the crosshair scale on gui options
This commit is contained in:
parent
6156b71436
commit
cd3002e17e
@ -62,6 +62,11 @@ float Gui_GetChatScale(void) {
|
||||
return Gui.RawChatScale;
|
||||
}
|
||||
|
||||
float Gui_GetCrosshairScale(void) {
|
||||
return Gui_Scale((Window_Main.Height / 480.0f)) * Gui.RawCrosshairScale;
|
||||
}
|
||||
|
||||
|
||||
void Gui_MakeTitleFont(struct FontDesc* font) { Font_Make(font, 16, FONT_FLAGS_BOLD); }
|
||||
void Gui_MakeBodyFont(struct FontDesc* font) { Font_Make(font, 16, FONT_FLAGS_NONE); }
|
||||
|
||||
@ -119,6 +124,7 @@ static void LoadOptions(void) {
|
||||
Gui.RawInventoryScale = Options_GetFloat(OPT_INVENTORY_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.RawCrosshairScale = Options_GetFloat(OPT_CROSSHAIR_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);
|
||||
|
@ -42,7 +42,7 @@ CC_VAR extern struct _GuiData {
|
||||
cc_bool ShowFPS;
|
||||
/* Whether classic-style inventory is used */
|
||||
cc_bool ClassicInventory;
|
||||
float RawHotbarScale, RawChatScale, RawInventoryScale;
|
||||
float RawHotbarScale, RawChatScale, RawInventoryScale, RawCrosshairScale;
|
||||
GfxResourceID GuiTex, GuiClassicTex, IconsTex, TouchTex;
|
||||
int DefaultLines;
|
||||
/* (internal) Bitmask of on-screen buttons, see Input.h */
|
||||
@ -60,6 +60,7 @@ float Gui_Scale(float value);
|
||||
float Gui_GetHotbarScale(void);
|
||||
float Gui_GetInventoryScale(void);
|
||||
float Gui_GetChatScale(void);
|
||||
float Gui_GetCrosshairScale(void);
|
||||
|
||||
CC_NOINLINE void Gui_MakeTitleFont(struct FontDesc* font);
|
||||
CC_NOINLINE void Gui_MakeBodyFont(struct FontDesc* font);
|
||||
|
10
src/Menus.c
10
src/Menus.c
@ -3065,6 +3065,9 @@ static void GuiOptionsScreen_SetHotbar(const cc_string* v) { ChatOptionsScreen_S
|
||||
static void GuiOptionsScreen_GetInventory(cc_string* v) { String_AppendFloat(v, Gui.RawInventoryScale, 1); }
|
||||
static void GuiOptionsScreen_SetInventory(const cc_string* v) { ChatOptionsScreen_SetScale(v, &Gui.RawInventoryScale, OPT_INVENTORY_SCALE); }
|
||||
|
||||
static void GuiOptionsScreen_GetCrosshair(cc_string* v) { String_AppendFloat(v, Gui.RawCrosshairScale, 1); }
|
||||
static void GuiOptionsScreen_SetCrosshair(const cc_string* v) { ChatOptionsScreen_SetScale(v, &Gui.RawCrosshairScale, OPT_CROSSHAIR_SCALE); }
|
||||
|
||||
static void GuiOptionsScreen_GetTabAuto(cc_string* v) { Menu_GetBool(v, Gui.TabAutocomplete); }
|
||||
static void GuiOptionsScreen_SetTabAuto(const cc_string* v) { Gui.TabAutocomplete = Menu_SetBool(v, OPT_TAB_AUTOCOMPLETE); }
|
||||
|
||||
@ -3084,6 +3087,8 @@ static void GuiOptionsScreen_InitWidgets(struct MenuOptionsScreen* s) {
|
||||
GuiOptionsScreen_GetHotbar, GuiOptionsScreen_SetHotbar },
|
||||
{ -1, 50, "Inventory scale", MenuOptionsScreen_Input,
|
||||
GuiOptionsScreen_GetInventory, GuiOptionsScreen_SetInventory },
|
||||
{ -1, 100, "Crosshair scale", MenuOptionsScreen_Input,
|
||||
GuiOptionsScreen_GetCrosshair, GuiOptionsScreen_SetCrosshair },
|
||||
|
||||
{ 1, -50, "Tab auto-complete", MenuOptionsScreen_Bool,
|
||||
GuiOptionsScreen_GetTabAuto, GuiOptionsScreen_SetTabAuto },
|
||||
@ -3093,14 +3098,15 @@ static void GuiOptionsScreen_InitWidgets(struct MenuOptionsScreen* s) {
|
||||
NULL, NULL }
|
||||
};
|
||||
|
||||
s->numCore = 7;
|
||||
s->maxVertices += 7 * BUTTONWIDGET_MAX;
|
||||
s->numCore = 8;
|
||||
s->maxVertices += 8 * BUTTONWIDGET_MAX;
|
||||
MenuOptionsScreen_InitButtons(s, buttons, Array_Elems(buttons), Menu_SwitchOptions);
|
||||
}
|
||||
|
||||
void GuiOptionsScreen_Show(void) {
|
||||
MenuInput_Float(menuOpts_descs[2], 0.25f, 4.00f, 1);
|
||||
MenuInput_Float(menuOpts_descs[3], 0.25f, 4.00f, 1);
|
||||
MenuInput_Float(menuOpts_descs[4], 0.25f, 4.00f, 1);
|
||||
|
||||
MenuOptionsScreen_Show(GuiOptionsScreen_InitWidgets);
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ Copyright 2014-2023 ClassiCube | Licensed under BSD-3
|
||||
#define OPT_INVENTORY_SCALE "gui-inventoryscale"
|
||||
#define OPT_CHAT_SCALE "gui-chatscale"
|
||||
#define OPT_CHAT_AUTO_SCALE "gui-autoscalechat"
|
||||
#define OPT_CROSSHAIR_SCALE "gui-crosshairscale"
|
||||
#define OPT_SHOW_FPS "gui-showfps"
|
||||
#define OPT_FONT_NAME "gui-fontname"
|
||||
#define OPT_BLACK_TEXT "gui-blacktextshadows"
|
||||
|
@ -351,7 +351,7 @@ static void HUDScreen_BuildCrosshairsMesh(struct VertexTextured** ptr) {
|
||||
static struct Texture tex = { 0, Tex_Rect(0,0,0,0), Tex_UV(0.0f,0.0f, 15/256.0f,15/64.0f) };
|
||||
int extent;
|
||||
|
||||
extent = (int)(CH_EXTENT * Gui_Scale(Window_Main.Height / 480.0f));
|
||||
extent = (int)(CH_EXTENT * Gui_GetCrosshairScale());
|
||||
tex.x = (Window_Main.Width / 2) - extent;
|
||||
tex.y = (Window_Main.Height / 2) - extent;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user