mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Fix software column remaining cutoff even at larger window resolution
This commit is contained in:
parent
185f560190
commit
fe9c21d381
@ -733,27 +733,27 @@ void LSlider_Init(struct LScreen* s, struct LSlider* w, int width, int height, B
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------TableWidget--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void FlagColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, int x, int y) {
|
||||
static void FlagColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, struct LTableCell* cell) {
|
||||
struct Bitmap* bmp = Flags_Get(row);
|
||||
if (!bmp) return;
|
||||
Drawer2D_BmpCopy(&Launcher_Framebuffer, x + flagXOffset, y + flagYOffset, bmp);
|
||||
Drawer2D_BmpCopy(&Launcher_Framebuffer, cell->x + flagXOffset, cell->y + flagYOffset, bmp);
|
||||
}
|
||||
|
||||
static void NameColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, int x, int y) {
|
||||
static void NameColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, struct LTableCell* cell) {
|
||||
args->text = row->name;
|
||||
}
|
||||
static int NameColumn_Sort(const struct ServerInfo* a, const struct ServerInfo* b) {
|
||||
return String_Compare(&b->name, &a->name);
|
||||
}
|
||||
|
||||
static void PlayersColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, int x, int y) {
|
||||
static void PlayersColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, struct LTableCell* cell) {
|
||||
String_Format2(&args->text, "%i/%i", &row->players, &row->maxPlayers);
|
||||
}
|
||||
static int PlayersColumn_Sort(const struct ServerInfo* a, const struct ServerInfo* b) {
|
||||
return b->players - a->players;
|
||||
}
|
||||
|
||||
static void UptimeColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, int x, int y) {
|
||||
static void UptimeColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, struct LTableCell* cell) {
|
||||
int uptime = row->uptime;
|
||||
char unit = 's';
|
||||
|
||||
@ -770,7 +770,10 @@ static int UptimeColumn_Sort(const struct ServerInfo* a, const struct ServerInfo
|
||||
return b->uptime - a->uptime;
|
||||
}
|
||||
|
||||
static void SoftwareColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, int x, int y) {
|
||||
static void SoftwareColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, struct LTableCell* cell) {
|
||||
/* last column, so adjust to fit size of table */
|
||||
int leftover = cell->table->width - cell->x;
|
||||
cell->width = max(cell->width, leftover);
|
||||
args->text = row->software;
|
||||
}
|
||||
static int SoftwareColumn_Sort(const struct ServerInfo* a, const struct ServerInfo* b) {
|
||||
@ -935,10 +938,12 @@ static void LTable_DrawRows(struct LTable* w) {
|
||||
cc_string str; char strBuffer[STRING_SIZE];
|
||||
struct ServerInfo* entry;
|
||||
struct DrawTextArgs args;
|
||||
struct LTableCell cell;
|
||||
int i, x, y, row, end;
|
||||
|
||||
String_InitArray(str, strBuffer);
|
||||
DrawTextArgs_Make(&args, &str, w->rowFont, true);
|
||||
cell.table = w;
|
||||
y = w->rowsBegY;
|
||||
end = w->topRow + w->visibleRows;
|
||||
|
||||
@ -950,13 +955,14 @@ static void LTable_DrawRows(struct LTable* w) {
|
||||
entry = LTable_Get(row);
|
||||
|
||||
for (i = 0; i < w->numColumns; i++) {
|
||||
args.text = str;
|
||||
w->columns[i].DrawRow(entry, &args, x, y);
|
||||
args.text = str; cell.x = x; cell.y = y;
|
||||
cell.width = w->columns[i].width;
|
||||
w->columns[i].DrawRow(entry, &args, &cell);
|
||||
|
||||
if (args.text.length) {
|
||||
Drawer2D_DrawClippedText(&Launcher_Framebuffer, &args,
|
||||
x + cellXOffset, y + rowYOffset,
|
||||
w->columns[i].width - cellXPadding);
|
||||
cell.width - cellXPadding);
|
||||
}
|
||||
|
||||
x += w->columns[i].width;
|
||||
|
@ -125,6 +125,7 @@ CC_NOINLINE void LSlider_Init(struct LScreen* s, struct LSlider* w, int width, i
|
||||
|
||||
struct ServerInfo;
|
||||
struct DrawTextArgs;
|
||||
struct LTableCell;
|
||||
|
||||
struct LTableColumn {
|
||||
/* Name of this column. */
|
||||
@ -134,7 +135,7 @@ struct LTableColumn {
|
||||
/* Draws the value of this column for the given row. */
|
||||
/* If args.Text is changed to something, that text gets drawn afterwards. */
|
||||
/* Most of the time that's all you need to do. */
|
||||
void (*DrawRow)(struct ServerInfo* row, struct DrawTextArgs* args, int x, int y);
|
||||
void (*DrawRow)(struct ServerInfo* row, struct DrawTextArgs* args, struct LTableCell* cell);
|
||||
/* Returns sort order of two rows, based on value of this column in both rows. */
|
||||
int (*SortOrder)(const struct ServerInfo* a, const struct ServerInfo* b);
|
||||
/* Whether a vertical gridline (and padding) appears after this. */
|
||||
@ -183,6 +184,8 @@ struct LTable {
|
||||
int _lastRow; /* last clicked row (for doubleclick join) */
|
||||
cc_uint64 _lastClick; /* timestamp of last mouse click on a row */
|
||||
};
|
||||
|
||||
struct LTableCell { struct LTable* table; int x, y, width; };
|
||||
/* Gets the current ith row */
|
||||
#define LTable_Get(row) (&FetchServersTask.servers[FetchServersTask.servers[row]._order])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user