public void OnScrollButonPress(ButtonWithText a_button) { if (OnButtonPress != null) { OnButtonPress(a_button); } }
/// <summary> /// Method to init menu /// </summary> /// <param name="data">Data to fill the scroll</param> public void InitScroll(List <string> data) { if (m_ListElements != null) { for (int i = 0; i < m_ListElements.Count; i++) { Destroy(m_ListElements[i]); } } m_ListElements = new List <GameObject>(); for (int i = 0; i < data.Count; i++) { GameObject element = Instantiate(m_ItemMenuPrefab) as GameObject; m_ListElements.Add(element); element.transform.SetParent(m_ContentRecTransform.transform); RectTransform cellRectTransform = element.GetComponent <RectTransform>(); if (cellRectTransform != null) { cellRectTransform.localScale = new Vector3(1.0f, 1.0f, 1.0f); } ButtonWithText Button = element.GetComponent <ButtonWithText>(); Button.ButtonIndex = i; Button.Title = data[i]; Button.OnButtonClicked += OnScrollButonPress; } }
static public void LoadContent(ContentManager Content, int BufferWidth, int BufferHeight) { //stick=new Stick() float buttonTextTransparency = 1; Texture2D stickBaseTexture = Content.Load <Texture2D>("UI\\base"); Texture2D stickTexture = Content.Load <Texture2D>("UI\\stick"); Texture2D baseButtonTexture = Content.Load <Texture2D>("UI\\buttonBase"); Texture2D leftArrowTexture = Content.Load <Texture2D>("UI\\rotateLeft"); Texture2D rightArrowTexture = Content.Load <Texture2D>("UI\\rotateRight"); //Texture2D fireButtonTexture = Content.Load<Texture2D>("UI\\fire"); //Texture2D landButtonTexture = Content.Load<Texture2D>("UI\\land"); Texture2D upgradeButtonTexture = Content.Load <Texture2D>("UI\\upgrade"); Texture2D zoomInTexture = Content.Load <Texture2D>("UI\\zoomIn"); Texture2D zoomOutTexture = Content.Load <Texture2D>("UI\\zoomOut"); spritefont = Content.Load <SpriteFont>("hudFont"); //stick = new Stick(stickBaseTexture, stickTexture, new Vector2(BufferWidth - 50 - rightArrowTexture.Width - stickBaseTexture.Width, BufferHeight - 50 - stickBaseTexture.Height)); //fireButton = new Button(fireButtonTexture, new Vector2(5, BufferHeight - 50 - fireButtonTexture.Height)); //fireButton = new ButtonWithText(baseButtonTexture, new Vector2(5, BufferHeight - 50 - baseButtonTexture.Height),spritefont,"Fire",buttonTextTransparency); //rotateLeft = new Button(leftArrowTexture, new Vector2(BufferWidth - 50 - stickBaseTexture.Width - leftArrowTexture.Width - rightArrowTexture.Width, BufferHeight - 50 - stickBaseTexture.Height)); //rotateRight = new Button(rightArrowTexture, new Vector2(BufferWidth - 50 - rightArrowTexture.Width, BufferHeight - 50 - stickBaseTexture.Height)); //landButton = new Button(landButtonTexture, new Vector2(BufferWidth / 2 - landButtonTexture.Width / 2, BufferHeight - 50 - landButtonTexture.Height)); landButton = new ButtonWithText(baseButtonTexture, new Vector2(BufferWidth / 2 - baseButtonTexture.Width / 2, BufferHeight - 50 - baseButtonTexture.Height), spritefont, "Land", buttonTextTransparency); //upgradeButton = new Button(upgradeButtonTexture, new Vector2(BufferWidth / 2 - landButtonTexture.Width / 2, BufferHeight - 50 - landButtonTexture.Height*2)); upgradeButton = new ButtonWithText(baseButtonTexture, new Vector2(BufferWidth / 2 - baseButtonTexture.Width / 2, BufferHeight - 50 - baseButtonTexture.Height * 2), spritefont, "Upgrade", buttonTextTransparency); zoomInButton = new Button(zoomInTexture, new Vector2(BufferWidth - 50 * 2 - zoomOutTexture.Width - zoomInTexture.Width, 0)); zoomOutButton = new Button(zoomOutTexture, new Vector2(BufferWidth - 50 - zoomOutTexture.Width, 0)); developerStats = new List <string>(); developerSpritefont = Content.Load <SpriteFont>("DeveloperFont"); }
private void OnOptionPress(ButtonWithText optionButton) { Debug.Log("<color=cyan>" + "[GrammarControl.OnOptionPress] index " + optionButton.ButtonIndex + "Name " + optionButton.Title + "</color>"); if ((optionButton.ButtonIndex < 0) || (optionButton.ButtonIndex >= AppController.Instance.LauncherControl.GrammarSet.Count)) { return; } m_selectedCategory = AppController.Instance.LauncherControl.GrammarSet[optionButton.ButtonIndex]; m_selectedGrammar = 0; m_menu.Hide(); SetGrammarData(); m_isDescriptionShown = true; m_ui.Show(); }
public override void OnInspectorGUI() { ButtonWithText component = (ButtonWithText)target; base.OnInspectorGUI(); EditorGUILayout.Space(); component.text = (TextMeshProUGUI)EditorGUILayout.ObjectField("Button text", component.text, typeof(TextMeshProUGUI), true); component.textNormalColor = EditorGUILayout.ColorField("Normal text color", component.textNormalColor); component.textHighlightedColor = EditorGUILayout.ColorField("Highlighted text color", component.textHighlightedColor); component.textPressedColor = EditorGUILayout.ColorField("Pressed text color", component.textPressedColor); component.textDisabledColor = EditorGUILayout.ColorField("Disabled text color", component.textDisabledColor); SerializedProperty tps = serializedObject.FindProperty("colorTransitionAdditionalGraphics"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(tps, true); if (EditorGUI.EndChangeCheck()) serializedObject.ApplyModifiedProperties(); component.useAllGraphicsAutomatically = EditorGUILayout.Toggle("Use All Graphics Automatically", component.useAllGraphicsAutomatically); } // OnInspectorGUI
} // SetText private void SetButton(string data) { if (this.propertyObject == null) { #if PANELS_DEBUG_ON Debug.LogError(string.Format("[PanelProperty][SetButton] Error! PropertyObject is not linked for '{0}' '{1}'", this.propertyName, this.propertyType)); #endif return; } ButtonWithText buttonComponent = this.propertyObject.GetComponent <ButtonWithText>(); if (buttonComponent == null) { #if PANELS_DEBUG_ON Debug.LogError(string.Format("[PanelProperty][SetButton] Error! PropertyObject '{0}' does not have 'ButtonWithText' component.", this.propertyObject.name)); #endif return; } buttonComponent.text.text = data; this.propertyObject.SetActive(true); } // SetButton
private void OkPopup(ButtonWithText Button) { Application.Quit(); }
//处理XML private void HandleXml(XmlNode list) { if (WrapPanel_Left_Character != null) { WrapPanel_Left_Character.Children.Clear(); } if (WrapPanel_Right_Character != null) { WrapPanel_Right_Character.Children.Clear(); } if (WrapPanel_Left_Food != null) { WrapPanel_Left_Food.Children.Clear(); } if (WrapPanel_Right_Food != null) { WrapPanel_Right_Food.Children.Clear(); } foreach (XmlNode Node in list) { #region "人物" if (Node.Name == "CharacterNode") { foreach (XmlNode childNode in Node) { if (childNode.Name == "Character") { string Picture = ""; string Name = ""; string EnName = ""; string Motto = ""; string Descriptions_1 = ""; string Descriptions_2 = ""; string Descriptions_3 = ""; string Health = ""; string Hunger = ""; string Sanity = ""; string LogMeter = ""; string Damage = ""; string DamageDay = ""; string DamageDusk = ""; string DamageNight = ""; string Introduce = ""; foreach (XmlNode Character in childNode) { switch (Character.Name) { case "Picture": Picture = RSN.ShortName(Character.InnerText, "GameResources/Character/"); break; case "Name": Name = Character.InnerText; break; case "EnName": EnName = Character.InnerText; break; case "Motto": Motto = Character.InnerText; break; case "Descriptions_1": Descriptions_1 = Character.InnerText; break; case "Descriptions_2": Descriptions_2 = Character.InnerText; break; case "Descriptions_3": Descriptions_3 = Character.InnerText; break; case "Health": Health = Character.InnerText; break; case "Hunger": Hunger = Character.InnerText; break; case "Sanity": Sanity = Character.InnerText; break; case "LogMeter": LogMeter = Character.InnerText; break; case "Damage": Damage = Character.InnerText; break; case "DamageDay": DamageDay = Character.InnerText; break; case "DamageDusk": DamageDusk = Character.InnerText; break; case "DamageNight": DamageNight = Character.InnerText; break; case "Introduce": Introduce = Character.InnerText; break; } } ButtonWithText BWT = new ButtonWithText(); BWT.Height = 205; BWT.Width = 140; BWT.ButtonGrid.Height = 190; BWT.ButtonGrid.Width = 140; BWT.GridPictureHeight.Height = new GridLength(160); BWT.UCImage.Height = 160; BWT.UCImage.Width = 140; BWT.UCImage.Source = RSN.PictureShortName(Picture); BWT.UCTextBlock.FontSize = 20; BWT.UCTextBlock.Text = Name; string[] BWTTag = { Picture, Name, EnName, Motto, Descriptions_1, Descriptions_2, Descriptions_3, Health, Hunger, Sanity, LogMeter, Damage, DamageDay, DamageDusk, DamageNight, Introduce }; object obj = BWTTag; if (Name == "威尔逊") { Character_Click_Handle(BWTTag); } BWT.UCButton.Tag = obj; BWT.UCButton.Click += Character_Click; try { WrapPanel_Right_Character.Children.Add(BWT); } catch { } } } } #endregion #region "食物" if (Node.Name == "FoodNode") { foreach (XmlNode childNode in Node) { switch (childNode.Name) { #region "食谱" case "FoodRecipe": ExpanderStackpanel ESRecipe = new ExpanderStackpanel("食谱", "../Resources/CP_CrockPot.png"); WrapPanel_Right_Food.Children.Add(ESRecipe); foreach (XmlNode Level2childNode in childNode) { if (Level2childNode.Name == "Food") { string Picture = ""; string Name = ""; string EnName = ""; string PortableCrockPot = ""; string Health = ""; string Hunger = ""; string Sanity = ""; string Perish = ""; string Cooktime = ""; string Priority = ""; string NeedPicture_1 = ""; string Need_1 = ""; string NeedPicture_or = ""; string Need_or = ""; string NeedPicture_2 = ""; string Need_2 = ""; string NeedPicture_3 = ""; string Need_3 = ""; string Restrictions_1 = ""; string RestrictionsAttributes_1 = ""; string Restrictions_2 = ""; string RestrictionsAttributes_2 = ""; string Restrictions_3 = ""; string RestrictionsAttributes_3 = ""; string Restrictions_4 = ""; string RestrictionsAttributes_4 = ""; string Restrictions_5 = ""; string RestrictionsAttributes_5 = ""; string Recommend_1 = ""; string Recommend_2 = ""; string Recommend_3 = ""; string Recommend_4 = ""; string Introduce = ""; foreach (XmlNode Food in Level2childNode) { switch (Food.Name) { case "Picture": Picture = RSN.ShortName(Food.InnerText, "GameResources/Food/"); break; case "Name": Name = Food.InnerText; break; case "EnName": EnName = Food.InnerText; break; case "PortableCrockPot": PortableCrockPot = Food.InnerText; break; case "Health": Health = Food.InnerText; break; case "Hunger": Hunger = Food.InnerText; break; case "Sanity": Sanity = Food.InnerText; break; case "Perish": Perish = Food.InnerText; break; case "Cooktime": Cooktime = Food.InnerText; break; case "Priority": Priority = Food.InnerText; break; case "NeedPicture_1": NeedPicture_1 = Food.InnerText; break; case "Need_1": Need_1 = Food.InnerText; break; case "NeedPicture_or": NeedPicture_or = Food.InnerText; break; case "Need_or": Need_or = Food.InnerText; break; case "NeedPicture_2": NeedPicture_2 = Food.InnerText; break; case "Need_2": Need_2 = Food.InnerText; break; case "NeedPicture_3": NeedPicture_3 = Food.InnerText; break; case "Need_3": Need_3 = Food.InnerText; break; case "Restrictions_1": Restrictions_1 = Food.InnerText; if (Food.Attributes["pre"] != null) { RestrictionsAttributes_1 = Food.Attributes["pre"].Value; } break; case "Restrictions_2": Restrictions_2 = Food.InnerText; if (Food.Attributes["pre"] != null) { RestrictionsAttributes_2 = Food.Attributes["pre"].Value; } break; case "Restrictions_3": Restrictions_3 = Food.InnerText; if (Food.Attributes["pre"] != null) { RestrictionsAttributes_3 = Food.Attributes["pre"].Value; } break; case "Restrictions_4": Restrictions_4 = Food.InnerText; if (Food.Attributes["pre"] != null) { RestrictionsAttributes_4 = Food.Attributes["pre"].Value; } break; case "Restrictions_5": Restrictions_5 = Food.InnerText; if (Food.Attributes["pre"] != null) { RestrictionsAttributes_5 = Food.Attributes["pre"].Value; } break; case "Recommend_1": Recommend_1 = Food.InnerText; break; case "Recommend_2": Recommend_2 = Food.InnerText; break; case "Recommend_3": Recommend_3 = Food.InnerText; break; case "Recommend_4": Recommend_4 = Food.InnerText; break; case "Introduce": Introduce = Food.InnerText; break; } } ButtonWithText BWT = new ButtonWithText(); BWT.UCImage.Source = RSN.PictureShortName(Picture); BWT.UCTextBlock.Text = Name; string[] BWTTag = { Picture, Name, EnName, PortableCrockPot, Health, Hunger, Sanity, Perish, Cooktime, Priority, NeedPicture_1, Need_1, NeedPicture_or, Need_or, NeedPicture_2, Need_2, NeedPicture_3, Need_3, Restrictions_1, RestrictionsAttributes_1, Restrictions_2, RestrictionsAttributes_2, Restrictions_3, RestrictionsAttributes_3, Restrictions_4, RestrictionsAttributes_4, Restrictions_5, RestrictionsAttributes_5, Recommend_1, Recommend_2, Recommend_3, Recommend_4, Introduce }; object obj = BWTTag; if (Name == "培根煎蛋") { Food_Recipe_Click_Handle(BWTTag); } BWT.UCButton.Tag = obj; BWT.UCButton.Click += Food_Recipe_Click; try { ESRecipe.UCWrapPanel.Children.Add(BWT); } catch { } } } break; #endregion #region "肉类" case "FoodMeats": ExpanderStackpanel ESMeast = new ExpanderStackpanel("肉类", "../Resources/GameResources/Food/FC_Meats.png"); WrapPanel_Right_Food.Children.Add(ESMeast); foreach (XmlNode Level2childNode in childNode) { if (Level2childNode.Name == "Food") { string Picture = ""; string Name = ""; string EnName = ""; string Health = ""; string Hunger = ""; string Sanity = ""; string Perish = ""; string Attribute = ""; string AttributeValue = ""; string Attribute_2 = ""; string AttributeValue_2 = ""; string Introduce = ""; foreach (XmlNode Food in Level2childNode) { switch (Food.Name) { case "Picture": Picture = RSN.ShortName(Food.InnerText, "GameResources/Food/"); break; case "Name": Name = Food.InnerText; break; case "EnName": EnName = Food.InnerText; break; case "Health": Health = Food.InnerText; break; case "Hunger": Hunger = Food.InnerText; break; case "Sanity": Sanity = Food.InnerText; break; case "Perish": Perish = Food.InnerText; break; case "Attribute": Attribute = Food.InnerText; break; case "AttributeValue": AttributeValue = Food.InnerText; break; case "Attribute_2": Attribute_2 = Food.InnerText; break; case "AttributeValue_2": AttributeValue_2 = Food.InnerText; break; case "Introduce": Introduce = Food.InnerText; break; } } ButtonWithText BWT = new ButtonWithText(); BWT.UCImage.Source = RSN.PictureShortName(Picture); BWT.UCTextBlock.Text = Name; string[] BWTTag = { Picture, Name, EnName, Health, Hunger, Sanity, Perish, Attribute, AttributeValue, Attribute_2, AttributeValue_2, Introduce }; object obj = BWTTag; BWT.UCButton.Tag = obj; BWT.UCButton.Click += Food_Click; try { ESMeast.UCWrapPanel.Children.Add(BWT); } catch { } } } break; #endregion #region "蔬菜" case "FoodVegetables": ExpanderStackpanel ESVegetables = new ExpanderStackpanel("蔬菜", "../Resources/GameResources/Food/FC_Vegetables.png"); WrapPanel_Right_Food.Children.Add(ESVegetables); foreach (XmlNode Level2childNode in childNode) { if (Level2childNode.Name == "Food") { string Picture = ""; string Name = ""; string EnName = ""; string Health = ""; string Hunger = ""; string Sanity = ""; string Perish = ""; string Attribute = ""; string AttributeValue = ""; string Attribute_2 = ""; string AttributeValue_2 = ""; string Introduce = ""; foreach (XmlNode Food in Level2childNode) { switch (Food.Name) { case "Picture": Picture = RSN.ShortName(Food.InnerText, "GameResources/Food/"); break; case "Name": Name = Food.InnerText; break; case "EnName": EnName = Food.InnerText; break; case "Health": Health = Food.InnerText; break; case "Hunger": Hunger = Food.InnerText; break; case "Sanity": Sanity = Food.InnerText; break; case "Perish": Perish = Food.InnerText; break; case "Attribute": Attribute = Food.InnerText; break; case "AttributeValue": AttributeValue = Food.InnerText; break; case "Attribute_2": Attribute_2 = Food.InnerText; break; case "AttributeValue_2": AttributeValue_2 = Food.InnerText; break; case "Introduce": Introduce = Food.InnerText; break; } } ButtonWithText BWT = new ButtonWithText(); BWT.UCImage.Source = RSN.PictureShortName(Picture); BWT.UCTextBlock.Text = Name; string[] BWTTag = { Picture, Name, EnName, Health, Hunger, Sanity, Perish, Attribute, AttributeValue, Attribute_2, AttributeValue_2, Introduce }; object obj = BWTTag; BWT.UCButton.Tag = obj; BWT.UCButton.Click += Food_Click; try { ESVegetables.UCWrapPanel.Children.Add(BWT); } catch { } } } break; #endregion #region "水果" case "FoodFruit": ExpanderStackpanel ESFruit = new ExpanderStackpanel("水果", "../Resources/GameResources/Food/FC_Fruit.png"); WrapPanel_Right_Food.Children.Add(ESFruit); foreach (XmlNode Level2childNode in childNode) { if (Level2childNode.Name == "Food") { string Picture = ""; string Name = ""; string EnName = ""; string Health = ""; string Hunger = ""; string Sanity = ""; string Perish = ""; string Attribute = ""; string AttributeValue = ""; string Attribute_2 = ""; string AttributeValue_2 = ""; string Introduce = ""; foreach (XmlNode Food in Level2childNode) { switch (Food.Name) { case "Picture": Picture = RSN.ShortName(Food.InnerText, "GameResources/Food/"); break; case "Name": Name = Food.InnerText; break; case "EnName": EnName = Food.InnerText; break; case "Health": Health = Food.InnerText; break; case "Hunger": Hunger = Food.InnerText; break; case "Sanity": Sanity = Food.InnerText; break; case "Perish": Perish = Food.InnerText; break; case "Attribute": Attribute = Food.InnerText; break; case "AttributeValue": AttributeValue = Food.InnerText; break; case "Attribute_2": Attribute_2 = Food.InnerText; break; case "AttributeValue_2": AttributeValue_2 = Food.InnerText; break; case "Introduce": Introduce = Food.InnerText; break; } } ButtonWithText BWT = new ButtonWithText(); BWT.UCImage.Source = RSN.PictureShortName(Picture); BWT.UCTextBlock.Text = Name; string[] BWTTag = { Picture, Name, EnName, Health, Hunger, Sanity, Perish, Attribute, AttributeValue, Attribute_2, AttributeValue_2, Introduce }; object obj = BWTTag; BWT.UCButton.Tag = obj; BWT.UCButton.Click += Food_Click; try { ESFruit.UCWrapPanel.Children.Add(BWT); } catch { } } } break; #endregion #region "蛋类" case "FoodEggs": ExpanderStackpanel ESEggs = new ExpanderStackpanel("蛋类", "../Resources/GameResources/Food/FC_Eggs.png"); WrapPanel_Right_Food.Children.Add(ESEggs); foreach (XmlNode Level2childNode in childNode) { if (Level2childNode.Name == "Food") { string Picture = ""; string Name = ""; string EnName = ""; string Health = ""; string Hunger = ""; string Sanity = ""; string Perish = ""; string Attribute = ""; string AttributeValue = ""; string Attribute_2 = ""; string AttributeValue_2 = ""; string Introduce = ""; foreach (XmlNode Food in Level2childNode) { switch (Food.Name) { case "Picture": Picture = RSN.ShortName(Food.InnerText, "GameResources/Food/"); break; case "Name": Name = Food.InnerText; break; case "EnName": EnName = Food.InnerText; break; case "Health": Health = Food.InnerText; break; case "Hunger": Hunger = Food.InnerText; break; case "Sanity": Sanity = Food.InnerText; break; case "Perish": Perish = Food.InnerText; break; case "Attribute": Attribute = Food.InnerText; break; case "AttributeValue": AttributeValue = Food.InnerText; break; case "Attribute_2": Attribute_2 = Food.InnerText; break; case "AttributeValue_2": AttributeValue_2 = Food.InnerText; break; case "Introduce": Introduce = Food.InnerText; break; } } ButtonWithText BWT = new ButtonWithText(); BWT.UCImage.Source = RSN.PictureShortName(Picture); BWT.UCTextBlock.Text = Name; string[] BWTTag = { Picture, Name, EnName, Health, Hunger, Sanity, Perish, Attribute, AttributeValue, Attribute_2, AttributeValue_2, Introduce }; object obj = BWTTag; BWT.UCButton.Tag = obj; BWT.UCButton.Click += Food_Click; try { ESEggs.UCWrapPanel.Children.Add(BWT); } catch { } } } break; #endregion #region "其他" case "FoodOthers": ExpanderStackpanel ESOthers = new ExpanderStackpanel("其他", "../Resources/GameResources/Food/F_twigs.png"); WrapPanel_Right_Food.Children.Add(ESOthers); foreach (XmlNode Level2childNode in childNode) { if (Level2childNode.Name == "Food") { string Picture = ""; string Name = ""; string EnName = ""; string Health = ""; string Hunger = ""; string Sanity = ""; string Perish = ""; string Attribute = ""; string AttributeValue = ""; string Attribute_2 = ""; string AttributeValue_2 = ""; string Introduce = ""; foreach (XmlNode Food in Level2childNode) { switch (Food.Name) { case "Picture": Picture = RSN.ShortName(Food.InnerText, "GameResources/Food/"); break; case "Name": Name = Food.InnerText; break; case "EnName": EnName = Food.InnerText; break; case "Health": Health = Food.InnerText; break; case "Hunger": Hunger = Food.InnerText; break; case "Sanity": Sanity = Food.InnerText; break; case "Perish": Perish = Food.InnerText; break; case "Attribute": Attribute = Food.InnerText; break; case "AttributeValue": AttributeValue = Food.InnerText; break; case "Attribute_2": Attribute_2 = Food.InnerText; break; case "AttributeValue_2": AttributeValue_2 = Food.InnerText; break; case "Introduce": Introduce = Food.InnerText; break; } } ButtonWithText BWT = new ButtonWithText(); BWT.UCImage.Source = RSN.PictureShortName(Picture); BWT.UCTextBlock.Text = Name; string[] BWTTag = { Picture, Name, EnName, Health, Hunger, Sanity, Perish, Attribute, AttributeValue, Attribute_2, AttributeValue_2, Introduce }; object obj = BWTTag; BWT.UCButton.Tag = obj; BWT.UCButton.Click += Food_Click; try { ESOthers.UCWrapPanel.Children.Add(BWT); } catch { } } } break; #endregion #region "非食材" case "FoodNoFC": ExpanderStackpanel ESNoFC = new ExpanderStackpanel("非食材", "../Resources/GameResources/Food/F_petals.png"); WrapPanel_Right_Food.Children.Add(ESNoFC); foreach (XmlNode Level2childNode in childNode) { if (Level2childNode.Name == "Food") { string Picture = ""; string Name = ""; string EnName = ""; string Health = ""; string Hunger = ""; string Sanity = ""; string Perish = ""; string Attribute = ""; string Introduce = ""; foreach (XmlNode Food in Level2childNode) { switch (Food.Name) { case "Picture": Picture = RSN.ShortName(Food.InnerText, "GameResources/Food/"); break; case "Name": Name = Food.InnerText; break; case "EnName": EnName = Food.InnerText; break; case "Health": Health = Food.InnerText; break; case "Hunger": Hunger = Food.InnerText; break; case "Sanity": Sanity = Food.InnerText; break; case "Perish": Perish = Food.InnerText; break; case "Attribute": Attribute = Food.InnerText; break; case "Introduce": Introduce = Food.InnerText; break; } } ButtonWithText BWT = new ButtonWithText(); BWT.UCImage.Source = RSN.PictureShortName(Picture); BWT.UCTextBlock.Text = Name; string[] BWTTag = { Picture, Name, EnName, Health, Hunger, Sanity, Perish, Attribute, Introduce }; object obj = BWTTag; BWT.UCButton.Tag = obj; BWT.UCButton.Click += Food_NoFC_Click; try { ESNoFC.UCWrapPanel.Children.Add(BWT); } catch { } } } break; #endregion } } } #endregion } }
/// <summary> /// Constructs the dialog /// </summary> /// <param name="launchesUntilPrompt"></param> /// <param name="maxRateShowTimes"></param> /// <param name="rateAppUri"></param> /// <param name="dialogDefinition"></param> /// <param name="font"></param> /// <param name="localizedStringsRepository"></param> /// <param name="rateMeDialogStrings"></param> /// <param name="webPageOpener"></param> /// <param name="settingsRepository"></param> /// <param name="buttonADefinition"></param> /// <param name="buttonBDefinition"></param> /// <param name="backgroundColor"></param> /// <param name="buttonsBackgroundColor"></param> /// <param name="buttonsShadowColor"></param> /// <param name="backgroundShadowColor"></param> /// <param name="titleColor"></param> /// <param name="buttonsTextColor"></param> /// <param name="titlePositionOffset"></param> /// <param name="buttonTextPadding"></param> /// <param name="titlePadding"></param> public RateMeDialog( int launchesUntilPrompt, int maxRateShowTimes, Uri rateAppUri, Rectangle dialogDefinition, SpriteFont font, ILocalizedStringsRepository localizedStringsRepository, RateMeDialogStrings rateMeDialogStrings, IWebPageOpener webPageOpener, ISettingsRepository settingsRepository, Rectangle buttonADefinition, Rectangle buttonBDefinition, Color backgroundColor, Color buttonsBackgroundColor, Color buttonsShadowColor, Color backgroundShadowColor, Color titleColor, Color buttonsTextColor, Vector2 titlePositionOffset, float buttonTextPadding, float titlePadding) { _launchesUntilPrompt = launchesUntilPrompt; _maxRateShowTimes = maxRateShowTimes; _rateAppUri = rateAppUri; _localizedStringsRepository = localizedStringsRepository; _settingsRepository = settingsRepository; AddStrings(rateMeDialogStrings); var buttonA = new ButtonWithText( font: font, text: localizedStringsRepository.Get(_rateItButtonTextKey), collisionRectangle: buttonADefinition, backgroundColor: buttonsBackgroundColor, textColor: buttonsTextColor, shadowColor: buttonsShadowColor, onClick: () => { _settingsRepository.SetBool(_dontShowAgainSettingKey, true); ShouldShowDialog = false; webPageOpener.OpenWebpage(_rateAppUri); }, textPadding: buttonTextPadding); var buttonB = new ButtonWithText( font: font, text: localizedStringsRepository.Get(_notNowButtonTextKey), collisionRectangle: buttonBDefinition, backgroundColor: buttonsBackgroundColor, textColor: buttonsTextColor, shadowColor: buttonsShadowColor, onClick: () => { // If users says "Not now", I reset the app launch count _settingsRepository.SetInt(_appLaunchCountSettingKey, 0); ShouldShowDialog = false; }, textPadding: buttonTextPadding); var minScale = Math.Min(buttonA.TextScale, buttonB.TextScale); buttonA.TextScale = minScale; buttonB.TextScale = minScale; _titleButtonButtonDialog = new Dialog( title: localizedStringsRepository.Get(_messageTextKey), font: font, dialogWindowDefinition: dialogDefinition, titlePositionOffset: titlePositionOffset, backgroundColor: backgroundColor, backgroundShadowColor: backgroundShadowColor, titleColor: titleColor, titlePadding: titlePadding, buttons: new ButtonWithText[] { buttonA, buttonB }); EvaluateRateMe(); }