mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
iOS: Avoid loading all system fonts when going to servers menu
This commit is contained in:
parent
47284db214
commit
69b0df4e3f
@ -25,7 +25,7 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
struct FontDesc titleFont, textFont, hintFont, logoFont;
|
struct FontDesc titleFont, textFont, hintFont, logoFont, rowFont;
|
||||||
/* Contains the pixels that are drawn to the window */
|
/* Contains the pixels that are drawn to the window */
|
||||||
static struct Bitmap framebuffer;
|
static struct Bitmap framebuffer;
|
||||||
/* The area/region of the window that needs to be redrawn and presented to the screen. */
|
/* The area/region of the window that needs to be redrawn and presented to the screen. */
|
||||||
@ -85,6 +85,7 @@ void LBackend_Free(void) {
|
|||||||
Font_Free(&textFont);
|
Font_Free(&textFont);
|
||||||
Font_Free(&hintFont);
|
Font_Free(&hintFont);
|
||||||
Font_Free(&logoFont);
|
Font_Free(&logoFont);
|
||||||
|
Font_Free(&rowFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LBackend_UpdateLogoFont(void) {
|
void LBackend_UpdateLogoFont(void) {
|
||||||
@ -706,13 +707,16 @@ void LBackend_SliderDraw(struct LSlider* w) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-------------------------------------------------------TableWidget-------------------------------------------------------*
|
*-------------------------------------------------------TableWidget-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void LBackend_TableInit(struct LTable* w) { }
|
void LBackend_TableInit(struct LTable* w) {
|
||||||
|
if (rowFont.handle) return;
|
||||||
|
Drawer2D_MakeFont(&rowFont, 11, FONT_FLAGS_NONE);
|
||||||
|
}
|
||||||
void LBackend_TableUpdate(struct LTable* w) { }
|
void LBackend_TableUpdate(struct LTable* w) { }
|
||||||
|
|
||||||
void LBackend_TableReposition(struct LTable* w) {
|
void LBackend_TableReposition(struct LTable* w) {
|
||||||
int rowsHeight;
|
int rowsHeight;
|
||||||
w->hdrHeight = Drawer2D_FontHeight(&textFont, true) + hdrYPadding;
|
w->hdrHeight = Drawer2D_FontHeight(&textFont, true) + hdrYPadding;
|
||||||
w->rowHeight = Drawer2D_FontHeight(w->rowFont, true) + rowYPadding;
|
w->rowHeight = Drawer2D_FontHeight(&rowFont, true) + rowYPadding;
|
||||||
|
|
||||||
w->rowsBegY = w->y + w->hdrHeight + gridlineHeight;
|
w->rowsBegY = w->y + w->hdrHeight + gridlineHeight;
|
||||||
w->rowsEndY = w->y + w->height;
|
w->rowsEndY = w->y + w->height;
|
||||||
@ -843,7 +847,7 @@ static void LTable_DrawRows(struct LTable* w) {
|
|||||||
int i, x, y, row, end;
|
int i, x, y, row, end;
|
||||||
|
|
||||||
String_InitArray(str, strBuffer);
|
String_InitArray(str, strBuffer);
|
||||||
DrawTextArgs_Make(&args, &str, w->rowFont, true);
|
DrawTextArgs_Make(&args, &str, &rowFont, true);
|
||||||
cell.table = w;
|
cell.table = w;
|
||||||
y = w->rowsBegY;
|
y = w->rowsBegY;
|
||||||
end = w->topRow + w->visibleRows;
|
end = w->topRow + w->visibleRows;
|
||||||
|
@ -1316,7 +1316,7 @@ static void ServersScreen_Init(struct LScreen* s_) {
|
|||||||
s->iptHash.TextChanged = ServersScreen_HashChanged;
|
s->iptHash.TextChanged = ServersScreen_HashChanged;
|
||||||
s->iptHash.ClipboardFilter = ServersScreen_HashFilter;
|
s->iptHash.ClipboardFilter = ServersScreen_HashFilter;
|
||||||
|
|
||||||
LTable_Init(&s->table, &s->rowFont);
|
LTable_Init(&s->table);
|
||||||
s->table.filter = &s->iptSearch.text;
|
s->table.filter = &s->iptSearch.text;
|
||||||
s->table.selectedHash = &s->iptHash.text;
|
s->table.selectedHash = &s->iptHash.text;
|
||||||
s->table.OnSelectedChanged = ServersScreen_OnSelectedChanged;
|
s->table.OnSelectedChanged = ServersScreen_OnSelectedChanged;
|
||||||
@ -1324,9 +1324,6 @@ static void ServersScreen_Init(struct LScreen* s_) {
|
|||||||
|
|
||||||
static void ServersScreen_Show(struct LScreen* s_) {
|
static void ServersScreen_Show(struct LScreen* s_) {
|
||||||
struct ServersScreen* s = (struct ServersScreen*)s_;
|
struct ServersScreen* s = (struct ServersScreen*)s_;
|
||||||
Drawer2D_MakeFont(&s->rowFont, 11, FONT_FLAGS_NONE);
|
|
||||||
|
|
||||||
s->table.rowFont = &s->rowFont;
|
|
||||||
LTable_Reset(&s->table);
|
LTable_Reset(&s->table);
|
||||||
LInput_ClearText(&s->iptHash);
|
LInput_ClearText(&s->iptHash);
|
||||||
LInput_ClearText(&s->iptSearch);
|
LInput_ClearText(&s->iptSearch);
|
||||||
@ -1360,11 +1357,6 @@ static void ServersScreen_Tick(struct LScreen* s_) {
|
|||||||
FetchServersTask.Base.success ? "Refresh" : "&cFailed");
|
FetchServersTask.Base.success ? "Refresh" : "&cFailed");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ServersScreen_Free(struct LScreen* s_) {
|
|
||||||
struct ServersScreen* s = (struct ServersScreen*)s_;
|
|
||||||
Font_Free(&s->rowFont);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ServersScreen_Layout(struct LScreen* s_) {
|
static void ServersScreen_Layout(struct LScreen* s_) {
|
||||||
struct ServersScreen* s = (struct ServersScreen*)s_;
|
struct ServersScreen* s = (struct ServersScreen*)s_;
|
||||||
LWidget_SetLocation(&s->iptSearch, ANCHOR_MIN, ANCHOR_MIN, 10, 10);
|
LWidget_SetLocation(&s->iptSearch, ANCHOR_MIN, ANCHOR_MIN, 10, 10);
|
||||||
@ -1410,7 +1402,6 @@ void ServersScreen_SetActive(void) {
|
|||||||
s->Init = ServersScreen_Init;
|
s->Init = ServersScreen_Init;
|
||||||
s->Show = ServersScreen_Show;
|
s->Show = ServersScreen_Show;
|
||||||
s->Tick = ServersScreen_Tick;
|
s->Tick = ServersScreen_Tick;
|
||||||
s->Free = ServersScreen_Free;
|
|
||||||
s->Layout = ServersScreen_Layout;
|
s->Layout = ServersScreen_Layout;
|
||||||
s->MouseWheel = ServersScreen_MouseWheel;
|
s->MouseWheel = ServersScreen_MouseWheel;
|
||||||
s->KeyDown = ServersScreen_KeyDown;
|
s->KeyDown = ServersScreen_KeyDown;
|
||||||
|
@ -629,13 +629,12 @@ static const struct LWidgetVTABLE ltable_VTABLE = {
|
|||||||
LTable_MouseDown, LTable_MouseUp, /* Select */
|
LTable_MouseDown, LTable_MouseUp, /* Select */
|
||||||
LTable_MouseWheel, /* Wheel */
|
LTable_MouseWheel, /* Wheel */
|
||||||
};
|
};
|
||||||
void LTable_Init(struct LTable* w, struct FontDesc* rowFont) {
|
void LTable_Init(struct LTable* w) {
|
||||||
int i;
|
int i;
|
||||||
w->VTABLE = <able_VTABLE;
|
w->VTABLE = <able_VTABLE;
|
||||||
w->type = LWIDGET_TABLE;
|
w->type = LWIDGET_TABLE;
|
||||||
w->columns = tableColumns;
|
w->columns = tableColumns;
|
||||||
w->numColumns = Array_Elems(tableColumns);
|
w->numColumns = Array_Elems(tableColumns);
|
||||||
w->rowFont = rowFont;
|
|
||||||
w->sortingCol = -1;
|
w->sortingCol = -1;
|
||||||
w->opaque = true;
|
w->opaque = true;
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ CC_NOINLINE void LLabel_SetConst(struct LLabel* w, const char* text);
|
|||||||
/* Represents a coloured translucent line separator. */
|
/* Represents a coloured translucent line separator. */
|
||||||
struct LLine {
|
struct LLine {
|
||||||
LWidget_Layout
|
LWidget_Layout
|
||||||
|
int _width;
|
||||||
};
|
};
|
||||||
CC_NOINLINE void LLine_Init(struct LLine* w, int width);
|
CC_NOINLINE void LLine_Init(struct LLine* w, int width);
|
||||||
CC_NOINLINE BitmapCol LLine_GetColor(void);
|
CC_NOINLINE BitmapCol LLine_GetColor(void);
|
||||||
@ -130,7 +131,7 @@ CC_NOINLINE BitmapCol LLine_GetColor(void);
|
|||||||
/* Represents a slider bar that may or may not be modifiable by the user. */
|
/* Represents a slider bar that may or may not be modifiable by the user. */
|
||||||
struct LSlider {
|
struct LSlider {
|
||||||
LWidget_Layout
|
LWidget_Layout
|
||||||
int value;
|
int value, _width, _height;
|
||||||
BitmapCol color;
|
BitmapCol color;
|
||||||
};
|
};
|
||||||
CC_NOINLINE void LSlider_Init(struct LSlider* w, int width, int height, BitmapCol color);
|
CC_NOINLINE void LSlider_Init(struct LSlider* w, int width, int height, BitmapCol color);
|
||||||
@ -167,8 +168,6 @@ struct LTable {
|
|||||||
struct LTableColumn* columns;
|
struct LTableColumn* columns;
|
||||||
/* Number of columns in the table. */
|
/* Number of columns in the table. */
|
||||||
int numColumns;
|
int numColumns;
|
||||||
/* Fonts for text in rows. */
|
|
||||||
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. */
|
||||||
@ -205,7 +204,7 @@ struct LTableCell { struct LTable* table; int x, y, width; };
|
|||||||
|
|
||||||
/* 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, struct FontDesc* rowFont);
|
void LTable_Init(struct LTable* table);
|
||||||
/* 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. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user