public void InitializeUI() { RemoveAllChildren(); linePropertyTarget = LinePropertyTarget.Shapes; panelMain = new UIDragablePanel(true, false, false); panelMain.SetPadding(6); panelMain.Left.Set(438f, 0f); panelMain.Top.Set(400f, 0f); panelMain.Width.Set(200f, 0f); panelMain.MinWidth.Set(200f, 0f); panelMain.MaxWidth.Set(Main.screenWidth, 0f); panelMain.Height.Set(300, 0f); panelMain.MinHeight.Set(300, 0f); panelMain.MaxHeight.Set(Main.screenHeight, 0f); panelMain.OnClick += (a, b) => { inputDistance.InputEnd(); inputCount.InputEnd(); }; Texture2D texture = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/closeButton"); closeButton = new UIHoverImageButton(texture, "Close"); closeButton.OnClick += (a, b) => Show = false; closeButton.Left.Set(-20f, 1f); closeButton.Top.Set(6f, 0f); panelMain.Append(closeButton); float topPos = 0; float leftPos = menuMargin; Vector2 textSize; //キャプション labelCaption = new UIText("Parallel Copy Setting"); labelCaption.Left.Set(leftPos, 0f); labelCaption.Top.Set(topPos, 0f); panelMain.Append(labelCaption); panelMain.AddDragTarget(labelCaption); textSize = Main.fontMouseText.MeasureString(labelCaption.Text); topPos += textSize.Y * 2; //距離:ラベル var label = new UIText("Distance (block):"); label.Left.Set(leftPos, 0f); label.Top.Set(topPos, 0f); panelMain.Append(label); panelMain.AddDragTarget(label); textSize = Main.fontMouseText.MeasureString(label.Text); topPos += textSize.Y; //距離:インプット inputDistance = new UIInputTextBox((int)Main.fontMouseText.MeasureString("9999").X, 4, true); inputDistance.Text = "8"; inputDistance.Left.Set(leftPos, 0f); inputDistance.Top.Set(topPos, 0f); inputDistance.OnClick += (a, b) => inputCount.InputEnd(); panelMain.Append(inputDistance); topPos += inputDistance.Height.Pixels + textSize.Y; //カウント:ラベル label = new UIText("Copy count:"); label.Left.Set(leftPos, 0f); label.Top.Set(topPos, 0f); panelMain.Append(label); panelMain.AddDragTarget(label); textSize = Main.fontMouseText.MeasureString(label.Text); topPos += textSize.Y; //カウント:インプット inputCount = new UIInputTextBox((int)Main.fontMouseText.MeasureString("99").X, 2, true); inputCount.Text = "10"; inputCount.Left.Set(leftPos, 0f); inputCount.Top.Set(topPos, 0f); inputCount.OnClick += (a, b) => inputDistance.InputEnd(); panelMain.Append(inputCount); topPos += inputCount.Height.Pixels + textSize.Y; panelMain.MinHeight.Set(topPos, 0f); panelMain.Height.Set(topPos, 0f); updateNeeded = true; }
public void InitializeUI() { RemoveAllChildren(); linePropertyTarget = LinePropertyTarget.Shapes; panelMain = new UIDragablePanel(true, false, false); panelMain.SetPadding(6); panelMain.Left.Set(438f, 0f); panelMain.Top.Set(400f, 0f); panelMain.Width.Set(200f, 0f); panelMain.MinWidth.Set(200f, 0f); panelMain.MaxWidth.Set(Main.screenWidth, 0f); panelMain.Height.Set(300, 0f); panelMain.MinHeight.Set(300, 0f); panelMain.MaxHeight.Set(Main.screenHeight, 0f); Texture2D texture = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/closeButton"); closeButton = new UIHoverImageButton(texture, "Close"); closeButton.OnClick += (a, b) => Show = false; closeButton.Left.Set(-20f, 1f); closeButton.Top.Set(6f, 0f); panelMain.Append(closeButton); float topPos = 0; float leftPos = menuMargin; //キャプション var label = new UIText("Line Property"); label.Left.Set(leftPos, 0f); label.Top.Set(topPos, 0f); panelMain.Append(label); panelMain.AddDragTarget(label); topPos += Main.fontMouseText.MeasureString("Line Property").Y; labelConfig = new UIText[3]; //設定対象:図形 labelConfig[0] = new UIText("Shapes"); labelConfig[0].TextColor = labelColorSelected; labelConfig[0].Left.Set(leftPos, 0f); labelConfig[0].Top.Set(topPos, 0f); labelConfig[0].OnMouseOver += Label_OnMouseOver; labelConfig[0].OnMouseOut += Label_OnMouseOut; labelConfig[0].OnClick += (a, b) => ChangeConfig(LinePropertyTarget.Shapes); panelMain.Append(labelConfig[0]); leftPos += Main.fontMouseText.MeasureString("Shapes").X + menuMargin; //設定対象:カーソル labelConfig[1] = new UIText("Cursor"); labelConfig[1].TextColor = labelColorInactive; labelConfig[1].Left.Set(leftPos, 0f); labelConfig[1].Top.Set(topPos, 0f); labelConfig[1].OnMouseOver += Label_OnMouseOver; labelConfig[1].OnMouseOut += Label_OnMouseOut; labelConfig[1].OnClick += (a, b) => ChangeConfig(LinePropertyTarget.Cursor); panelMain.Append(labelConfig[1]); leftPos += Main.fontMouseText.MeasureString("Cursor").X + menuMargin; //設定対象:カーソルスナップ labelConfig[2] = new UIText("Snap"); labelConfig[2].TextColor = labelColorInactive; labelConfig[2].Left.Set(leftPos, 0f); labelConfig[2].Top.Set(topPos, 0f); labelConfig[2].OnMouseOver += Label_OnMouseOver; labelConfig[2].OnMouseOut += Label_OnMouseOut; labelConfig[2].OnClick += (a, b) => ChangeConfig(LinePropertyTarget.CursorSnap); panelMain.Append(labelConfig[2]); leftPos += Main.fontMouseText.MeasureString("Snap").X + menuMargin; leftPos = menuMargin; topPos += Main.fontMouseText.MeasureString("Shapes").Y * 2; //線幅 label = new UIText("Line width:"); label.Left.Set(leftPos, 0f); label.Top.Set(topPos, 0f); panelMain.Append(label); panelMain.AddDragTarget(label); topPos += Main.fontMouseText.MeasureString("Line width:").Y; sliderWidth = new UISlider(1, 16); sliderWidth.Left.Set(leftPos, 0f); sliderWidth.Top.Set(topPos, 0f); sliderWidth.OnChanged += SliderWidth_OnChanged; panelMain.Append(sliderWidth); topPos += sliderWidth.Height.Pixels; //線色 label = new UIText("Line color:"); label.Left.Set(leftPos, 0f); label.Top.Set(topPos, 0f); panelMain.Append(label); panelMain.AddDragTarget(label); topPos += Main.fontMouseText.MeasureString("Line color:").Y; sliderColor = new UISliderColor(); sliderColor.Left.Set(leftPos, 0f); sliderColor.Top.Set(topPos, 0f); sliderColor.OnChanged += SliderColor_OnChanged; panelMain.Append(sliderColor); topPos += sliderColor.Height.Pixels; //透過率 label = new UIText("Color transmittance:"); label.Left.Set(leftPos, 0f); label.Top.Set(topPos, 0f); panelMain.Append(label); panelMain.AddDragTarget(label); topPos += Main.fontMouseText.MeasureString("Color transmittance:").Y; sliderTransmittance = new UISlider(); sliderTransmittance.Left.Set(leftPos, 0f); sliderTransmittance.Top.Set(topPos, 0f); sliderTransmittance.OnChanged += SliderTransmittance_OnChanged; panelMain.Append(sliderTransmittance); topPos += sliderTransmittance.Height.Pixels * 2; panelMain.MinHeight.Set(topPos, 0f); panelMain.Height.Set(topPos, 0f); updateNeeded = true; }
public void InitializeUI() { RemoveAllChildren(); panelMain = new UIDragablePanel(true, true, true); panelMain.caption = caption; panelMain.drawCaptionPosition = 0; panelMain.SetPadding(6); panelMain.Left.Set(240f, 0f); panelMain.Top.Set(400f, 0f); panelMain.Width.Set(196f, 0f); panelMain.MinWidth.Set(196f, 0f); panelMain.MaxWidth.Set(Main.screenWidth, 0f); panelMain.Height.Set(142, 0f); panelMain.MinHeight.Set(110, 0f); panelMain.MaxHeight.Set(Main.screenHeight, 0f); Texture2D texture = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/closeButton"); closeButton = new UIHoverImageButton(texture, "Close"); closeButton.OnClick += (a, b) => Show = false; closeButton.Left.Set(-20f, 1f); //closeButton.Top.Set(6f, 0f); closeButton.Top.Set(0f, 0f); panelMain.Append(closeButton); //float topPos = menuMargin + Main.fontMouseText.MeasureString(caption).Y; float topPos = 0; float leftPos = 0; //ボタン:レンジ矩形 texture = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/rangeRectangle"); btnRangeRect = new UIImageListButton( new List <Texture2D>() { texture, texture }, new List <object>() { true, false }, new List <string>() { "Display range rectangle: On", "Display range rectangle: Off" }, 1); btnRangeRect.OnClick += (a, b) => { btnRangeRect.NextIamge(); btnRangeRect.visibilityActive = btnRangeRect.visibilityInactive = btnRangeRect.GetValue <bool>() ? 1.0f : 0.4f; }; leftPos += menuMargin; btnRangeRect.Left.Set(leftPos, 0f); btnRangeRect.Top.Set(topPos, 0f); panelMain.Append(btnRangeRect); //ボタン:フライカメラ btnFlyCam = new UIImageListButton( new List <Texture2D>() { Main.itemTexture[ItemID.AngelWings].Resize(menuIconSize), Main.itemTexture[ItemID.AngelWings].Resize(menuIconSize), }, new List <object>() { true, false }, new List <string>() { "Fly cam: On", "Fly cam: Off" }, 1); btnFlyCam.OnClick += (a, b) => { btnFlyCam.NextIamge(); FlyCam.Enabled = btnFlyCam.GetValue <bool>(); btnFlyCam.visibilityActive = btnFlyCam.visibilityInactive = btnFlyCam.GetValue <bool>() ? 1.0f : 0.4f; }; leftPos += menuMargin + menuIconSize; btnFlyCam.Left.Set(leftPos, 0f); btnFlyCam.Top.Set(topPos, 0f); panelMain.Append(btnFlyCam); //ボタン:レンジ btnRange = new UIImageListButton( new List <Texture2D>() { Main.itemTexture[ItemID.Toolbelt].Resize(menuIconSize), Main.itemTexture[ItemID.Toolbelt].Resize(menuIconSize), }, new List <object>() { true, false }, new List <string>() { "Infinity range: On", "Infinity range: Off" }, 1); btnRange.OnClick += (a, b) => { btnRange.NextIamge(); btnRange.visibilityActive = btnRange.visibilityInactive = btnRange.GetValue <bool>() ? 1.0f : 0.4f; }; leftPos += menuMargin + menuIconSize; btnRange.Left.Set(leftPos, 0f); btnRange.Top.Set(topPos, 0f); panelMain.Append(btnRange); //ボタン:スナップ btnSnap = new UIImageListButton( (new ImageList(ModLoader.GetMod("TeraCAD").GetTexture("ToolUI/Snap"), 28, 28)).listTexture, new List <object>() { SnapType.TopLeft, SnapType.TopCenter, SnapType.TopRight, SnapType.LeftCenter, SnapType.Center, SnapType.RightCenter, SnapType.BottomLeft, SnapType.BottomCenter, SnapType.BottomRight, }, new List <string>() { "Snap: TopLeft", "Snap: TopCenter", "Snap: TopRight", "Snap: LeftCenter", "Snap: Center", "Snap: RightCenter", "Snap: BottomLeft", "Snap: BottomCenter", "Snap: BottomRight", }, 0); btnSnap.OnClick += (a, b) => { btnSnap.NextIamge(); ToolBox.snapType = btnSnap.GetValue <SnapType>(); }; btnSnap.OnRightClick += (a, b) => { btnSnap.PrevIamge(); ToolBox.snapType = btnSnap.GetValue <SnapType>(); }; leftPos += menuMargin + menuIconSize; btnSnap.Left.Set(leftPos, 0f); btnSnap.Top.Set(topPos, 0f); panelMain.Append(btnSnap); //ボタン:コンフィグ var btnConfig = new UIImageListButton( new List <Texture2D>() { Main.itemTexture[ItemID.Cog].Resize(menuIconSize), }, new List <object>() { 0 }, new List <string>() { "Show Line Property" }, 0); btnConfig.OnClick += (a, b) => LinePropertyUI.instance.Show = !LinePropertyUI.instance.Show; leftPos += menuMargin + menuIconSize; btnConfig.Left.Set(leftPos, 0f); btnConfig.Top.Set(topPos, 0f); panelMain.Append(btnConfig); topPos += menuIconSize + menuMargin; //ツールボックス panelTool = new UIPanel(); panelTool.SetPadding(6); panelTool.Top.Set(topPos, 0f); panelTool.Width.Set(0, 1f); panelTool.Height.Set(-52, 1f); panelMain.Append(panelTool); gridTool = new UIGrid(); gridTool.Width.Set(-20f, 1f); gridTool.Height.Set(0, 1f); gridTool.ListPadding = 2f; panelTool.Append(gridTool); var scrollbar = new FixedUIScrollbar(userInterface); scrollbar.SetView(100f, 1000f); scrollbar.Height.Set(0, 1f); scrollbar.Left.Set(-20, 1f); panelTool.Append(scrollbar); gridTool.SetScrollbar(scrollbar); //シェイプツール var imageList = new ImageList(ModLoader.GetMod("TeraCAD").GetTexture("ToolUI/ShapeTools"), 28, 28); //選択ツール var btnSelect = new UISlotTool(imageList[0], ToolType.Select, gridTool.Count, "Selecct"); btnSelect.OnClick += (a, b) => ToolBox.Select(btnSelect); gridTool.Add(btnSelect); //直線ツール var btnLine = new UISlotTool(imageList[1], ToolType.Line, gridTool.Count, "Line"); btnLine.OnClick += (a, b) => ToolBox.Select(btnLine); gridTool.Add(btnLine); //矩形ツール var btnRect = new UISlotTool(imageList[2], ToolType.Rect, gridTool.Count, "Recangle"); btnRect.OnClick += (a, b) => ToolBox.Select(btnRect); gridTool.Add(btnRect); //円ツール var btnCircle = new UISlotTool(imageList[3], ToolType.Circle, gridTool.Count, "Circle"); btnCircle.OnClick += (a, b) => ToolBox.Select(btnCircle); gridTool.Add(btnCircle); //楕円ツール //var btnEllipse = new UISlotTool(imageList[4], ToolType.Ellipse, gridTool.Count, "Ellipse"); //btnEllipse.OnClick += (a, b) => ToolBox.Select(btnEllipse); //gridTool.Add(btnEllipse); //イメージツール var btnImage = new UISlotTool(Main.itemTexture[ItemID.TheCursedMan], ToolType.Image, gridTool.Count, "Image"); btnImage.OnClick += (a, b) => { ToolBox.Select(btnImage); ImageUI.instance.Show = btnImage.isSelect; }; gridTool.Add(btnImage); //削除ツール var btnEraser = new UISlotTool(imageList[5], ToolType.Eraser, gridTool.Count, "Eraser"); btnEraser.OnClick += (a, b) => ToolBox.Select(btnEraser); gridTool.Add(btnEraser); //全削除ツール var btnAllClear = new UISlotTool(Main.trashTexture.Resize(menuIconSize), ToolType.AllClear, gridTool.Count, "All Clear"); btnAllClear.OnClick += (a, b) => ToolBox.Select(btnAllClear); gridTool.Add(btnAllClear); //平行コピー var btnParallelCopy = new UISlotTool(imageList[6], ToolType.ParallelCopy, gridTool.Count, "Parallel Copy"); btnParallelCopy.OnClick += (a, b) => ToolBox.Select(btnParallelCopy); gridTool.Add(btnParallelCopy); updateNeeded = true; }
public void InitializeUI() { RemoveAllChildren(); panelMain = new UIDragablePanel(true, true, true); panelMain.caption = caption; panelMain.drawCaptionPosition = 1; panelMain.SetPadding(6); panelMain.Left.Set(438f, 0f); panelMain.Top.Set(400f, 0f); panelMain.Width.Set(300f, 0f); panelMain.MinWidth.Set(300f, 0f); panelMain.MaxWidth.Set(Main.screenWidth, 0f); panelMain.Height.Set(210, 0f); panelMain.MinHeight.Set(210, 0f); panelMain.MaxHeight.Set(Main.screenHeight, 0f); Texture2D texture = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/closeButton"); closeButton = new UIHoverImageButton(texture, "Close"); closeButton.OnClick += (a, b) => Show = false; closeButton.Left.Set(-20f, 1f); closeButton.Top.Set(6f, 0f); panelMain.Append(closeButton); float topPos = 0; float leftPos = menuMargin; //ボタン:ロード btnLoad = new UIImageListButton( new List <Texture2D>() { Main.itemTexture[ItemID.AlphabetStatueL].Resize(menuIconSize) }, new List <object>() { 0 }, new List <string>() { "Load image" }, 0); var btn = btnLoad; btn.OnClick += (a, b) => LoadImage(); leftPos += menuMargin; btn.Left.Set(leftPos, 0f); btn.Top.Set(topPos, 0f); panelMain.Append(btn); //ボタン:配置モード btnPositionMode = new UIImageListButton( new List <Texture2D>() { Main.itemTexture[ItemID.AlphabetStatueW].Resize(menuIconSize), Main.itemTexture[ItemID.AlphabetStatueS].Resize(menuIconSize) }, new List <object>() { ImagePositionMode.World, ImagePositionMode.Screen }, new List <string>() { "Image position: World", "Image position: Screen" }, 0); btn = btnPositionMode; btn.OnClick += (a, b) => btn.NextIamge(); leftPos += menuIconSize + menuMargin; btn.Left.Set(leftPos, 0f); btn.Top.Set(topPos, 0f); panelMain.Append(btn); //ツールボックス panelGrid = new UIPanel(); var panel = panelGrid; panel.SetPadding(6); panel.Top.Set(32, 0f); panel.Width.Set(0, 1f); panel.Height.Set(-40, 1f); panelMain.Append(panel); grid = new UIGrid(); grid.Width.Set(-20f, 1f); grid.Height.Set(0, 1f); grid.ListPadding = 2f; panel.Append(grid); var scrollbar = new FixedUIScrollbar(userInterface); scrollbar.SetView(100f, 1000f); scrollbar.Height.Set(0, 1f); scrollbar.Left.Set(-20, 1f); panel.Append(scrollbar); grid.SetScrollbar(scrollbar); slider = new UISlider(); slider.Value = 0.8f; leftPos += menuIconSize + menuMargin; slider.Left.Set(leftPos, 0f); slider.Top.Set(topPos, 0f); panelMain.Append(slider); updateNeeded = true; }
public override void OnInitialize() { playerBackGroundTexture = TextureManager.Load("Images/UI/PlayerBackground"); teamDPSPanel = new UIDragablePanel(); teamDPSPanel.SetPadding(6); teamDPSPanel.Left.Set(-310f, 0f); teamDPSPanel.HAlign = 1f; teamDPSPanel.Top.Set(90f, 0f); teamDPSPanel.Width.Set(415f, 0f); teamDPSPanel.MinWidth.Set(50f, 0f); teamDPSPanel.MaxWidth.Set(500f, 0f); teamDPSPanel.Height.Set(350, 0f); teamDPSPanel.MinHeight.Set(50, 0f); teamDPSPanel.MaxHeight.Set(300, 0f); teamDPSPanel.BackgroundColor = new Color(73, 94, 171); //Append(favoritePanel); label = new UIText("DPS"); label.OnClick += Label_OnClick; teamDPSPanel.Append(label); teamDPSPanel.AddDragTarget(label); //var togglePercentButton = new UIHoverImageButton(Main.itemTexture[ItemID.SuspiciousLookingEye], "Toggle %"); var togglePercentButton = new UIHoverImageButton(DPSExtreme.instance.GetTexture("PercentButton"), "Toggle %"); togglePercentButton.OnClick += (a, b) => showPercent = !showPercent; togglePercentButton.Left.Pixels = 174; togglePercentButton.Top.Pixels = -4; //toggleCompletedButton.Top.Pixels = spacing; teamDPSPanel.Append(togglePercentButton); var labelDimensions = label.GetInnerDimensions(); int top = (int)labelDimensions.Height + 4; dpsList = new UIGrid(); dpsList.Width.Set(0, 1f); dpsList.Height.Set(-top, 1f); dpsList.Top.Set(top, 0f); dpsList.ListPadding = 0f; teamDPSPanel.Append(dpsList); teamDPSPanel.AddDragTarget(dpsList); var type = Assembly.GetAssembly(typeof(Mod)).GetType("Terraria.ModLoader.UI.Elements.UIGrid"); FieldInfo loadModsField = type.GetField("_innerList", BindingFlags.Instance | BindingFlags.NonPublic); teamDPSPanel.AddDragTarget((UIElement)loadModsField.GetValue(dpsList)); // list._innerList bossList = new UIGrid(); bossList.Width.Set(0, 1f); bossList.Height.Set(-top, 1f); bossList.Top.Set(top, 0f); bossList.ListPadding = 0f; //teamDPSPanel.Append(bossList); teamDPSPanel.AddDragTarget(bossList); teamDPSPanel.AddDragTarget((UIElement)loadModsField.GetValue(bossList)); var scrollbar = new InvisibleFixedUIScrollbar(userInterface); scrollbar.SetView(100f, 1000f); scrollbar.Height.Set(0, 1f); scrollbar.Left.Set(-20, 1f); teamDPSPanel.Append(scrollbar); dpsList.SetScrollbar(scrollbar); scrollbar = new InvisibleFixedUIScrollbar(userInterface); scrollbar.SetView(100f, 1000f); scrollbar.Height.Set(0, 1f); scrollbar.Left.Set(-20, 1f); teamDPSPanel.Append(scrollbar); bossList.SetScrollbar(scrollbar); //updateNeeded = true; }