diff --git a/RP_L4/RPL4FE.cpp b/RP_L4/RPL4FE.cpp index 9f4b40b..78beb10 100644 --- a/RP_L4/RPL4FE.cpp +++ b/RP_L4/RPL4FE.cpp @@ -612,15 +612,18 @@ namespace //--------------------------------------------------------------- // Layout: three columns of lists + the launch button //--------------------------------------------------------------- + // 'first' is the index of the group's own list to start at, so a long + // group can be laid out as several columns; the items stay contiguous + // in fe->items, so the header still draws once, above the first one. void AddGroupItems( FEState *fe, int group, int count, - int x, int *y, int row_h, int width) + int x, int *y, int row_h, int width, int first = 0) { for (int i = 0; i < count; ++i) { FEItem *item = &fe->items[fe->itemCount++]; item->group = group; - item->index = i; + item->index = first + i; item->rect.left = x; item->rect.top = *y; item->rect.right = x + width; @@ -642,8 +645,28 @@ namespace int col1 = client_w / 14; int col2 = col1 + col_w + client_w / 28; int col3 = col2 + col_w + client_w / 28; + int col4 = col3 + col_w + client_w / 28; int top = client_h / 7; + //--------------------------------------------------------------- + // The vehicle list outgrew one column when the promoted resource + // file brought eleven more machines: at 1080p it ran a couple of + // hundred pixels past the bottom of the window. Wrap it over two + // columns rather than shrinking rows below the 18px floor, and + // shift the loadout column (and the buttons that live with it) + // one place right. A roster short enough for one column lays out + // exactly as it always did. + //--------------------------------------------------------------- + int rows_per_col = (client_h - top - 3 * row_h) / row_h; + if (rows_per_col < 1) rows_per_col = 1; + + int vehicle_count = FE_COUNT(kVehicles); + Logical wrap_vehicles = (vehicle_count > rows_per_col); + int vehicle_split = wrap_vehicles + ? (vehicle_count + 1) / 2 // balanced, not filled-then-spilled + : vehicle_count; + int loadout_col = wrap_vehicles ? col4 : col3; + int y = top; AddGroupItems(fe, GroupScenario, FE_COUNT(kScenarios), col1, &y, row_h, col_w); int map_count; @@ -654,27 +677,33 @@ namespace AddGroupItems(fe, GroupLength, FE_COUNT(kLengths), col1, &y, row_h, col_w); y = top; - AddGroupItems(fe, GroupVehicle, FE_COUNT(kVehicles), col2, &y, row_h, col_w); + AddGroupItems(fe, GroupVehicle, vehicle_split, col2, &y, row_h, col_w); + if (wrap_vehicles) + { + y = top; + AddGroupItems(fe, GroupVehicle, vehicle_count - vehicle_split, + col3, &y, row_h, col_w, vehicle_split); + } y = top + 2 * row_h; // leave room for the name edit + header if (IsFootball(fe->selection)) { - AddGroupItems(fe, GroupTeam, FE_COUNT(kTeams), col3, &y, row_h, col_w); - AddGroupItems(fe, GroupPosition, FE_COUNT(kPositions), col3, &y, row_h, col_w); + AddGroupItems(fe, GroupTeam, FE_COUNT(kTeams), loadout_col, &y, row_h, col_w); + AddGroupItems(fe, GroupPosition, FE_COUNT(kPositions), loadout_col, &y, row_h, col_w); } else { - AddGroupItems(fe, GroupColor, FE_COUNT(kColors), col3, &y, row_h, col_w); - AddGroupItems(fe, GroupBadge, FE_COUNT(kBadges), col3, &y, row_h, col_w); + AddGroupItems(fe, GroupColor, FE_COUNT(kColors), loadout_col, &y, row_h, col_w); + AddGroupItems(fe, GroupBadge, FE_COUNT(kBadges), loadout_col, &y, row_h, col_w); } // launch button FEItem *launch = &fe->items[fe->itemCount++]; launch->group = GroupLaunch; launch->index = 0; - launch->rect.left = col3; + launch->rect.left = loadout_col; launch->rect.top = client_h - 3 * row_h; - launch->rect.right = col3 + col_w; + launch->rect.right = loadout_col + col_w; launch->rect.bottom = client_h - row_h; // Steam lobby buttons, offered whenever environ.ini asked for Steam. @@ -684,17 +713,17 @@ namespace FEItem *host = &fe->items[fe->itemCount++]; host->group = GroupSteamHost; host->index = 0; - host->rect.left = col3; + host->rect.left = loadout_col; host->rect.top = client_h - 6 * row_h; - host->rect.right = col3 + col_w; + host->rect.right = loadout_col + col_w; host->rect.bottom = client_h - 5 * row_h; FEItem *join = &fe->items[fe->itemCount++]; join->group = GroupSteamJoin; join->index = 0; - join->rect.left = col3; + join->rect.left = loadout_col; join->rect.top = client_h - (9 * row_h) / 2; - join->rect.right = col3 + col_w; + join->rect.right = loadout_col + col_w; join->rect.bottom = client_h - (7 * row_h) / 2; } @@ -719,7 +748,7 @@ namespace if (fe->nameEdit != NULL) { MoveWindow(fe->nameEdit, - col3, top - row_h / 4, col_w, row_h, TRUE); + loadout_col, top - row_h / 4, col_w, row_h, TRUE); } }