public void InitButtons() { if (mViewHeight.HasValue) { int height = 0; GameObject buttonPref = Resources.Load(cButtonPrefab) as GameObject; int buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight; int spacing = (int)DragArea.transform.FindChild("ScrollArea").GetComponent <VerticalLayoutGroup>().spacing; buttonHeight += spacing; for (int i = 0; i < mNumberOfButtons; ++i) { GameObject button = GameObject.Instantiate(buttonPref) as GameObject; button.transform.SetParent(DragArea.transform.FindChild("ScrollArea")); button.GetComponent <IntButtonHandler>().NotificationInt = i; button.GetComponent <IntButtonHandler>().NotificationCatcher = this; int number = mWizard.NumberofUnknownSpells(i + 1); ViewUtility.ChangeSimpleButtonText(string.Format(cRankButtonText, i + 1, number), button); ViewUtility.EnableSimpleButton(button, number != 0); mButtons.Add(button); height += buttonHeight; } if (height > mViewHeight.Value) { // removing the spacing from the last button for nicer view height -= spacing; } mTotalHeight = height; } }
protected override void InitRankSelection() { SetTopText("Select the spell Rank"); DnDCharacter character = (DnDCharacter)AppStorage.Instance.CurrentCharacter; if (mSelectedClass > character.Classes.Count) { return; } DnDClassSoul soul = character.Classes[mSelectedClass]; GameObject buttonPref = Resources.Load(cSimplePrefab) as GameObject; int buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight; int spacing = (int)DragArea.transform.FindChild("ScrollArea").GetComponent <VerticalLayoutGroup>().spacing; buttonHeight += spacing; for (int i = 0; i < soul.KnownSpells.Count; ++i) { GameObject button = GameObject.Instantiate(buttonPref) as GameObject; button.transform.SetParent(DragArea.transform.FindChild("ScrollArea")); ViewUtility.ChangeSimpleButtonText("rank " + i, button); button.GetComponent <IntButtonHandler>().NotificationInt = i; button.GetComponent <IntButtonHandler>().NotificationCatcher = this; mTotalHeight += buttonHeight; ViewUtility.EnableSimpleButton(button, soul.KnownSpells[i].Count > 0); mButtonList.Add(button); } if (mViewHeight < mTotalHeight) { mTotalHeight -= spacing; } UpdateNow = true; }
public void InitButtons() { if (mViewHeight.HasValue) { int height = 0; GameObject buttonPref = Resources.Load(cButtonPrefab) as GameObject; int buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight; int spacing = (int)DragArea.transform.FindChild("ScrollArea").GetComponent <VerticalLayoutGroup>().spacing; buttonHeight += spacing; for (int i = 0; i < mSpellsToDisplay.Count; ++i) { GameObject button = GameObject.Instantiate(buttonPref) as GameObject; button.transform.SetParent(DragArea.transform.FindChild("ScrollArea")); button.GetComponent <IntButtonHandler>().NotificationInt = i; button.GetComponent <IntButtonHandler>().NotificationCatcher = this; string text = ViewUtility.MakeStringVivaldiViable(mSpellsToDisplay[i].ToShortString()); ViewUtility.ChangeSimpleButtonText(text, button); mButtons.Add(button); height += buttonHeight; } if (height > mViewHeight.Value) { // removing the spacing from the last button for nicer view height -= spacing; } mTotalHeight = height; } }
private void ShowMessageBox(string title, string body, string buttonText) { if (MessageBox != null) { MessageBox.transform.FindChild("Background").FindChild("Top").FindChild("TitleText").GetComponent <Text>().text = title; MessageBox.transform.FindChild("Background").FindChild("Body").FindChild("BodyText").GetComponent <Text>().text = body; GameObject button = MessageBox.transform.FindChild("Background").FindChild("Bottom").FindChild("Button").gameObject; ViewUtility.ChangeSimpleButtonText(buttonText, button); MessageBox.gameObject.SetActive(true); } }
/// <summary> /// for sorcerers and other swaggers /// </summary> private void InitKnownSpells() { int mainSpells = 0; if (mSoul.MainSpells.Count > mSelectedRank) { mainSpells = mSoul.KnownSpells[mSelectedRank].Count; } GameObject buttonPref = null; int buttonHeight = 0; if (mainSpells == 0) { buttonPref = Resources.Load(cLabelPrefab) as GameObject; buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight; mTotalHeight += buttonHeight; // display label GameObject obj = GameObject.Instantiate(buttonPref) as GameObject; obj.transform.SetParent(DragArea.transform.FindChild("ScrollArea")); ViewUtility.ChangeSimpleButtonText("You know no spells of this rank", obj); mButtonList.Add(obj); } if (mainSpells > 0) { buttonPref = Resources.Load(cSimplePrefab) as GameObject; buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight; // for loop to add main spells for (int i = 0; i < mainSpells; ++i) { GameObject button = GameObject.Instantiate(buttonPref) as GameObject; button.transform.SetParent(DragArea.transform.FindChild("ScrollArea")); ViewUtility.ChangeSimpleButtonText(mSoul.KnownSpells[mSelectedRank][i].ToShortString(), button); button.GetComponent <IntButtonHandler>().NotificationInt = i; button.GetComponent <IntButtonHandler>().NotificationCatcher = this; mTotalHeight += buttonHeight; mButtonList.Add(button); } } }
private void InitSimpleButtons() { GameObject buttonPref = Resources.Load(cSimplePrefab) as GameObject; int buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight; int spacing = (int)DragArea.transform.FindChild("ScrollArea").GetComponent <VerticalLayoutGroup>().spacing; buttonHeight += spacing; for (int i = 0; i < mCurrentSpells.Count; ++i) { GameObject button = GameObject.Instantiate(buttonPref) as GameObject; button.transform.SetParent(DragArea.transform.FindChild("ScrollArea")); ViewUtility.ChangeSimpleButtonText(mCurrentSpells[i].ToShortString(), button); button.GetComponent <IntButtonHandler>().NotificationInt = i; button.GetComponent <IntButtonHandler>().NotificationCatcher = this; mTotalHeight += buttonHeight; mButtonList.Add(button); } if (mViewHeight < mTotalHeight) { mTotalHeight -= spacing; } UpdateNow = true; }
/// <summary> /// for clerics, wizards and other hard learners /// </summary> private void InitPreparedSpells() { int mainSpells = 0; bool extraSpell = false; if (mSoul.MainSpells.Count > mSelectedRank) { mainSpells = mSoul.MainSpells[mSelectedRank].Count; } if (mSoul.CanCastExtraSpell && mSoul.ExtraSpells.Count > mSelectedRank) { if (mSoul.ExtraSpells[mSelectedRank].Key != null) { extraSpell = true; } } GameObject buttonPref = null; int buttonHeight = 0; if (mainSpells == 0 && !extraSpell) { buttonPref = Resources.Load(cLabelPrefab) as GameObject; buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight; mTotalHeight += buttonHeight; // display label GameObject obj = GameObject.Instantiate(buttonPref) as GameObject; obj.transform.SetParent(DragArea.transform.FindChild("ScrollArea")); ViewUtility.ChangeSimpleButtonText("no spells prepared for this rank", obj); mButtonList.Add(obj); } if (mainSpells > 0) { buttonPref = Resources.Load(cSimplePrefab) as GameObject; buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight; // for loop to add main spells for (int i = 0; i < mainSpells; ++i) { GameObject button = GameObject.Instantiate(buttonPref) as GameObject; button.transform.SetParent(DragArea.transform.FindChild("ScrollArea")); ViewUtility.ChangeSimpleButtonText(mSoul.MainSpells[mSelectedRank][i].Key.ToShortString(), button); button.GetComponent <IntButtonHandler>().NotificationInt = i; button.GetComponent <IntButtonHandler>().NotificationCatcher = this; mTotalHeight += buttonHeight; ViewUtility.EnableSimpleButton(button, !mSoul.MainSpells[mSelectedRank][i].Value); mButtonList.Add(button); } } if (extraSpell) { buttonPref = Resources.Load(cTwoPartPrefab) as GameObject; buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight; // add extra spell button GameObject eButton = GameObject.Instantiate(buttonPref) as GameObject; eButton.transform.SetParent(DragArea.transform.FindChild("ScrollArea")); ViewUtility.ChangeTwoPartButtonText(mSoul.ExtraSpells[mSelectedRank].Key.ToShortString(), "(extra)", eButton); eButton.GetComponent <IntButtonHandler>().NotificationInt = mSelectedRank; eButton.GetComponent <IntButtonHandler>().ButtonID = cExtraSpell; eButton.GetComponent <IntButtonHandler>().NotificationCatcher = this; mTotalHeight += buttonHeight; ViewUtility.EnableSimpleButton(eButton, !mSoul.ExtraSpells[mSelectedRank].Value); mButtonList.Add(eButton); } }