public override void OnInspectorGUI () { serializedObject.Update(); NGUIEditorTools.SetLabelWidth(80f); mButton = target as UIImageButton; mSprite = EditorGUILayout.ObjectField("Sprite", mButton.target, typeof(UISprite), true) as UISprite; if (mButton.target != mSprite) { NGUIEditorTools.RegisterUndo("Image Button Change", mButton); mButton.target = mSprite; if (mSprite != null) mSprite.spriteName = mButton.normalSprite; } if (mSprite != null) { ComponentSelector.Draw<UIAtlas>(mSprite.atlas, OnSelectAtlas, true); if (mSprite.atlas != null) { NGUIEditorTools.DrawSpriteField("Normal", mSprite.atlas, mButton.normalSprite, OnNormal); NGUIEditorTools.DrawSpriteField("Hover", mSprite.atlas, mButton.hoverSprite, OnHover); NGUIEditorTools.DrawSpriteField("Pressed", mSprite.atlas, mButton.pressedSprite, OnPressed); NGUIEditorTools.DrawSpriteField("Disabled", mSprite.atlas, mButton.disabledSprite, OnDisabled); NGUIEditorTools.DrawProperty("Pixel Snap", serializedObject, "pixelSnap"); } } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI () { EditorGUIUtility.LookLikeControls(80f); mButton = target as UIImageButton; mSprite = EditorGUILayout.ObjectField("Sprite", mButton.target, typeof(UISprite), true) as UISprite; if (mButton.target != mSprite) { NGUIEditorTools.RegisterUndo("Image Button Change", mButton); mButton.target = mSprite; if (mSprite != null) mSprite.spriteName = mButton.normalSprite; } if (mSprite != null) { ComponentSelector.Draw<UIAtlas>(mSprite.atlas, OnSelectAtlas); if (mSprite.atlas != null) { NGUIEditorTools.SpriteField("Normal", mSprite.atlas, mButton.normalSprite, OnNormal); NGUIEditorTools.SpriteField("Hover", mSprite.atlas, mButton.hoverSprite, OnHover); NGUIEditorTools.SpriteField("Pressed", mSprite.atlas, mButton.pressedSprite, OnPressed); } } }
//������Editor�����ڻ����Զ���inspector��ע�⣬�������ֻ���ڳ�����ѡ���˶�����ڼ���������е�����ťʱ�Żᱻִ�У���ִ�д��������������ĴΡ� public override void OnInspectorGUI() { //EditorGUIUtility���������趨Editor ��Ĭ�������ʽ�������ǰѱ�ǩ(label)�Ŀ����Ϊ80f EditorGUIUtility.LookLikeControls(80f); //target��Editor�еij�Ա������ָ����ǵ�ǰ�����б�ѡ�еĶ��� mButton = target as UIImageButton; //�ڼ�������д���һ��������ͨ����ק�ȷ�ʽ���и�ֵ mSprite = EditorGUILayout.ObjectField("Sprite", mButton.target, typeof(UISprite), true) as UISprite; //��Sprite���е�ֵ�뵱ǰbutton�е�target��һֵʱ������ if (mButton.target != mSprite) { NGUIEditorTools.RegisterUndo("Image Button Change", mButton); mButton.target = mSprite; if (mSprite != null) mSprite.spriteName = mButton.normalSprite; } if (mSprite != null) { //����EditorGUILayout.ObjectField ��֧���Զ������(components), �˺����Զ����˶������ǽ�֧�ִ���ʷ��¼��ѡ�� ComponentSelector.Draw<UIAtlas>(mSprite.atlas, OnSelectAtlas); //��������sprite������ص����� if (mSprite.atlas != null) { NGUIEditorTools.SpriteField("Normal" , mSprite.atlas, mButton.normalSprite, OnNormal); NGUIEditorTools.SpriteField("Hover" , mSprite.atlas, mButton.hoverSprite, OnHover); NGUIEditorTools.SpriteField("Pressed", mSprite.atlas, mButton.pressedSprite, OnPressed); } } }
private void Init() { if (_isInit) return; _button = GetComponent<UIButton>(); _imageButton = GetComponent<UIImageButton>(); _isInit = true; }
public override void OnInspectorGUI () { #pragma warning disable 0618 EditorGUIUtility.LookLikeControls(80f); #pragma warning restore 0618 mButton = target as UIImageButton; UISprite sprite = EditorGUILayout.ObjectField("Sprite", mButton.target, typeof(UISprite), true) as UISprite; if (mButton.target != sprite) { NGUIEditorTools.RegisterUndo("Image Button Change", mButton); mButton.target = sprite; if (sprite != null) sprite.spriteName = mButton.normalSprite; } if (mButton.target != null) { ComponentSelector.Draw<UIAtlas>(sprite.atlas as UIAtlas, OnSelectAtlas); if (sprite.atlas != null) { string normal = UISpriteInspector.SpriteField(sprite.atlas as UIAtlas, "Normal", mButton.normalSprite); string hover = UISpriteInspector.SpriteField(sprite.atlas as UIAtlas, "Hover", mButton.hoverSprite); string press = UISpriteInspector.SpriteField(sprite.atlas as UIAtlas, "Pressed", mButton.pressedSprite); if (mButton.normalSprite != normal || mButton.hoverSprite != hover || mButton.pressedSprite != press) { NGUIEditorTools.RegisterUndo("Image Button Change", mButton, mButton.gameObject, sprite); mButton.normalSprite = normal; mButton.hoverSprite = hover; mButton.pressedSprite = press; sprite.spriteName = normal; sprite.MakePixelPerfect(); NGUITools.AddWidgetCollider(mButton.gameObject); } } } }
public virtual void loadDataProducts(string type) { LogUtil.Log("Load loadDataProducts:type:" + type); List <GameProduct> products = null; if (!string.IsNullOrEmpty(type)) { products = GameProducts.Instance.GetListByType(type); } else { products = GameProducts.Instance.GetAll(); } LogUtil.Log("Load products: products.Count: " + products.Count); int i = 0; foreach (GameProduct product in products) { GameObject item = NGUITools.AddChild(listGridRoot, listItemItemPrefab); item.name = "WeaponItem" + i; GameProductInfo info = product.GetDefaultProductInfoByLocale(); UIUtil.UpdateLabelObject(item.transform, "LabelName", info.display_name); UIUtil.UpdateLabelObject(item.transform, "LabelDescription", info.description); UIUtil.UpdateLabelObject(item.transform, "LabelCost", info.cost); Transform inventoryItem = item.transform.FindChild("Container/Inventory"); if (inventoryItem != null) { double currentValue = 0; if (product.type == GameProductType.rpgUpgrade) { currentValue = GameProfileRPGs.Current.GetUpgrades(); UIUtil.UpdateLabelObject(inventoryItem, "LabelCurrentValue", currentValue.ToString("N0")); } else { inventoryItem.gameObject.Hide(); } } Transform iconTransform = item.transform.FindChild("Container/Icon"); if (iconTransform != null) { GameObject iconObject = iconTransform.gameObject; UISprite iconSprite = iconObject.GetComponent <UISprite>(); if (iconSprite != null) { iconSprite.alpha = 1f; // TODO change out image... } } // Update button action Transform buttonObject = item.transform.FindChild("Container/Button/ButtonAction"); if (buttonObject != null) { UIImageButton button = buttonObject.gameObject.GetComponent <UIImageButton>(); if (button != null) { // TODO change to get from character skin string productType = product.type; string productCode = product.code; string productCharacter = GameProfileCharacters.Current.GetCurrentCharacterProfileCode(); //productCode = productCode.Replace(productType + "-", ""); button.name = BaseUIButtonNames.buttonGameActionItemBuyUse + "$" + productType + "$" + productCode + "$" + productCharacter; } } i++; } }
/// <summary> /// Button creation function. /// </summary> void CreateImageButton(GameObject go) { if (UISettings.atlas != null) { GUILayout.BeginHorizontal(); string bg = UISpriteInspector.SpriteField(UISettings.atlas, "Normal", mImage0, GUILayout.Width(200f)); GUILayout.Space(20f); GUILayout.Label("Normal state sprite"); GUILayout.EndHorizontal(); if (mImage0 != bg) { mImage0 = bg; Save(); } GUILayout.BeginHorizontal(); bg = UISpriteInspector.SpriteField(UISettings.atlas, "Hover", mImage1, GUILayout.Width(200f)); GUILayout.Space(20f); GUILayout.Label("Hover state sprite"); GUILayout.EndHorizontal(); if (mImage1 != bg) { mImage1 = bg; Save(); } GUILayout.BeginHorizontal(); bg = UISpriteInspector.SpriteField(UISettings.atlas, "Pressed", mImage2, GUILayout.Width(200f)); GUILayout.Space(20f); GUILayout.Label("Pressed state sprite"); GUILayout.EndHorizontal(); if (mImage2 != bg) { mImage2 = bg; Save(); } } if (ShouldCreate(go, UISettings.atlas != null)) { int depth = NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = "Image Button"; UIAtlas.Sprite sp = UISettings.atlas.GetSprite(mImage0); UISprite sprite = (sp.inner == sp.outer) ? NGUITools.AddWidget <UISprite>(go) : (UISprite)NGUITools.AddWidget <UISlicedSprite>(go); sprite.name = "Background"; sprite.depth = depth; sprite.atlas = UISettings.atlas; sprite.spriteName = mImage0; sprite.transform.localScale = new Vector3(150f, 40f, 1f); sprite.MakePixelPerfect(); if (UISettings.font != null) { UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.font = UISettings.font; lbl.text = go.name; lbl.MakePixelPerfect(); } // Add a collider NGUITools.AddWidgetCollider(go); // Add the scripts UIImageButton ib = go.AddComponent <UIImageButton>(); ib.target = sprite; ib.normalSprite = mImage0; ib.hoverSprite = mImage1; ib.pressedSprite = mImage2; go.AddComponent <UIButtonSound>(); Selection.activeGameObject = go; } }
public UIModPackItem(string name, string[] mods) { this.filename = name; this.mods = mods; this.numMods = mods.Length; modMissing = new bool[mods.Length]; numModsEnabled = 0; numModsDisabled = 0; numModsMissing = 0; for (int i = 0; i < mods.Length; i++) { if (UIModPacks.mods.Contains(mods[i])) { if (ModLoader.IsEnabled(mods[i])) { numModsEnabled++; } else { numModsDisabled++; } } else { modMissing[i] = true; numModsMissing++; } } BorderColor = new Color(89, 116, 213) * 0.7f; dividerTexture = TextureManager.Load("Images/UI/Divider"); innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); Height.Pixels = 126; Width.Percent = 1f; SetPadding(6f); modName = new UIText(name) { Left = { Pixels = 10 }, Top = { Pixels = 5 } }; Append(modName); var viewListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewList")) { Width = { Pixels = 100 }, Height = { Pixels = 36 }, Left = { Pixels = 407 }, Top = { Pixels = 40 } }.WithFadedMouseOver(); viewListButton.PaddingTop -= 2f; viewListButton.PaddingBottom -= 2f; viewListButton.OnClick += ViewListInfo; Append(viewListButton); enableListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableThisList")) { Width = { Pixels = 151 }, Height = { Pixels = 36 }, Left = { Pixels = 248 }, Top = { Pixels = 40 } }.WithFadedMouseOver(); enableListButton.PaddingTop -= 2f; enableListButton.PaddingBottom -= 2f; enableListButton.OnClick += EnableList; Append(enableListButton); enableListOnlyButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableOnlyThisList")) { Width = { Pixels = 190 }, Height = { Pixels = 36 }, Left = { Pixels = 50 }, Top = { Pixels = 40 } }.WithFadedMouseOver(); enableListOnlyButton.PaddingTop -= 2f; enableListOnlyButton.PaddingBottom -= 2f; enableListOnlyButton.OnClick += EnableListOnly; Append(enableListOnlyButton); viewInModBrowserButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewModsInModBrowser")) { Width = { Pixels = 246 }, Height = { Pixels = 36 }, Left = { Pixels = 50 }, Top = { Pixels = 80 } }.WithFadedMouseOver(); viewInModBrowserButton.PaddingTop -= 2f; viewInModBrowserButton.PaddingBottom -= 2f; viewInModBrowserButton.OnClick += ViewInModBrowser; Append(viewInModBrowserButton); updateListWithEnabledButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackUpdateListWithEnabled")) { Width = { Pixels = 225 }, Height = { Pixels = 36 }, Left = { Pixels = 304 }, Top = { Pixels = 80 } }.WithFadedMouseOver(); updateListWithEnabledButton.PaddingTop -= 2f; updateListWithEnabledButton.PaddingBottom -= 2f; updateListWithEnabledButton.OnClick += (a, b) => UIModPacks.SaveModList(filename); Append(updateListWithEnabledButton); deleteButton = new UIImageButton(TextureManager.Load("Images/UI/ButtonDelete")) { Top = { Pixels = 40 } }; deleteButton.OnClick += DeleteButtonClick; Append(deleteButton); }
public override void OnInitialize() { keyboardPanel = new UIPanel(); keyboardPanel.SetPadding(8); keyboardPanel.Left.Set(-550f, 1f); keyboardPanel.Top.Set(-370f, 1f); keyboardPanel.Width.Set(500f, 0f); keyboardPanel.Height.Set(300f, 0f); keyboardPanel.BackgroundColor = new Color(73, 94, 171); codeTextBox = new NewUITextBoxMultiLine("Type code here", 1f); codeTextBox.SetUnfocusKeys(false, false); codeTextBox.BackgroundColor = Color.Transparent; codeTextBox.BorderColor = Color.Transparent; codeTextBox.Left.Pixels = 0; codeTextBox.Top.Pixels = 0; codeTextBox.Width.Set(-20, 1f); //filterTextBox.OnTextChanged += () => { filterText = filterTextBox.Text; updateneeded = true; }; codeTextBox.OnEnterPressed += EnterAction; codeTextBox.OnTabPressed += TabAction; codeTextBox.OnUpPressed += UpAction; //keyboardPanel.Append(codeTextBox); replOutput = new UIList(); replOutput.Width.Set(-25f, 1f); // left spacing plus scrollbar //replOutput.Height.Set(-codeTextBox.GetDimensions().Height - 32, 1f); replOutput.Height.Set(-26, 1f); replOutput.Left.Set(0, 0f); //replOutput.Top.Set(codeTextBox.GetDimensions().Height, 0f); replOutput.Top.Set(0, 0f); replOutput.ListPadding = 10f; replOutput.Add(codeTextBox); keyboardPanel.Append(replOutput); keyboardScrollbar = new UIElements.FixedUIScrollbar(userInterface); keyboardScrollbar.SetView(100f, 1000f); keyboardScrollbar.Top.Pixels = codeTextBox.GetDimensions().Height; keyboardScrollbar.Height.Set(-26, 1f); keyboardScrollbar.Left.Set(-4, 0f); keyboardScrollbar.HAlign = 1f; keyboardPanel.Append(keyboardScrollbar); replOutput.SetScrollbar(keyboardScrollbar); Asset <Texture2D> texture = Main.Assets.Request <Texture2D>("Images/UI/Cursor_2"); UIImageButton eyeDropperButton = new UIImageButton(texture); eyeDropperButton.Height.Pixels = 20; //eyeDropperButton.Width.Pixels = 20; eyeDropperButton.OnClick += EyeDropperButton_OnClick; eyeDropperButton.Top.Set(-26, 1f); keyboardPanel.Append(eyeDropperButton); texture = Main.Assets.Request <Texture2D>("Images/UI/ButtonSeed"); UIHoverImageButton openText = new UIHoverImageButton(texture, texture.Frame(), "Open External Editor"); openText.OnClick += OpenTextButton_OnClick; openText.Top.Set(-26 / Main.UIScale, 1f); openText.Left.Set(26 / Main.UIScale, 0f); keyboardPanel.Append(openText); texture = Main.Assets.Request <Texture2D>("Images/UI/ButtonPlay"); UIHoverImageButton runText = new UIHoverImageButton(texture, texture.Frame(), "Execute External Code"); runText.OnClick += RunTextButton_OnClick; runText.Top.Set(-26, 1f); runText.Left.Set(52, 0f); keyboardPanel.Append(runText); Append(keyboardPanel); }
public override void OnInitialize() { MusicianShopsPanel = new UIPanel(); MusicianShopsPanel.SetPadding(0); MusicianShopsPanel.Left.Set(575f, 0f); MusicianShopsPanel.Top.Set(275f, 0f); MusicianShopsPanel.Width.Set(260f, 0f); MusicianShopsPanel.Height.Set(105f, 0f); MusicianShopsPanel.BackgroundColor = new Color(73, 94, 171); MusicianShopsPanel.OnMouseDown += new UIElement.MouseEvent(DragStart); MusicianShopsPanel.OnMouseUp += new UIElement.MouseEvent(DragEnd); string MusicianShops1; string MusicianShops2; string MusicianShops3; if (Language.ActiveCulture == GameCulture.Chinese) { MusicianShops1 = "原版八音盒"; MusicianShops2 = "灾厄八音盒"; MusicianShops3 = "模组/瑟银八音盒"; } else { MusicianShops1 = "Vanilla Music Boxes"; MusicianShops2 = "Calamity Music Boxes"; MusicianShops3 = "Mod/Thorium Music Boxes"; } UIText text = new UIText(MusicianShops1); text.Left.Set(35, 0f); text.Top.Set(10, 0f); text.Width.Set(90, 0f); text.Height.Set(22, 0f); MusicianShopsPanel.Append(text); UIText text2 = new UIText(MusicianShops2); text2.Left.Set(35, 0f); text2.Top.Set(40, 0f); text2.Width.Set(90, 0f); text2.Height.Set(22, 0f); MusicianShopsPanel.Append(text2); UIText text3 = new UIText(MusicianShops3); text3.Left.Set(35, 0f); text3.Top.Set(70, 0f); text3.Width.Set(90, 0f); text3.Height.Set(22, 0f); MusicianShopsPanel.Append(text3); Texture2D buttonPlayTexture = ModContent.GetTexture("Terraria/UI/ButtonPlay"); UIImageButton playButton = new UIImageButton(buttonPlayTexture); playButton.Left.Set(10, 0f); playButton.Top.Set(10, 0f); playButton.Width.Set(22, 0f); playButton.Height.Set(22, 0f); playButton.OnClick += new MouseEvent(PlayButtonClicked1); MusicianShopsPanel.Append(playButton); UIImageButton playButton2 = new UIImageButton(buttonPlayTexture); playButton2.Left.Set(10, 0f); playButton2.Top.Set(40, 0f); playButton2.Width.Set(22, 0f); playButton2.Height.Set(22, 0f); playButton2.OnClick += new MouseEvent(PlayButtonClicked2); MusicianShopsPanel.Append(playButton2); UIImageButton playButton3 = new UIImageButton(buttonPlayTexture); playButton3.Left.Set(10, 0f); playButton3.Top.Set(70, 0f); playButton3.Width.Set(22, 0f); playButton3.Height.Set(22, 0f); playButton3.OnClick += new MouseEvent(PlayButtonClicked3); MusicianShopsPanel.Append(playButton3); Texture2D buttonDeleteTexture = ModContent.GetTexture("Terraria/UI/ButtonDelete"); UIImageButton closeButton = new UIImageButton(buttonDeleteTexture); closeButton.Left.Set(230, 0f); closeButton.Top.Set(10, 0f); closeButton.Width.Set(22, 0f); closeButton.Height.Set(22, 0f); closeButton.OnClick += new MouseEvent(CloseButtonClicked); MusicianShopsPanel.Append(closeButton); base.Append(MusicianShopsPanel); }
public UIModPackItem(string name, string[] mods) { this.filename = name; this.mods = mods; this.numMods = mods.Length; modMissing = new bool[mods.Length]; numModsEnabled = 0; numModsDisabled = 0; numModsMissing = 0; for (int i = 0; i < mods.Length; i++) { if (UIModPacks.mods.Contains(mods[i])) { if (ModLoader.IsEnabled(mods[i])) { numModsEnabled++; } else { numModsDisabled++; } } else { modMissing[i] = true; numModsMissing++; } } this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); this.Height.Set(126f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); this.modName = new UIText(name, 1f, false); this.modName.Left.Set(10f, 0f); this.modName.Top.Set(5f, 0f); base.Append(this.modName); UITextPanel <string> viewListButton = new UITextPanel <string>("View List", 1f, false); viewListButton.Width.Set(100f, 0f); viewListButton.Height.Set(30f, 0f); viewListButton.Left.Set(430f, 0f); viewListButton.Top.Set(40f, 0f); viewListButton.PaddingTop -= 2f; viewListButton.PaddingBottom -= 2f; viewListButton.OnMouseOver += UICommon.FadedMouseOver; viewListButton.OnMouseOut += UICommon.FadedMouseOut; viewListButton.OnClick += ViewListInfo; base.Append(viewListButton); enableListButton = new UITextPanel <string>("Enable this List", 1f, false); enableListButton.Width.Set(100f, 0f); enableListButton.Height.Set(30f, 0f); enableListButton.Left.Set(273f, 0f); enableListButton.Top.Set(40f, 0f); enableListButton.PaddingTop -= 2f; enableListButton.PaddingBottom -= 2f; enableListButton.OnMouseOver += UICommon.FadedMouseOver; enableListButton.OnMouseOut += UICommon.FadedMouseOut; enableListButton.OnClick += EnableList; base.Append(enableListButton); enableListOnlyButton = new UITextPanel <string>("Enable only this List", 1f, false); enableListOnlyButton.Width.Set(100f, 0f); enableListOnlyButton.Height.Set(30f, 0f); enableListOnlyButton.Left.Set(75f, 0f); enableListOnlyButton.Top.Set(40f, 0f); enableListOnlyButton.PaddingTop -= 2f; enableListOnlyButton.PaddingBottom -= 2f; enableListOnlyButton.OnMouseOver += UICommon.FadedMouseOver; enableListOnlyButton.OnMouseOut += UICommon.FadedMouseOut; enableListOnlyButton.OnClick += EnableListOnly; base.Append(enableListOnlyButton); viewInModBrowserButton = new UITextPanel <string>("View Mods in Mod Browser", 1f, false); viewInModBrowserButton.Width.Set(50f, 0f); viewInModBrowserButton.Height.Set(30f, 0f); viewInModBrowserButton.Left.Set(75f, 0f); viewInModBrowserButton.Top.Set(80f, 0f); viewInModBrowserButton.PaddingTop -= 2f; viewInModBrowserButton.PaddingBottom -= 2f; viewInModBrowserButton.OnMouseOver += UICommon.FadedMouseOver; viewInModBrowserButton.OnMouseOut += UICommon.FadedMouseOut; viewInModBrowserButton.OnClick += ViewInModBrowser; base.Append(viewInModBrowserButton); deleteButton = new UIImageButton(TextureManager.Load("Images/UI/ButtonDelete")); deleteButton.Top.Set(40f, 0f); deleteButton.OnClick += this.DeleteButtonClick; base.Append(deleteButton); }
// Color slider // customdata? // random jitter on all floats? // TODO, browser and Eyedropper, and Intents-Open other tool to select from it. public override void OnInitialize() { mainPanel = new UIPanel(); //mainPanel.SetPadding(0); mainPanel.Left.Set(-290f, 1f); mainPanel.Top.Set(-620f, 1f); mainPanel.Width.Set(240f, 0f); mainPanel.Height.Set(520f, 0f); mainPanel.SetPadding(12); mainPanel.BackgroundColor = new Color(173, 194, 171); int top = 0; UIText text = new UIText("Dust:", 0.85f); text.Top.Set(top, 0f); //text.Left.Set(12f, 0f); mainPanel.Append(text); UITextPanel <string> resetButton = new UITextPanel <string>("Reset Tool"); resetButton.SetPadding(4); resetButton.Width.Set(-10, 0.5f); resetButton.Left.Set(0, 0.5f); resetButton.Top.Set(top, 0f); resetButton.OnClick += ResetButton_OnClick; mainPanel.Append(resetButton); top += 20; noGravityCheckbox = new UICheckbox("No Gravity", ""); noGravityCheckbox.Top.Set(top, 0f); //gravityCheckbox.Left.Set(12f, 0f); mainPanel.Append(noGravityCheckbox); top += 20; noLightCheckbox = new UICheckbox("No Light", ""); noLightCheckbox.Top.Set(top, 0f); mainPanel.Append(noLightCheckbox); top += 20; showSpawnRectangleCheckbox = new UICheckbox("Show Spawn Rectangle", ""); showSpawnRectangleCheckbox.Top.Set(top, 0f); mainPanel.Append(showSpawnRectangleCheckbox); top += 30; scaleDataProperty = new UIFloatRangedDataValue("Scale:", 1f, 0, 5f); UIElement uiRange = new UIRange <float>(scaleDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; widthDataProperty = new UIIntRangedDataValue("Width:", 30, 0, 400); uiRange = new UIRange <int>(widthDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; heightDataProperty = new UIIntRangedDataValue("Height:", 30, 0, 400); uiRange = new UIRange <int>(heightDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; UIImageButton b = new UIImageButton(ModdersToolkit.instance.GetTexture("UIElements/searchIcon")); b.OnClick += (s, e) => { ShowDustChooser = !ShowDustChooser; Recalculate(); }; b.Top.Set(top, 0f); mainPanel.Append(b); typeDataProperty = new IntDataRangeProperty("Type:", 1, DustTool.dustCount, true); //TODO fix. typeDataProperty.range.Top.Set(top, 0f); typeDataProperty.range.Left.Set(20, 0f); typeDataProperty.range.Width.Set(-20, 1f); mainPanel.Append(typeDataProperty.range); //top += 30; //UIImageButton b = new UIImageButton(ModdersToolkit.instance.GetTexture("UIElements/eyedropper")); dustChooserUI = new DustChooserUI(userInterface); top += 30; useCustomColorCheckbox = new UICheckbox("Use Custom Color", ""); useCustomColorCheckbox.Top.Set(top, 0f); mainPanel.Append(useCustomColorCheckbox); top += 20; colorDataProperty = new ColorDataRangeProperty("Color:"); colorDataProperty.range.Top.Set(top, 0f); mainPanel.Append(colorDataProperty.range); top += 30; alphaDataProperty = new UIIntRangedDataValue("Alpha:", 0, 0, 255); uiRange = new UIRange <int>(alphaDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; shaderDataProperty = new UIIntRangedDataValue("Shader:", 0, 0, DustTool.shaderCount); uiRange = new UIRange <int>(shaderDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; speedXDataProperty = new UIFloatRangedDataValue("SpeedX:", 0, -10, 10); uiRange = new UIRange <float>(speedXDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; speedYDataProperty = new UIFloatRangedDataValue("SpeedY:", 0, -10, 10); uiRange = new UIRange <float>(speedYDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); //todo, position this better? displays as well? // top += 30; // var ui2DRange = new UI2DRange<float>(speedXDataProperty, speedYDataProperty); // ui2DRange.Top.Set(top, 0f); // //ui2DRange.Width.Set(0, 1f); // mainPanel.Append(ui2DRange); top += 30; fadeInDataProperty = new UIFloatRangedDataValue("FadeIn:", 0, 0, 3); uiRange = new UIRange <float>(fadeInDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; spawnChanceDataProperty = new UIFloatRangedDataValue("Spawn%:", 1f, 0, 1, true, true); uiRange = new UIRange <float>(spawnChanceDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 24; UIRadioButtonGroup g = new UIRadioButtonGroup(); NewDustRadioButton = new UIRadioButton("NewDust", "Dust.NewDust method"); NewDustPerfectRadioButton = new UIRadioButton("NewDustPerfect", "Dust.NewDust method"); NewDustDirectRadioButton = new UIRadioButton("NewDustDirect", "Dust.NewDust method"); g.Add(NewDustRadioButton); g.Add(NewDustPerfectRadioButton); g.Add(NewDustDirectRadioButton); g.Top.Pixels = top; g.Width.Set(0, .75f); mainPanel.Append(g); NewDustRadioButton.Selected = true; UIHoverImageButton copyCodeButton = new UIHoverImageButton(ModdersToolkit.instance.GetTexture("UIElements/CopyCodeButton"), "Copy code to clipboard"); copyCodeButton.OnClick += CopyCodeButton_OnClick; copyCodeButton.Top.Set(-20, 1f); copyCodeButton.Left.Set(-20, 1f); mainPanel.Append(copyCodeButton); Append(mainPanel); }
public UIModPackItem(string name, string[] mods) { this.filename = name; this.mods = mods; this.numMods = mods.Length; modMissing = new bool[mods.Length]; numModsEnabled = 0; numModsDisabled = 0; numModsMissing = 0; for (int i = 0; i < mods.Length; i++) { if (UIModPacks.mods.Contains(mods[i])) { if (ModLoader.IsEnabled(mods[i])) { numModsEnabled++; } else { numModsDisabled++; } } else { modMissing[i] = true; numModsMissing++; } } this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); this.Height.Set(126f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); this.modName = new UIText(name, 1f, false); this.modName.Left.Set(10f, 0f); this.modName.Top.Set(5f, 0f); base.Append(this.modName); UIAutoScaleTextTextPanel <string> viewListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewList"), 1f, false); viewListButton.Width.Set(100f, 0f); viewListButton.Height.Set(40f, 0f); viewListButton.Left.Set(407f, 0f); viewListButton.Top.Set(40f, 0f); viewListButton.PaddingTop -= 2f; viewListButton.PaddingBottom -= 2f; viewListButton.OnMouseOver += UICommon.FadedMouseOver; viewListButton.OnMouseOut += UICommon.FadedMouseOut; viewListButton.OnClick += ViewListInfo; base.Append(viewListButton); enableListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableThisList"), 1f, false); enableListButton.Width.Set(151f, 0f); enableListButton.Height.Set(36f, 0f); enableListButton.Left.Set(248f, 0f); enableListButton.Top.Set(40f, 0f); enableListButton.PaddingTop -= 2f; enableListButton.PaddingBottom -= 2f; enableListButton.OnMouseOver += UICommon.FadedMouseOver; enableListButton.OnMouseOut += UICommon.FadedMouseOut; enableListButton.OnClick += EnableList; base.Append(enableListButton); enableListOnlyButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableOnlyThisList"), 1f, false); enableListOnlyButton.Width.Set(190f, 0f); enableListOnlyButton.Height.Set(36f, 0f); enableListOnlyButton.Left.Set(50f, 0f); enableListOnlyButton.Top.Set(40f, 0f); enableListOnlyButton.PaddingTop -= 2f; enableListOnlyButton.PaddingBottom -= 2f; enableListOnlyButton.OnMouseOver += UICommon.FadedMouseOver; enableListOnlyButton.OnMouseOut += UICommon.FadedMouseOut; enableListOnlyButton.OnClick += EnableListOnly; base.Append(enableListOnlyButton); viewInModBrowserButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewModsInModBrowser"), 1f, false); viewInModBrowserButton.Width.Set(246f, 0f); viewInModBrowserButton.Height.Set(36f, 0f); viewInModBrowserButton.Left.Set(50f, 0f); viewInModBrowserButton.Top.Set(80f, 0f); viewInModBrowserButton.PaddingTop -= 2f; viewInModBrowserButton.PaddingBottom -= 2f; viewInModBrowserButton.OnMouseOver += UICommon.FadedMouseOver; viewInModBrowserButton.OnMouseOut += UICommon.FadedMouseOut; viewInModBrowserButton.OnClick += ViewInModBrowser; base.Append(viewInModBrowserButton); updateListWithEnabledButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackUpdateListWithEnabled"), 1f, false); updateListWithEnabledButton.Width.Set(225f, 0f); updateListWithEnabledButton.Height.Set(36f, 0f); updateListWithEnabledButton.Left.Set(304f, 0f); updateListWithEnabledButton.Top.Set(80f, 0f); updateListWithEnabledButton.PaddingTop -= 2f; updateListWithEnabledButton.PaddingBottom -= 2f; updateListWithEnabledButton.OnMouseOver += UICommon.FadedMouseOver; updateListWithEnabledButton.OnMouseOut += UICommon.FadedMouseOut; updateListWithEnabledButton.OnClick += (a, b) => UIModPacks.SaveModList(filename); Append(updateListWithEnabledButton); deleteButton = new UIImageButton(TextureManager.Load("Images/UI/ButtonDelete")); deleteButton.Top.Set(40f, 0f); deleteButton.OnClick += this.DeleteButtonClick; base.Append(deleteButton); }
public override void OnInitialize() { UnitsUIPanel = new DragableUIPanel(); UnitsUIPanel.HAlign = 0.9f; UnitsUIPanel.VAlign = 0.9f; UnitsUIPanel.Width.Set(180f, 0f); UnitsUIPanel.Height.Set(180f, 0f); unitsLeftText = new UIText("Units Left: "); unitsLeftText.Top.Set(0f, 0f); unitsLeftText.Left.Set(20f, 0f); unitsLeftText.Width.Set(40f, 0f); unitsLeftText.Height.Set(20f, 0f); UnitsUIPanel.Append(unitsLeftText); Texture2D soldierTextureImage = ModContent.GetTexture("JoJoStands/Projectiles/PlayerStands/BadCompany/BadCompanySoldier_Prone"); soldierTexture = new UIImage(soldierTextureImage); soldierTexture.HAlign = 0.1f; soldierTexture.VAlign = 0.5f; soldierTexture.Width.Set(soldierTextureImage.Width, 0f); soldierTexture.Height.Set(soldierTextureImage.Height, 0f); UnitsUIPanel.Append(soldierTexture); soldiersActiveText = new UIText("0"); soldiersActiveText.HAlign = soldierTexture.HAlign; soldiersActiveText.VAlign = soldierTexture.VAlign + textDistanceFromTexture; soldiersActiveText.Width.Set(20f, 0f); soldiersActiveText.Height.Set(20f, 0f); UnitsUIPanel.Append(soldiersActiveText); Texture2D leftButtonTexture = ModContent.GetTexture("JoJoStands/Extras/LeftArrow"); subtractSoldierButton = new UIImageButton(leftButtonTexture); subtractSoldierButton.HAlign = soldiersActiveText.HAlign - buttonPadding; subtractSoldierButton.VAlign = soldiersActiveText.VAlign; subtractSoldierButton.Width.Set(leftButtonTexture.Width, 0f); subtractSoldierButton.Height.Set(leftButtonTexture.Height, 0f); subtractSoldierButton.OnClick += OnClickSubtractSoldierButton; UnitsUIPanel.Append(subtractSoldierButton); Texture2D rightButtonTexture = ModContent.GetTexture("JoJoStands/Extras/RightArrow"); addSoldierButton = new UIImageButton(rightButtonTexture); addSoldierButton.HAlign = soldiersActiveText.HAlign + buttonPadding; addSoldierButton.VAlign = soldiersActiveText.VAlign; addSoldierButton.Width.Set(rightButtonTexture.Width, 0f); addSoldierButton.Height.Set(rightButtonTexture.Height, 0f); addSoldierButton.OnClick += OnClickAddSoldierButton; UnitsUIPanel.Append(addSoldierButton); Texture2D tankTextureImage = ModContent.GetTexture("JoJoStands/Projectiles/PlayerStands/BadCompany/BadCompanyTank"); tankTexture = new UIImage(tankTextureImage); tankTexture.HAlign = 0.5f; tankTexture.VAlign = 0.5f; tankTexture.Width.Set(tankTextureImage.Width, 0f); tankTexture.Height.Set(tankTextureImage.Height, 0f); UnitsUIPanel.Append(tankTexture); tanksActiveText = new UIText("0"); tanksActiveText.HAlign = tankTexture.HAlign; tanksActiveText.VAlign = tankTexture.VAlign + textDistanceFromTexture; tanksActiveText.Width.Set(20f, 0f); tanksActiveText.Height.Set(20f, 0f); UnitsUIPanel.Append(tanksActiveText); subtractTankButton = new UIImageButton(leftButtonTexture); subtractTankButton.HAlign = tanksActiveText.HAlign - buttonPadding; subtractTankButton.VAlign = tanksActiveText.VAlign; subtractTankButton.Width.Set(leftButtonTexture.Width, 0f); subtractTankButton.Height.Set(leftButtonTexture.Height, 0f); subtractTankButton.OnClick += OnClickSubtractTankButton; UnitsUIPanel.Append(subtractTankButton); addTankButton = new UIImageButton(rightButtonTexture); addTankButton.HAlign = tanksActiveText.HAlign + buttonPadding; addTankButton.VAlign = tanksActiveText.VAlign; addTankButton.Width.Set(rightButtonTexture.Width, 0f); addTankButton.Height.Set(rightButtonTexture.Height, 0f); addTankButton.OnClick += OnClickAddTankButton; UnitsUIPanel.Append(addTankButton); Texture2D chopperTextureImage = ModContent.GetTexture("JoJoStands/Extras/UnitsUIChopper"); chopperTexture = new UIImage(chopperTextureImage); chopperTexture.HAlign = 0.9f; chopperTexture.VAlign = 0.5f; chopperTexture.Width.Set(chopperTextureImage.Width, 0f); chopperTexture.Height.Set(chopperTextureImage.Height, 0f); UnitsUIPanel.Append(chopperTexture); choppersActiveText = new UIText("0"); choppersActiveText.HAlign = chopperTexture.HAlign; choppersActiveText.VAlign = chopperTexture.VAlign + textDistanceFromTexture; choppersActiveText.Width.Set(20f, 0f); choppersActiveText.Height.Set(20f, 0f); UnitsUIPanel.Append(choppersActiveText); subtractChopperButton = new UIImageButton(leftButtonTexture); subtractChopperButton.HAlign = choppersActiveText.HAlign - buttonPadding; subtractChopperButton.VAlign = choppersActiveText.VAlign; subtractChopperButton.Width.Set(leftButtonTexture.Width, 0f); subtractChopperButton.Height.Set(leftButtonTexture.Height, 0f); subtractChopperButton.OnClick += OnClickSubtractChopperButton; UnitsUIPanel.Append(subtractChopperButton); addChopperButton = new UIImageButton(rightButtonTexture); addChopperButton.HAlign = choppersActiveText.HAlign + buttonPadding; addChopperButton.VAlign = choppersActiveText.VAlign; addChopperButton.Width.Set(rightButtonTexture.Width, 0f); addChopperButton.Height.Set(rightButtonTexture.Height, 0f); addChopperButton.OnClick += OnClickAddChopperButton; UnitsUIPanel.Append(addChopperButton); Append(UnitsUIPanel); }
public override void OnInitialize() { mainPanel = new UIPanel(); mainPanel.SetPadding(6); int width = 350; int height = 840; mainPanel.Left.Set(-40f - width, 1f); mainPanel.Top.Set(-110f - height, 1f); mainPanel.Width.Set(width, 0f); mainPanel.Height.Set(height, 0f); mainPanel.BackgroundColor = new Color(173, 94, 171); int playgroundPanelWidth = 400; int playgroundPanelHeight = 150; playgroundPanel = new DebugDrawUIPanel(); playgroundPanel.SetPadding(0); playgroundPanel.Left.Set(0, .15f); playgroundPanel.Top.Set(0, .5f); playgroundPanel.Width.Set(playgroundPanelWidth, 0f); playgroundPanel.Height.Set(playgroundPanelHeight, 0f); playgroundPanel.BackgroundColor = new Color(108, 226, 108); Append(playgroundPanel); playgroundText = new UIText("Example UIText"); playgroundTextPanel = new UITextPanel <string>("Example UITextPanel"); playgroundImageButton = new UIImageButton(TextureAssets.InventoryBack10); // checkboxes int top = 0; int indent = 0; UIElement uiRange; UIText text = new UIText("UIPlayground UI:", 0.85f); //text.Top.Set(12f, 0f); //text.Left.Set(12f, 0f); mainPanel.Append(text); top += 20; panelPaddingData = new UIIntRangedDataValue("Panel Padding:", 0, 0, 12); uiRange = new UIRange <int>(panelPaddingData); panelPaddingData.OnValueChanged += () => UpdatePlaygroundChildren(); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); uiRange.Left.Set(indent, 0); mainPanel.Append(uiRange); top += 20; drawInnerDimensionsCheckbox = new UICheckbox("Draw Inner Dimensions", "Inner Dimensions takes into account Padding of the current UIElement"); drawInnerDimensionsCheckbox.TextColor = Color.Blue; drawInnerDimensionsCheckbox.Top.Set(top, 0f); drawInnerDimensionsCheckbox.Left.Set(indent, 0f); mainPanel.Append(drawInnerDimensionsCheckbox); top += 20; drawDimensionsCheckbox = new UICheckbox("Draw Dimensions", ""); drawDimensionsCheckbox.TextColor = Color.Pink; drawDimensionsCheckbox.Top.Set(top, 0f); drawDimensionsCheckbox.Left.Set(indent, 0f); mainPanel.Append(drawDimensionsCheckbox); top += 20; drawOuterDimensionsCheckbox = new UICheckbox("Draw Outer Dimensions", "Outer Dimensions takes into account Margin of the current UIElement"); drawOuterDimensionsCheckbox.TextColor = Color.Yellow; drawOuterDimensionsCheckbox.Top.Set(top, 0f); drawOuterDimensionsCheckbox.Left.Set(indent, 0f); mainPanel.Append(drawOuterDimensionsCheckbox); top += 20; top += 8; // additional spacing playgroundTextCheckbox = new UICheckbox("UIText", "Show UIText"); playgroundTextCheckbox.Top.Set(top, 0f); playgroundTextCheckbox.Left.Set(indent, 0f); playgroundTextCheckbox.OnSelectedChanged += () => UpdatePlaygroundChildren(); mainPanel.Append(playgroundTextCheckbox); top += 20; indent = 18; textHAlign = new UIFloatRangedDataValue("HAlign:", 0, 0, 1); textVAlign = new UIFloatRangedDataValue("VAlign:", 0, 0, 1); textLeftPixels = new UIFloatRangedDataValue("LeftPixels:", 0, 0, playgroundPanelWidth); textLeftPercent = new UIFloatRangedDataValue("LeftPercent:", 0, 0, 1); textTopPixels = new UIFloatRangedDataValue("TopPixels:", 0, 0, playgroundPanelHeight); textTopPercent = new UIFloatRangedDataValue("TopPercent:", 0, 0, 1); AppendRange(ref top, indent, textHAlign); AppendRange(ref top, indent, textVAlign); AppendRange(ref top, indent, textLeftPixels); AppendRange(ref top, indent, textLeftPercent); AppendRange(ref top, indent, textTopPixels); AppendRange(ref top, indent, textTopPercent); textHAlign.OnValueChanged += () => UpdatePlaygroundChildren(); textVAlign.OnValueChanged += () => UpdatePlaygroundChildren(); textLeftPixels.OnValueChanged += () => UpdatePlaygroundChildren(); textLeftPercent.OnValueChanged += () => UpdatePlaygroundChildren(); textTopPixels.OnValueChanged += () => UpdatePlaygroundChildren(); textTopPercent.OnValueChanged += () => UpdatePlaygroundChildren(); indent = 0; top += 8; // additional spacing playgroundTextPanelCheckbox = new UICheckbox("UITextPanel", "Show UITextPanel"); playgroundTextPanelCheckbox.Top.Set(top, 0f); playgroundTextPanelCheckbox.Left.Set(indent, 0f); playgroundTextPanelCheckbox.OnSelectedChanged += () => UpdatePlaygroundChildren(); mainPanel.Append(playgroundTextPanelCheckbox); top += 20; textPanelTextInput = new NewUITextBox("UITextPanel Text Here", 0.85f); textPanelTextInput.SetText(playgroundTextPanel.Text); //textPanelTextInput.SetPadding(0); textPanelTextInput.Top.Set(top, 0f); textPanelTextInput.Left.Set(indent, 0f); textPanelTextInput.Width.Set(-indent, 1f); mainPanel.Append(textPanelTextInput); textPanelTextInput.OnTextChanged += () => // order matters { //if (mainPanel.Parent != null) // UpdatePlaygroundChildren(); // playgroundTextPanel.SetText(textPanelTextInput.Text, textPanelTextScale.Data, false); }; top += 20; textPanelTextScale = new UIFloatRangedDataValue("TextScale:", playgroundTextPanel.TextScale, .2f, 3f); textPanelPadding = new UIFloatRangedDataValue("Padding:", playgroundTextPanel.PaddingBottom, 0, 12); textPanelHAlign = new UIFloatRangedDataValue("HAlign:", 0, 0, 1); textPanelVAlign = new UIFloatRangedDataValue("VAlign:", 0, 0, 1); textPanelLeftPixels = new UIFloatRangedDataValue("LeftPixels:", 0, 0, playgroundPanelWidth); textPanelLeftPercent = new UIFloatRangedDataValue("LeftPercent:", 0, 0, 1); textPanelTopPixels = new UIFloatRangedDataValue("TopPixels:", 0, 0, playgroundPanelHeight); textPanelTopPercent = new UIFloatRangedDataValue("TopPercent:", 0, 0, 1); textPanelWidthPixels = new UIFloatRangedDataValue("WidthPixels:", playgroundTextPanel.Width.Pixels, 0, playgroundPanelWidth); textPanelWidthPercent = new UIFloatRangedDataValue("WidthPercent:", playgroundTextPanel.Width.Precent, 0, 1); textPanelHeightPixels = new UIFloatRangedDataValue("HeightPixels:", playgroundTextPanel.Height.Pixels, 0, playgroundPanelHeight); textPanelHeightPercent = new UIFloatRangedDataValue("HeightPercent:", playgroundTextPanel.Height.Precent, 0, 1); //textPanelMinWidthPixels = new UIFloatRangedDataValue("MinWidthPixels:", playgroundTextPanel.MinWidth.Pixels, 0, playgroundPanelWidth); //textPanelMinWidthPercent = new UIFloatRangedDataValue("MinWidthPercent:", playgroundTextPanel.MinWidth.Precent, 0, 1); //textPanelMinHeightPixels = new UIFloatRangedDataValue("MinHeightPixels:", playgroundTextPanel.MinHeight.Pixels, 0, playgroundPanelHeight); //textPanelMinHeightPercent = new UIFloatRangedDataValue("MinHeightPercent:", playgroundTextPanel.MinHeight.Precent, 0, 1); AppendRange(ref top, indent, textPanelTextScale); AppendRange(ref top, indent, textPanelPadding); AppendRange(ref top, indent, textPanelHAlign); AppendRange(ref top, indent, textPanelVAlign); AppendRange(ref top, indent, textPanelLeftPixels); AppendRange(ref top, indent, textPanelLeftPercent); AppendRange(ref top, indent, textPanelTopPixels); AppendRange(ref top, indent, textPanelTopPercent); AppendRange(ref top, indent, textPanelWidthPixels); AppendRange(ref top, indent, textPanelWidthPercent); AppendRange(ref top, indent, textPanelHeightPixels); AppendRange(ref top, indent, textPanelHeightPercent); //AppendRange(ref top, indent, textPanelMinWidthPixels); //AppendRange(ref top, indent, textPanelMinWidthPercent); //AppendRange(ref top, indent, textPanelMinHeightPixels); //AppendRange(ref top, indent, textPanelMinHeightPercent); textPanelTextScale.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelPadding.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelHAlign.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelVAlign.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelLeftPixels.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelLeftPercent.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelTopPixels.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelTopPercent.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelWidthPixels.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelWidthPercent.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelHeightPixels.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelHeightPercent.OnValueChanged += () => UpdatePlaygroundChildren(); //textPanelMinWidthPixels.OnValueChanged += () => UpdatePlaygroundChildren(); //textPanelMinWidthPercent.OnValueChanged += () => UpdatePlaygroundChildren(); //textPanelMinHeightPixels.OnValueChanged += () => UpdatePlaygroundChildren(); //textPanelMinHeightPercent.OnValueChanged += () => UpdatePlaygroundChildren(); textPanelMinWidthHeightDisplay = new UIText("", 0.85f); textPanelMinWidthHeightDisplay.Top.Set(top, 0f); textPanelMinWidthHeightDisplay.Width.Set(-indent, 1f); textPanelMinWidthHeightDisplay.Left.Set(indent, 0); mainPanel.Append(textPanelMinWidthHeightDisplay); top += 20; indent = 0; top += 8; // additional spacing playgroundImageButtonCheckbox = new UICheckbox("UIImageButton", "Show UIImageButton"); playgroundImageButtonCheckbox.Top.Set(top, 0f); playgroundImageButtonCheckbox.Left.Set(indent, 0f); playgroundImageButtonCheckbox.OnSelectedChanged += () => UpdatePlaygroundChildren(); mainPanel.Append(playgroundImageButtonCheckbox); top += 20; indent = 18; imageButtonHAlign = new UIFloatRangedDataValue("HAlign:", 0, 0, 1); imageButtonVAlign = new UIFloatRangedDataValue("VAlign:", 0, 0, 1); imageButtonLeftPixels = new UIFloatRangedDataValue("LeftPixels:", 0, 0, playgroundPanelWidth); imageButtonLeftPercent = new UIFloatRangedDataValue("LeftPercent:", 0, 0, 1); imageButtonTopPixels = new UIFloatRangedDataValue("TopPixels:", 0, 0, playgroundPanelHeight); imageButtonTopPercent = new UIFloatRangedDataValue("TopPercent:", 0, 0, 1); AppendRange(ref top, indent, imageButtonHAlign); AppendRange(ref top, indent, imageButtonVAlign); AppendRange(ref top, indent, imageButtonLeftPixels); AppendRange(ref top, indent, imageButtonLeftPercent); AppendRange(ref top, indent, imageButtonTopPixels); AppendRange(ref top, indent, imageButtonTopPercent); imageButtonHAlign.OnValueChanged += () => UpdatePlaygroundChildren(); imageButtonVAlign.OnValueChanged += () => UpdatePlaygroundChildren(); imageButtonLeftPixels.OnValueChanged += () => UpdatePlaygroundChildren(); imageButtonLeftPercent.OnValueChanged += () => UpdatePlaygroundChildren(); imageButtonTopPixels.OnValueChanged += () => UpdatePlaygroundChildren(); imageButtonTopPercent.OnValueChanged += () => UpdatePlaygroundChildren(); text = new UIText("UIPlayground UI Extra:", 0.85f); mainPanel.Append(text); top += 20; drawAllDimensionsCheckbox = new UICheckbox("Draw All UIElement Dimensions", "This will draw outer dimensions for Elements in your mod."); drawAllDimensionsCheckbox.Top.Set(top, 0f); //drawAllDimensionsCheckbox.Left.Set(indent, 0f); mainPanel.Append(drawAllDimensionsCheckbox); top += 20; colorDataProperty = new ColorDataRangeProperty("Color:"); colorDataProperty.range.Top.Set(top, 0f); mainPanel.Append(colorDataProperty.range); top += 20; drawAllDimensionsDepthData = new UIIntRangedDataValue("Draw All Depth:", -1, -1, 10); uiRange = new UIRange <int>(drawAllDimensionsDepthData); //drawAllDimensionsDepthData.OnValueChanged += () => UpdatePlaygroundChildren(); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); //uiRange.Left.Set(indent, 0); mainPanel.Append(uiRange); top += 30; drawAllParallaxCheckbox = new UICheckbox("Draw with Parallax", "This will offset UIElements to help visualize their hierarchy"); drawAllParallaxCheckbox.Top.Set(top, 0f); //drawAllParallaxCheckbox.Left.Set(indent, 0f); mainPanel.Append(drawAllParallaxCheckbox); parallaxXProperty = new UIFloatRangedDataValue("ParallaxX:", 0, -10, 10); parallaxYProperty = new UIFloatRangedDataValue("ParallaxY:", 0, -10, 10); var ui2DRange = new UI2DRange <float>(parallaxXProperty, parallaxYProperty); ui2DRange.Top.Set(top, 0f); ui2DRange.Left.Set(200, 0f); mainPanel.Append(ui2DRange); top += 30; Append(mainPanel); }
void Awake () { button = GetComponent<UIImageButton>(); NGUITools.SetActive(button.gameObject, false); }
public MyUIWorldListItem(WorldFileData data, bool mentalMode) { MentalMode = mentalMode; BorderColor = new Color(89, 116, 213) * 0.7f; _dividerTexture = TextureManager.Load("Images/UI/Divider"); _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); _buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive"); _buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive"); _buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive"); _buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive"); _buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay"); _buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete"); Height.Set(96f, 0f); Width.Set(0f, 1f); base.SetPadding(6f); _data = data; _worldIcon = new UIImage(GetIcon()); _worldIcon.Left.Set(4f, 0f); _worldIcon.OnDoubleClick += new UIElement.MouseEvent(PlayGame); base.Append(_worldIcon); UIImageButton uIImageButton = new UIImageButton(_buttonPlayTexture); uIImageButton.VAlign = 1f; uIImageButton.Left.Set(4f, 0f); uIImageButton.OnClick += new UIElement.MouseEvent(PlayGame); base.OnDoubleClick += new UIElement.MouseEvent(PlayGame); uIImageButton.OnMouseOver += new UIElement.MouseEvent(PlayMouseOver); uIImageButton.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut); base.Append(uIImageButton); UIImageButton uIImageButton2 = new UIImageButton(_data.IsFavorite ? _buttonFavoriteActiveTexture : _buttonFavoriteInactiveTexture); uIImageButton2.VAlign = 1f; uIImageButton2.Left.Set(28f, 0f); uIImageButton2.OnClick += new UIElement.MouseEvent(FavoriteButtonClick); uIImageButton2.OnMouseOver += new UIElement.MouseEvent(FavoriteMouseOver); uIImageButton2.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut); uIImageButton2.SetVisibility(1f, _data.IsFavorite ? 0.8f : 0.4f); base.Append(uIImageButton2); if (SocialAPI.Cloud != null) { UIImageButton uIImageButton3 = new UIImageButton(_data.IsCloudSave ? _buttonCloudActiveTexture : _buttonCloudInactiveTexture); uIImageButton3.VAlign = 1f; uIImageButton3.Left.Set(52f, 0f); uIImageButton3.OnClick += new UIElement.MouseEvent(CloudButtonClick); uIImageButton3.OnMouseOver += new UIElement.MouseEvent(CloudMouseOver); uIImageButton3.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut); base.Append(uIImageButton3); } UIImageButton uIImageButton4 = new UIImageButton(_buttonDeleteTexture); uIImageButton4.VAlign = 1f; uIImageButton4.HAlign = 1f; uIImageButton4.OnClick += new UIElement.MouseEvent(DeleteButtonClick); uIImageButton4.OnMouseOver += new UIElement.MouseEvent(DeleteMouseOver); uIImageButton4.OnMouseOut += new UIElement.MouseEvent(DeleteMouseOut); _deleteButton = uIImageButton4; if (!_data.IsFavorite) { base.Append(uIImageButton4); } _buttonLabel = new UIText("", 1f, false); _buttonLabel.VAlign = 1f; _buttonLabel.Left.Set(80f, 0f); _buttonLabel.Top.Set(-3f, 0f); base.Append(_buttonLabel); _deleteButtonLabel = new UIText("", 1f, false); _deleteButtonLabel.VAlign = 1f; _deleteButtonLabel.HAlign = 1f; _deleteButtonLabel.Left.Set(-30f, 0f); _deleteButtonLabel.Top.Set(-3f, 0f); base.Append(_deleteButtonLabel); }
// Use this for initialization void Start () { button = GetComponent<UIImageButton>(); if(init_screen.inst != null) init_screen.inst.close_screen(); }
// Use this for initialization void Start () { Logger.Log("start potion "+_potionID, Logger.Level.TRACE); if(potionDisplayer==null){ potionDisplayer = transform.parent.GetComponent<PotionsDisplayer>() as PotionsDisplayer; } _imageButton = gameObject.GetComponent<UIImageButton>() as UIImageButton; _uri = getRandomSprite(); setSprite(_uri); }
public override void OnInitialize() { Instance = this; #region Panel definition mapDevicePanel = new UIPanel(); mapDevicePanel.SetPadding(0); mapDevicePanel.Left.Set(position.X, 0f); mapDevicePanel.Top.Set(position.Y, 0f); mapDevicePanel.Width.Set(UIItemSlot.defaultBackgroundTexture.Width + (10 * 4) + (100 * 2), 0f); mapDevicePanel.Height.Set(UIItemSlot.defaultBackgroundTexture.Height + 30 + (10 * 2) + 45, 0f); mapDevicePanel.BackgroundColor = new Color(73, 94, 171); mapDevicePanel.OnMouseDown += new MouseEvent(DragStart); mapDevicePanel.OnMouseUp += new MouseEvent(DragEnd); #endregion #region Close button UIImageButton closeButton = new UIImageButton(ModContent.GetTexture("PathOfModifiers/UI/CloseButton")); closeButton.Left.Set(mapDevicePanel.Width.Pixels - 26, 0); closeButton.Top.Set(10, 0); closeButton.OnClick += OnCloseButtonClicked; mapDevicePanel.Append(closeButton); #endregion #region Map slot mapSlot = new UIItemSlot(new Item(), null, 1); mapSlot.Left.Set(10, 0f); mapSlot.Top.Set(30, 0f); mapSlot.CheckCanPutIntoSlot += MapCanPutIntoSlot; mapSlot.CheckIsLocked += delegate(ref bool isLocked) { if (!isLocked) { isLocked = IsLocked; } }; mapSlot.OnItemChange += MapItemChanged; mapSlot.OnItemChange += OnSlotItemChange; mapDevicePanel.Append(mapSlot); #endregion #region Action buttons UITextButton beginButton = new UITextButton("Begin", Color.White); beginButton.Left.Set(UIItemSlot.defaultBackgroundTexture.Width + (10 * 2), 0f); beginButton.Top.Set(30, 0f); beginButton.Width.Set(100, 0f); beginButton.Height.Set(UIItemSlot.defaultBackgroundTexture.Height, 0f); beginButton.OnClick += new MouseEvent(BeginButtonClicked); mapDevicePanel.Append(beginButton); UITextButton endButton = new UITextButton("End", Color.White); endButton.Left.Set(UIItemSlot.defaultBackgroundTexture.Width + (10 * 3) + (100 * 1), 0f); endButton.Top.Set(30, 0f); endButton.Width.Set(100, 0f); endButton.Height.Set(UIItemSlot.defaultBackgroundTexture.Height, 0f); endButton.OnClick += new MouseEvent(EndButtonClicked); mapDevicePanel.Append(endButton); #endregion UIPanelConditioned beginConditionPanel = new UIPanelConditioned(); beginConditionPanel.Left.Set(UIItemSlot.defaultBackgroundTexture.Width + (10 * 2), 0f); beginConditionPanel.Top.Set(30, 0f); beginConditionPanel.Width.Set(100, 0f); beginConditionPanel.Height.Set(UIItemSlot.defaultBackgroundTexture.Height, 0f); beginConditionPanel.drawableCondition = delegate() { return(MapDevice.activeMD.mapItem.IsAir || MapDevice.activeMD.timeLeft > 0 || !(MapDevice.activeMD.mapItem.modItem is Items.Map)); }; mapDevicePanel.Append(beginConditionPanel); UIPanelConditioned endConditionPanel = new UIPanelConditioned(); endConditionPanel.Left.Set(UIItemSlot.defaultBackgroundTexture.Width + (10 * 3) + (100 * 1), 0f); endConditionPanel.Top.Set(30, 0f); endConditionPanel.Width.Set(100, 0f); endConditionPanel.Height.Set(UIItemSlot.defaultBackgroundTexture.Height, 0f); endConditionPanel.drawableCondition = delegate() { return(MapDevice.activeMD.timeLeft == 0); }; mapDevicePanel.Append(endConditionPanel); UIText timeLeftLabelText = new UIText("Time Left", 0.6f, true); timeLeftLabelText.Left.Set(10, 0); timeLeftLabelText.Top.Set(UIItemSlot.defaultBackgroundTexture.Height + 30 + (10 * 1) + 15, 0f); mapDevicePanel.Append(timeLeftLabelText); timeLeftText = new UIText(GetTimeLeftString(0), 1.2f, true); timeLeftText.Left.Set(150, 0); timeLeftText.Top.Set(UIItemSlot.defaultBackgroundTexture.Height + 30 + (10 * 1), 0f); mapDevicePanel.Append(timeLeftText); Append(mapDevicePanel); }
public UIWorldLoadSpecial(GenerationProgress progress, Mod mod) { instance = this; menuTexture = mod.GetTexture("menu"); previousTexture = mod.GetTexture("previous"); playTexture = mod.GetTexture("play"); pauseTexture = mod.GetTexture("pause"); nextTexture = mod.GetTexture("next"); menuButton = new UIImageButton(menuTexture); previousButton = new UIImageButton(previousTexture); playButton = new UIImageButton(playTexture); pauseButton = new UIImageButton(pauseTexture); nextButton = new UIImageButton(nextTexture); cancelButton = new UIImageButton(mod.GetTexture("cancel")); passesPanel = new UIPanel(); passesPanel.SetPadding(3); passesPanel.Left.Pixels = listHidden ? panelWidth : 0; passesPanel.HAlign = 1f; passesPanel.Top.Set(0f, 0f); passesPanel.Width.Set(panelWidth, 0f); passesPanel.Height.Set(0f, 1f); passesPanel.BackgroundColor = new Color(73, 94, 171); passesList = new UIList(); passesList.Width.Set(0f, 1f); passesList.Height.Set(0f, 1f); passesList.ListPadding = 12f; passesPanel.Append(passesList); UIScrollbar passesListScrollbar = new UIScrollbar(); passesListScrollbar.SetView(100f, 1000f); passesListScrollbar.Height.Set(0f, 1f); passesListScrollbar.HAlign = 1f; passesPanel.Append(passesListScrollbar); passesList.SetScrollbar(passesListScrollbar); int order = 0; for (int i = 0; i < WorldGenPreviewerModWorld.generationPasses.Count; i++) { GenPass pass = WorldGenPreviewerModWorld.generationPasses[i]; if (pass.Name != "World Gen Paused") { order++; UIPassItem testLabel = new UIPassItem(order, pass, pass.Name, 1f, false); //testLabel.Top.Pixels = y; //y += 10; passesList.Add(testLabel); //passesPanel.Append(testLabel); } } Append(passesPanel); buttonPanel = new UIPanel(); buttonPanel.SetPadding(0); //buttonPanel.Left.Set(0f, .5f); buttonPanel.HAlign = 0.5f; buttonPanel.Top.Set(180f, 0f); //buttonPanel.Width.Set(170f, 0f); buttonPanel.Height.Set(32 + spacing * 2 + 16, 0f); buttonPanel.BackgroundColor = new Color(73, 94, 171); float calculatedWidth = spacing; buttonPanel.Append(menuButton); menuButton.OnClick += MenuClick; menuButton.Left.Pixels = calculatedWidth; menuButton.Top.Pixels = spacing; calculatedWidth += spacing + 32; buttonPanel.Append(previousButton); previousButton.OnClick += PreviousClick; previousButton.Left.Pixels = calculatedWidth; previousButton.Top.Pixels = spacing; calculatedWidth += spacing + 32; buttonPanel.Append(playButton); playButton.OnClick += PlayClick; playButton.Left.Pixels = calculatedWidth; playButton.Top.Pixels = spacing; calculatedWidth += spacing + 32; buttonPanel.Append(pauseButton); pauseButton.OnClick += PauseClick; pauseButton.Left.Pixels = calculatedWidth; pauseButton.Top.Pixels = spacing; calculatedWidth += spacing + 32; buttonPanel.Append(nextButton); nextButton.OnClick += NextClick; nextButton.Left.Pixels = calculatedWidth; nextButton.Top.Pixels = spacing; calculatedWidth += spacing + 32; buttonPanel.Append(cancelButton); cancelButton.OnClick += CancelClick; cancelButton.Left.Pixels = calculatedWidth; cancelButton.Top.Pixels = spacing; calculatedWidth += spacing + 32; statusLabel = new UIText("Status: Normal", 1f, false); statusLabel.VAlign = 1f; statusLabel.HAlign = 0.5f; statusLabel.Top.Set(-5f, 0f); buttonPanel.Append(statusLabel); buttonPanel.Width.Pixels = calculatedWidth; Append(buttonPanel); this._progressBar.Top.Pixels = 70f; this._progressBar.HAlign = 0.5f; this._progressBar.VAlign = 0f; this._progressBar.Recalculate(); this._progressMessage.CopyStyle(this._progressBar); UIHeader expr_78_cp_0 = this._progressMessage; expr_78_cp_0.Top.Pixels = expr_78_cp_0.Top.Pixels - 70f; this._progressMessage.Recalculate(); this._progress = progress; base.Append(this._progressBar); base.Append(this._progressMessage); }
public override void OnInitialize() { ChooseClass = new UIPanel(); ChooseClass.SetPadding(0); ChooseClass.Left.Set(400f, 0f); ChooseClass.Top.Set(100f, 0f); ChooseClass.Width.Set(800f, 0f); ChooseClass.Height.Set(300f, 0f); ChooseClass.BackgroundColor = new Color(73, 94, 171); ChooseClass.OnMouseDown += new UIElement.MouseEvent(DragStart); ChooseClass.OnMouseUp += new UIElement.MouseEvent(DragEnd); Texture2D buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete"); UIImageButton closeButton = new UIImageButton(buttonDeleteTexture); closeButton.Left.Set(740, 0f); closeButton.Top.Set(10, 0f); closeButton.Width.Set(22, 0f); closeButton.Height.Set(22, 0f); closeButton.OnClick += new MouseEvent(CloseButtonClicked); ChooseClass.Append(closeButton); UIText ChooseClassText = new UIText("Choose your class to start with:", 1, true); ChooseClassText.Left.Set(20, 0f); ChooseClassText.Top.Set(40, 0f); ChooseClassText.Width.Set(50, 0f); ChooseClassText.Height.Set(50, 0f); ChooseClass.Append(ChooseClassText); UIText WarriorText = new UIText("Warrior", 1, false); WarriorText.Left.Set(50, 0f); WarriorText.Top.Set(220, 0f); WarriorText.Width.Set(50, 0f); WarriorText.Height.Set(50, 0f); WarriorText.OnClick += new MouseEvent(WarriorButtonClicked); ChooseClass.Append(WarriorText); UIText RangerText = new UIText("Ranger", 1, false); RangerText.Left.Set(200, 0f); RangerText.Top.Set(220, 0f); RangerText.Width.Set(50, 0f); RangerText.Height.Set(50, 0f); RangerText.OnClick += new MouseEvent(RangerButtonClicked); ChooseClass.Append(RangerText); UIText SorcererText = new UIText("Sorcerer", 1, false); SorcererText.Left.Set(350, 0f); SorcererText.Top.Set(220, 0f); SorcererText.Width.Set(50, 0f); SorcererText.Height.Set(50, 0f); SorcererText.OnClick += new MouseEvent(SorcererButtonClicked); ChooseClass.Append(SorcererText); UIText ConjurerText = new UIText("Conjurer", 1, false); ConjurerText.Left.Set(500, 0f); ConjurerText.Top.Set(220, 0f); ConjurerText.Width.Set(50, 0f); ConjurerText.Height.Set(50, 0f); ConjurerText.OnClick += new MouseEvent(ConjurerButtonClicked); ChooseClass.Append(ConjurerText); UIText ThrowerText = new UIText("Thrower", 1, false); ThrowerText.Left.Set(650, 0f); ThrowerText.Top.Set(220, 0f); ThrowerText.Width.Set(50, 0f); ThrowerText.Height.Set(50, 0f); ThrowerText.OnClick += new MouseEvent(ThrowerButtonClicked); ChooseClass.Append(ThrowerText); base.Append(ChooseClass); }
void Awake() { m_instance = this; m_spMarketUIMogoUIRefreshCtrl = transform.FindChild("MarketUIMogoUIRefreshCtrl").GetComponentsInChildren <UISprite>(true)[0]; keyView = transform.FindChild("keyView").gameObject; keyActivateBtn = keyView.transform.FindChild("Button").GetComponent <MogoButton>(); keyInput = keyView.transform.FindChild("Input").GetComponent <UIInput>(); // 热销 hotImgBtn = transform.FindChild("hot").GetComponent <UIImageButton>(); hot = transform.FindChild("hot").GetComponent <MogoButton>(); hot.clickHandler = HotList; hot.pressHandler = HotPress; // 等级礼包 itemImgBtn = transform.FindChild("item").GetComponent <UIImageButton>(); item = transform.FindChild("item").GetComponent <MogoButton>(); item.clickHandler = ItemList; item.pressHandler = ItemPress; m_goItemIconNotice = transform.FindChild("item/ItemIconNotice").gameObject; // 宝石 jewelImgBtn = transform.FindChild("jewel").GetComponent <UIImageButton>(); jewel = transform.FindChild("jewel").GetComponent <MogoButton>(); jewel.clickHandler = JewelList; jewel.pressHandler = JewelPress; // 激活码礼包 keyImgBtn = transform.FindChild("key").GetComponent <UIImageButton>(); key = transform.FindChild("key").GetComponent <MogoButton>(); key.clickHandler = KeyView; key.pressHandler = KeyPress; keyActivateBtn.clickHandler = Activate; //翅膀 wingImgBtn = transform.FindChild("Wing").GetComponent <UIImageButton>(); wing = transform.FindChild("Wing").GetComponent <MogoButton>(); wing.clickHandler = WingView; wing.pressHandler = WingPress; m_marketUIBtnClose = transform.FindChild("MarketUIBtnClose").GetComponentsInChildren <MogoButton>(true)[0]; m_marketUIBtnClose.clickHandler = CloseHandler; m_goMarketUIArrowL = transform.FindChild("MarketUIArrow/MarketUIArrowL").gameObject; m_goMarketUIArrowR = transform.FindChild("MarketUIArrow/MarketUIArrowR").gameObject; pay = transform.FindChild("MarketUIBtnPay").GetComponent <MogoButton>(); rmb = transform.FindChild("MarketUIDiamondNum").GetComponent <UILabel>(); page = transform.FindChild("MarketUIPageNum").GetComponent <UILabel>(); m_MarketTabLabelList[(int)MarketUITab.HotTab] = transform.FindChild("hot/HotLabel").GetComponent <UILabel>(); m_MarketTabLabelList[(int)MarketUITab.JewelTab] = transform.FindChild("jewel/JewelLabel").GetComponent <UILabel>(); m_MarketTabLabelList[(int)MarketUITab.ItemTab] = transform.FindChild("item/ItemLabel").GetComponent <UILabel>(); m_MarketTabLabelList[(int)MarketUITab.KeyTab] = transform.FindChild("key/KeyLabel").GetComponent <UILabel>(); m_MarketTabLabelList[(int)MarketUITab.WingTab] = transform.FindChild("Wing/WingLabel").GetComponent <UILabel>(); foreach (var pair in m_MarketTabLabelList) { if (pair.Key == (int)MarketUITab.HotTab) { MarketTabDown(pair.Key); } else { MarketTabUp(pair.Key); } } // ChineseData if (m_MarketTabLabelList[(int)MarketUITab.HotTab] != null) { m_MarketTabLabelList[(int)MarketUITab.HotTab].text = LanguageData.GetContent(200011); // "热销"; } if (m_MarketTabLabelList[(int)MarketUITab.JewelTab] != null) { m_MarketTabLabelList[(int)MarketUITab.JewelTab].text = LanguageData.GetContent(200012); // "宝石"; } if (m_MarketTabLabelList[(int)MarketUITab.ItemTab] != null) { m_MarketTabLabelList[(int)MarketUITab.ItemTab].text = LanguageData.GetContent(200013); // "道具"; } if (m_MarketTabLabelList[(int)MarketUITab.KeyTab] != null) { m_MarketTabLabelList[(int)MarketUITab.KeyTab].text = LanguageData.GetContent(200014); // "激活码"; } if (m_MarketTabLabelList[(int)MarketUITab.WingTab] != null) { m_MarketTabLabelList[(int)MarketUITab.WingTab].text = LanguageData.GetContent(7525); //翅膀 } gameObject.transform.FindChild("MarketUIBtnPay/MarketUIBtnPayText").GetComponent <UILabel>().text = LanguageData.GetContent(5001); // "充值"; Transform cell = transform.FindChild("list/PropCell"); Transform listStage = transform.FindChild("list"); listView = listStage.GetComponent <MogoList>(); listView.turnPage = TurnPage; list.Add(new MarketItemView(cell)); for (int ii = 1; ii <= pageSize - 1; ii++) { GameObject copyCell = GameObject.Instantiate(cell.gameObject) as GameObject; MarketItemView itemCell = new MarketItemView(copyCell.transform); itemCell.AddToParent(listStage, gameObject.transform.rotation); list.Add(itemCell); itemCell.LocalPosition = cell.localPosition + new Vector3(CELL_WIDTH * ii, 0, 0); } //pre.clickHandler = PrePage; //next.clickHandler = NextPage; pay.clickHandler = Pay; buy = new MarketBuyView(gameObject.transform.FindChild("Buy")); buy.Close(); hotImgBtn.SelectedStatus(true); keyView.SetActive(false); EventDispatcher.AddEventListener <MarketItem>(MarketEvent.OpenBuy, OpenBuy); EventDispatcher.AddEventListener <bool>(MarketEvent.LigthArrow, LightArrowHandler); }
void Awake() { m_instance = this; m_spMarketUIMogoUIRefreshCtrl = transform.FindChild("MarketUIMogoUIRefreshCtrl").GetComponentsInChildren<UISprite>(true)[0]; keyView = transform.FindChild("keyView").gameObject; keyActivateBtn = keyView.transform.FindChild("Button").GetComponent<MogoButton>(); keyInput = keyView.transform.FindChild("Input").GetComponent<UIInput>(); // 热销 hotImgBtn = transform.FindChild("hot").GetComponent<UIImageButton>(); hot = transform.FindChild("hot").GetComponent<MogoButton>(); hot.clickHandler = HotList; hot.pressHandler = HotPress; // 等级礼包 itemImgBtn = transform.FindChild("item").GetComponent<UIImageButton>(); item = transform.FindChild("item").GetComponent<MogoButton>(); item.clickHandler = ItemList; item.pressHandler = ItemPress; m_goItemIconNotice = transform.FindChild("item/ItemIconNotice").gameObject; // 宝石 jewelImgBtn = transform.FindChild("jewel").GetComponent<UIImageButton>(); jewel = transform.FindChild("jewel").GetComponent<MogoButton>(); jewel.clickHandler = JewelList; jewel.pressHandler = JewelPress; // 激活码礼包 keyImgBtn = transform.FindChild("key").GetComponent<UIImageButton>(); key = transform.FindChild("key").GetComponent<MogoButton>(); key.clickHandler = KeyView; key.pressHandler = KeyPress; keyActivateBtn.clickHandler = Activate; //翅膀 wingImgBtn = transform.FindChild("Wing").GetComponent<UIImageButton>(); wing = transform.FindChild("Wing").GetComponent<MogoButton>(); wing.clickHandler = WingView; wing.pressHandler = WingPress; m_marketUIBtnClose = transform.FindChild("MarketUIBtnClose").GetComponentsInChildren<MogoButton>(true)[0]; m_marketUIBtnClose.clickHandler = CloseHandler; m_goMarketUIArrowL = transform.FindChild("MarketUIArrow/MarketUIArrowL").gameObject; m_goMarketUIArrowR = transform.FindChild("MarketUIArrow/MarketUIArrowR").gameObject; pay = transform.FindChild("MarketUIBtnPay").GetComponent<MogoButton>(); rmb = transform.FindChild("MarketUIDiamondNum").GetComponent<UILabel>(); page = transform.FindChild("MarketUIPageNum").GetComponent<UILabel>(); m_MarketTabLabelList[(int)MarketUITab.HotTab] = transform.FindChild("hot/HotLabel").GetComponent<UILabel>(); m_MarketTabLabelList[(int)MarketUITab.JewelTab] = transform.FindChild("jewel/JewelLabel").GetComponent<UILabel>(); m_MarketTabLabelList[(int)MarketUITab.ItemTab] = transform.FindChild("item/ItemLabel").GetComponent<UILabel>(); m_MarketTabLabelList[(int)MarketUITab.KeyTab] = transform.FindChild("key/KeyLabel").GetComponent<UILabel>(); m_MarketTabLabelList[(int)MarketUITab.WingTab] = transform.FindChild("Wing/WingLabel").GetComponent<UILabel>(); foreach (var pair in m_MarketTabLabelList) { if (pair.Key == (int)MarketUITab.HotTab) MarketTabDown(pair.Key); else MarketTabUp(pair.Key); } // ChineseData if (m_MarketTabLabelList[(int)MarketUITab.HotTab] != null) m_MarketTabLabelList[(int)MarketUITab.HotTab].text = LanguageData.GetContent(200011); // "热销"; if (m_MarketTabLabelList[(int)MarketUITab.JewelTab] != null) m_MarketTabLabelList[(int)MarketUITab.JewelTab].text = LanguageData.GetContent(200012); // "宝石"; if (m_MarketTabLabelList[(int)MarketUITab.ItemTab] != null) m_MarketTabLabelList[(int)MarketUITab.ItemTab].text = LanguageData.GetContent(200013); // "道具"; if (m_MarketTabLabelList[(int)MarketUITab.KeyTab] != null) m_MarketTabLabelList[(int)MarketUITab.KeyTab].text = LanguageData.GetContent(200014); // "激活码"; if (m_MarketTabLabelList[(int)MarketUITab.WingTab] != null) m_MarketTabLabelList[(int)MarketUITab.WingTab].text = LanguageData.GetContent(7525); //翅膀 gameObject.transform.FindChild("MarketUIBtnPay/MarketUIBtnPayText").GetComponent<UILabel>().text = LanguageData.GetContent(5001); // "充值"; Transform cell = transform.FindChild("list/PropCell"); Transform listStage = transform.FindChild("list"); listView = listStage.GetComponent<MogoList>(); listView.turnPage = TurnPage; list.Add(new MarketItemView(cell)); for (int ii = 1; ii <= pageSize - 1; ii++) { GameObject copyCell = GameObject.Instantiate(cell.gameObject) as GameObject; MarketItemView itemCell = new MarketItemView(copyCell.transform); itemCell.AddToParent(listStage, gameObject.transform.rotation); list.Add(itemCell); itemCell.LocalPosition = cell.localPosition + new Vector3(CELL_WIDTH * ii, 0, 0); } //pre.clickHandler = PrePage; //next.clickHandler = NextPage; pay.clickHandler = Pay; buy = new MarketBuyView(gameObject.transform.FindChild("Buy")); buy.Close(); hotImgBtn.SelectedStatus(true); keyView.SetActive(false); EventDispatcher.AddEventListener<MarketItem>(MarketEvent.OpenBuy, OpenBuy); EventDispatcher.AddEventListener<bool>(MarketEvent.LigthArrow, LightArrowHandler); }
void Start() { _imageButton = GetComponent<UIImageButton>(); _sprite = GetComponent<UISprite>(); }
public override void OnInitialize() { OperatorShopsPanel = new UIPanel(); OperatorShopsPanel.SetPadding(0); OperatorShopsPanel.Left.Set(575f, 0f); OperatorShopsPanel.Top.Set(275f, 0f); OperatorShopsPanel.Width.Set(260f, 0f); OperatorShopsPanel.Height.Set(130f, 0f); OperatorShopsPanel.BackgroundColor = new Color(73, 94, 171); OperatorShopsPanel.OnMouseDown += new UIElement.MouseEvent(DragStart); OperatorShopsPanel.OnMouseUp += new UIElement.MouseEvent(DragEnd); UIText text = new UIText("Materials/Boss Drops"); text.Left.Set(35, 0f); text.Top.Set(10, 0f); text.Width.Set(90, 0f); text.Height.Set(22, 0f); text.OnClick += new MouseEvent(PlayButtonClicked1); OperatorShopsPanel.Append(text); UIText text2 = new UIText("Vanilla Treasure Bags"); text2.Left.Set(35, 0f); text2.Top.Set(40, 0f); text2.Width.Set(70, 0f); text2.Height.Set(22, 0f); text2.OnClick += new MouseEvent(PlayButtonClicked2); OperatorShopsPanel.Append(text2); UIText text3 = new UIText("Modded Treasure Bags #1"); text3.Left.Set(35, 0f); text3.Top.Set(70, 0f); text3.Width.Set(120, 0f); text3.Height.Set(22, 0f); text3.OnClick += new MouseEvent(PlayButtonClicked3); OperatorShopsPanel.Append(text3); UIText text4 = new UIText("Modded Treasure Bags #2"); text4.Left.Set(35, 0f); text4.Top.Set(100, 0f); text4.Width.Set(120, 0f); text4.Height.Set(22, 0f); text4.OnClick += new MouseEvent(PlayButtonClicked4); OperatorShopsPanel.Append(text4); Texture2D buttonPlayTexture = ModContent.GetTexture("Terraria/UI/ButtonPlay"); UIImageButton playButton = new UIImageButton(buttonPlayTexture); playButton.Left.Set(10, 0f); playButton.Top.Set(10, 0f); playButton.Width.Set(22, 0f); playButton.Height.Set(22, 0f); playButton.OnClick += new MouseEvent(PlayButtonClicked1); OperatorShopsPanel.Append(playButton); UIImageButton playButton2 = new UIImageButton(buttonPlayTexture); playButton2.Left.Set(10, 0f); playButton2.Top.Set(40, 0f); playButton2.Width.Set(22, 0f); playButton2.Height.Set(22, 0f); playButton2.OnClick += new MouseEvent(PlayButtonClicked2); OperatorShopsPanel.Append(playButton2); UIImageButton playButton3 = new UIImageButton(buttonPlayTexture); playButton3.Left.Set(10, 0f); playButton3.Top.Set(70, 0f); playButton3.Width.Set(22, 0f); playButton3.Height.Set(22, 0f); playButton3.OnClick += new MouseEvent(PlayButtonClicked3); OperatorShopsPanel.Append(playButton3); UIImageButton playButton4 = new UIImageButton(buttonPlayTexture); playButton4.Left.Set(10, 0f); playButton4.Top.Set(100, 0f); playButton4.Width.Set(22, 0f); playButton4.Height.Set(22, 0f); playButton4.OnClick += new MouseEvent(PlayButtonClicked4); OperatorShopsPanel.Append(playButton4); Texture2D buttonDeleteTexture = ModContent.GetTexture("Terraria/UI/ButtonDelete"); UIImageButton closeButton = new UIImageButton(buttonDeleteTexture); closeButton.Left.Set(230, 0f); closeButton.Top.Set(10, 0f); closeButton.Width.Set(22, 0f); closeButton.Height.Set(22, 0f); closeButton.OnClick += new MouseEvent(CloseButtonClicked); OperatorShopsPanel.Append(closeButton); base.Append(OperatorShopsPanel); }
// Use this for initialization void Start () { button = GetComponent<UIImageButton>(); }
public override void OnInitialize() { float add = 0f; float width = 0f; float Revenge = 0f; int k = 0; if (ModLoader.GetMod("ThoriumMod") != null) { add += 60f; width += 160f; k = k + 2; } if (ModLoader.GetMod("CalamityMod") != null) { add += 90f; Revenge = 90f; } if (ModLoader.GetMod("Redemption") != null) { width += 80f; k = k + 1; } ZZPlayerInfoInterface = new UIPanel(); ZZPlayerInfoInterface.SetPadding(0); ZZPlayerInfoInterface.Left.Set(325f, 0f); ZZPlayerInfoInterface.Top.Set(335f, 0f); ZZPlayerInfoInterface.Width.Set(500f + width, 0f); ZZPlayerInfoInterface.Height.Set(380f + add + Revenge, 0f); ZZPlayerInfoInterface.BackgroundColor = new Color(73, 94, 171, 200); ZZPlayerInfoInterface.OnMouseDown += new UIElement.MouseEvent(DragStart); ZZPlayerInfoInterface.OnMouseUp += new UIElement.MouseEvent(DragEnd); PlayerInfo = new UIPlayerInfoDisplay(); PlayerInfo.Left.Set(30, 0f); PlayerInfo.Top.Set(30, 0f); PlayerInfo.Width.Set(300f, 0f); PlayerInfo.Height.Set(22, 0f); ZZPlayerInfoInterface.Append(PlayerInfo); PlayerClass = new UIPlayerClass(); PlayerClass.Left.Set(35, 0f); PlayerClass.Top.Set(240 + add, 0f); PlayerClass.Width.Set(15, 0f); PlayerClass.Height.Set(22, 0f); ZZPlayerInfoInterface.Append(PlayerClass); Texture2D buttonPlayerClass = ModContent.GetTexture("Terraria/UI/ButtonPlay");; UIImageButton PlayButton = new UIImageButton(buttonPlayerClass); PlayButton.Left.Set(40, 0f); PlayButton.Top.Set(240 + add, 0f); PlayButton.Width.Set(20, 0f); PlayButton.Height.Set(20, 0f); PlayButton.OnClick += new MouseEvent(PlayButtonClicked); ZZPlayerInfoInterface.Append(PlayButton); UIImageButton PlayButton2 = new UIImageButton(buttonPlayerClass); PlayButton2.Left.Set(120, 0f); PlayButton2.Top.Set(240 + add, 0f); PlayButton2.Width.Set(20, 0f); PlayButton2.Height.Set(20, 0f); PlayButton2.OnClick += new MouseEvent(PlayButton2Clicked); ZZPlayerInfoInterface.Append(PlayButton2); UIImageButton PlayButton3 = new UIImageButton(buttonPlayerClass); PlayButton3.Left.Set(200, 0f); PlayButton3.Top.Set(240 + add, 0f); PlayButton3.Width.Set(20, 0f); PlayButton3.Height.Set(20, 0f); PlayButton3.OnClick += new MouseEvent(PlayButton3Clicked); ZZPlayerInfoInterface.Append(PlayButton3); UIImageButton PlayButton4 = new UIImageButton(buttonPlayerClass); PlayButton4.Left.Set(280, 0f); PlayButton4.Top.Set(240 + add, 0f); PlayButton4.Width.Set(20, 0f); PlayButton4.Height.Set(20, 0f); PlayButton4.OnClick += new MouseEvent(PlayButton4Clicked); ZZPlayerInfoInterface.Append(PlayButton4); UIImageButton PlayButton5 = new UIImageButton(buttonPlayerClass); PlayButton5.Left.Set(360, 0f); PlayButton5.Top.Set(240 + add, 0f); PlayButton5.Width.Set(20, 0f); PlayButton5.Height.Set(20, 0f); PlayButton5.OnClick += new MouseEvent(PlayButton5Clicked); ZZPlayerInfoInterface.Append(PlayButton5); if (ModLoader.GetMod("ThoriumMod") != null) { UIImageButton PlayButton6 = new UIImageButton(buttonPlayerClass); PlayButton6.Left.Set(360 + 80, 0f); PlayButton6.Top.Set(240 + add, 0f); PlayButton6.Width.Set(20, 0f); PlayButton6.Height.Set(20, 0f); PlayButton6.OnClick += new MouseEvent(PlayButtonThorium1Clicked); ZZPlayerInfoInterface.Append(PlayButton6); UIImageButton PlayButton7 = new UIImageButton(buttonPlayerClass); PlayButton7.Left.Set(360 + 160, 0f); PlayButton7.Top.Set(240 + add, 0f); PlayButton7.Width.Set(20, 0f); PlayButton7.Height.Set(20, 0f); PlayButton7.OnClick += new MouseEvent(PlayButtonThorium2Clicked); ZZPlayerInfoInterface.Append(PlayButton7); } if (ModLoader.GetMod("Redemption") != null) { UIImageButton PlayButton8 = new UIImageButton(buttonPlayerClass); PlayButton8.Left.Set(360 + 80 * k, 0f); PlayButton8.Top.Set(240 + add, 0f); PlayButton8.Width.Set(20, 0f); PlayButton8.Height.Set(20, 0f); PlayButton8.OnClick += new MouseEvent(PlayButtonRedemptionClicked); ZZPlayerInfoInterface.Append(PlayButton8); } Mod mod = ZZLocalizationMod.Instance; Texture2D buttonDeleteTexture = ModContent.GetTexture("Terraria/UI/ButtonDelete"); UIImageButton closeButton = new UIImageButton(buttonDeleteTexture); closeButton.Left.Set(460 + width, 0f); closeButton.Top.Set(10, 0f); closeButton.Width.Set(22, 0f); closeButton.Height.Set(22, 0f); closeButton.OnClick += new MouseEvent(CloseButtonClicked); ZZPlayerInfoInterface.Append(closeButton); base.Append(ZZPlayerInfoInterface); }
public override void OnInitialize() { base.OnInitialize(); CookbookHeader BombBagHeader = new CookbookHeader("Bomb Bag"); BombBagHeader.HAlign = 0.6f; BombBagHeader.Top.Pixels = -20; BombBagHeader.TextColor = Color.LightGray; UIText BombBagFlavorText = new UIText("Never Ending Explosives"); BombBagFlavorText.HAlign = 0.5f; BombBagFlavorText.Top.Pixels = 30; BombBagFlavorText.TextColor = Color.GreenYellow; BombBagHeader.Append(BombBagFlavorText); UIText BombBagDescription = new UIText("Chance to throw a second\n" + "explosive at no addition cost"); BombBagDescription.Top.Pixels = 40; BombBagDescription.HAlign = 0.69f; BombBagDescription.TextColor = Color.DarkGray; leftPage.Append(BombBagDescription); leftPage.Append(BombBagHeader); CookbookHeader MysteryBombHeader = new CookbookHeader("Mystery Bomb"); MysteryBombHeader.HAlign = 0.75f; MysteryBombHeader.Top.Pixels = -20; MysteryBombHeader.TextColor = Color.LightGray; UIText MysteryBombFlavorText = new UIText("Strange shape for a bomb"); MysteryBombFlavorText.HAlign = 0.5f; MysteryBombFlavorText.Top.Pixels = 30; MysteryBombFlavorText.TextColor = Color.Red; MysteryBombHeader.Append(MysteryBombFlavorText); UIText MysteryBombDescription = new UIText("Chance to not consume explosives"); MysteryBombDescription.Top.Pixels = 40; MysteryBombDescription.HAlign = 0.95f; MysteryBombDescription.TextColor = Color.LightGray; rightPage.Append(MysteryBombDescription); rightPage.Append(MysteryBombHeader); CaptainExplosiveNPCBox = new UIPanel(); CaptainExplosiveNPCBox.Height.Pixels = 112; CaptainExplosiveNPCBox.Width.Pixels = 80; CaptainExplosiveNPCBox.Top.Pixels = 330; CaptainExplosiveNPCBox.HAlign = 0.5f; CaptainExplosiveNPCBox.Left.Pixels = 10; CaptainExplosiveNPCBox.BackgroundColor = new Color(0, 0, 0, 50); CaptainExplosiveNPCBox.BorderColor = new Color(0, 0, 0, 75); leftPage.Append(CaptainExplosiveNPCBox); UIText foundBB = new UIText(" Sold By:\nCaptain Explosive"); foundBB.TextColor = Color.LightGray; foundBB.HAlign = 0.5f; foundBB.Top.Pixels = -60; CaptainExplosiveNPCBox.Append(foundBB); UIText foundCENPC = new UIText("Always"); foundCENPC.TextColor = Color.LightGray; foundCENPC.HAlign = 0.5f; foundCENPC.Top.Pixels = 110; CaptainExplosiveNPCBox.Append(foundCENPC); CaptainExplosiveNPCAnimated = new AnimatedImage("ExtraExplosives/UI/AnarchistCookbookUI/Animations/CaptainExplosiveNPC/CaptainExplosiveNPC", 13, 5); CaptainExplosiveNPCAnimated.HAlign = 0.5f; CaptainExplosiveNPCAnimated.VAlign = 0.5f; CaptainExplosiveNPCAnimated.Height.Pixels = 112; CaptainExplosiveNPCAnimated.Width.Pixels = 80; CaptainExplosiveNPCBox.Append(CaptainExplosiveNPCAnimated); KoboldBox = new UIPanel(); KoboldBox.Height.Pixels = 112; KoboldBox.Width.Pixels = 108; KoboldBox.Top.Pixels = 330; KoboldBox.HAlign = 0.5f; KoboldBox.Left.Pixels = -70; KoboldBox.BackgroundColor = new Color(0, 0, 0, 50); KoboldBox.BorderColor = new Color(0, 0, 0, 75); rightPage.Append(KoboldBox); UIText foundMB1 = new UIText(" Dropped By:\n Kobold"); foundMB1.TextColor = Color.LightGray; foundMB1.HAlign = 0.5f; foundMB1.Top.Pixels = -60; foundMB1.Left.Pixels = 30; KoboldBox.Append(foundMB1); UIText foundK = new UIText(" Part of the:\nOld One's Army"); foundK.TextColor = Color.LightGray; foundK.HAlign = 0.5f; foundK.Top.Pixels = 110; foundK.Left.Pixels = 80; KoboldBox.Append(foundK); KoboldAnimated = new AnimatedImage("ExtraExplosives/UI/AnarchistCookbookUI/Animations/Kobold/Kobold", 8, 5); KoboldAnimated.HAlign = 0.5f; KoboldAnimated.VAlign = 0.5f; KoboldAnimated.Height.Pixels = 112; KoboldAnimated.Width.Pixels = 108; KoboldBox.Append(KoboldAnimated); KoboldGliderBox = new UIPanel(); KoboldGliderBox.Height.Pixels = 92; KoboldGliderBox.Width.Pixels = 156; KoboldGliderBox.Top.Pixels = 340; KoboldGliderBox.HAlign = 0.5f; KoboldGliderBox.Left.Pixels = 90; KoboldGliderBox.BackgroundColor = new Color(0, 0, 0, 50); KoboldGliderBox.BorderColor = new Color(0, 0, 0, 75); rightPage.Append(KoboldGliderBox); UIText foundMB2 = new UIText("\nKobold Glider"); foundMB2.TextColor = Color.LightGray; foundMB2.HAlign = 0.5f; foundMB2.Top.Pixels = -60; KoboldGliderBox.Append(foundMB2); KoboldGliderAnimated = new AnimatedImage("ExtraExplosives/UI/AnarchistCookbookUI/Animations/Kobold/KoboldGliderPiece", 2, 30); KoboldGliderAnimated.HAlign = 0.5f; KoboldGliderAnimated.VAlign = 0.5f; KoboldGliderAnimated.Height.Pixels = 92; KoboldGliderAnimated.Width.Pixels = 156; KoboldGliderBox.Append(KoboldGliderAnimated); ToggleBombBag = new UIImageButton(ModContent.GetTexture("ExtraExplosives/UI/AnarchistCookbookUI/Box")); BombBag = new UIImage(ModContent.GetTexture("ExtraExplosives/Items/Accessories/AnarchistCookbook/BombBag")); BombBag.VAlign = 0.5f; BombBag.HAlign = 0.5f; ToggleBombBag.Append(BombBag); // Image of bomb bag for labeling ToggleBombBag.Left.Pixels = 25; ToggleBombBag.Top.Pixels = leftPage.Height.Pixels / 2 - 100; ToggleBombBag.OnClick += new MouseEvent(BombBagToggle); leftPage.Append(ToggleBombBag); ToggleMysteryBomb = new UIImageButton(ModContent.GetTexture("ExtraExplosives/UI/AnarchistCookbookUI/Box")); MysteryBomb = new UIImage(ModContent.GetTexture("ExtraExplosives/Items/Accessories/AnarchistCookbook/MysteryBomb")); MysteryBomb.VAlign = 0.5f; MysteryBomb.HAlign = 0.5f; ToggleMysteryBomb.Append(MysteryBomb); // Image of bomb bag for labeling ToggleMysteryBomb.Left.Pixels = 50; ToggleMysteryBomb.Top.Pixels = leftPage.Height.Pixels / 2 - 100; ToggleMysteryBomb.OnClick += new MouseEvent(MysteryBombToggle); rightPage.Append(ToggleMysteryBomb); BombBagImage = new UIImage(ModContent.GetTexture("ExtraExplosives/UI/AnarchistCookbookUI/Accessories/BombBag")); BombBagImage.Left.Pixels = 0; BombBagImage.Top.Pixels = 0; BombBagImage.ImageScale = 0.8f; BombBagImage.OnClick += new MouseEvent(BombBagToggle); leftPage.Append(BombBagImage); MysteryBombImage = new UIImage(ModContent.GetTexture("ExtraExplosives/UI/AnarchistCookbookUI/Accessories/MysteryBomb")); MysteryBombImage.Left.Pixels = 20; MysteryBombImage.Top.Pixels = -16; MysteryBombImage.ImageScale = 0.7f; MysteryBombImage.OnClick += new MouseEvent(MysteryBombToggle); rightPage.Append(MysteryBombImage); BombBag_GreyscaleImage = new UIImage(ModContent.GetTexture("ExtraExplosives/UI/AnarchistCookbookUI/Accessories/BombBag_Greyscale")); BombBag_GreyscaleImage.Left.Pixels = 0; BombBag_GreyscaleImage.Top.Pixels = 0; BombBag_GreyscaleImage.ImageScale = 0.8f; BombBag_GreyscaleImage.OnClick += new MouseEvent(BombBagToggle); leftPage.Append(BombBag_GreyscaleImage); MysteryBomb_GreyscaleImage = new UIImage(ModContent.GetTexture("ExtraExplosives/UI/AnarchistCookbookUI/Accessories/MysteryBomb_Greyscale")); MysteryBomb_GreyscaleImage.Left.Pixels = 20; MysteryBomb_GreyscaleImage.Top.Pixels = -16; MysteryBomb_GreyscaleImage.ImageScale = 0.7f; MysteryBomb_GreyscaleImage.OnClick += new MouseEvent(MysteryBombToggle); rightPage.Append(MysteryBomb_GreyscaleImage); }
public void SearchFriendDone(bool isSuccess) { clearItems(); GameObject newItem = ResourceManager.Instance.loadWidget("FriendAddItem"); //(GameObject)Instantiate(friendListItem); newItem.transform.parent = gridFriend.transform; newItem.transform.localPosition = new Vector3(0, 0, -1); newItem.transform.localScale = new Vector3(1, 1, 1); newItem.name = Obj_MyselfPlayer.GetMe().friendSearchResult.guid.ToString(); //friendList[i].GetAccountName(); UIEventListener.Get(newItem.transform.FindChild("ApplyBtn").gameObject).onClick += friendAdd; Transform QxzbTopStarTrans = newItem.transform.FindChild("QxzbTopStar"); if (QxzbTopStarTrans != null) { //沒有群雄爭霸第一名 if (Obj_MyselfPlayer.GetMe().friendSearchResult.nQxzbTopStar >= 3 && Obj_MyselfPlayer.GetMe().friendSearchResult.nQxzbTopStar <= 7) { QxzbTopStarTrans.gameObject.SetActive(true); Transform starBgSpTrans = QxzbTopStarTrans.FindChild("StarBgObj/starBgSp"); if (starBgSpTrans != null) { UISprite spStarBg = starBgSpTrans.GetComponent <UISprite>(); if (spStarBg != null) { spStarBg.spriteName = UserFriend.friendStarTopBg[Obj_MyselfPlayer.GetMe().friendSearchResult.nQxzbTopStar]; } } Transform topStarTrans = QxzbTopStarTrans.FindChild("StarRank"); if (topStarTrans != null) { UISprite spTopStar = topStarTrans.GetComponent <UISprite>(); if (spTopStar != null) { spTopStar.spriteName = UserFriend.friendStarTop[Obj_MyselfPlayer.GetMe().friendSearchResult.nQxzbTopStar]; } } } else { QxzbTopStarTrans.gameObject.SetActive(false); } } //------------------------卡牌背景及外框-------------------------------- //2013-10-12 Jack Wen ////templeID < 0 情况的容错处理,暂时显示默认头像,且错误头像点击不给予反映// if (Obj_MyselfPlayer.GetMe().friendSearchResult.cardTempletID > 0) { UISprite icon_bg = newItem.transform.FindChild("CardIcon/CardIconBtn/Sprite-BG").GetComponent <UISprite>(); UISprite icon_border = newItem.transform.FindChild("CardIcon/CardIconBtn/Sprite").GetComponent <UISprite>(); int icon_star = TableManager.GetCardByID(Obj_MyselfPlayer.GetMe().friendSearchResult.cardTempletID).Star; icon_bg.spriteName = UserCardItem.littleCardFrameName[icon_star]; icon_border.spriteName = UserCardItem.littleCardBorderName[icon_star]; UIEventListener.Get(newItem.transform.FindChild("CardIcon/CardIconBtn").gameObject).onClick += ShowCardInfo; } //-------------------------------------------------------------------- UILabel nameLabel = newItem.transform.FindChild("Labels/Label-Name").GetComponent <UILabel>(); nameLabel.text = Obj_MyselfPlayer.GetMe().friendSearchResult.name; //friendList[i].GetAccountName(); //--------------------------------------------------------------------- //2013-7-26 Jack Wen UILabel levelLabel = newItem.transform.FindChild("Labels/Label-Level-Value").GetComponent <UILabel>(); levelLabel.text = Obj_MyselfPlayer.GetMe().friendSearchResult.level.ToString(); UILabel stateLabel = newItem.transform.FindChild("Labels/Label-State").GetComponent <UILabel>(); int lastOnlineTime = Obj_MyselfPlayer.GetMe().friendSearchResult.lastOnlineHours; int lastLogoutTime = Obj_MyselfPlayer.GetMe().friendSearchResult.lastLogoutHours; if (lastOnlineTime == -1 && lastLogoutTime >= 0) { UIImageButton button = newItem.GetComponent <UIImageButton>(); button.normalSprite = "liebiao_beijing_3"; button.hoverSprite = "liebiao_beijing_3"; button.pressedSprite = "liebiao_beijing_3"; UISprite back = newItem.transform.FindChild("Sprite/Background").GetComponent <UISprite>(); back.spriteName = "liebiao_beijing_3"; back = newItem.transform.FindChild("Sprite/haoyoubeijing").GetComponent <UISprite>(); back.alpha = 0.5f; if (lastLogoutTime / 60 >= 24) { stateLabel.text = "[222222]离线:" + lastLogoutTime / 60 / 24 + "天"; } else if (lastLogoutTime / 60 < 24 && lastLogoutTime / 60 > 0) { stateLabel.text = "[222222]离线:" + lastLogoutTime / 60 + "小时"; } else { stateLabel.text = "[222222]离线:" + lastLogoutTime % 60 + "分钟"; } } else if (lastOnlineTime >= 0 && lastLogoutTime == -1) { stateLabel.text = "[a5e295]登陆:" + lastOnlineTime / 60 + "小时前"; } //头像按钮显示卡牌信息 //2013-7-30 Jack Wen //五行显示 UISprite sttributeIcon = newItem.transform.FindChild("Sprite-Attribut").GetComponent <UISprite>(); string strIconName = ""; if (Obj_MyselfPlayer.GetMe().friendSearchResult.cardTempletID > 0) { int nAttributeID = TableManager.GetCardByID(Obj_MyselfPlayer.GetMe().friendSearchResult.cardTempletID).Element; switch (nAttributeID) { case 0: strIconName = "jin"; break; case 1: strIconName = "mu"; break; case 2: strIconName = "shui"; break; case 3: strIconName = "huo"; break; case 4: strIconName = "tu"; break; } } else { strIconName = "jin"; } sttributeIcon.spriteName = strIconName; UISprite icon = newItem.transform.FindChild("CardIcon/CardIconBtn/Sprite-Icon").GetComponent <UISprite>(); icon.spriteName = TableManager.GetAppearanceByID(TableManager.GetCardByID(Obj_MyselfPlayer.GetMe().friendSearchResult.cardTempletID).Appearance).HeadIcon; //2013-8-2 Jack Wen //加入好友主卡牌星级显示 if (Obj_MyselfPlayer.GetMe().friendSearchResult.cardTempletID > 0) { Tab_Card tabCard = TableManager.GetCardByID(Obj_MyselfPlayer.GetMe().friendSearchResult.cardTempletID); for (int start_i = 1; start_i < 8; start_i++) { if (start_i <= tabCard.Star) { newItem.transform.FindChild("StartManager/start_" + start_i).gameObject.SetActive(true); } else { newItem.transform.FindChild("StartManager/start_" + start_i).gameObject.SetActive(false); } } } //2013-8-6 Jack Wen //显示卡牌等级 UILabel cardLevel = newItem.transform.FindChild("Sprite/Panel-Lv/Label-lv").GetComponent <UILabel>(); cardLevel.text = Obj_MyselfPlayer.GetMe().friendSearchResult.cardLevel.ToString(); //--------------------------------------------------------------------- items.Add(newItem); }
void Awake() { button = GetComponent <UIImageButton>(); NGUITools.SetActive(button.gameObject, false); }
public UIRange(string labeltext, Func <float> getProportion, Action <float> setProportion, Action validateInput, bool fine = false) { this.Height.Set(20f, 0f); this._GetProportion = getProportion ?? (() => 0f); this._SetProportion = setProportion ?? ((s) => { }); if (fine) { label = new UIText(labeltext, 0.85f); label.Width.Set(0, .25f); label.VAlign = 0.5f; label.HAlign = 0; Append(label); slider = new UISlider(null, _GetProportion, _SetProportion, null, 0, Color.AliceBlue); slider.Height.Set(16, 0f); slider.Width.Set(0, .25f); slider.Left.Set(0, .25f); slider.VAlign = 0.5f; //slider.HAlign = .25f; Append(slider); minus = new UIImageButton(ModdersToolkit.instance.GetTexture("UIElements/ButtonMinus")); minus.OnClick += Minus_OnClick; //minus.Height.Set(16, 0f); minus.Width.Set(0, .125f); minus.Left.Set(2, .5f); //minus.Left.Set(0, .5f); //minus.HAlign = .5f; //minus.HAlign = .625f; Append(minus); plus = new UIImageButton(ModdersToolkit.instance.GetTexture("UIElements/ButtonPlus")); plus.OnClick += Plus_OnClick; //plus.Height.Set(16, 0f); plus.Width.Set(0, .125f); plus.Left.Set(2, .625f); plus.VAlign = 0.5f; //plus.HAlign = .75f; Append(plus); input = new NewUITextBox("input:", 0.85f); input.SetPadding(0); input.OnUnfocus += validateInput; //input.PaddingLeft = 12; input.Width.Set(0, .25f); input.Left.Set(0, .75f); input.VAlign = 0.5f; //input.HAlign = 1f; Append(input); } else { label = new UIText(labeltext, 0.85f); label.Width.Set(0, .33f); label.VAlign = 0.5f; //label.HAlign = -0.5f; Append(label); slider = new UISlider(null, _GetProportion, _SetProportion, null, 0, Color.AliceBlue); slider.Height.Set(16, 0f); slider.Width.Set(0, .33f); //slider.Left.Precent = 0.5f; slider.Left.Precent = 0.33f; slider.VAlign = 0.5f; //slider.HAlign = .5f; Append(slider); input = new NewUITextBox("input:", 0.85f); input.SetPadding(0); input.OnUnfocus += validateInput; //input.PaddingLeft = 12; input.Width.Set(0, .33f); //input.HAlign = 1f; input.VAlign = 0.5f; input.Left.Precent = 0.66f; Append(input); } }
public override void OnInitialize() { PipBoyTPPanel = new UIPanel(); PipBoyTPPanel.SetPadding(0); PipBoyTPPanel.Left.Set(575f, 0f); PipBoyTPPanel.Top.Set(275f, 0f); PipBoyTPPanel.Width.Set(250f, 0f); PipBoyTPPanel.Height.Set(200f, 0f); PipBoyTPPanel.BackgroundColor = new Color(73, 94, 171); PipBoyTPPanel.OnMouseDown += new UIElement.MouseEvent(DragStart); PipBoyTPPanel.OnMouseUp += new UIElement.MouseEvent(DragEnd); UIText text = new UIText("Beach Left/Right"); text.Left.Set(60, 0f); text.Top.Set(10, 0f); text.Width.Set(60, 0f); text.Height.Set(22, 0f); PipBoyTPPanel.Append(text); UIText text2 = new UIText("Ocean Left/Right"); text2.Left.Set(60, 0f); text2.Top.Set(40, 0f); text2.Width.Set(120, 0f); text2.Height.Set(22, 0f); PipBoyTPPanel.Append(text2); UIText text3 = new UIText("Dungeon"); text3.Left.Set(60, 0f); text3.Top.Set(70, 0f); text3.Width.Set(70, 0f); text3.Height.Set(22, 0f); text3.OnClick += new MouseEvent(PlayButtonClicked3); PipBoyTPPanel.Append(text3); UIText text4 = new UIText("Underworld Left/Right"); text4.Left.Set(60, 0f); text4.Top.Set(100, 0f); text4.Width.Set(120, 0f); text4.Height.Set(22, 0f); PipBoyTPPanel.Append(text4); UIText text5 = new UIText("Jungle Left/Right"); text5.Left.Set(60, 0f); text5.Top.Set(130, 0f); text5.Width.Set(100, 0f); text5.Height.Set(22, 0f); PipBoyTPPanel.Append(text5); UIText text6 = new UIText("Temple"); text6.Left.Set(60, 0f); text6.Top.Set(160, 0f); text6.Width.Set(75, 0f); text6.Height.Set(22, 0f); text6.OnClick += new MouseEvent(PlayButtonClicked6); PipBoyTPPanel.Append(text6); Mod mod = AlchemistNPC.Instance; Texture2D buttonPlayTexture = ModLoader.GetTexture("Terraria/UI/ButtonPlay"); Texture2D buttonBackTexture = mod.GetTexture("Interface/ButtonBack"); UIImageButton playButton = new UIImageButton(buttonBackTexture); playButton.Left.Set(10, 0f); playButton.Top.Set(10, 0f); playButton.Width.Set(22, 0f); playButton.Height.Set(22, 0f); playButton.OnClick += new MouseEvent(PlayButtonClicked1); PipBoyTPPanel.Append(playButton); UIImageButton playButton2 = new UIImageButton(buttonBackTexture); playButton2.Left.Set(10, 0f); playButton2.Top.Set(40, 0f); playButton2.Width.Set(22, 0f); playButton2.Height.Set(22, 0f); playButton2.OnClick += new MouseEvent(PlayButtonClicked2); PipBoyTPPanel.Append(playButton2); UIImageButton playButton3 = new UIImageButton(buttonPlayTexture); playButton3.Left.Set(10, 0f); playButton3.Top.Set(70, 0f); playButton3.Width.Set(22, 0f); playButton3.Height.Set(22, 0f); playButton3.OnClick += new MouseEvent(PlayButtonClicked3); PipBoyTPPanel.Append(playButton3); UIImageButton playButton4 = new UIImageButton(buttonBackTexture); playButton4.Left.Set(10, 0f); playButton4.Top.Set(100, 0f); playButton4.Width.Set(22, 0f); playButton4.Height.Set(22, 0f); playButton4.OnClick += new MouseEvent(PlayButtonClicked4); PipBoyTPPanel.Append(playButton4); UIImageButton playButton5 = new UIImageButton(buttonBackTexture); playButton5.Left.Set(10, 0f); playButton5.Top.Set(130, 0f); playButton5.Width.Set(22, 0f); playButton5.Height.Set(22, 0f); playButton5.OnClick += new MouseEvent(PlayButtonClicked5); PipBoyTPPanel.Append(playButton5); UIImageButton playButton6 = new UIImageButton(buttonPlayTexture); playButton6.Left.Set(10, 0f); playButton6.Top.Set(160, 0f); playButton6.Width.Set(22, 0f); playButton6.Height.Set(22, 0f); playButton6.OnClick += new MouseEvent(PlayButtonClicked6); PipBoyTPPanel.Append(playButton6); UIImageButton playButton11 = new UIImageButton(buttonPlayTexture); playButton11.Left.Set(35, 0f); playButton11.Top.Set(10, 0f); playButton11.Width.Set(22, 0f); playButton11.Height.Set(22, 0f); playButton11.OnClick += new MouseEvent(PlayButtonClicked11); PipBoyTPPanel.Append(playButton11); UIImageButton playButton22 = new UIImageButton(buttonPlayTexture); playButton22.Left.Set(35, 0f); playButton22.Top.Set(40, 0f); playButton22.Width.Set(22, 0f); playButton22.Height.Set(22, 0f); playButton22.OnClick += new MouseEvent(PlayButtonClicked22); PipBoyTPPanel.Append(playButton22); UIImageButton playButton44 = new UIImageButton(buttonPlayTexture); playButton44.Left.Set(35, 0f); playButton44.Top.Set(100, 0f); playButton44.Width.Set(22, 0f); playButton44.Height.Set(22, 0f); playButton44.OnClick += new MouseEvent(PlayButtonClicked44); PipBoyTPPanel.Append(playButton44); UIImageButton playButton55 = new UIImageButton(buttonPlayTexture); playButton55.Left.Set(35, 0f); playButton55.Top.Set(130, 0f); playButton55.Width.Set(22, 0f); playButton55.Height.Set(22, 0f); playButton55.OnClick += new MouseEvent(PlayButtonClicked55); PipBoyTPPanel.Append(playButton55); Texture2D buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete"); UIImageButton closeButton = new UIImageButton(buttonDeleteTexture); closeButton.Left.Set(220, 0f); closeButton.Top.Set(10, 0f); closeButton.Width.Set(22, 0f); closeButton.Height.Set(22, 0f); closeButton.OnClick += new MouseEvent(CloseButtonClicked); PipBoyTPPanel.Append(closeButton); base.Append(PipBoyTPPanel); }
// CreateClippingPlane #endregion #region CreateImageButton /// <summary> /// Creates an image button /// </summary> /// <param name="xmlNode"></param> /// <param name="targetRootPanel"></param> /// <param name="lastAnchor"></param> /// <param name="lastAnchorPath"></param> /// <param name="actualOutput"></param> /// <param name="targetWidth"></param> /// <param name="targetHeight"></param> /// <param name="psdAssetFolderPath"></param> /// <returns></returns> public static GameObject CreateImageButton(XMLNode xmlNode, UIPanel targetRootPanel, Transform lastAnchor, string lastAnchorPath, PsdImportedOutput actualOutput, float targetWidth, float targetHeight, string psdAssetFolderPath) { // get the widget info XmlWidgetInfo WidgetInfo = new XmlWidgetInfo(xmlNode); // Create an atlas if one does not exist if (NGUISettings.atlas == null) { NGUISettings.atlas = PsdAtlasManager.CreateNewAtlas(psdAssetFolderPath); } // get the button pressed states Dictionary <EButtonState, string> ButtonStatesDict = new Dictionary <EButtonState, string>(); if (!string.IsNullOrEmpty(WidgetInfo.ButtonPressedState)) { ButtonStatesDict.Add(EButtonState.Pressed, WidgetInfo.ButtonPressedState); } if (!string.IsNullOrEmpty(WidgetInfo.ButtonIdleState)) { ButtonStatesDict.Add(EButtonState.Idle, WidgetInfo.ButtonIdleState); } if (!string.IsNullOrEmpty(WidgetInfo.ButtonHoverState)) { ButtonStatesDict.Add(EButtonState.Hover, WidgetInfo.ButtonHoverState); } if (!string.IsNullOrEmpty(WidgetInfo.ButtonDisabledState)) { ButtonStatesDict.Add(EButtonState.Disabled, WidgetInfo.ButtonDisabledState); } // create the button GameObject NewGo = CreateNguiChildBaseGo(WidgetInfo, targetWidth, targetHeight, targetRootPanel, lastAnchor, lastAnchorPath, actualOutput); UIImageButton NewImageButton = NewGo.AddComponent <UIImageButton>(); // add the UISprite widget UISprite SpriteWidget = NewGo.AddComponent <UISprite>(); SpriteWidget.atlas = NGUISettings.atlas; SpriteWidget.pivot = NGUISettings.pivot; SpriteWidget.depth = NGUITools.CalculateNextDepth(targetRootPanel.gameObject); SpriteWidget.MakePixelPerfect(); NGUITools.AddWidgetCollider(NewImageButton.gameObject); NewImageButton.target = SpriteWidget; // set the UIImage button sprites bool WidthHeightSet = false; foreach (EButtonState ButtonKey in ButtonStatesDict.Keys) { // get the sprite, add to atlas if null UISpriteData ButtonSprite = GetSpriteData(psdAssetFolderPath, ButtonStatesDict[ButtonKey]); if (ButtonSprite == null) { continue; } // set sprite for the image button switch (ButtonKey) { case EButtonState.Idle: NewImageButton.normalSprite = ButtonSprite.name; break; case EButtonState.Pressed: NewImageButton.pressedSprite = ButtonSprite.name; break; case EButtonState.Hover: NewImageButton.hoverSprite = ButtonSprite.name; break; case EButtonState.Disabled: NewImageButton.disabledSprite = ButtonSprite.name; break; } // set dimensions, if not already set // NOTE: we check first, because setting the width/height performs a lot of calcs and redraws, so it's best to only set once if (!WidthHeightSet) { WidthHeightSet = true; SpriteWidget.width = ButtonSprite.width; SpriteWidget.height = ButtonSprite.height; } } // set the normal sprite SpriteWidget.spriteName = NewImageButton.normalSprite; return(NewGo); }
private void RecursiveDrawTransformation(Dictionary <TransformationDefinition, ManyToManyNode <TransformationDefinition> > tree, ManyToManyNode <TransformationDefinition> mtmn, ref int xOffset, ref int yOffset) { if (!mtmn.Current.HasMenuIcon || !mtmn.Current.CheckPrePlayerConditions()) { return; } Texture2D buffIcon = mtmn.Current.BuffIconGetter.Invoke(); if (buffIcon == null) { return; } UIImageButton transformationButton = null; UIImage unknownImage = null, unknownImageGray = null, lockedImage = null; InitButton(ref transformationButton, buffIcon, new MouseEvent((evt, element) => TrySelectingTransformation(mtmn.Current, evt, element)), xOffset, yOffset, backPanelImage); InitImage(ref unknownImage, GFX.unknownImage, 0, 0, transformationButton); unknownImage.ImageScale = 0f; InitImage(ref unknownImageGray, GFX.unknownImageGray, 0, 0, unknownImage); unknownImage.ImageScale = 0f; InitImage(ref lockedImage, GFX.lockedImage, 0, 0, unknownImageGray); lockedImage.ImageScale = 0f; _imagePairs.Add(mtmn.Current, new UIImagePair(transformationButton, unknownImage, unknownImageGray, lockedImage)); _imagePositions.Add(mtmn.Current, new Point(xOffset, yOffset)); xOffset += buffIcon.Width + SMALL_SPACE; int localXOffset = xOffset; for (int i = 0; i < mtmn.Next.Count; i++) { TransformationDefinition nextDef = mtmn.Next[i]; if (nextDef.BuffIconGetter == null) { continue; } List <Vector2> points = new List <Vector2>(); points.Add(_imagePositions[mtmn.Current].ToVector2()); for (int j = 0; j < mtmn.Previous.Count; j++) { if (mtmn.Previous[j].BuffIconGetter == null) { continue; } points.Add(_imagePositions[mtmn.Previous[j]].ToVector2()); } _polyLinesToDraw.Add(points.ToArray()); RecursiveDrawTransformation(tree, tree[nextDef], ref xOffset, ref yOffset); if (i + 1 < mtmn.Next.Count) { yOffset += buffIcon.Height + SMALL_SPACE * 2; } xOffset = localXOffset; } }
public override void OnInspectorGUI() { NGUIEditorTools.SetLabelWidth(80f); mButton = target as UIImageButton; if (mButton.targets == null) { mButton.targets = new UISprite[0]; } // // UISprite sprite = EditorGUILayout.ObjectField("Sprite", mButton.targets, typeof(UISprite), true) as UISprite; // // if (mButton.targets != sprite) // { // NGUIEditorTools.RegisterUndo("Image Button Change", mButton); // mButton.targets = sprite; // if (sprite != null) sprite.spriteName = mButton.normalSprite; // } // if (parDelIndex >= 0) // { // mButton.targets = ArrayInspector.ArrayRemoveByIndex(mButton.targets, parDelIndex); // parDelIndex = -1; // } // mButton.targets = DrawLuaGameObjList(mButton.targets); serializedObject.Update(); EditorGUIUtility.LookLikeInspector(); SerializedProperty tps = serializedObject.FindProperty("targets"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(tps, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } EditorGUIUtility.LookLikeControls(); if (mButton.targets.Length != 0) { UISprite sprite = mButton.targets[0]; if (sprite != null) { ComponentSelector.Draw <UIAtlas>(sprite.atlas, OnSelectAtlas); if (sprite.atlas != null) { string normal = mButton.normalSprite; string hover = mButton.hoverSprite; string press = mButton.pressedSprite; string disable = mButton.disableSprite; NGUIEditorTools.DrawSpriteField("Normal", "Normal state sprite", sprite.atlas, normal, (name) => { if (name != normal) { normal = name; Callback(sprite, normal, hover, press, disable); } }, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Hover", "Hover state sprite", sprite.atlas, hover, (name) => { if (hover != name) { hover = name; Callback(sprite, normal, hover, press, disable); } }, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Pressed", "Pressed state sprite", sprite.atlas, press, (name) => { if (press != name) { press = name; Callback(sprite, normal, hover, press, disable); } }, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Disabled", "Disabled state sprite", sprite.atlas, disable, (name) => { if (disable != name) { disable = name; Callback(sprite, normal, hover, press, disable); } }, GUILayout.Width(120f)); } } } }
public override void OnInitialize() { SizeMultiplier = (Main.screenHeight / 1080f); baseYOffset *= SizeMultiplier; baseXOffset *= SizeMultiplier; YOffset *= SizeMultiplier; XOffset *= SizeMultiplier; Instance = this; statsPanel = new UIPanel(); statsPanel.SetPadding(0); statsPanel.Left.Set(400f * SizeMultiplier, 0f); statsPanel.Top.Set(100f * SizeMultiplier, 0f); statsPanel.Width.Set(1000 * SizeMultiplier, 0f); statsPanel.Height.Set(600 * SizeMultiplier, 0f); statsPanel.BackgroundColor = new Color(73, 94, 171, 150); statsPanel.OnMouseDown += new UIElement.MouseEvent(DragStart); statsPanel.OnMouseUp += new UIElement.MouseEvent(DragEnd); PointsLeft = new UIText("Points : 0 / 0", SizeMultiplier); PointsLeft.Left.Set(250 * SizeMultiplier, 0f); PointsLeft.Top.Set(20 * SizeMultiplier, 0f); PointsLeft.Width.Set(0, 0f); PointsLeft.Height.Set(0, 0f); statsPanel.Append(PointsLeft); ResetText = new UIText("RESET", SizeMultiplier, true) { TextColor = Color.Gray }; ResetText.Left.Set(50 * SizeMultiplier, 0f); ResetText.Top.Set(20 * SizeMultiplier, 0f); ResetText.Width.Set(0, 0f); ResetText.Height.Set(0, 0f); ResetText.OnClick += new MouseEvent(ResetStats); ResetText.OnMouseOver += new MouseEvent(ResetTextHover); ResetText.OnMouseOut += new MouseEvent(ResetTextOut); statsPanel.Append(ResetText); Texture2D Button = ModContent.GetTexture("Terraria/UI/ButtonPlay"); for (int i = 0; i < 12; i++) { if (i < 8) { UIImageButton UpgradeStatButton = new UIImageButton(Button); UpgradeStatButton.Left.Set(baseXOffset + XOffset * 2, 0f); UpgradeStatButton.Top.Set(baseYOffset + (YOffset * i), 0f); UpgradeStatButton.Width.Set(22 * SizeMultiplier, 0f); UpgradeStatButton.Height.Set(22 * SizeMultiplier, 0f); Stat Statused = (Stat)i; UpgradeStatButton.OnMouseOver += new MouseEvent((UIMouseEvent, UIElement) => UpdateStat(UIMouseEvent, UIElement, Statused)); UpgradeStatButton.OnMouseOut += new MouseEvent(ResetOver); UpgradeStatButton.OnClick += new MouseEvent((UIMouseEvent, UIElement) => UpgradeStat(UIMouseEvent, UIElement, Statused, 1)); UpgradeStatButton.OnRightClick += new MouseEvent((UIMouseEvent, UIElement) => UpgradeStat(UIMouseEvent, UIElement, Statused, 5)); UpgradeStatButton.OnMiddleClick += new MouseEvent((UIMouseEvent, UIElement) => UpgradeStat(UIMouseEvent, UIElement, Statused, 25)); UpgradeStatButton.OnScrollWheel += new ScrollWheelEvent((UIMouseEvent, UIElement) => UpgradeStatWheel(UIMouseEvent, UIElement, Statused)); statsPanel.Append(UpgradeStatButton); progressStatsBar[i] = new StatProgress((Stat)i, ModContent.GetTexture("AnotherRpgMod/Textures/UI/Blank")); progressStatsBar[i].Left.Set(baseXOffset + XOffset * 1.0f, 0f); progressStatsBar[i].Top.Set(baseYOffset + (YOffset * i) + 6, 0f); progressStatsBar[i].Width.Set(105, 0); progressStatsBar[i].HAlign = 0; progressStatsBar[i].Height.Set(10, 0); progressStatsBar[i].width = 105; progressStatsBar[i].left = baseYOffset + (YOffset * i); statsPanel.Append(progressStatsBar[i]); progressStatsBarBG[i] = new ProgressBG(ModContent.GetTexture("AnotherRpgMod/Textures/UI/Blank")); progressStatsBarBG[i].Left.Set(baseXOffset + XOffset * 1.0f, 0f); progressStatsBarBG[i].Top.Set(baseYOffset + (YOffset * i) + 6, 0f); progressStatsBarBG[i].Width.Set(105, 0); progressStatsBarBG[i].HAlign = 0; progressStatsBarBG[i].Height.Set(10, 0); progressStatsBarBG[i].color = new Color(10, 0, 0, 128); progressStatsBar[i].left = baseYOffset + (YOffset * i); statsPanel.Append(progressStatsBarBG[i]); StatProgress[i] = new UIText("0", SizeMultiplier); StatProgress[i].SetText("0/2"); StatProgress[i].Left.Set(baseXOffset + XOffset * 2.3f, 0f); StatProgress[i].Top.Set(baseYOffset + (YOffset * i), 0f); StatProgress[i].HAlign = 0f; StatProgress[i].VAlign = 0f; StatProgress[i].MinWidth.Set(150 * SizeMultiplier, 0); StatProgress[i].MaxWidth.Set(150 * SizeMultiplier, 0); statsPanel.Append(StatProgress[i]); UpgradeStatText[i] = new UIText("0", SizeMultiplier); UpgradeStatText[i].SetText("Mana : 10 + 10"); UpgradeStatText[i].Left.Set(baseXOffset - 75, 0f); UpgradeStatText[i].Top.Set(baseYOffset + (YOffset * i), 0f); UpgradeStatText[i].HAlign = 0f; UpgradeStatText[i].VAlign = 0f; UpgradeStatText[i].MinWidth.Set(150 * SizeMultiplier, 0); UpgradeStatText[i].MaxWidth.Set(150 * SizeMultiplier, 0); statsPanel.Append(UpgradeStatText[i]); } InfoStat = new UIText("0", SizeMultiplier); InfoStat.SetText(""); InfoStat.Left.Set(baseXOffset - 75 * SizeMultiplier, 0f); InfoStat.Top.Set(baseYOffset + 300 * SizeMultiplier, 0f); InfoStat.HAlign = 0f; InfoStat.VAlign = 0f; InfoStat.MinWidth.Set(150 * SizeMultiplier, 0); InfoStat.MaxWidth.Set(150 * SizeMultiplier, 0); statsPanel.Append(InfoStat); UpgradeStatDetails[i] = new UIText("", SizeMultiplier); if (i < 3 || i > 7) { UpgradeStatDetails[i].SetText("Health : 100 - 5 Heart x 20 Health Per Heart"); } UpgradeStatDetails[i].SetText("Melee Damage Multiplier : 1"); UpgradeStatDetails[i].Left.Set(baseXOffset + (XOffset * 2.9f), 0f); UpgradeStatDetails[i].Top.Set(baseYOffset + (YOffset * i), 0f); UpgradeStatDetails[i].HAlign = 0f; UpgradeStatDetails[i].VAlign = 0f; UpgradeStatDetails[i].MinWidth.Set(300f * SizeMultiplier, 0); UpgradeStatDetails[i].MaxWidth.Set(300f * SizeMultiplier, 0); statsPanel.Append(UpgradeStatDetails[i]); UpgradeStatOver[i] = new UIText("", SizeMultiplier) { TextColor = Color.Aqua }; UpgradeStatOver[i].SetText(""); UpgradeStatOver[i].Left.Set(baseXOffset + (XOffset * 6.7f), 0f); UpgradeStatOver[i].Top.Set(baseYOffset + (YOffset * i), 0f); UpgradeStatOver[i].HAlign = 0f; UpgradeStatOver[i].VAlign = 0f; UpgradeStatOver[i].MinWidth.Set(20f * SizeMultiplier, 0); UpgradeStatOver[i].MaxWidth.Set(20f * SizeMultiplier, 0); statsPanel.Append(UpgradeStatOver[i]); } Append(statsPanel); }
public UIModPackItem(string name, string[] mods) { _filename = name; _mods = mods; _numMods = mods.Length; _modMissing = new bool[mods.Length]; _numModsEnabled = 0; _numModsDisabled = 0; _numModsMissing = 0; for (int i = 0; i < mods.Length; i++) { if (UIModPacks.Mods.Contains(mods[i])) { if (ModLoader.IsEnabled(mods[i])) { _numModsEnabled++; } else { _numModsDisabled++; } } else { _modMissing[i] = true; _numModsMissing++; } } BorderColor = new Color(89, 116, 213) * 0.7f; _dividerTexture = UICommon.DividerTexture; _innerPanelTexture = UICommon.InnerPanelTexture; Height.Pixels = 126; Width.Percent = 1f; SetPadding(6f); _modName = new UIText(name) { Left = { Pixels = 10 }, Top = { Pixels = 5 } }; Append(_modName); var viewListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewList")) { Width = { Pixels = 100 }, Height = { Pixels = 36 }, Left = { Pixels = 407 }, Top = { Pixels = 40 } }.WithFadedMouseOver(); viewListButton.PaddingTop -= 2f; viewListButton.PaddingBottom -= 2f; viewListButton.OnClick += ViewListInfo; Append(viewListButton); _enableListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableThisList")) { Width = { Pixels = 151 }, Height = { Pixels = 36 }, Left = { Pixels = 248 }, Top = { Pixels = 40 } }.WithFadedMouseOver(); _enableListButton.PaddingTop -= 2f; _enableListButton.PaddingBottom -= 2f; _enableListButton.OnClick += EnableList; Append(_enableListButton); _enableListOnlyButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableOnlyThisList")) { Width = { Pixels = 190 }, Height = { Pixels = 36 }, Left = { Pixels = 50 }, Top = { Pixels = 40 } }.WithFadedMouseOver(); _enableListOnlyButton.PaddingTop -= 2f; _enableListOnlyButton.PaddingBottom -= 2f; _enableListOnlyButton.OnClick += EnableListOnly; Append(_enableListOnlyButton); _viewInModBrowserButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewModsInModBrowser")) { Width = { Pixels = 246 }, Height = { Pixels = 36 }, Left = { Pixels = 50 }, Top = { Pixels = 80 } }.WithFadedMouseOver(); _viewInModBrowserButton.PaddingTop -= 2f; _viewInModBrowserButton.PaddingBottom -= 2f; _viewInModBrowserButton.OnClick += ViewInModBrowser; Append(_viewInModBrowserButton); _updateListWithEnabledButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackUpdateListWithEnabled")) { Width = { Pixels = 225 }, Height = { Pixels = 36 }, Left = { Pixels = 304 }, Top = { Pixels = 80 } }.WithFadedMouseOver(); _updateListWithEnabledButton.PaddingTop -= 2f; _updateListWithEnabledButton.PaddingBottom -= 2f; _updateListWithEnabledButton.OnClick += (a, b) => UIModPacks.SaveModList(_filename); Append(_updateListWithEnabledButton); _deleteButton = new UIImageButton(Main.Assets.Request <Texture2D>("Images/UI/ButtonDelete")) { Top = { Pixels = 40 } }; _deleteButton.OnClick += DeleteButtonClick; Append(_deleteButton); }
public override void OnInitialize() { mainPanel = new UIDragableElement(); //mainPanel.Left.Set(300f, 0f); //mainPanel.Top.Set(300f, 0f); mainPanel.HAlign = 0.5f; mainPanel.VAlign = 0.5f; mainPanel.Width.Set(1280f, 0f); mainPanel.Height.Set(720f, 0f); //mainPanel.SetPadding(12); //mainPanel.SetPadding(0); mainPanel.OnScrollWheel += OnScrollWheel_FixHotbarScroll; Append(mainPanel); if (offsetX != -1) { mainPanel.Left.Set(offsetX, 0f); mainPanel.Top.Set(offsetY, 0f); //mainPanel.HAlign = 0f; //mainPanel.VAlign = 0f; } //mainPanel.BackgroundColor = UICommon.DefaultUIBlue; var panelBackground = new UIImage(ModContent.GetTexture("SpiritMod/Items/Books/UI/LuminousOcean")); panelBackground.SetPadding(12); mainPanel.Append(panelBackground); mainPanel.AddDragTarget(panelBackground); Texture2D closeTexture = ModContent.GetTexture("SpiritMod/Items/Books/UI/closeButton"); UIImageButton closeButton = new UIImageButton(closeTexture); closeButton.Left.Set(-30, 1f); closeButton.Top.Set(5, 0f); closeButton.Width.Set(15, 0f); closeButton.Height.Set(15, 0f); closeButton.OnClick += CloseButton_OnClick; panelBackground.Append(closeButton); //UIPanel messageBoxPanel = new UIPanel { // Width = { Percent = 1f }, // Height = { Pixels = -110, Percent = 1f }, // Top = { Pixels = 110, }, // BackgroundColor = UICommon.MainPanelBackground //}; //mainPanel.Append(messageBoxPanel); UIElement messageBoxPanel = new UIElement { Width = { Percent = 1f }, Height = { Pixels = -50, Percent = 1f }, Top = { Pixels = 50, }, }; panelBackground.Append(messageBoxPanel); mainPanel.AddDragTarget(messageBoxPanel); //var messageBoxScrollbar = new FixedUIScrollbar(ModContent.GetInstance<SpiritMod>().BookUserInterface) { // Height = { Pixels = -20, Percent = 1f }, // VAlign = 0.5f, // HAlign = 1f //}.WithView(100f, 1000f); ////messageBoxPanel.Append(messageBoxScrollbar); //messageBox.Append(messageBoxScrollbar); //messageBox.SetScrollbar(messageBoxScrollbar); }
public UIServerListItem(SavedServer server) { BorderColor = new Color(89, 116, 213) * 0.7f; _buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive"); _buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive"); _buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay"); _buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete"); Height.Set(64, 0f); Width.Set(0f, 1f); SetPadding(6f); OnDoubleClick += JoinServer; Server = server; UIImageButton JoinButton = new UIImageButton(_buttonPlayTexture); JoinButton.VAlign = 1f; JoinButton.Left.Set(4f, 0f); JoinButton.OnClick += JoinServer; JoinButton.OnMouseOver += JoinMouseOver; JoinButton.OnMouseOut += ButtonMouseOut; Append(JoinButton); UIImageButton FavoriteButton = new UIImageButton(Server.IsFavorite ? _buttonFavoriteActiveTexture : _buttonFavoriteInactiveTexture); FavoriteButton.VAlign = 1f; FavoriteButton.Left.Set(28f, 0f); FavoriteButton.OnClick += FavoriteButtonClick; FavoriteButton.OnMouseOver += FavoriteMouseOver; FavoriteButton.OnMouseOut += ButtonMouseOut; FavoriteButton.SetVisibility(1f, Server.IsFavorite ? 0.8f : 0.4f); Append(FavoriteButton); UIImageButton ConfigButton = new UIImageButton(BetterServerList.ConfigButtonTexture); ConfigButton.VAlign = 1f; ConfigButton.Left.Set(28f + 24, 0f); ConfigButton.OnClick += ConfigButtonClick; ConfigButton.OnMouseOver += ConfigMouseOver; ConfigButton.OnMouseOut += ButtonMouseOut; Append(ConfigButton); UIImageButton ForgetButton = new UIImageButton(_buttonDeleteTexture); ForgetButton.VAlign = 1f; ForgetButton.HAlign = 1f; ForgetButton.OnClick += DeleteButtonClick; ForgetButton.OnMouseOver += DeleteMouseOver; ForgetButton.OnMouseOut += DeleteMouseOut; _deleteButton = ForgetButton; if (!Server.IsFavorite) { Append(ForgetButton); } int buttonLabelLeft = 80; primaryButtonLabel = new UIText(""); primaryButtonLabel.VAlign = 1f; primaryButtonLabel.Left.Set(buttonLabelLeft, 0f); primaryButtonLabel.Top.Set(-3f, 0f); Append(primaryButtonLabel); secondaryButtonLabel = new UIText(""); secondaryButtonLabel.VAlign = 1f; secondaryButtonLabel.HAlign = 1f; secondaryButtonLabel.Left.Set(-30f, 0f); secondaryButtonLabel.Top.Set(-3f, 0f); Append(secondaryButtonLabel); }
public override void OnInitialize() { BrewerShopsPanel = new UIPanel(); BrewerShopsPanel.SetPadding(0); BrewerShopsPanel.Left.Set(575f, 0f); BrewerShopsPanel.Top.Set(275f, 0f); BrewerShopsPanel.Width.Set(385f, 0f); BrewerShopsPanel.Height.Set(190f, 0f); BrewerShopsPanel.BackgroundColor = new Color(73, 94, 171); BrewerShopsPanel.OnMouseDown += new UIElement.MouseEvent(DragStart); BrewerShopsPanel.OnMouseUp += new UIElement.MouseEvent(DragEnd); UIText text = new UIText("Vanilla"); text.Left.Set(35, 0f); text.Top.Set(10, 0f); text.Width.Set(60, 0f); text.Height.Set(22, 0f); text.OnClick += new MouseEvent(PlayButtonClicked1); BrewerShopsPanel.Append(text); UIText text2 = new UIText("Mod/Calamity"); text2.Left.Set(35, 0f); text2.Top.Set(40, 0f); text2.Width.Set(120, 0f); text2.Height.Set(22, 0f); text2.OnClick += new MouseEvent(PlayButtonClicked2); BrewerShopsPanel.Append(text2); UIText text21 = new UIText("Thorium/RG"); text21.Left.Set(35, 0f); text21.Top.Set(70, 0f); text21.Width.Set(100, 0f); text21.Height.Set(22, 0f); text21.OnClick += new MouseEvent(PlayButtonClicked2); BrewerShopsPanel.Append(text21); UIText text3 = new UIText("MorePotions"); text3.Left.Set(35, 0f); text3.Top.Set(100, 0f); text3.Width.Set(70, 0f); text3.Height.Set(22, 0f); text3.OnClick += new MouseEvent(PlayButtonClicked3); BrewerShopsPanel.Append(text3); UIText text4 = new UIText("UnuBattleRods/Tacklebox/Tremor"); text4.Left.Set(35, 0f); text4.Top.Set(130, 0f); text4.Width.Set(150, 0f); text4.Height.Set(22, 0f); text4.OnClick += new MouseEvent(PlayButtonClicked4); BrewerShopsPanel.Append(text4); UIText text5 = new UIText("Wildlife/Sacred/Spirit/Cristilium/ExpSentr"); text5.Left.Set(35, 0f); text5.Top.Set(160, 0f); text5.Width.Set(200, 0f); text5.Height.Set(22, 0f); text5.OnClick += new MouseEvent(PlayButtonClicked5); BrewerShopsPanel.Append(text5); Texture2D buttonPlayTexture = ModLoader.GetTexture("Terraria/UI/ButtonPlay"); UIImageButton playButton = new UIImageButton(buttonPlayTexture); playButton.Left.Set(10, 0f); playButton.Top.Set(10, 0f); playButton.Width.Set(22, 0f); playButton.Height.Set(22, 0f); playButton.OnClick += new MouseEvent(PlayButtonClicked1); BrewerShopsPanel.Append(playButton); UIImageButton playButton2 = new UIImageButton(buttonPlayTexture); playButton2.Left.Set(10, 0f); playButton2.Top.Set(40, 0f); playButton2.Width.Set(22, 0f); playButton2.Height.Set(22, 0f); playButton2.OnClick += new MouseEvent(PlayButtonClicked2); BrewerShopsPanel.Append(playButton2); UIImageButton playButton21 = new UIImageButton(buttonPlayTexture); playButton21.Left.Set(10, 0f); playButton21.Top.Set(70, 0f); playButton21.Width.Set(22, 0f); playButton21.Height.Set(22, 0f); playButton21.OnClick += new MouseEvent(PlayButtonClicked21); BrewerShopsPanel.Append(playButton21); UIImageButton playButton3 = new UIImageButton(buttonPlayTexture); playButton3.Left.Set(10, 0f); playButton3.Top.Set(100, 0f); playButton3.Width.Set(22, 0f); playButton3.Height.Set(22, 0f); playButton3.OnClick += new MouseEvent(PlayButtonClicked3); BrewerShopsPanel.Append(playButton3); UIImageButton playButton4 = new UIImageButton(buttonPlayTexture); playButton4.Left.Set(10, 0f); playButton4.Top.Set(130, 0f); playButton4.Width.Set(22, 0f); playButton4.Height.Set(22, 0f); playButton4.OnClick += new MouseEvent(PlayButtonClicked4); BrewerShopsPanel.Append(playButton4); UIImageButton playButton5 = new UIImageButton(buttonPlayTexture); playButton5.Left.Set(10, 0f); playButton5.Top.Set(160, 0f); playButton5.Width.Set(22, 0f); playButton5.Height.Set(22, 0f); playButton5.OnClick += new MouseEvent(PlayButtonClicked5); BrewerShopsPanel.Append(playButton5); Texture2D buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete"); UIImageButton closeButton = new UIImageButton(buttonDeleteTexture); closeButton.Left.Set(350, 0f); closeButton.Top.Set(10, 0f); closeButton.Width.Set(22, 0f); closeButton.Height.Set(22, 0f); closeButton.OnClick += new MouseEvent(CloseButtonClicked); BrewerShopsPanel.Append(closeButton); base.Append(BrewerShopsPanel); }
// Use this for initialization void Start() { Debug.Log("start potion "+_potionID); _imageButton = gameObject.GetComponent<UIImageButton>() as UIImageButton; _uri = getRandomSprite(); setSprite(_uri); }