public object ShowTrades(bool giveControl = true) { Dictionary <string, PairValue> options = new Dictionary <string, PairValue>(); bool empty = true; foreach (ITrader t in ActiveTraders) { foreach (IPhysical s in t.Trades.Keys) { options.Add(string.Format("│{0,-15}│{1,-10}│{2,-15}│{3,10} $│", t.Name, s.GetType().Name, s.GetSpecs(), t.Trades[s]), new PairValue(new TraderItem(t, s, t.Trades[s]))); empty = false; } } if (!empty) { OptionTable ot = new OptionTable(options, new System.Drawing.Point(0, 0), 100, 18); ot.Draw(); if (giveControl) { return(ot.GiveControl()); } } else { var popup = new g.Popup("No trades here!"); popup.GiveControl(); } return(null); }
static void Main() { Setup(); Player.MainSpaceship = new Spaceship("Bruhlia", new Point(0, 0)); Systems.Add(new PlanetarySystem("Solar System", new List <Planet>())); Systems.Add(new PlanetarySystem("Andromeda", new List <Planet>())); Systems[0].AddPlanet(new Planet("Earth")); Systems[1].AddPlanet(new Planet("Nua")); Factory zaz = new Factory("ZAZ Factory"); Systems[0][0].ActiveTraders.Add(zaz); for (int i = 0; i < 8; i++) { Item item = new Item(100 * i + 100, 10 * i * i + 50); zaz.Inventory.Add(item); ((ITrader)zaz).AddToTrades(item, i * 5000 + 50000); } c.SetCursorPosition(0, 0); while (true) { object pl = ShowPlanets(); Planet pln = pl as Planet; bool cont = true; while (cont) { object pv = pln.ShowTrades(); if (pv != null) { TraderItem ti = pv as TraderItem; ti.Trader.Sell(Player, ti.Item, ti.Price); } else { cont = false; } } g.Clear(); } Systems[0][0].ShowTrades(false); c.WriteLine(Player.Money); foreach (IPhysical p in Player.Inventory) { c.WriteLine(p.GetSpecs()); } var msg = new g.Popup("bruh", g.Popup.DialogButtons.YesNo); msg.GiveControl(); c.ReadKey(true); }