mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Replace TextGroupWidget_SetUsePlaceHolder with simpler method
This commit is contained in:
parent
467bac486c
commit
addeb72d30
@ -157,8 +157,8 @@ struct TextAtlas {
|
||||
struct Texture tex;
|
||||
int offset, curX;
|
||||
float uScale;
|
||||
int16_t widths[TEXTATLAS_MAX_WIDTHS];
|
||||
int16_t offsets[TEXTATLAS_MAX_WIDTHS];
|
||||
short widths[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_Free(struct TextAtlas* atlas);
|
||||
|
@ -710,8 +710,8 @@ static void HUDScreen_ConstructWidgets(struct HUDScreen* s) {
|
||||
TextGroupWidget_Create(&s->status, CHAT_MAX_STATUS, &s->chatFont,
|
||||
s->statusTextures, HUDScreen_GetStatus);
|
||||
Widget_SetLocation(&s->status, ANCHOR_MAX, ANCHOR_MIN, 0, 0);
|
||||
s->status.placeholderHeight[0] = false; /* Texture pack download status */
|
||||
Elem_Init(&s->status);
|
||||
TextGroupWidget_SetUsePlaceHolder(&s->status, 0, false);
|
||||
|
||||
TextGroupWidget_Create(&s->bottomRight, CHAT_MAX_BOTTOMRIGHT, &s->chatFont,
|
||||
s->bottomRightTextures, HUDScreen_GetBottomRight);
|
||||
|
@ -2174,14 +2174,6 @@ static void TextGroupWidget_UpdateY(struct TextGroupWidget* w) {
|
||||
}
|
||||
}
|
||||
|
||||
void TextGroupWidget_SetUsePlaceHolder(struct TextGroupWidget* w, int index, bool placeHolder) {
|
||||
w->placeholderHeight[index] = placeHolder;
|
||||
if (w->textures[index].ID) return;
|
||||
|
||||
w->textures[index].Height = placeHolder ? w->defaultHeight : 0;
|
||||
TextGroupWidget_UpdateY(w);
|
||||
}
|
||||
|
||||
int TextGroupWidget_UsedHeight(struct TextGroupWidget* w) {
|
||||
struct Texture* textures = w->textures;
|
||||
int i, height = 0;
|
||||
@ -2221,7 +2213,7 @@ static void TextGroupWidget_UpdateDimensions(struct TextGroupWidget* w) {
|
||||
Widget_Reposition(w);
|
||||
}
|
||||
|
||||
struct Portion { int16_t Beg, Len, LineBeg, LineLen; };
|
||||
struct Portion { short Beg, Len, LineBeg, LineLen; };
|
||||
#define TEXTGROUPWIDGET_HTTP_LEN 7 /* length of http:// */
|
||||
#define TEXTGROUPWIDGET_URL 0x8000
|
||||
#define TEXTGROUPWIDGET_PACKED_LEN 0x7FFF
|
||||
@ -2515,8 +2507,7 @@ static void TextGroupWidget_Init(void* widget) {
|
||||
w->defaultHeight = height;
|
||||
|
||||
for (i = 0; i < w->lines; i++) {
|
||||
w->textures[i].Height = height;
|
||||
w->placeholderHeight[i] = true;
|
||||
w->textures[i].Height = w->placeholderHeight[i] ? height : 0;
|
||||
}
|
||||
TextGroupWidget_UpdateDimensions(w);
|
||||
}
|
||||
@ -2548,8 +2539,12 @@ static struct WidgetVTABLE TextGroupWidget_VTABLE = {
|
||||
TextGroupWidget_Reposition
|
||||
};
|
||||
void TextGroupWidget_Create(struct TextGroupWidget* w, int lines, FontDesc* font, struct Texture* textures, TextGroupWidget_Get getLine) {
|
||||
int i;
|
||||
Widget_Reset(w);
|
||||
w->VTABLE = &TextGroupWidget_VTABLE;
|
||||
for (i = 0; i < lines; i++) {
|
||||
w->placeholderHeight[i] = true;
|
||||
}
|
||||
|
||||
w->lines = lines;
|
||||
w->font = font;
|
||||
|
@ -203,6 +203,7 @@ struct TextGroupWidget {
|
||||
Widget_Layout
|
||||
int lines, defaultHeight;
|
||||
FontDesc* font;
|
||||
/* Whether a line has non-zero height when that line has no text in it. */
|
||||
bool placeholderHeight[TEXTGROUPWIDGET_MAX_LINES];
|
||||
bool underlineUrls;
|
||||
struct Texture* textures;
|
||||
@ -211,9 +212,6 @@ struct TextGroupWidget {
|
||||
};
|
||||
|
||||
CC_NOINLINE void TextGroupWidget_Create(struct TextGroupWidget* w, int lines, FontDesc* font, struct Texture* textures, TextGroupWidget_Get getLine);
|
||||
/* Sets whether the given line has non-zero height when that line has no text in it. */
|
||||
/* By default, all lines are placeholder lines. */
|
||||
CC_NOINLINE void TextGroupWidget_SetUsePlaceHolder(struct TextGroupWidget* w, int index, bool placeHolder);
|
||||
/* 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. */
|
||||
CC_NOINLINE void TextGroupWidget_ShiftUp(struct TextGroupWidget* w);
|
||||
|
Loading…
x
Reference in New Issue
Block a user