mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
Take FontDesc out of Core.h and remove its Typedef
This commit is contained in:
parent
aac15edbab
commit
12833fdaa5
@ -119,7 +119,6 @@ typedef cc_uint64 TimeMS;
|
|||||||
|
|
||||||
typedef struct Rect2D_ { int X, Y, Width, Height; } Rect2D;
|
typedef struct Rect2D_ { int X, Y, Width, Height; } Rect2D;
|
||||||
typedef struct Size2D_ { int Width, Height; } Size2D;
|
typedef struct Size2D_ { int Width, Height; } Size2D;
|
||||||
typedef struct FontDesc_ { void* Handle; cc_uint16 Size, Style; } FontDesc;
|
|
||||||
typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec;
|
typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec;
|
||||||
|
|
||||||
/*#define CC_BUILD_GL11*/
|
/*#define CC_BUILD_GL11*/
|
||||||
|
@ -19,13 +19,13 @@ BitmapCol Drawer2D_Cols[DRAWER2D_MAX_COLS];
|
|||||||
static char fontNameBuffer[STRING_SIZE];
|
static char fontNameBuffer[STRING_SIZE];
|
||||||
String Drawer2D_FontName = String_FromArray(fontNameBuffer);
|
String Drawer2D_FontName = String_FromArray(fontNameBuffer);
|
||||||
|
|
||||||
void DrawTextArgs_Make(struct DrawTextArgs* args, STRING_REF const String* text, FontDesc* font, bool useShadow) {
|
void DrawTextArgs_Make(struct DrawTextArgs* args, STRING_REF const String* text, struct FontDesc* font, bool useShadow) {
|
||||||
args->text = *text;
|
args->text = *text;
|
||||||
args->font = font;
|
args->font = font;
|
||||||
args->useShadow = useShadow;
|
args->useShadow = useShadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTextArgs_MakeEmpty(struct DrawTextArgs* args, FontDesc* font, bool useShadow) {
|
void DrawTextArgs_MakeEmpty(struct DrawTextArgs* args, struct FontDesc* font, bool useShadow) {
|
||||||
args->text = String_Empty;
|
args->text = String_Empty;
|
||||||
args->font = font;
|
args->font = font;
|
||||||
args->useShadow = useShadow;
|
args->useShadow = useShadow;
|
||||||
@ -47,14 +47,14 @@ static String font_candidates[9] = {
|
|||||||
String_FromConst("Roboto") /* android */
|
String_FromConst("Roboto") /* android */
|
||||||
};
|
};
|
||||||
|
|
||||||
void Drawer2D_MakeFont(FontDesc* desc, int size, int style) {
|
void Drawer2D_MakeFont(struct FontDesc* desc, int size, int style) {
|
||||||
int i;
|
int i;
|
||||||
ReturnCode res;
|
ReturnCode res;
|
||||||
|
|
||||||
if (Drawer2D_BitmappedText) {
|
if (Drawer2D_BitmappedText) {
|
||||||
desc->Handle = NULL;
|
desc->handle = NULL;
|
||||||
desc->Size = size;
|
desc->size = size;
|
||||||
desc->Style = style;
|
desc->style = style;
|
||||||
} else {
|
} else {
|
||||||
font_candidates[0] = Drawer2D_FontName;
|
font_candidates[0] = Drawer2D_FontName;
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ void Drawer2D_SetFontBitmap(Bitmap* bmp) {
|
|||||||
/* Measures width of the given text when drawn with the given system font. */
|
/* Measures width of the given text when drawn with the given system font. */
|
||||||
static int Font_SysTextWidth(struct DrawTextArgs* args);
|
static int Font_SysTextWidth(struct DrawTextArgs* args);
|
||||||
/* Measures height of any text when drawn with the given system font. */
|
/* Measures height of any text when drawn with the given system font. */
|
||||||
static int Font_SysFontHeight(const FontDesc* desc);
|
static int Font_SysFontHeight(const struct FontDesc* desc);
|
||||||
/* Draws the given text with the given system font onto the given bitmap. */
|
/* Draws the given text with the given system font onto the given bitmap. */
|
||||||
static int Font_SysTextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col, bool shadow);
|
static int Font_SysTextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col, bool shadow);
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ static void Drawer2D_DrawCore(Bitmap* bmp, struct DrawTextArgs* args, int x, int
|
|||||||
BitmapCol black = BITMAPCOL_CONST(0, 0, 0, 255);
|
BitmapCol black = BITMAPCOL_CONST(0, 0, 0, 255);
|
||||||
BitmapCol col;
|
BitmapCol col;
|
||||||
String text = args->text;
|
String text = args->text;
|
||||||
int i, point = args->font->Size, count = 0;
|
int i, point = args->font->size, count = 0;
|
||||||
|
|
||||||
int xPadding, yPadding;
|
int xPadding, yPadding;
|
||||||
int srcX, srcY, dstX, dstY;
|
int srcX, srcY, dstX, dstY;
|
||||||
@ -504,7 +504,7 @@ static void Drawer2D_DrawCore(Bitmap* bmp, struct DrawTextArgs* args, int x, int
|
|||||||
x = begX;
|
x = begX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(args->font->Style & FONT_FLAG_UNDERLINE)) return;
|
if (!(args->font->style & FONT_FLAG_UNDERLINE)) return;
|
||||||
/* scale up bottom row of a cell to drawn text font */
|
/* scale up bottom row of a cell to drawn text font */
|
||||||
cellY = (8 - 1) * dstHeight / 8;
|
cellY = (8 - 1) * dstHeight / 8;
|
||||||
underlineY = y + (cellY + yPadding);
|
underlineY = y + (cellY + yPadding);
|
||||||
@ -523,7 +523,7 @@ static void Drawer2D_DrawCore(Bitmap* bmp, struct DrawTextArgs* args, int x, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Drawer2D_DrawBitmapText(Bitmap* bmp, struct DrawTextArgs* args, int x, int y) {
|
static void Drawer2D_DrawBitmapText(Bitmap* bmp, struct DrawTextArgs* args, int x, int y) {
|
||||||
int offset = Drawer2D_ShadowOffset(args->font->Size);
|
int offset = Drawer2D_ShadowOffset(args->font->size);
|
||||||
|
|
||||||
if (args->useShadow) {
|
if (args->useShadow) {
|
||||||
Drawer2D_DrawCore(bmp, args, x + offset, y + offset, true);
|
Drawer2D_DrawCore(bmp, args, x + offset, y + offset, true);
|
||||||
@ -532,7 +532,7 @@ static void Drawer2D_DrawBitmapText(Bitmap* bmp, struct DrawTextArgs* args, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int Drawer2D_MeasureBitmapWidth(const struct DrawTextArgs* args) {
|
static int Drawer2D_MeasureBitmapWidth(const struct DrawTextArgs* args) {
|
||||||
int i, point = args->font->Size;
|
int i, point = args->font->size;
|
||||||
int xPadding, width;
|
int xPadding, width;
|
||||||
String text;
|
String text;
|
||||||
|
|
||||||
@ -608,10 +608,10 @@ int Drawer2D_TextHeight(struct DrawTextArgs* args) {
|
|||||||
return Drawer2D_FontHeight(args->font, args->useShadow);
|
return Drawer2D_FontHeight(args->font, args->useShadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Drawer2D_FontHeight(const FontDesc* font, bool useShadow) {
|
int Drawer2D_FontHeight(const struct FontDesc* font, bool useShadow) {
|
||||||
int height, point;
|
int height, point;
|
||||||
if (Drawer2D_BitmappedText) {
|
if (Drawer2D_BitmappedText) {
|
||||||
point = font->Size;
|
point = font->size;
|
||||||
/* adjust coords to make drawn text match GDI fonts */
|
/* adjust coords to make drawn text match GDI fonts */
|
||||||
height = Drawer2D_AdjHeight(point);
|
height = Drawer2D_AdjHeight(point);
|
||||||
|
|
||||||
@ -991,16 +991,16 @@ String Font_Lookup(const String* fontName, int style) {
|
|||||||
return path.length ? path : Font_LookupOf(fontName, 'R');
|
return path.length ? path : Font_LookupOf(fontName, 'R');
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnCode Font_Make(FontDesc* desc, const String* fontName, int size, int style) {
|
ReturnCode Font_Make(struct FontDesc* desc, const String* fontName, int size, int style) {
|
||||||
struct SysFont* font;
|
struct SysFont* font;
|
||||||
String value, path, index;
|
String value, path, index;
|
||||||
int faceIndex;
|
int faceIndex;
|
||||||
FT_Open_Args args;
|
FT_Open_Args args;
|
||||||
FT_Error err;
|
FT_Error err;
|
||||||
|
|
||||||
desc->Size = size;
|
desc->size = size;
|
||||||
desc->Style = style;
|
desc->style = style;
|
||||||
desc->Handle = NULL;
|
desc->handle = NULL;
|
||||||
|
|
||||||
value = Font_Lookup(fontName, style);
|
value = Font_Lookup(fontName, style);
|
||||||
if (!value.length) return ERR_INVALID_ARGUMENT;
|
if (!value.length) return ERR_INVALID_ARGUMENT;
|
||||||
@ -1009,28 +1009,28 @@ ReturnCode Font_Make(FontDesc* desc, const String* fontName, int size, int style
|
|||||||
|
|
||||||
font = (struct SysFont*)Mem_Alloc(1, sizeof(struct SysFont), "SysFont");
|
font = (struct SysFont*)Mem_Alloc(1, sizeof(struct SysFont), "SysFont");
|
||||||
if ((err = SysFont_Init(&path, font, &args))) { Mem_Free(font); return err; }
|
if ((err = SysFont_Init(&path, font, &args))) { Mem_Free(font); return err; }
|
||||||
desc->Handle = font;
|
desc->handle = font;
|
||||||
|
|
||||||
if ((err = FT_New_Face(ft_lib, &args, faceIndex, &font->face))) return err;
|
if ((err = FT_New_Face(ft_lib, &args, faceIndex, &font->face))) return err;
|
||||||
return FT_Set_Char_Size(font->face, size * 64, 0, Display_DpiX, Display_DpiY);
|
return FT_Set_Char_Size(font->face, size * 64, 0, Display_DpiX, Display_DpiY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font_Free(FontDesc* desc) {
|
void Font_Free(struct FontDesc* desc) {
|
||||||
struct SysFont* font;
|
struct SysFont* font;
|
||||||
desc->Size = 0;
|
desc->size = 0;
|
||||||
desc->Style = 0;
|
desc->style = 0;
|
||||||
/* NULL for fonts created by Drawer2D_MakeFont and bitmapped text mode is on */
|
/* NULL for fonts created by Drawer2D_MakeFont and bitmapped text mode is on */
|
||||||
if (!desc->Handle) return;
|
if (!desc->handle) return;
|
||||||
|
|
||||||
font = (struct SysFont*)desc->Handle;
|
font = (struct SysFont*)desc->handle;
|
||||||
FT_Done_Face(font->face);
|
FT_Done_Face(font->face);
|
||||||
Mem_Free(font);
|
Mem_Free(font);
|
||||||
desc->Handle = NULL;
|
desc->handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEXT_CEIL(x) (((x) + 63) >> 6)
|
#define TEXT_CEIL(x) (((x) + 63) >> 6)
|
||||||
static int Font_SysTextWidth(struct DrawTextArgs* args) {
|
static int Font_SysTextWidth(struct DrawTextArgs* args) {
|
||||||
struct SysFont* font = (struct SysFont*)args->font->Handle;
|
struct SysFont* font = (struct SysFont*)args->font->handle;
|
||||||
FT_Face face = font->face;
|
FT_Face face = font->face;
|
||||||
String text = args->text;
|
String text = args->text;
|
||||||
int i, width = 0, charWidth;
|
int i, width = 0, charWidth;
|
||||||
@ -1058,8 +1058,8 @@ static int Font_SysTextWidth(struct DrawTextArgs* args) {
|
|||||||
return TEXT_CEIL(width);
|
return TEXT_CEIL(width);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Font_SysFontHeight(const FontDesc* desc) {
|
static int Font_SysFontHeight(const struct FontDesc* desc) {
|
||||||
struct SysFont* font = (struct SysFont*)desc->Handle;
|
struct SysFont* font = (struct SysFont*)desc->handle;
|
||||||
FT_Face face = font->face;
|
FT_Face face = font->face;
|
||||||
return TEXT_CEIL(face->size->metrics.height);
|
return TEXT_CEIL(face->size->metrics.height);
|
||||||
}
|
}
|
||||||
@ -1113,7 +1113,7 @@ static void DrawBlackWhiteGlyph(FT_Bitmap* img, Bitmap* bmp, int x, int y, Bitma
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int Font_SysTextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col, bool shadow) {
|
static int Font_SysTextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col, bool shadow) {
|
||||||
struct SysFont* font = (struct SysFont*)args->font->Handle;
|
struct SysFont* font = (struct SysFont*)args->font->handle;
|
||||||
FT_BitmapGlyph* glyphs = font->glyphs;
|
FT_BitmapGlyph* glyphs = font->glyphs;
|
||||||
|
|
||||||
FT_Face face = font->face;
|
FT_Face face = font->face;
|
||||||
@ -1166,7 +1166,7 @@ static int Font_SysTextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y
|
|||||||
x -= glyph->left; y -= offset;
|
x -= glyph->left; y -= offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->font->Style & FONT_FLAG_UNDERLINE) {
|
if (args->font->style & FONT_FLAG_UNDERLINE) {
|
||||||
int ul_pos = FT_MulFix(face->underline_position, face->size->metrics.y_scale);
|
int ul_pos = FT_MulFix(face->underline_position, face->size->metrics.y_scale);
|
||||||
int ul_thick = FT_MulFix(face->underline_thickness, face->size->metrics.y_scale);
|
int ul_thick = FT_MulFix(face->underline_thickness, face->size->metrics.y_scale);
|
||||||
|
|
||||||
|
@ -7,15 +7,16 @@
|
|||||||
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct DrawTextArgs { String text; FontDesc* font; bool useShadow; };
|
struct FontDesc { void* handle; cc_uint16 size, style; };
|
||||||
|
struct DrawTextArgs { String text; struct FontDesc* font; bool useShadow; };
|
||||||
struct Texture;
|
struct Texture;
|
||||||
struct IGameComponent;
|
struct IGameComponent;
|
||||||
extern struct IGameComponent Drawer2D_Component;
|
extern struct IGameComponent Drawer2D_Component;
|
||||||
|
|
||||||
void DrawTextArgs_Make(struct DrawTextArgs* args, STRING_REF const String* text, FontDesc* font, bool useShadow);
|
void DrawTextArgs_Make(struct DrawTextArgs* args, STRING_REF const String* text, struct FontDesc* font, bool useShadow);
|
||||||
void DrawTextArgs_MakeEmpty(struct DrawTextArgs* args, FontDesc* font, bool useShadow);
|
void DrawTextArgs_MakeEmpty(struct DrawTextArgs* args, struct FontDesc* font, bool useShadow);
|
||||||
/* Initialises the given font. When Drawer2D_BitmappedText is false, creates native font handle using Font_Make. */
|
/* Initialises the given font. When Drawer2D_BitmappedText is false, creates native font handle using Font_Make. */
|
||||||
CC_NOINLINE void Drawer2D_MakeFont(FontDesc* desc, int size, int style);
|
CC_NOINLINE void Drawer2D_MakeFont(struct FontDesc* desc, int size, int style);
|
||||||
|
|
||||||
/* Whether text should be drawn and measured using the currently set font bitmap. */
|
/* Whether text should be drawn and measured using the currently set font bitmap. */
|
||||||
/* If false, then text is instead draw using platform/system fonts. */
|
/* If false, then text is instead draw using platform/system fonts. */
|
||||||
@ -72,7 +73,7 @@ CC_API Size2D Drawer2D_MeasureText(struct DrawTextArgs* args);
|
|||||||
/* Similar to Drawer2D_DrawText, but trims the text with trailing ".." if wider than maxWidth. */
|
/* Similar to Drawer2D_DrawText, but trims the text with trailing ".." if wider than maxWidth. */
|
||||||
void Drawer2D_DrawClippedText(Bitmap* bmp, struct DrawTextArgs* args, int x, int y, int maxWidth);
|
void Drawer2D_DrawClippedText(Bitmap* bmp, struct DrawTextArgs* args, int x, int y, int maxWidth);
|
||||||
/* Returns the line height for drawing any character in the font. */
|
/* Returns the line height for drawing any character in the font. */
|
||||||
int Drawer2D_FontHeight(const FontDesc* font, bool useShadow);
|
int Drawer2D_FontHeight(const struct FontDesc* font, bool useShadow);
|
||||||
|
|
||||||
/* Creates a texture consisting only of the given text drawn onto it. */
|
/* Creates a texture consisting only of the given text drawn onto it. */
|
||||||
/* NOTE: The returned texture is always padded up to nearest power of two dimensions. */
|
/* NOTE: The returned texture is always padded up to nearest power of two dimensions. */
|
||||||
@ -103,9 +104,9 @@ void Font_GetNames(StringsBuffer* buffer);
|
|||||||
/* Finds the path and face number of the given system font, with closest matching style */
|
/* Finds the path and face number of the given system font, with closest matching style */
|
||||||
String Font_Lookup(const String* fontName, int style);
|
String Font_Lookup(const String* fontName, int style);
|
||||||
/* Allocates a new system font from the given arguments. */
|
/* Allocates a new system font from the given arguments. */
|
||||||
ReturnCode Font_Make(FontDesc* desc, const String* fontName, int size, int style);
|
ReturnCode Font_Make(struct FontDesc* desc, const String* fontName, int size, int style);
|
||||||
/* Frees an allocated font. */
|
/* Frees an allocated font. */
|
||||||
CC_API void Font_Free(FontDesc* desc);
|
CC_API void Font_Free(struct FontDesc* desc);
|
||||||
/* Attempts to decode one or fonts from the given file. */
|
/* Attempts to decode one or fonts from the given file. */
|
||||||
/* NOTE: If this file has been decoded before (fontscache.txt), does nothing. */
|
/* NOTE: If this file has been decoded before (fontscache.txt), does nothing. */
|
||||||
void SysFonts_Register(const String* path);
|
void SysFonts_Register(const String* path);
|
||||||
|
@ -233,7 +233,7 @@ static void Entity_MakeNameTexture(struct Entity* e) {
|
|||||||
BitmapCol origWhiteCol;
|
BitmapCol origWhiteCol;
|
||||||
|
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
FontDesc font;
|
struct FontDesc font;
|
||||||
bool bitmapped;
|
bool bitmapped;
|
||||||
String name;
|
String name;
|
||||||
Size2D size;
|
Size2D size;
|
||||||
|
@ -290,7 +290,7 @@ void Gui_OnResize(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-------------------------------------------------------TextAtlas---------------------------------------------------------*
|
*-------------------------------------------------------TextAtlas---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void TextAtlas_Make(struct TextAtlas* atlas, const String* chars, const FontDesc* font, const String* prefix) {
|
void TextAtlas_Make(struct TextAtlas* atlas, const String* chars, const struct FontDesc* font, const String* prefix) {
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
Size2D size;
|
Size2D size;
|
||||||
Bitmap bmp;
|
Bitmap bmp;
|
||||||
@ -324,7 +324,7 @@ void TextAtlas_Make(struct TextAtlas* atlas, const String* chars, const FontDesc
|
|||||||
}
|
}
|
||||||
Mem_Free(bmp.Scan0);
|
Mem_Free(bmp.Scan0);
|
||||||
|
|
||||||
Drawer2D_ReducePadding_Tex(&atlas->tex, font->Size, 4);
|
Drawer2D_ReducePadding_Tex(&atlas->tex, font->size, 4);
|
||||||
atlas->uScale = 1.0f / (float)bmp.Width;
|
atlas->uScale = 1.0f / (float)bmp.Width;
|
||||||
atlas->tex.uv.U2 = atlas->offset * atlas->uScale;
|
atlas->tex.uv.U2 = atlas->offset * atlas->uScale;
|
||||||
atlas->tex.Width = atlas->offset;
|
atlas->tex.Width = atlas->offset;
|
||||||
|
@ -16,6 +16,7 @@ enum GuiAnchor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct IGameComponent;
|
struct IGameComponent;
|
||||||
|
struct FontDesc;
|
||||||
struct Widget;
|
struct Widget;
|
||||||
extern struct IGameComponent Gui_Component;
|
extern struct IGameComponent Gui_Component;
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ struct TextAtlas {
|
|||||||
short widths[TEXTATLAS_MAX_WIDTHS];
|
short widths[TEXTATLAS_MAX_WIDTHS];
|
||||||
short offsets[TEXTATLAS_MAX_WIDTHS];
|
short offsets[TEXTATLAS_MAX_WIDTHS];
|
||||||
};
|
};
|
||||||
void TextAtlas_Make(struct TextAtlas* atlas, const String* chars, const FontDesc* font, const String* prefix);
|
void TextAtlas_Make(struct TextAtlas* atlas, const String* chars, const struct FontDesc* font, const String* prefix);
|
||||||
void TextAtlas_Free(struct TextAtlas* atlas);
|
void TextAtlas_Free(struct TextAtlas* atlas);
|
||||||
void TextAtlas_Add(struct TextAtlas* atlas, int charI, VertexP3fT2fC4b** vertices);
|
void TextAtlas_Add(struct TextAtlas* atlas, int charI, VertexP3fT2fC4b** vertices);
|
||||||
void TextAtlas_AddInt(struct TextAtlas* atlas, int value, VertexP3fT2fC4b** vertices);
|
void TextAtlas_AddInt(struct TextAtlas* atlas, int value, VertexP3fT2fC4b** vertices);
|
||||||
|
@ -316,10 +316,8 @@ static bool InputHandler_CheckIsFree(BlockID block) {
|
|||||||
void InputHandler_PickBlocks(bool cooldown, bool left, bool middle, bool right) {
|
void InputHandler_PickBlocks(bool cooldown, bool left, bool middle, bool right) {
|
||||||
TimeMS now = DateTime_CurrentUTC_MS();
|
TimeMS now = DateTime_CurrentUTC_MS();
|
||||||
int delta = (int)(now - input_lastClick);
|
int delta = (int)(now - input_lastClick);
|
||||||
|
|
||||||
IVec3 pos;
|
IVec3 pos;
|
||||||
BlockID old, cur, block;
|
BlockID old, cur, block;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (cooldown && delta < 250) return; /* 4 times per second */
|
if (cooldown && delta < 250) return; /* 4 times per second */
|
||||||
input_lastClick = now;
|
input_lastClick = now;
|
||||||
|
@ -1099,7 +1099,7 @@ static struct ServersScreen {
|
|||||||
struct LButton btnBack, btnConnect, btnRefresh;
|
struct LButton btnBack, btnConnect, btnRefresh;
|
||||||
struct LTable table;
|
struct LTable table;
|
||||||
struct LWidget* _widgets[6];
|
struct LWidget* _widgets[6];
|
||||||
FontDesc rowFont;
|
struct FontDesc rowFont;
|
||||||
float tableAcc;
|
float tableAcc;
|
||||||
} ServersScreen_Instance;
|
} ServersScreen_Instance;
|
||||||
|
|
||||||
|
@ -1089,7 +1089,7 @@ static struct LWidgetVTABLE ltable_VTABLE = {
|
|||||||
LTable_MouseDown, LTable_StopDragging, /* Select */
|
LTable_MouseDown, LTable_StopDragging, /* Select */
|
||||||
LTable_MouseWheel, /* Wheel */
|
LTable_MouseWheel, /* Wheel */
|
||||||
};
|
};
|
||||||
void LTable_Init(struct LTable* w, FontDesc* rowFont) {
|
void LTable_Init(struct LTable* w, struct FontDesc* rowFont) {
|
||||||
int i;
|
int i;
|
||||||
w->VTABLE = <able_VTABLE;
|
w->VTABLE = <able_VTABLE;
|
||||||
w->Columns = tableColumns;
|
w->Columns = tableColumns;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
struct LScreen;
|
struct LScreen;
|
||||||
|
struct FontDesc;
|
||||||
|
|
||||||
struct LWidgetVTABLE {
|
struct LWidgetVTABLE {
|
||||||
/* Called to draw contents of this widget */
|
/* Called to draw contents of this widget */
|
||||||
@ -94,7 +95,7 @@ CC_NOINLINE void LInput_Clear(struct LInput* w);
|
|||||||
/* Represents non-interactable text. */
|
/* Represents non-interactable text. */
|
||||||
struct LLabel {
|
struct LLabel {
|
||||||
LWidget_Layout
|
LWidget_Layout
|
||||||
FontDesc* Font;
|
struct FontDesc* Font;
|
||||||
String Text;
|
String Text;
|
||||||
Size2D _TextSize;
|
Size2D _TextSize;
|
||||||
char _TextBuffer[STRING_SIZE];
|
char _TextBuffer[STRING_SIZE];
|
||||||
@ -149,7 +150,7 @@ struct LTable {
|
|||||||
/* Number of columns in the table. */
|
/* Number of columns in the table. */
|
||||||
int NumColumns;
|
int NumColumns;
|
||||||
/* Fonts for text in rows. */
|
/* Fonts for text in rows. */
|
||||||
FontDesc* RowFont;
|
struct FontDesc* RowFont;
|
||||||
/* Y start and end of rows and height of each row. */
|
/* Y start and end of rows and height of each row. */
|
||||||
int RowsBegY, RowsEndY, RowHeight;
|
int RowsBegY, RowsEndY, RowHeight;
|
||||||
/* Y height of headers. */
|
/* Y height of headers. */
|
||||||
@ -185,7 +186,7 @@ struct LTable {
|
|||||||
|
|
||||||
/* Initialises a table. */
|
/* Initialises a table. */
|
||||||
/* NOTE: Must also call LTable_Reset to make a table actually useful. */
|
/* NOTE: Must also call LTable_Reset to make a table actually useful. */
|
||||||
void LTable_Init(struct LTable* table, FontDesc* rowFont);
|
void LTable_Init(struct LTable* table, struct FontDesc* rowFont);
|
||||||
/* Resets state of a table (reset sorter, filter, etc) */
|
/* Resets state of a table (reset sorter, filter, etc) */
|
||||||
void LTable_Reset(struct LTable* table);
|
void LTable_Reset(struct LTable* table);
|
||||||
/* Adjusts Y position of rows and number of visible rows. */
|
/* Adjusts Y position of rows and number of visible rows. */
|
||||||
|
@ -21,10 +21,10 @@ struct LScreen* Launcher_Screen;
|
|||||||
Rect2D Launcher_Dirty;
|
Rect2D Launcher_Dirty;
|
||||||
Bitmap Launcher_Framebuffer;
|
Bitmap Launcher_Framebuffer;
|
||||||
bool Launcher_ClassicBackground;
|
bool Launcher_ClassicBackground;
|
||||||
FontDesc Launcher_TitleFont, Launcher_TextFont, Launcher_HintFont;
|
struct FontDesc Launcher_TitleFont, Launcher_TextFont, Launcher_HintFont;
|
||||||
|
|
||||||
static bool pendingRedraw;
|
static bool pendingRedraw;
|
||||||
static FontDesc logoFont;
|
static struct FontDesc logoFont;
|
||||||
|
|
||||||
bool Launcher_ShouldExit, Launcher_ShouldUpdate;
|
bool Launcher_ShouldExit, Launcher_ShouldUpdate;
|
||||||
static void Launcher_ApplyUpdate(void);
|
static void Launcher_ApplyUpdate(void);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
struct LScreen;
|
struct LScreen;
|
||||||
|
struct FontDesc;
|
||||||
|
|
||||||
/* Currently active screen/menu. */
|
/* Currently active screen/menu. */
|
||||||
extern struct LScreen* Launcher_Screen;
|
extern struct LScreen* Launcher_Screen;
|
||||||
@ -17,9 +18,9 @@ extern Bitmap Launcher_Framebuffer;
|
|||||||
/* Whether to use stone tile background like minecraft.net. */
|
/* Whether to use stone tile background like minecraft.net. */
|
||||||
extern bool Launcher_ClassicBackground;
|
extern bool Launcher_ClassicBackground;
|
||||||
/* Default font for buttons and labels. */
|
/* Default font for buttons and labels. */
|
||||||
extern FontDesc Launcher_TitleFont, Launcher_TextFont;
|
extern struct FontDesc Launcher_TitleFont, Launcher_TextFont;
|
||||||
/* Default font for input widget hints. */
|
/* Default font for input widget hints. */
|
||||||
extern FontDesc Launcher_HintFont;
|
extern struct FontDesc Launcher_HintFont;
|
||||||
|
|
||||||
/* Whether at the next tick, the launcher window should proceed to stop displaying frames and subsequently exit. */
|
/* Whether at the next tick, the launcher window should proceed to stop displaying frames and subsequently exit. */
|
||||||
extern bool Launcher_ShouldExit;
|
extern bool Launcher_ShouldExit;
|
||||||
|
38
src/Menus.c
38
src/Menus.c
@ -64,8 +64,8 @@ static void Menu_Back(void* s, int i, struct ButtonWidget* btn, Widget_LeftClick
|
|||||||
Menu_Button(s, i, btn, width, onClick, ANCHOR_CENTRE, ANCHOR_MAX, 0, 25);
|
Menu_Button(s, i, btn, width, onClick, ANCHOR_CENTRE, ANCHOR_MAX, 0, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
CC_NOINLINE static void Menu_MakeTitleFont(FontDesc* font) { Drawer2D_MakeFont(font, 16, FONT_STYLE_BOLD); }
|
CC_NOINLINE static void Menu_MakeTitleFont(struct FontDesc* font) { Drawer2D_MakeFont(font, 16, FONT_STYLE_BOLD); }
|
||||||
CC_NOINLINE static void Menu_MakeBodyFont(FontDesc* font) { Drawer2D_MakeFont(font, 16, FONT_STYLE_NORMAL); }
|
CC_NOINLINE static void Menu_MakeBodyFont(struct FontDesc* font) { Drawer2D_MakeFont(font, 16, FONT_STYLE_NORMAL); }
|
||||||
static void Menu_NullFunc(void* screen) { }
|
static void Menu_NullFunc(void* screen) { }
|
||||||
|
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ static struct ListScreen {
|
|||||||
Screen_Layout
|
Screen_Layout
|
||||||
struct ButtonWidget buttons[LIST_SCREEN_ITEMS];
|
struct ButtonWidget buttons[LIST_SCREEN_ITEMS];
|
||||||
struct ButtonWidget left, right, done;
|
struct ButtonWidget left, right, done;
|
||||||
FontDesc font;
|
struct FontDesc font;
|
||||||
float wheelAcc;
|
float wheelAcc;
|
||||||
int currentIndex;
|
int currentIndex;
|
||||||
Widget_LeftClick EntryClick;
|
Widget_LeftClick EntryClick;
|
||||||
@ -476,7 +476,7 @@ static void PauseScreen_CheckHacksAllowed(void* screen) {
|
|||||||
|
|
||||||
static void PauseScreen_ContextRecreated(void* screen) {
|
static void PauseScreen_ContextRecreated(void* screen) {
|
||||||
struct PauseScreen* s = (struct PauseScreen*)screen;
|
struct PauseScreen* s = (struct PauseScreen*)screen;
|
||||||
FontDesc titleFont;
|
struct FontDesc titleFont;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Menu_MakeTitleFont(&titleFont);
|
Menu_MakeTitleFont(&titleFont);
|
||||||
@ -567,7 +567,7 @@ void PauseScreen_Show(void) {
|
|||||||
static struct OptionsGroupScreen {
|
static struct OptionsGroupScreen {
|
||||||
Screen_Layout
|
Screen_Layout
|
||||||
int selectedI;
|
int selectedI;
|
||||||
FontDesc textFont;
|
struct FontDesc textFont;
|
||||||
struct ButtonWidget buttons[7];
|
struct ButtonWidget buttons[7];
|
||||||
struct TextWidget desc;
|
struct TextWidget desc;
|
||||||
struct ButtonWidget done;
|
struct ButtonWidget done;
|
||||||
@ -609,7 +609,7 @@ static void OptionsGroupScreen_ContextLost(void* screen) {
|
|||||||
|
|
||||||
static void OptionsGroupScreen_ContextRecreated(void* screen) {
|
static void OptionsGroupScreen_ContextRecreated(void* screen) {
|
||||||
struct OptionsGroupScreen* s = (struct OptionsGroupScreen*)screen;
|
struct OptionsGroupScreen* s = (struct OptionsGroupScreen*)screen;
|
||||||
FontDesc titleFont;
|
struct FontDesc titleFont;
|
||||||
int i;
|
int i;
|
||||||
Menu_MakeTitleFont(&titleFont);
|
Menu_MakeTitleFont(&titleFont);
|
||||||
Menu_MakeBodyFont(&s->textFont);
|
Menu_MakeBodyFont(&s->textFont);
|
||||||
@ -683,7 +683,7 @@ static struct EditHotkeyScreen {
|
|||||||
struct HotkeyData curHotkey, origHotkey;
|
struct HotkeyData curHotkey, origHotkey;
|
||||||
int selectedI;
|
int selectedI;
|
||||||
bool supressNextPress;
|
bool supressNextPress;
|
||||||
FontDesc titleFont, textFont;
|
struct FontDesc titleFont, textFont;
|
||||||
struct MenuInputWidget input;
|
struct MenuInputWidget input;
|
||||||
struct ButtonWidget buttons[5], cancel;
|
struct ButtonWidget buttons[5], cancel;
|
||||||
} EditHotkeyScreen_Instance;
|
} EditHotkeyScreen_Instance;
|
||||||
@ -903,7 +903,7 @@ void EditHotkeyScreen_Show(struct HotkeyData original) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct GenLevelScreen {
|
static struct GenLevelScreen {
|
||||||
Screen_Layout
|
Screen_Layout
|
||||||
FontDesc textFont;
|
struct FontDesc textFont;
|
||||||
struct ButtonWidget flatgrass, vanilla, cancel;
|
struct ButtonWidget flatgrass, vanilla, cancel;
|
||||||
struct MenuInputWidget* selected;
|
struct MenuInputWidget* selected;
|
||||||
struct MenuInputWidget inputs[4];
|
struct MenuInputWidget inputs[4];
|
||||||
@ -1007,7 +1007,7 @@ static void GenLevelScreen_ContextLost(void* screen) {
|
|||||||
|
|
||||||
static void GenLevelScreen_ContextRecreated(void* screen) {
|
static void GenLevelScreen_ContextRecreated(void* screen) {
|
||||||
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
||||||
FontDesc titleFont;
|
struct FontDesc titleFont;
|
||||||
Menu_MakeTitleFont(&titleFont);
|
Menu_MakeTitleFont(&titleFont);
|
||||||
Menu_MakeBodyFont(&s->textFont);
|
Menu_MakeBodyFont(&s->textFont);
|
||||||
|
|
||||||
@ -1090,7 +1090,7 @@ static void ClassicGenScreen_Make(struct ClassicGenScreen* s, int i, int y, Widg
|
|||||||
|
|
||||||
static void ClassicGenScreen_ContextRecreated(void* screen) {
|
static void ClassicGenScreen_ContextRecreated(void* screen) {
|
||||||
struct ClassicGenScreen* s = (struct ClassicGenScreen*)screen;
|
struct ClassicGenScreen* s = (struct ClassicGenScreen*)screen;
|
||||||
FontDesc titleFont;
|
struct FontDesc titleFont;
|
||||||
|
|
||||||
Menu_MakeTitleFont(&titleFont);
|
Menu_MakeTitleFont(&titleFont);
|
||||||
ButtonWidget_SetConst(&s->buttons[0], "Small", &titleFont);
|
ButtonWidget_SetConst(&s->buttons[0], "Small", &titleFont);
|
||||||
@ -1133,7 +1133,7 @@ void ClassicGenScreen_Show(void) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct SaveLevelScreen {
|
static struct SaveLevelScreen {
|
||||||
Screen_Layout
|
Screen_Layout
|
||||||
FontDesc titleFont, textFont;
|
struct FontDesc titleFont, textFont;
|
||||||
struct ButtonWidget save, schem, cancel;
|
struct ButtonWidget save, schem, cancel;
|
||||||
struct MenuInputWidget input;
|
struct MenuInputWidget input;
|
||||||
struct TextWidget mcEdit, desc;
|
struct TextWidget mcEdit, desc;
|
||||||
@ -1355,7 +1355,7 @@ static void FontListScreen_EntryClick(void* screen, void* widget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void FontListScreen_UpdateEntry(struct ListScreen* s, struct ButtonWidget* button, const String* text) {
|
static void FontListScreen_UpdateEntry(struct ListScreen* s, struct ButtonWidget* button, const String* text) {
|
||||||
FontDesc font;
|
struct FontDesc font;
|
||||||
ReturnCode res;
|
ReturnCode res;
|
||||||
|
|
||||||
if (String_CaselessEqualsConst(text, LIST_SCREEN_EMPTY)) {
|
if (String_CaselessEqualsConst(text, LIST_SCREEN_EMPTY)) {
|
||||||
@ -1519,7 +1519,7 @@ static struct KeyBindingsScreen {
|
|||||||
InitKeyBindings DoInit;
|
InitKeyBindings DoInit;
|
||||||
const char* titleText;
|
const char* titleText;
|
||||||
const char* msgText;
|
const char* msgText;
|
||||||
FontDesc titleFont;
|
struct FontDesc titleFont;
|
||||||
struct TextWidget title, msg;
|
struct TextWidget title, msg;
|
||||||
struct ButtonWidget back, left, right;
|
struct ButtonWidget back, left, right;
|
||||||
struct ButtonWidget buttons[12];
|
struct ButtonWidget buttons[12];
|
||||||
@ -1586,7 +1586,7 @@ static void KeyBindingsScreen_ContextLost(void* screen) {
|
|||||||
|
|
||||||
static void KeyBindingsScreen_ContextRecreated(void* screen) {
|
static void KeyBindingsScreen_ContextRecreated(void* screen) {
|
||||||
struct KeyBindingsScreen* s = (struct KeyBindingsScreen*)screen;
|
struct KeyBindingsScreen* s = (struct KeyBindingsScreen*)screen;
|
||||||
FontDesc textFont;
|
struct FontDesc textFont;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Menu_MakeTitleFont(&s->titleFont);
|
Menu_MakeTitleFont(&s->titleFont);
|
||||||
@ -1778,7 +1778,7 @@ static struct MenuOptionsScreen {
|
|||||||
int activeI, selectedI, descriptionsCount;
|
int activeI, selectedI, descriptionsCount;
|
||||||
InitMenuOptions DoInit, DoRecreateExtra, OnHacksChanged;
|
InitMenuOptions DoInit, DoRecreateExtra, OnHacksChanged;
|
||||||
int numButtons;
|
int numButtons;
|
||||||
FontDesc titleFont, textFont;
|
struct FontDesc titleFont, textFont;
|
||||||
struct ButtonWidget ok, Default;
|
struct ButtonWidget ok, Default;
|
||||||
struct MenuInputWidget input;
|
struct MenuInputWidget input;
|
||||||
struct TextGroupWidget extHelp;
|
struct TextGroupWidget extHelp;
|
||||||
@ -2804,7 +2804,7 @@ static void TexIdsOverlay_ContextRecreated(void* screen) {
|
|||||||
static const String chars = String_FromConst("0123456789");
|
static const String chars = String_FromConst("0123456789");
|
||||||
static const String prefix = String_FromConst("f");
|
static const String prefix = String_FromConst("f");
|
||||||
struct TexIdsOverlay* s = (struct TexIdsOverlay*)screen;
|
struct TexIdsOverlay* s = (struct TexIdsOverlay*)screen;
|
||||||
FontDesc textFont, titleFont;
|
struct FontDesc textFont, titleFont;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
size = Window_Height / ATLAS2D_TILES_PER_ROW;
|
size = Window_Height / ATLAS2D_TILES_PER_ROW;
|
||||||
@ -2965,7 +2965,7 @@ static void UrlWarningOverlay_AppendUrl(void* screen, void* b) {
|
|||||||
|
|
||||||
static void UrlWarningOverlay_ContextRecreated(void* screen) {
|
static void UrlWarningOverlay_ContextRecreated(void* screen) {
|
||||||
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
|
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
|
||||||
FontDesc titleFont, textFont;
|
struct FontDesc titleFont, textFont;
|
||||||
Menu_MakeTitleFont(&titleFont);
|
Menu_MakeTitleFont(&titleFont);
|
||||||
Menu_MakeBodyFont(&textFont);
|
Menu_MakeBodyFont(&textFont);
|
||||||
|
|
||||||
@ -3018,7 +3018,7 @@ static struct TexPackOverlay {
|
|||||||
bool deny, alwaysDeny;
|
bool deny, alwaysDeny;
|
||||||
cc_uint32 contentLength;
|
cc_uint32 contentLength;
|
||||||
String url, identifier;
|
String url, identifier;
|
||||||
FontDesc textFont;
|
struct FontDesc textFont;
|
||||||
struct ButtonWidget buttons[4];
|
struct ButtonWidget buttons[4];
|
||||||
struct TextWidget labels[4];
|
struct TextWidget labels[4];
|
||||||
char _identifierBuffer[STRING_SIZE + 4];
|
char _identifierBuffer[STRING_SIZE + 4];
|
||||||
@ -3101,7 +3101,7 @@ static void TexPackOverlay_ContextLost(void* screen) {
|
|||||||
|
|
||||||
static void TexPackOverlay_ContextRecreated(void* screen) {
|
static void TexPackOverlay_ContextRecreated(void* screen) {
|
||||||
struct TexPackOverlay* s = (struct TexPackOverlay*)screen;
|
struct TexPackOverlay* s = (struct TexPackOverlay*)screen;
|
||||||
FontDesc titleFont;
|
struct FontDesc titleFont;
|
||||||
Menu_MakeTitleFont(&titleFont);
|
Menu_MakeTitleFont(&titleFont);
|
||||||
Menu_MakeBodyFont(&s->textFont);
|
Menu_MakeBodyFont(&s->textFont);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ struct HUDScreen {
|
|||||||
struct HotbarWidget hotbar;
|
struct HotbarWidget hotbar;
|
||||||
/* player list state */
|
/* player list state */
|
||||||
struct PlayerListWidget playerList;
|
struct PlayerListWidget playerList;
|
||||||
FontDesc playerFont;
|
struct FontDesc playerFont;
|
||||||
bool showingList, wasShowingList;
|
bool showingList, wasShowingList;
|
||||||
/* chat state */
|
/* chat state */
|
||||||
int inputOldHeight;
|
int inputOldHeight;
|
||||||
@ -37,7 +37,7 @@ struct HUDScreen {
|
|||||||
bool suppressNextPress;
|
bool suppressNextPress;
|
||||||
int chatIndex;
|
int chatIndex;
|
||||||
int lastDownloadStatus;
|
int lastDownloadStatus;
|
||||||
FontDesc chatFont, announcementFont;
|
struct FontDesc chatFont, announcementFont;
|
||||||
struct TextWidget announcement;
|
struct TextWidget announcement;
|
||||||
struct ChatInputWidget input;
|
struct ChatInputWidget input;
|
||||||
struct TextGroupWidget status, bottomRight, chat, clientStatus;
|
struct TextGroupWidget status, bottomRight, chat, clientStatus;
|
||||||
@ -79,7 +79,7 @@ CC_NOINLINE static bool IsOnlyHudActive(void) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct InventoryScreen {
|
static struct InventoryScreen {
|
||||||
Screen_Layout
|
Screen_Layout
|
||||||
FontDesc font;
|
struct FontDesc font;
|
||||||
struct TableWidget table;
|
struct TableWidget table;
|
||||||
bool releasedInv, deferredSelect;
|
bool releasedInv, deferredSelect;
|
||||||
} InventoryScreen_Instance;
|
} InventoryScreen_Instance;
|
||||||
@ -234,7 +234,7 @@ void InventoryScreen_Show(void) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct StatusScreen {
|
static struct StatusScreen {
|
||||||
Screen_Layout
|
Screen_Layout
|
||||||
FontDesc font;
|
struct FontDesc font;
|
||||||
struct TextWidget line1, line2;
|
struct TextWidget line1, line2;
|
||||||
struct TextAtlas posAtlas;
|
struct TextAtlas posAtlas;
|
||||||
double accumulator;
|
double accumulator;
|
||||||
@ -423,7 +423,7 @@ void StatusScreen_Show(void) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct LoadingScreen {
|
static struct LoadingScreen {
|
||||||
Screen_Layout
|
Screen_Layout
|
||||||
FontDesc font;
|
struct FontDesc font;
|
||||||
float progress;
|
float progress;
|
||||||
|
|
||||||
struct TextWidget title, message;
|
struct TextWidget title, message;
|
||||||
@ -696,7 +696,7 @@ static bool HUDScreen_ChatUpdateFont(struct HUDScreen* s) {
|
|||||||
Math_Clamp(size, 8, 60);
|
Math_Clamp(size, 8, 60);
|
||||||
|
|
||||||
/* don't recreate font if possible */
|
/* don't recreate font if possible */
|
||||||
if (size == s->chatFont.Size) return false;
|
if (size == s->chatFont.size) return false;
|
||||||
HUDScreen_FreeChatFonts(s);
|
HUDScreen_FreeChatFonts(s);
|
||||||
Drawer2D_MakeFont(&s->chatFont, size, FONT_STYLE_NORMAL);
|
Drawer2D_MakeFont(&s->chatFont, size, FONT_STYLE_NORMAL);
|
||||||
|
|
||||||
@ -1243,7 +1243,7 @@ static struct DisconnectScreen {
|
|||||||
int lastSecsLeft;
|
int lastSecsLeft;
|
||||||
struct ButtonWidget reconnect;
|
struct ButtonWidget reconnect;
|
||||||
|
|
||||||
FontDesc titleFont, messageFont;
|
struct FontDesc titleFont, messageFont;
|
||||||
struct TextWidget title, message;
|
struct TextWidget title, message;
|
||||||
char _titleBuffer[STRING_SIZE];
|
char _titleBuffer[STRING_SIZE];
|
||||||
char _messageBuffer[STRING_SIZE];
|
char _messageBuffer[STRING_SIZE];
|
||||||
|
@ -58,7 +58,7 @@ void TextWidget_Make(struct TextWidget* w, cc_uint8 horAnchor, cc_uint8 verAncho
|
|||||||
Widget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
|
Widget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWidget_Set(struct TextWidget* w, const String* text, const FontDesc* font) {
|
void TextWidget_Set(struct TextWidget* w, const String* text, const struct FontDesc* font) {
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
Gfx_DeleteTexture(&w->tex.ID);
|
Gfx_DeleteTexture(&w->tex.ID);
|
||||||
|
|
||||||
@ -71,14 +71,14 @@ void TextWidget_Set(struct TextWidget* w, const String* text, const FontDesc* fo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (w->reducePadding) {
|
if (w->reducePadding) {
|
||||||
Drawer2D_ReducePadding_Tex(&w->tex, font->Size, 4);
|
Drawer2D_ReducePadding_Tex(&w->tex, font->size, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
w->width = w->tex.Width; w->height = w->tex.Height;
|
w->width = w->tex.Width; w->height = w->tex.Height;
|
||||||
Widget_Reposition(w);
|
Widget_Reposition(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWidget_SetConst(struct TextWidget* w, const char* text, const FontDesc* font) {
|
void TextWidget_SetConst(struct TextWidget* w, const char* text, const struct FontDesc* font) {
|
||||||
String str = String_FromReadonly(text);
|
String str = String_FromReadonly(text);
|
||||||
TextWidget_Set(w, &str, font);
|
TextWidget_Set(w, &str, font);
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick on
|
|||||||
Widget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
|
Widget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const FontDesc* font) {
|
void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const struct FontDesc* font) {
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
Gfx_DeleteTexture(&w->tex.ID);
|
Gfx_DeleteTexture(&w->tex.ID);
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const FontDesc
|
|||||||
Widget_Reposition(w);
|
Widget_Reposition(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text, const FontDesc* font) {
|
void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text, const struct FontDesc* font) {
|
||||||
String str = String_FromReadonly(text);
|
String str = String_FromReadonly(text);
|
||||||
ButtonWidget_Set(w, &str, font);
|
ButtonWidget_Set(w, &str, font);
|
||||||
}
|
}
|
||||||
@ -1457,7 +1457,7 @@ void MenuInputWidget_Create(struct MenuInputWidget* w, int width, int height, co
|
|||||||
String_Copy(&w->base.text, text);
|
String_Copy(&w->base.text, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuInputWidget_SetFont(struct MenuInputWidget* w, FontDesc* font) {
|
void MenuInputWidget_SetFont(struct MenuInputWidget* w, struct FontDesc* font) {
|
||||||
w->base.font = font;
|
w->base.font = font;
|
||||||
w->base.lineHeight = Drawer2D_FontHeight(font, false);
|
w->base.lineHeight = Drawer2D_FontHeight(font, false);
|
||||||
InputWidget_UpdateText(&w->base);
|
InputWidget_UpdateText(&w->base);
|
||||||
@ -1717,7 +1717,7 @@ void ChatInputWidget_Create(struct ChatInputWidget* w) {
|
|||||||
String_InitArray(w->origStr, w->_origBuffer);
|
String_InitArray(w->origStr, w->_origBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatInputWidget_SetFont(struct ChatInputWidget* w, FontDesc* font) {
|
void ChatInputWidget_SetFont(struct ChatInputWidget* w, struct FontDesc* font) {
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
DrawTextArgs_Make(&args, &chatInputPrefix, font, true);
|
DrawTextArgs_Make(&args, &chatInputPrefix, font, true);
|
||||||
|
|
||||||
@ -1749,7 +1749,7 @@ static void PlayerListWidget_DrawName(struct Texture* tex, struct PlayerListWidg
|
|||||||
|
|
||||||
DrawTextArgs_Make(&args, &tmp, w->font, !w->classic);
|
DrawTextArgs_Make(&args, &tmp, w->font, !w->classic);
|
||||||
Drawer2D_MakeTextTexture(tex, &args);
|
Drawer2D_MakeTextTexture(tex, &args);
|
||||||
Drawer2D_ReducePadding_Tex(tex, w->font->Size, 3);
|
Drawer2D_ReducePadding_Tex(tex, w->font->size, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PlayerListWidget_HighlightedName(struct PlayerListWidget* w, int x, int y) {
|
static int PlayerListWidget_HighlightedName(struct PlayerListWidget* w, int x, int y) {
|
||||||
@ -2106,7 +2106,7 @@ static const struct WidgetVTABLE PlayerListWidget_VTABLE = {
|
|||||||
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
PlayerListWidget_Reposition
|
PlayerListWidget_Reposition
|
||||||
};
|
};
|
||||||
void PlayerListWidget_Create(struct PlayerListWidget* w, FontDesc* font, bool classic) {
|
void PlayerListWidget_Create(struct PlayerListWidget* w, struct FontDesc* font, bool classic) {
|
||||||
Widget_Reset(w);
|
Widget_Reset(w);
|
||||||
w->VTABLE = &PlayerListWidget_VTABLE;
|
w->VTABLE = &PlayerListWidget_VTABLE;
|
||||||
w->horAnchor = ANCHOR_CENTRE;
|
w->horAnchor = ANCHOR_CENTRE;
|
||||||
@ -2407,9 +2407,9 @@ static void TextGroupWidget_DrawAdvanced(struct TextGroupWidget* w, struct Textu
|
|||||||
ul = (bit.Len & TEXTGROUPWIDGET_URL);
|
ul = (bit.Len & TEXTGROUPWIDGET_URL);
|
||||||
args->text = String_UNSAFE_Substring(text, bit.LineBeg, bit.LineLen);
|
args->text = String_UNSAFE_Substring(text, bit.LineBeg, bit.LineLen);
|
||||||
|
|
||||||
if (ul) args->font->Style |= FONT_FLAG_UNDERLINE;
|
if (ul) args->font->style |= FONT_FLAG_UNDERLINE;
|
||||||
Drawer2D_DrawText(&bmp, args, x, 0);
|
Drawer2D_DrawText(&bmp, args, x, 0);
|
||||||
if (ul) args->font->Style &= ~FONT_FLAG_UNDERLINE;
|
if (ul) args->font->style &= ~FONT_FLAG_UNDERLINE;
|
||||||
|
|
||||||
x += partWidths[i];
|
x += partWidths[i];
|
||||||
}
|
}
|
||||||
@ -2438,7 +2438,7 @@ void TextGroupWidget_Redraw(struct TextGroupWidget* w, int index) {
|
|||||||
} else {
|
} else {
|
||||||
Drawer2D_MakeTextTexture(&tex, &args);
|
Drawer2D_MakeTextTexture(&tex, &args);
|
||||||
}
|
}
|
||||||
Drawer2D_ReducePadding_Tex(&tex, w->font->Size, 3);
|
Drawer2D_ReducePadding_Tex(&tex, w->font->size, 3);
|
||||||
} else {
|
} else {
|
||||||
tex.Height = w->collapsible[index] ? 0 : w->defaultHeight;
|
tex.Height = w->collapsible[index] ? 0 : w->defaultHeight;
|
||||||
}
|
}
|
||||||
@ -2466,11 +2466,11 @@ void TextGroupWidget_RedrawAllWithCol(struct TextGroupWidget* group, char col) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextGroupWidget_SetFont(struct TextGroupWidget* w, FontDesc* font) {
|
void TextGroupWidget_SetFont(struct TextGroupWidget* w, struct FontDesc* font) {
|
||||||
int i, height;
|
int i, height;
|
||||||
|
|
||||||
height = Drawer2D_FontHeight(font, true);
|
height = Drawer2D_FontHeight(font, true);
|
||||||
Drawer2D_ReducePadding_Height(&height, font->Size, 3);
|
Drawer2D_ReducePadding_Height(&height, font->size, 3);
|
||||||
w->defaultHeight = height;
|
w->defaultHeight = height;
|
||||||
|
|
||||||
for (i = 0; i < w->lines; i++) {
|
for (i = 0; i < w->lines; i++) {
|
||||||
@ -2752,7 +2752,7 @@ static const struct WidgetVTABLE SpecialInputWidget_VTABLE = {
|
|||||||
SpecialInputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
SpecialInputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
SpecialInputWidget_Reposition
|
SpecialInputWidget_Reposition
|
||||||
};
|
};
|
||||||
void SpecialInputWidget_Create(struct SpecialInputWidget* w, FontDesc* font, struct InputWidget* target) {
|
void SpecialInputWidget_Create(struct SpecialInputWidget* w, struct FontDesc* font, struct InputWidget* target) {
|
||||||
Widget_Reset(w);
|
Widget_Reset(w);
|
||||||
w->VTABLE = &SpecialInputWidget_VTABLE;
|
w->VTABLE = &SpecialInputWidget_VTABLE;
|
||||||
w->verAnchor = ANCHOR_MAX;
|
w->verAnchor = ANCHOR_MAX;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
/* Contains all 2D widget implementations.
|
/* Contains all 2D widget implementations.
|
||||||
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
|
struct FontDesc;
|
||||||
|
|
||||||
/* A text label. */
|
/* A text label. */
|
||||||
struct TextWidget {
|
struct TextWidget {
|
||||||
@ -19,9 +20,9 @@ struct TextWidget {
|
|||||||
CC_NOINLINE void TextWidget_Make(struct TextWidget* w,
|
CC_NOINLINE void TextWidget_Make(struct TextWidget* w,
|
||||||
cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset);
|
cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset);
|
||||||
/* Draws the given text into a texture, then updates the position and size of this widget. */
|
/* Draws the given text into a texture, then updates the position and size of this widget. */
|
||||||
CC_NOINLINE void TextWidget_Set(struct TextWidget* w, const String* text, const FontDesc* font);
|
CC_NOINLINE void TextWidget_Set(struct TextWidget* w, const String* text, const struct FontDesc* font);
|
||||||
/* Shorthand for TextWidget_Set using String_FromReadonly */
|
/* Shorthand for TextWidget_Set using String_FromReadonly */
|
||||||
CC_NOINLINE void TextWidget_SetConst(struct TextWidget* w, const char* text, const FontDesc* font);
|
CC_NOINLINE void TextWidget_SetConst(struct TextWidget* w, const char* text, const struct FontDesc* font);
|
||||||
|
|
||||||
|
|
||||||
typedef void (*Button_Get)(String* raw);
|
typedef void (*Button_Get)(String* raw);
|
||||||
@ -39,9 +40,9 @@ struct ButtonWidget {
|
|||||||
CC_NOINLINE void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick,
|
CC_NOINLINE void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick,
|
||||||
cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset);
|
cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset);
|
||||||
/* Draws the given text into a texture, then updates the position and size of this widget. */
|
/* Draws the given text into a texture, then updates the position and size of this widget. */
|
||||||
CC_NOINLINE void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const FontDesc* font);
|
CC_NOINLINE void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const struct FontDesc* font);
|
||||||
/* Shorthand for ButtonWidget_Set using String_FromReadonly */
|
/* Shorthand for ButtonWidget_Set using String_FromReadonly */
|
||||||
CC_NOINLINE void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text, const FontDesc* font);
|
CC_NOINLINE void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text, const struct FontDesc* font);
|
||||||
|
|
||||||
/* Clickable and draggable scrollbar. */
|
/* Clickable and draggable scrollbar. */
|
||||||
struct ScrollbarWidget {
|
struct ScrollbarWidget {
|
||||||
@ -72,7 +73,7 @@ struct TableWidget {
|
|||||||
Widget_Layout
|
Widget_Layout
|
||||||
int blocksCount, blocksPerRow, rowsCount;
|
int blocksCount, blocksPerRow, rowsCount;
|
||||||
int lastCreatedIndex;
|
int lastCreatedIndex;
|
||||||
FontDesc* font;
|
struct FontDesc* font;
|
||||||
int selectedIndex, cellSize;
|
int selectedIndex, cellSize;
|
||||||
float selBlockExpand;
|
float selBlockExpand;
|
||||||
GfxResourceID vb;
|
GfxResourceID vb;
|
||||||
@ -98,7 +99,7 @@ CC_NOINLINE void TableWidget_Recreate(struct TableWidget* w);
|
|||||||
#define INPUTWIDGET_LEN STRING_SIZE
|
#define INPUTWIDGET_LEN STRING_SIZE
|
||||||
struct InputWidget {
|
struct InputWidget {
|
||||||
Widget_Layout
|
Widget_Layout
|
||||||
FontDesc* font;
|
struct FontDesc* font;
|
||||||
int (*GetMaxLines)(void);
|
int (*GetMaxLines)(void);
|
||||||
void (*RemakeTexture)(void* elem); /* Remakes the raw texture containing all the chat lines. Also updates dimensions. */
|
void (*RemakeTexture)(void* elem); /* Remakes the raw texture containing all the chat lines. Also updates dimensions. */
|
||||||
void (*OnPressedEnter)(void* elem); /* Invoked when the user presses enter. */
|
void (*OnPressedEnter)(void* elem); /* Invoked when the user presses enter. */
|
||||||
@ -180,7 +181,7 @@ struct MenuInputWidget {
|
|||||||
};
|
};
|
||||||
CC_NOINLINE void MenuInputWidget_Create(struct MenuInputWidget* w, int width, int height, const String* text, struct MenuInputDesc* d);
|
CC_NOINLINE void MenuInputWidget_Create(struct MenuInputWidget* w, int width, int height, const String* text, struct MenuInputDesc* d);
|
||||||
/* Sets the font used, then redraws the input widget. */
|
/* Sets the font used, then redraws the input widget. */
|
||||||
CC_NOINLINE void MenuInputWidget_SetFont(struct MenuInputWidget* w, FontDesc* font);
|
CC_NOINLINE void MenuInputWidget_SetFont(struct MenuInputWidget* w, struct FontDesc* font);
|
||||||
|
|
||||||
|
|
||||||
struct ChatInputWidget {
|
struct ChatInputWidget {
|
||||||
@ -192,7 +193,7 @@ struct ChatInputWidget {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CC_NOINLINE void ChatInputWidget_Create(struct ChatInputWidget* w);
|
CC_NOINLINE void ChatInputWidget_Create(struct ChatInputWidget* w);
|
||||||
CC_NOINLINE void ChatInputWidget_SetFont(struct ChatInputWidget* w, FontDesc* font);
|
CC_NOINLINE void ChatInputWidget_SetFont(struct ChatInputWidget* w, struct FontDesc* font);
|
||||||
|
|
||||||
|
|
||||||
/* Retrieves the text for the i'th line in the group */
|
/* Retrieves the text for the i'th line in the group */
|
||||||
@ -204,7 +205,7 @@ typedef String (*TextGroupWidget_Get)(void* obj, int i);
|
|||||||
struct TextGroupWidget {
|
struct TextGroupWidget {
|
||||||
Widget_Layout
|
Widget_Layout
|
||||||
int lines, defaultHeight;
|
int lines, defaultHeight;
|
||||||
FontDesc* font;
|
struct FontDesc* font;
|
||||||
/* Whether a line has zero height when that line has no text in it. */
|
/* Whether a line has zero height when that line has no text in it. */
|
||||||
bool collapsible[TEXTGROUPWIDGET_MAX_LINES];
|
bool collapsible[TEXTGROUPWIDGET_MAX_LINES];
|
||||||
bool underlineUrls;
|
bool underlineUrls;
|
||||||
@ -214,7 +215,7 @@ struct TextGroupWidget {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CC_NOINLINE void TextGroupWidget_Create(struct TextGroupWidget* w, int lines, struct Texture* textures, TextGroupWidget_Get getLine);
|
CC_NOINLINE void TextGroupWidget_Create(struct TextGroupWidget* w, int lines, struct Texture* textures, TextGroupWidget_Get getLine);
|
||||||
CC_NOINLINE void TextGroupWidget_SetFont(struct TextGroupWidget* w, FontDesc* font);
|
CC_NOINLINE void TextGroupWidget_SetFont(struct TextGroupWidget* w, struct FontDesc* font);
|
||||||
/* Deletes first line, then moves all other lines upwards, then redraws last line. */
|
/* Deletes first line, then moves all other lines upwards, then redraws last line. */
|
||||||
/* NOTE: GetLine must also adjust the lines it returns for this to behave properly. */
|
/* NOTE: GetLine must also adjust the lines it returns for this to behave properly. */
|
||||||
CC_NOINLINE void TextGroupWidget_ShiftUp(struct TextGroupWidget* w);
|
CC_NOINLINE void TextGroupWidget_ShiftUp(struct TextGroupWidget* w);
|
||||||
@ -238,7 +239,7 @@ static String TextGroupWidget_UNSAFE_Get(struct TextGroupWidget* w, int i) { ret
|
|||||||
|
|
||||||
struct PlayerListWidget {
|
struct PlayerListWidget {
|
||||||
Widget_Layout
|
Widget_Layout
|
||||||
FontDesc* font;
|
struct FontDesc* font;
|
||||||
int namesCount, elementOffset;
|
int namesCount, elementOffset;
|
||||||
int xMin, xMax, yHeight;
|
int xMin, xMax, yHeight;
|
||||||
bool classic;
|
bool classic;
|
||||||
@ -246,7 +247,7 @@ struct PlayerListWidget {
|
|||||||
cc_uint16 ids[TABLIST_MAX_NAMES * 2];
|
cc_uint16 ids[TABLIST_MAX_NAMES * 2];
|
||||||
struct Texture textures[TABLIST_MAX_NAMES * 2];
|
struct Texture textures[TABLIST_MAX_NAMES * 2];
|
||||||
};
|
};
|
||||||
CC_NOINLINE void PlayerListWidget_Create(struct PlayerListWidget* w, FontDesc* font, bool classic);
|
CC_NOINLINE void PlayerListWidget_Create(struct PlayerListWidget* w, struct FontDesc* font, bool classic);
|
||||||
CC_NOINLINE void PlayerListWidget_GetNameUnder(struct PlayerListWidget* w, int mouseX, int mouseY, String* name);
|
CC_NOINLINE void PlayerListWidget_GetNameUnder(struct PlayerListWidget* w, int mouseX, int mouseY, String* name);
|
||||||
|
|
||||||
|
|
||||||
@ -263,14 +264,14 @@ struct SpecialInputWidget {
|
|||||||
bool pendingRedraw;
|
bool pendingRedraw;
|
||||||
struct InputWidget* target;
|
struct InputWidget* target;
|
||||||
struct Texture tex;
|
struct Texture tex;
|
||||||
FontDesc* font;
|
struct FontDesc* font;
|
||||||
int titleHeight;
|
int titleHeight;
|
||||||
struct SpecialInputTab tabs[5];
|
struct SpecialInputTab tabs[5];
|
||||||
String colString;
|
String colString;
|
||||||
char _colBuffer[DRAWER2D_MAX_COLS * 4];
|
char _colBuffer[DRAWER2D_MAX_COLS * 4];
|
||||||
};
|
};
|
||||||
|
|
||||||
CC_NOINLINE void SpecialInputWidget_Create(struct SpecialInputWidget* w, FontDesc* font, struct InputWidget* target);
|
CC_NOINLINE void SpecialInputWidget_Create(struct SpecialInputWidget* w, struct FontDesc* font, struct InputWidget* target);
|
||||||
CC_NOINLINE void SpecialInputWidget_Redraw(struct SpecialInputWidget* w);
|
CC_NOINLINE void SpecialInputWidget_Redraw(struct SpecialInputWidget* w);
|
||||||
CC_NOINLINE void SpecialInputWidget_UpdateCols(struct SpecialInputWidget* w);
|
CC_NOINLINE void SpecialInputWidget_UpdateCols(struct SpecialInputWidget* w);
|
||||||
CC_NOINLINE void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, bool active);
|
CC_NOINLINE void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, bool active);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user