/// <summary> /// Adds our DeckSlotUI to a grid control in our screen /// </summary> protected override void AddInitialUI() { base.AddInitialUI(); Vector2 slotSize = new Vector2(200, 300); DeckSlotUIGridControl = AddScreenUIObject(new GridControl(4, ScreenDimensions, ScreenCentre)); DeckSlotUIGridControl.Margin = new Vector2(ScreenDimensions.X * 0.1f, ScreenDimensions.Y * 0.05f); for (int i = 0; i < PlayerDataRegistry.maxDeckNumber; ++i) { DebugUtils.AssertNotNull(PlayerDataRegistry.Instance.Decks[i]); DeckSlotUI deckSlotUI = DeckSlotUIGridControl.AddChild(new DeckSlotUI(PlayerDataRegistry.Instance.Decks[i], slotSize, Vector2.Zero)); deckSlotUI.StoredObject = PlayerDataRegistry.Instance.Decks[i]; } }
/// <summary> /// Transitions to a new deck editing screen /// </summary> /// <param name="baseObject"></param> private void EditButton_OnLeftClicked(BaseObject baseObject) { Debug.Assert(baseObject is Button); Button editButton = (baseObject as Button); DebugUtils.AssertNotNull(editButton.Parent); Debug.Assert(editButton.Parent is DeckSlotUI); DeckSlotUI deckSlotUI = editButton.Parent as DeckSlotUI; DebugUtils.AssertNotNull(deckSlotUI.StoredObject); Debug.Assert(deckSlotUI.StoredObject is Deck); Deck deck = deckSlotUI.StoredObject as Deck; DebugUtils.AssertNotNull(deck); ScreenManager.Instance.Transition(new DeckEditingScreen(deck)); }