void displayPage(int page_number, int table_width, int table_height) { //Would be nice to have an abstract GUI utility for doing this kind of stuff. int row = 0; int col = 0; int field_width = (int)(Screen.width * .40f); int field_height = 50; int per_page = (table_width / field_width) * (table_height / field_height); int page_max = per_page * page_number; int height_so_far = 0; for (int i = page_max - per_page; i < Mathf.Min(badgeStore.Size(), page_max); i++) { int x = col * field_width; int y = row * field_height; icon_style.normal.background = badgeStore.icon(i); GUI.Box(new Rect(x, y, 50, 50), "", icon_style); if (badgeStore.path(i).Contains("incomplete")) { label_style.normal.textColor = Color.gray; } else { label_style.normal.textColor = Color.black; } GUI.Label(new Rect(x + 55, y, Screen.width * .40f - 50, 50), badgeStore.label(i), label_style); height_so_far += field_height; row++; if (height_so_far > table_height) { row = 0; col++; height_so_far = 0; } } }
void displayPage(int page_number, int table_width, int table_height) { //Would be nice to have an abstract GUI utility for doing this kind of stuff. int row = 0; int col = 0; int field_width = (int)(Screen.width * .40f); int field_height = 50; int per_page = columnHeights[page_number - 1]; //(table_width / field_width) * (table_height / field_height); int page_max = 0; //columnHeights.Take(page_number).Sum(); //per_page; // * page_number; for (int i = 0; i < page_number - 1; i++) { page_max += columnHeights[i]; } int height_so_far = 0; for (int i = page_max /*- per_page*/; i < Mathf.Min(badgeStore.Size(), page_max + per_page); i++) { int x = col * field_width; int y = row * field_height; icon_style.normal.background = badgeStore.icon(i); GUI.Box(new Rect(x, y, 50, 50), "", icon_style); if (badgeStore.path(i).Contains("incomplete")) { label_style.normal.textColor = Color.gray; } else { label_style.normal.textColor = Color.black; } // make the name a button if ((badgeStore.Get(i)).buttonUnlockable && !unlockPopup) { if (GUI.Button(new Rect(x + 55, y, Screen.width * .40f - 50, 50), badgeStore.label(i), label_style)) { unlockPopup = true; unlockName = badgeStore.name(i); Debug.Log(unlockName + " clicked"); } } else { GUI.Label(new Rect(x + 55, y, Screen.width * .40f - 50, 50), badgeStore.label(i), label_style); } height_so_far += field_height; row++; if (height_so_far > table_height) { row = 0; col++; height_so_far = 0; } } }