Exemple #1
0
        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;
        }
Exemple #2
0
        private void SliderColor_OnChanged(UISliderColor obj)
        {
            lineColor[(int)linePropertyTarget] = sliderColor.color;

            SetConfigTargetColor();
        }