/// <summary> /// Newest item is on top. /// </summary> /// <param name="fontName">The name of the font to use when drawing.</param> public void updateItemsToDraw() { // First clear the list of Labels itemsToDraw.clear(); // Check every single slot of the inventory for (int i = contentList.Count - 1; i >= 0; --i) { // This is the current inventory slot. InventorySlot slot = contentList[i]; // If there are no items in this slot... if (slot.StackSize <= 0) { // ... remove it, and continue contentList.RemoveAt(i); continue; } // Hey, we now know there ARE items in here. Let's make sure the GuiList knows about them. itemsToDraw.addLabel(slot.ToLabel(fontName)); } }
/// <summary> /// Prints a Unit's information on the screen, or makes the information labels disappear if there is no Unit. /// </summary> /// <param name="a">The Army of which the information should be printed.</param> public void PrintArmyInfo(Army a) { // No Army? Make the info disappear :o if (a == null) { listArmySoldiers.Visible = false; return; } // Hey, we have an army to print :) listArmySoldiers.Visible = true; listArmySoldiers.clear(); foreach (string soldierType in a.UnitsAndCounts.Keys) { // Create the label to add to the list StringBuilder sb = new StringBuilder(); sb.Append(soldierType); sb.Append(": "); sb.Append(a.UnitsAndCounts[soldierType]); // Add this label to the list listArmySoldiers.addLabel(GuiLabel.createNewLabel(new Vector2(), sb.ToString(), "font")); } }