# HG changeset patch # User Alys Brooks # Date 2022-05-25 07:13:53 # Node ID 6a06e61b430cfb1fee7b5b41be482d1f6134e4da # Parent ce2d3dd6110a476c2d9f3d0e5c7ba03b17339e2c Factor out line code. diff --git a/isometric-park-fna/UI/BudgetWindow.cs b/isometric-park-fna/UI/BudgetWindow.cs --- a/isometric-park-fna/UI/BudgetWindow.cs +++ b/isometric-park-fna/UI/BudgetWindow.cs @@ -68,6 +68,17 @@ return true; } + public String line_format(String name, decimal first, decimal second) { + int between_name_col = 6; + int between_cols = 4; + var first_formatted = String.Format("${0:}", first).PadLeft(6, '.'); + var second_formatted = String.Format("${0:}", second).PadLeft(6, '.'); + + var formatted = String.Format("{0,5:}{1:}{2,6:}{3:}{4,6:}", name, new String('.', between_name_col), first_formatted, new String('.', between_cols), second_formatted); + + return formatted; + } + public void draw(SpriteBatch batch) { @@ -102,8 +113,8 @@ batch.DrawString(font, String.Format("Starting Funds.........${0:}", this.budget.money), new Vector2(x, bar_height * 2 + y), Color.Black); batch.DrawString(font, String.Format("REVENUE", this.budget.upkeep), new Vector2(x, bar_height * 4 + y), Color.Black); - batch.DrawString(font, String.Format("Subsidy................${0:}....${1:}", this.budget.subsidy, this.previous_budget.subsidy), new Vector2(x, bar_height * 5 + y), Color.Black); - batch.DrawString(font, String.Format("Contracts..............${0:}....${1:}", this.budget.contracts, this.previous_budget.contracts), new Vector2(x, bar_height * 6 + y), Color.Black); + batch.DrawString(font, line_format("Subsidy", this.budget.subsidy, this.previous_budget.subsidy), new Vector2(x, bar_height * 5 + y), Color.Black); + batch.DrawString(font, line_format("Contracts", this.budget.contracts, this.previous_budget.contracts), new Vector2(x, bar_height * 6 + y), Color.Black); batch.DrawString(font, String.Format("Misc...................${0:}....${1:}", this.budget.misc, this.previous_budget.misc), new Vector2(x, bar_height * 7 + y), Color.Black); batch.DrawString(font, String.Format("EXPENSES", this.budget.upkeep), new Vector2(x, bar_height * 10 + y), Color.Black);