/// <summary> /// Generates the trade row based on the cached state variables. /// This only needs to be run once. /// </summary> /// <returns>Generated trade row</returns> private Displayable generateTradeRow() { // Create a row to hold everything HorizontalFlexContainer row = new HorizontalFlexContainer(DEFAULT_SPACING); // Create a column to hold the text VerticalFlexContainer textColumn = new VerticalFlexContainer(0f); // Trade with ... label textColumn.Add( new Container( new DynamicTextWidget( textCallback: () => "Phinix_trade_activeTrade_tradeWithLabel".Translate(TextHelper.StripRichText(cachedOtherPartyDisplayName)), anchor: TextAnchor.MiddleLeft ), height: TRADE_WITH_LABEL_HEIGHT ) ); // Accepted state label textColumn.Add( new Container( new DynamicTextWidget( textCallback: () => ("Phinix_trade_activeTrade_theyHave" + (!cachedOtherPartyAccepted ? "Not" : "") + "Accepted").Translate(), font: GameFont.Tiny, anchor: TextAnchor.MiddleLeft ), height: ACCEPTED_STATE_LABEL_HEIGHT ) ); // Add the text column to the row row.Add(textColumn); // Open button row.Add( new Container( new ButtonWidget( label: "Phinix_trade_activeTrade_openButton".Translate(), clickAction: () => Find.WindowStack.Add(new TradeWindow(TradeId)) ), width: BUTTON_WIDTH ) ); // Cancel button row.Add( new Container( new ButtonWidget( label: "Phinix_trade_cancelButton".Translate(), clickAction: () => Client.Instance.CancelTrade(TradeId) ), width: BUTTON_WIDTH ) ); return(row); }
public VerticalPaddedContainer(Displayable child, float width) { this.child = child; this.width = width; // Build a vertically-padded container with the same content this.paddedChild = new VerticalFlexContainer(0f); this.paddedChild.Add(new SpacerWidget()); this.paddedChild.Add(child); this.paddedChild.Add(new SpacerWidget()); }
/// <inheritdoc /> public override void Draw(Rect inRect) { // Check if the child is non-fluid and smaller than the allocated space if (!child.IsFluidHeight && inRect.height > child.CalcHeight(inRect.width)) { // Create a flex container to hold the child and spacers VerticalFlexContainer column = new VerticalFlexContainer(0f); // Sandwich the child between two spacers column.Add(new SpacerWidget()); column.Add(child); column.Add(new SpacerWidget()); // Draw the container column.Draw(inRect); } else { // Just draw the child, there's no padding to be done here child.Draw(inRect); } }
/// <inheritdoc /> public override void Draw(Rect inRect) { // Try get the other party's UUID and display name if (!Client.Instance.TryGetOtherPartyUuid(tradeId, out string otherPartyUuid) || !Client.Instance.TryGetDisplayName(otherPartyUuid, out string otherPartyDisplayName)) { // Failed to get the other party's display name throw new Exception("Failed to get the other party's display name when drawing a TradeRow"); } // Try get the other party's accepted state if (!Client.Instance.TryGetPartyAccepted(tradeId, otherPartyUuid, out bool otherPartyAccepted)) { // Failed to get the other party's accepted state throw new Exception("Failed to get whether the other party has accepted or not when drawing a TradeRow"); } // Create a row to hold everything HorizontalFlexContainer row = new HorizontalFlexContainer(DEFAULT_SPACING); // Create a column to hold the text VerticalFlexContainer textColumn = new VerticalFlexContainer(0f); // Trade with ... label textColumn.Add( new Container( new TextWidget( text: "Phinix_trade_activeTrade_tradeWithLabel".Translate(TextHelper.StripRichText(otherPartyDisplayName)), anchor: TextAnchor.MiddleLeft ), height: TRADE_WITH_LABEL_HEIGHT ) ); // Accepted state label textColumn.Add( new Container( new TextWidget( text: ("Phinix_trade_activeTrade_theyHave" + (!otherPartyAccepted ? "Not" : "") + "Accepted").Translate(), font: GameFont.Tiny, anchor: TextAnchor.MiddleLeft ), height: ACCEPTED_STATE_LABEL_HEIGHT ) ); // Add the text column to the row row.Add(textColumn); // Open button row.Add( new Container( new ButtonWidget( label: "Phinix_trade_activeTrade_openButton".Translate(), clickAction: () => Find.WindowStack.Add(new TradeWindow(tradeId)) ), width: BUTTON_WIDTH ) ); // Cancel button row.Add( new Container( new ButtonWidget( label: "Phinix_trade_cancelButton".Translate(), clickAction: () => Client.Instance.CancelTrade(tradeId) ), width: BUTTON_WIDTH ) ); // Draw a background highlight if (drawAlternateBackground) { Widgets.DrawHighlight(inRect); } // Draw the row row.Draw(inRect); }