public IList <InventoryPage> GetSharingPages(out bool includesCurrent) { var pages = new List <InventoryPage>(this.Pages.Count); includesCurrent = false; for (int i = 0; i < this.Pages.Count; i++) { InventoryPage page = this.Pages[i]; if (page.IsSharing) { if (i == this.CurrentPageIdx) { includesCurrent = true; } pages.Add(page); } } return(pages); }
public void Load(string lowercaseBookName, TagCompound tags) { string prefix; if (lowercaseBookName == "default") { prefix = ""; } else { prefix = lowercaseBookName + "_"; } if (ExtensibleInventoryMod.Instance.Config.DebugModeReset) { return; } if (!tags.ContainsKey(prefix + "page_count") || !tags.ContainsKey(prefix + "curr_page")) { return; } this.Pages.Clear(); //bool foundSharing = false; int pages = tags.GetInt(prefix + "page_count"); int currPage = tags.GetInt(prefix + "curr_page"); for (int i = 0; i < pages; i++) { InventoryPage page = new InventoryPage(); this.Pages.Add(page); string pageNumKey = prefix + "page_" + i; //foundSharing = tags.ContainsKey( pageNumKey + "_s" ); // //if( foundSharing ) { // page.IsSharing = tags.GetBool( pageNumKey + "_s" ); //} if (i == currPage) { continue; } for (int j = 0; j < InventoryPage.BasePageCapacity; j++) { string pageNumItemNumKey = pageNumKey + "_" + j; if (tags.ContainsKey(pageNumItemNumKey)) { try { page.Items[j] = ItemIO.Load(tags.GetCompound(pageNumItemNumKey)); } catch (Exception e) { string err = "Could not load item for book " + lowercaseBookName + " on page " + i + " at position " + j + "; please report this issue in the forum thread with your .tplr file."; if (ExtensibleInventoryMod.Instance.Config.DebugModeSkipLoadErrors) { LogHelpers.Warn(err); } else { throw new ModHelpersException(err, e); } } } else { page.Items[j] = new Item(); } //if( !foundSharing && tags.ContainsKey( pageNumItemNumKey+"_s" ) ) { // Oops! // foundSharing = true; // page.IsSharing = tags.GetBool( pageNumItemNumKey + "_s" ); //} } } this.CurrentPageIdx = currPage; }
public float GaugeFullness() { return(InventoryPage.GaugeItemSetFullness(this.Items)); }
//////////////// public bool IsEmpty() { return(InventoryPage.IsItemSetEmpty(this.Items)); }