/// <summary> /// Adds the list to the gump. Called "commit", since no further operations on the list will have any effect. /// </summary> internal void CommitList() { DebugWrite("CommitList called."); IEnumerator ie = listEntries.GetEnumerator(); int loc = 0; int count = 0; int pageID = 1; int heightsum = topbar == null ? 0 : topbar.Height + sk.ListEntrySpacer; int widthsum = topbar == null && style == "icons" ? 0 : topbar.Width + sk.ListEntrySpacer; DebugWrite("Topbar: " + topbar + " heightsum: " + heightsum); //SetupPage(title, true, false, 1); while (ie.MoveNext()) { bool first = loc < numperpage; bool last = loc > (listEntries.Count - numperpage - (topbar != null?1:0)); DebugWrite("First: " + first + " Last: " + last); DebugWrite("Current loc: " + loc + " numperpage: " + numperpage + " Mod: " + loc % numperpage); if (loc % numperpage == 0 && count < listEntries.Count - 1) { SetupPage(title, first, last, pageID); loc++; pageID++; heightsum = topbar == null ? 0 : topbar.Height + sk.ListEntrySpacer; widthsum = topbar == null && style == "icons" ? 0 : topbar.Width + sk.ListEntrySpacer; } GumpListEntry gle = (GumpListEntry)((KeyValuePair <int, GumpListEntry>)ie.Current).Value; if (gle != topbar) { switch (style) { case "details": gle.Y = Y + heightsum; //sk.ListStartY + gle.X = X; //sk.ListStartX + gle.AppendTo(page); heightsum += sk.ListEntrySpacer + gle.Height; break; case "icons": gle.Y = Y + heightsum; //+sk.ListStartY gle.X = X + widthsum; //sk.ListStartX + gle.AppendTo(page); heightsum += sk.ListEntrySpacer + gle.Height; widthsum += sk.ListEntrySpacer + gle.Width; break; } loc++; count++; } } }
/// <summary> /// Sets up a new page for the GumpList to add items to. /// </summary> /// <param name="title">The title of the page.</param> /// <param name="first">Determines if actions for the first page should be taken.</param> /// <param name="last">Determines if actions for the last page should be taken.</param> /// <param name="pg">The page number of this page.</param> private void SetupPage(string title, bool first, bool last, int pg) { if (topbar != null) { topbar.X = X; //+sk.ListStartX; topbar.Y = Y; //+sk.ListStartY; topbar.AppendTo(page); } ButtonInfo ListPrevButton = sk.ButtonInfo["ListPrevButton"]; ButtonInfo ListNextButton = sk.ButtonInfo["ListNextButton"]; //ButtonInfo inf2 = sk.ButtonInfo["ListDoneButton"]; page.AddPage(pg); page.AddLabel(sk.ListTitleX, sk.ListTitleY, sk.ListTitleHue, title); DebugWrite("Page: " + pg); if (!first) { DebugWrite("Adding previous button: " + (pg - 1)); if (ListPrevButton.bgID != 0) { this.AddSuperButton(X + ListPrevButton.X, Y + ListPrevButton.Y, ListPrevButton.H, ListPrevButton.W, ListPrevButton.bgID, sk.ListUnderButtonN, sk.ListUnderButtonP, ListPrevButton.text, GumpButtonType.Page, 0, pg - 1); } else { page.AddButton(ListPrevButton.X, ListPrevButton.Y, ListPrevButton.up, ListPrevButton.down, 1, GumpButtonType.Page, pg - 1); } } if (!last) { DebugWrite("Adding next button: " + (pg + 1)); if (ListNextButton.bgID != 0) { this.AddSuperButton(X + ListNextButton.X, Y + ListNextButton.Y, ListNextButton.H, ListNextButton.W, ListNextButton.bgID, sk.ListUnderButtonN, sk.ListUnderButtonP, ListNextButton.text, GumpButtonType.Page, 0, pg + 1); } else { page.AddButton(ListNextButton.X, ListNextButton.Y, ListNextButton.up, ListNextButton.down, 1, GumpButtonType.Page, pg + 1); } } //AddSuperButton(inf2.X, inf2.Y, inf2.H, inf2.W, inf2.bgID, sk.EntryButtonUnderlay, sk.EntryButtonUnderlay, inf2.text, GumpButtonType.Reply, 1, 0); }