public void RemoveTableCell(ImTableCell tableCell) { tableCells.Remove(tableCell); RemoveChild(tableCell); RefreshHeight(); ArrangeCells(); }
private void ArrangeCells() { ImTableCell doneCell = null; foreach (ImTableCell cell in tableCells) { if (cell.tableCellType == TableCellType.Done) { doneCell = cell; } } if (doneCell != null) { tableCells.Remove(doneCell); tableCells.Add(doneCell); } float yPositionSoFar = height_ / 2f - inset_ / 2f; foreach (ImTableCell tableCell in tableCells) { yPositionSoFar -= tableCell.height; tableCell.y = yPositionSoFar; } }
public void Dismiss() { isShowing = false; this.isVisible = false; for (int i = tableCells.Count - 1; i >= 0; i--) { ImTableCell cell = tableCells[i]; RemoveTableCell(cell); } correspondingEntity = null; }
public void AddTableCell(string centerLabelString, TableCellType type) { ImTableCell tableCell = new ImTableCell("tableCell", 8f, 3f, width_ - inset_, Color.white, type); tableCells.Add(tableCell); tableCell.x = inset_ / 2f - width_ / 2f; tableCell.AddCenterLabel("TwCen", centerLabelString, Color.black, 0.2f); AddChild(tableCell); RefreshHeight(); ArrangeCells(); }
public void AddTableCell(string leftLabelString, string rightSpriteImageName, ImAbstractItem item, TableCellType type) { ImTableCell tableCell = new ImTableCell("tableCell", 8f, 3f, width_ - inset_, Color.white, type); tableCells.Add(tableCell); tableCell.x = inset_ / 2f - width_ / 2f; tableCell.AddLeftLabel("TwCen", leftLabelString, Color.black, 0.2f); tableCell.AddRightSprite(rightSpriteImageName, 1f); tableCell.rightSpriteComponent.sprite.color = Color.blue; tableCell.item = item; AddChild(tableCell); RefreshHeight(); ArrangeCells(); }
public void HandlePopoverNeedsInventoryRefresh(WTPopoverDialogue popover) { ImNode node = (ImNode)popover.correspondingEntity; bool hasTitle = false; bool hasDone = false; foreach (ImTableCell cell in popover.tableCells) { if (cell.tableCellType == TableCellType.Done) { hasDone = true; } if (cell.tableCellType == TableCellType.Title) { hasTitle = true; } } if (!hasTitle) { popover.AddTableCell(ImConfig.NameForNodePlacement(node.nodePlacement), TableCellType.Title); } foreach (ImAbstractItem item in inventory) { ImTableCell cellWithItem = null; foreach (ImTableCell itemCell in popover.tableCells) { if (itemCell.item == item) { cellWithItem = itemCell; } } if (cellWithItem == null && item.CanBeUsedOnEntity(popover.correspondingEntity)) { popover.AddTableCell(item.Description(), "Futile_White", item, TableCellType.Item); } if (cellWithItem != null && !item.CanBeUsedOnEntity(popover.correspondingEntity)) { popover.RemoveTableCell(cellWithItem); } } if (!hasDone) { popover.AddTableCell("Done", TableCellType.Done); } }