public override void Enter() { float boundingY = GameOptions.Height * (PaddingVertical * 3.0f) + 80.0f; float boundingX = GameOptions.Width * (PaddingHorizontal * 2.5f); Numberbox numberSecondsPerTurn = new Numberbox("Seconds Per Turn", 180) { Position = new Vector2f(boundingX, boundingY), Value = Server.SecondsPerTurn, MinimumValue = 30 }; Numberbox numberboxPointCap = new Numberbox("Point Cap", 99) { Position = new Vector2f(GameOptions.Width - boundingX, boundingY), Value = Server.PointCap }; Entities.Add(numberboxPointCap); numberboxPointCap.Position.X -= numberboxPointCap.Width; Entities.Add(numberSecondsPerTurn); List <Checkbox> decks = new List <Checkbox>(); for (int i = 0; i < CardLoader.Decks.Count; i++) { CardLoader.CardDeck deck = CardLoader.Decks[i]; Checkbox checkboxDeck = new Checkbox(deck.Name, deck.Include) { Position = new Vector2f(boundingX + (i / 4 * 128), boundingY + 64.0f + 80.0f + ((i % 4) * 64.0f)) }; decks.Add(checkboxDeck); Entities.Add(checkboxDeck); } Button applyButton = new Button(new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f + GameOptions.Height / 3.0f + 16.0f), "Apply"); applyButton.OnClick += () => { Apply(decks, numberboxPointCap, numberSecondsPerTurn); return(true); }; Entities.Add(applyButton); base.Enter(); }
private static void Apply(List <Checkbox> decks, Numberbox numberboxPointCap, Numberbox numberSecondsPerTurn) { if (decks.Count(d => d.Value) == 0) { Game.PushState(new PopupOverlay("You must select at least one deck in order to host a game.")); return; } Server.PointCap = numberboxPointCap.Value; Server.SecondsPerTurn = numberSecondsPerTurn.Value; foreach (Checkbox deck in decks) { CardLoader.Decks.First(d => d.Name == deck.Label).Include = deck.Value; } Game.PopState(); }