Esempio n. 1
0
        private UIPanel makeOtherPanel()
        {
            UIPanel panel = new UIPanel();

            //panel.Width = StyleDimension.Fill;
            //panel.Height = StyleDimension.Fill;
            //	panel.Top.Pixels = top;
            panel.BackgroundColor = Color.LightCoral * 0.7f;

            int top = 0;

            playerMeleeCheckbox = new UICheckbox("Override HoldoutOffset", "Affects non-staff useStyle 5 weapons. (Guns)");
            playerMeleeCheckbox.Top.Set(top, 0f);
            //playerMeleeCheckbox.Left.Set(0, 0f);
            panel.Append(playerMeleeCheckbox);

            top += 20;

            holdoutXData = new UIIntRangedDataValue("Holdout X:", 0, -30, 30);
            UIElement uiRange = new UIRange <int>(holdoutXData);

            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            panel.Append(uiRange);

            top += 20;

            holdoutYData = new UIIntRangedDataValue("Holdout Y:", 0, -30, 30);
            uiRange      = new UIRange <int>(holdoutYData);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            panel.Append(uiRange);

            top += 20;

            var data = new UIFloatRangedDataValue("Scale:", 1f, 0f, 5f);

            data.DataGetter = () => Main.LocalPlayer.HeldItem.scale;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.scale = value;
            uiRange         = new UIRange <float>(data);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            panel.Append(uiRange);

            top += 20;

            UIText printItemInfoText = new UIText("Print ItemInfo", 0.85f);

            printItemInfoText.Top.Set(top, 0f);
            printItemInfoText.OnClick += PrintItemInfo_OnClick;
            panel.Append(printItemInfoText);

            return(panel);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a slider with the type float
        /// </summary>
        /// <param name="inDataValue"></param>
        /// <param name="outDataValue"></param>
        /// <param name="top">Y Position relative to the UIElement it's appended to (0 is Top most pixel)</param>
        /// <param name="topPixels">Percentage Y Position relative to the UIElement it's appended to (0 is Top most pixel, 1 is bottom most pixel)</param>
        /// <param name="width">How wide the slider is</param>
        /// <param name="widthPixels">How wide (in percent) the slider is</param>
        /// <param name="appendTo">which UIElement it should append to</param>
        public static UIElement MakeSlider(UIFloatRangedDataValue inDataValue, out UIFloatRangedDataValue outDataValue, UIElement appendTo, float top = 0, float left = -20, float width = 0, float widthPixels = 1)
        {
            outDataValue = inDataValue;
            UIElement Slider = new UIRange <float>(inDataValue);

            Slider.MarginTop  = top;
            Slider.MarginLeft = left;
            Slider.Width.Set(width, widthPixels);
            appendTo.Append(Slider);

            return(Slider);
        }
Esempio n. 3
0
        public override void OnInitialize()
        {
            base.OnInitialize();
            mainPanel = new UIPanel();
            width     = 310;
            height    = 610;
            mainPanel.SetPadding(6);
            mainPanel.BackgroundColor = Color.Orange * 0.7f;

            int    top  = 0;
            UIText text = new UIText("Projectiles:", 0.85f);

            text.Top.Set(top, 0f);
            mainPanel.Append(text);

            UITextPanel <string> clearProjectilesButton = new UITextPanel <string>("Clear Projectiles");

            clearProjectilesButton.OnClick += (a, b) => {
                for (int i = 0; i < Main.maxProjectiles; i++)
                {
                    if (Main.projectile[i].active)
                    {
                        Main.projectile[i].Kill();
                        if (Main.netMode == 1)
                        {
                            NetMessage.SendData(27, -1, -1, null, i, 0f, 0f, 0f, 0);
                        }
                    }
                }
            };
            clearProjectilesButton.Top.Set(top, 0f);
            clearProjectilesButton.Width.Set(-10, 0.5f);
            clearProjectilesButton.HAlign = 1;
            clearProjectilesButton.SetPadding(4);
            mainPanel.Append(clearProjectilesButton);

            top += 20;

            UIText text2 = new UIText("Filter:", 0.85f);

            text2.Top.Set(top, 0f);
            mainPanel.Append(text2);

            searchFilter = new NewUITextBox("Search", 0.85f);
            searchFilter.SetPadding(0);
            searchFilter.OnTextChanged += () => { ValidateInput(); updateNeeded = true; };
            searchFilter.Top.Set(top, 0f);
            searchFilter.Left.Set(text2.GetInnerDimensions().Width, 0f);
            searchFilter.Width.Set(-text2.GetInnerDimensions().Width, 1f);
            searchFilter.Height.Set(20, 0f);
            //searchFilter.VAlign = 0.5f;
            mainPanel.Append(searchFilter);
            top += 20;

            speedXDataProperty = new UIFloatRangedDataValue("SpeedX:", 0, -10, 10);
            speedYDataProperty = new UIFloatRangedDataValue("SpeedY:", 0, -10, 10);
            var ui2DRange = new UI2DRange <float>(speedXDataProperty, speedYDataProperty);

            ui2DRange.Top.Set(top, 0f);
            mainPanel.Append(ui2DRange);
            top += 30;

            ai0DataProperty = new UIFloatRangedDataValue("ai0:", 0, -10, 10);
            var uiRange = new UIRange <float>(ai0DataProperty);

            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            ai1DataProperty = new UIFloatRangedDataValue("ai1:", 0, -10, 10);
            uiRange         = new UIRange <float>(ai1DataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            knockbackDataProperty = new UIFloatRangedDataValue("Knockback:", 0, 0, 20);
            uiRange = new UIRange <float>(knockbackDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            damageDataProperty = new UIIntRangedDataValue("Damage:", 20, 0, 200);
            var uiRangeI = new UIRange <int>(damageDataProperty);

            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            aiStyleDataProperty = new UIIntRangedDataValue("AIStyle:", -1, -1, 145);
            uiRangeI            = new UIRange <int>(aiStyleDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            drawOffsetXDataProperty = new UIIntRangedDataValue("drawOffsetX:", 0, -30, 30);
            uiRangeI = new UIRange <int>(drawOffsetXDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            drawOriginOffsetXDataProperty = new UIIntRangedDataValue("drawOriginOffsetX:", 0, -30, 30);
            uiRangeI = new UIRange <int>(drawOriginOffsetXDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            drawOriginOffsetYDataProperty = new UIIntRangedDataValue("drawOriginOffsetY:", 0, -30, 30);
            uiRangeI = new UIRange <int>(drawOriginOffsetYDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            hostile = new UIBoolNDataValue("Hostile");
            var hostileCheckbox = new UITriStateCheckbox(hostile);

            hostileCheckbox.Top.Set(top, 0f);
            mainPanel.Append(hostileCheckbox);
            top += 30;

            friendly = new UIBoolNDataValue("Friendly");
            var friendlyCheckbox = new UITriStateCheckbox(friendly);

            friendlyCheckbox.Top.Set(top, 0f);
            mainPanel.Append(friendlyCheckbox);
            top += 25;

            pause = new UICheckbox("Pause", "Pauses All Projectiles (Prevent AI from running)");
            pause.Top.Set(top, 0f);
            mainPanel.Append(pause);

            UIHoverImageButton stepButton = new UIHoverImageButton(ModdersToolkit.Instance.GetTexture("UIElements/next"), "Step");

            stepButton.OnClick += (s, e) => step = true;
            stepButton.Top.Set(top - 6, 0f);
            stepButton.Left.Set(80, 0f);
            mainPanel.Append(stepButton);

            top += 25;

            freeze = new UICheckbox("Freeze", "Zero out velocity during PreAI for All Projectiles");
            freeze.Top.Set(top, 0f);
            mainPanel.Append(freeze);
            top += 25;

            projectileGrid            = new UIGrid(7);
            projectileGrid.Top.Pixels = top;
            //autoTrashGrid.Left.Pixels = spacing;
            projectileGrid.Width.Set(-25f, 1f);             // leave space for scroll?
            projectileGrid.Height.Set(-top, 1f);
            projectileGrid.ListPadding = 6f;
            mainPanel.Append(projectileGrid);

            // this will initialize grid
            updateNeeded = true;

            var projectileGridScrollbar = new UIElements.FixedUIScrollbar(_userInterface);

            projectileGridScrollbar.SetView(100f, 1000f);
            projectileGridScrollbar.Top.Pixels = top;            // + spacing;
            projectileGridScrollbar.Height.Set(-top /*- spacing*/, 1f);
            projectileGridScrollbar.HAlign = 1f;
            mainPanel.Append(projectileGridScrollbar);
            projectileGrid.SetScrollbar(projectileGridScrollbar);

            AdjustMainPanelDimensions(mainPanel);
            Append(mainPanel);
        }
 public FullFloatDataRangeProperty(UIFloatRangedDataValue inData)
 {
     range = new UIRange <float>(inData.label, inData.GetProportion, inData.SetProportion, ValidateInput);
     range.Width.Set(0, 1f);
 }
Esempio n. 5
0
        // 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);
        }
Esempio n. 6
0
        public override void OnInitialize()
        {
            mainPanel = new UIPanel();
            mainPanel.Left.Set(-350f, 1f);
            mainPanel.Top.Set(-740f, 1f);
            mainPanel.Width.Set(310f, 0f);
            mainPanel.Height.Set(640f, 0f);
            mainPanel.SetPadding(6);
            mainPanel.BackgroundColor = Color.PeachPuff * 0.8f;

            int    top  = 0;
            UIText text = new UIText("Shaders:", 0.85f);

            text.Top.Set(top, 0f);
            mainPanel.Append(text);
            top += 20;

            int topModSourcesPanel = 0;
            var modSourcesPanel    = new UIPanel();

            modSourcesPanel.Top.Set(top, 0f);
            modSourcesPanel.Width.Set(0, 1f);
            modSourcesPanel.Height.Set(370f, 0f);
            modSourcesPanel.SetPadding(6);
            modSourcesPanel.BackgroundColor = Color.Blue * 0.7f;
            top += 376;

            text = new UIText("Mod Sources:", 0.85f);
            text.Top.Set(topModSourcesPanel, 0f);
            modSourcesPanel.Append(text);
            topModSourcesPanel += 20;

            var modListBackPanel = new UIPanel();

            modListBackPanel.Top.Set(topModSourcesPanel, 0);
            modListBackPanel.Width.Set(0, 1f);
            modListBackPanel.Height.Set(120f, 0f);
            modListBackPanel.SetPadding(6);
            modListBackPanel.BackgroundColor = Color.Green * 0.7f;

            modList = new UIList();
            modList.Width.Set(-25f, 1f);
            modList.Height.Set(0, 1f);
            modList.ListPadding = 0f;
            modListBackPanel.Append(modList);

            var modListScrollbar = new UIElements.FixedUIScrollbar(userInterface);

            modListScrollbar.SetView(100f, 1000f);
            modListScrollbar.Top.Pixels = 4;
            modListScrollbar.Height.Set(-8, 1f);
            modListScrollbar.HAlign = 1f;
            modListBackPanel.Append(modListScrollbar);
            modList.SetScrollbar(modListScrollbar);

            modSourcesPanel.Append(modListBackPanel);
            mainPanel.Append(modSourcesPanel);
            topModSourcesPanel += 130;

            text = new UIText("Filter:", 0.85f);
            text.Top.Set(topModSourcesPanel, 0f);
            modSourcesPanel.Append(text);

            searchFilter = new NewUITextBox("Search", 0.85f);
            searchFilter.SetPadding(0);
            searchFilter.OnTextChanged += () => { updateneeded = true; };
            searchFilter.Top.Set(topModSourcesPanel, 0f);
            searchFilter.Left.Set(text.GetInnerDimensions().Width + 6, 0f);
            searchFilter.Width.Set(-(text.GetInnerDimensions().Width + 6), 1f);
            searchFilter.Height.Set(20, 0f);
            modSourcesPanel.Append(searchFilter);
            topModSourcesPanel += 26;

            currentShader = new UIText("Current: None selected", 0.85f);
            currentShader.Top.Set(topModSourcesPanel, 0f);
            currentShader.Left.Set(0, 0f);
            currentShader.Width.Set(0, 1);
            currentShader.HAlign = 0;
            modSourcesPanel.Append(currentShader);
            topModSourcesPanel += 20;

            var shaderListBackPanel = new UIPanel();

            shaderListBackPanel.Top.Set(topModSourcesPanel, 0);
            shaderListBackPanel.Width.Set(0, 1f);
            shaderListBackPanel.Height.Set(140f, 0f);
            shaderListBackPanel.SetPadding(6);
            shaderListBackPanel.BackgroundColor = Color.Green * 0.7f;

            shaderList = new UIList();
            shaderList.Width.Set(-25f, 1f);
            shaderList.Height.Set(0, 1f);
            shaderList.ListPadding = 0f;
            shaderListBackPanel.Append(shaderList);

            var shaderListScrollbar = new UIElements.FixedUIScrollbar(userInterface);

            shaderListScrollbar.SetView(100f, 1000f);
            shaderListScrollbar.Top.Pixels = 4;
            shaderListScrollbar.Height.Set(-8, 1f);
            shaderListScrollbar.HAlign = 1f;
            shaderListBackPanel.Append(shaderListScrollbar);
            shaderList.SetScrollbar(shaderListScrollbar);
            modSourcesPanel.Append(shaderListBackPanel);

            topModSourcesPanel     += 146;
            watchModSourcesCheckbox = new UICheckbox("Watch Mod Sources", "Automatically Compile Mod Sources Shaders when Changed on Disk", false);
            watchModSourcesCheckbox.Top.Set(topModSourcesPanel, 0);
            watchModSourcesCheckbox.OnSelectedChanged += WatchModSources_OnSelectedChanged;
            modSourcesPanel.Append(watchModSourcesCheckbox);
            topModSourcesPanel += 20;


            int topTestShaderPanel = 0;
            var testShaderPanel    = new UIPanel();

            testShaderPanel.Top.Set(top, 0f);
            testShaderPanel.Width.Set(0, 1f);
            testShaderPanel.Height.Set(230f, 0f);
            testShaderPanel.SetPadding(6);
            testShaderPanel.BackgroundColor = Color.LightBlue * 0.7f;
            top += 230;
            mainPanel.Append(testShaderPanel);

            text = new UIText("Test Shader:", 0.85f);
            text.Top.Set(topTestShaderPanel, 0f);
            testShaderPanel.Append(text);
            topTestShaderPanel += 20;

            // Current Working Shader
            // Status Text: "Compiled .fx"
            // Filter?
            // Checkbox: Force

            UIRadioButtonGroup g = new UIRadioButtonGroup();

            armorShaderRadioButton  = new UIRadioButton("Armor", "Generate an Armor Shader");
            screenShaderRadioButton = new UIRadioButton("Screen", "Generate a Screen Shader");
            g.Add(armorShaderRadioButton);
            g.Add(screenShaderRadioButton);
            g.Top.Pixels = topTestShaderPanel;
            g.Width.Set(0, .75f);
            testShaderPanel.Append(g);
            armorShaderRadioButton.Selected = true;
            topTestShaderPanel += (int)g.Height.Pixels;

            var createTestShaderButton = new UITextPanel <string>("Create/Recreate Test Shader");

            createTestShaderButton.OnClick += CreateTestShaderFileButton_OnClick;
            createTestShaderButton.Top.Set(topTestShaderPanel, 0f);
            createTestShaderButton.Left.Set(0, 0f);
            createTestShaderButton.SetPadding(4);
            testShaderPanel.Append(createTestShaderButton);
            topTestShaderPanel += 26;

            var openTestShaderButton = new UITextPanel <string>("Edit Test Shader");

            openTestShaderButton.OnClick += OpenTestShaderFileButton_OnClick;
            openTestShaderButton.Top.Set(topTestShaderPanel, 0f);
            openTestShaderButton.Left.Set(0, 0f);
            openTestShaderButton.SetPadding(4);
            testShaderPanel.Append(openTestShaderButton);
            topTestShaderPanel += 26;

            var compileShaderButton = new UITextPanel <string>("Compile Test Shader");

            compileShaderButton.OnClick += CompileTestShaderButton_OnClick;
            compileShaderButton.Top.Set(topTestShaderPanel, 0f);
            compileShaderButton.Left.Set(0, 0f);
            compileShaderButton.SetPadding(4);
            testShaderPanel.Append(compileShaderButton);
            topTestShaderPanel += 26;

            topTestShaderPanel     += 4;
            watchTestShaderCheckbox = new UICheckbox("Watch Test Shader File", "Automatically Compile Test Shader when Changed on Disk", true);
            watchTestShaderCheckbox.Top.Set(topTestShaderPanel, 0);
            watchTestShaderCheckbox.OnSelectedChanged += WatchTestShader_OnSelectedChanged;
            testShaderPanel.Append(watchTestShaderCheckbox);
            topTestShaderPanel += 20;

            forceShaderCheckbox = new UICheckbox("Force Shader Active", "Automatically enable the last compiled screen shader.", true);
            forceShaderCheckbox.Top.Set(topTestShaderPanel, 0);
            //forceShaderCheckbox.OnSelectedChanged += ForceShaderCheckbox_OnSelectedChanged;
            testShaderPanel.Append(forceShaderCheckbox);
            topTestShaderPanel += 20;

            var uiRanges = new List <UIElement>();

            colorDataProperty = new Dusts.ColorDataRangeProperty("uColor:");
            colorDataProperty.range.Top.Set(top, 0f);
            colorDataProperty.OnValueChanged += () => Filters.Scene["ModdersToolkit:TestScreenShader"].GetShader().UseColor(colorDataProperty.Data);
            uiRanges.Add(colorDataProperty.range);

            intensityData            = new UIFloatRangedDataValue("uIntensity:", 1f, 0f, 1f);
            intensityData.DataGetter = () => Filters.Scene["ModdersToolkit:TestScreenShader"].GetShader().Intensity;
            intensityData.DataSetter = (value) => Filters.Scene["ModdersToolkit:TestScreenShader"].GetShader().UseIntensity(value);
            uiRanges.Add(new UIRange <float>(intensityData));

            //var uDirectionXProperty = new UIFloatRangedDataValue("uDirectionX:", 0, -1, 1);
            //uDirectionXProperty.DataGetter = () => Filters.Scene["ModdersToolkit:TestScreenShader"].GetShader().UseDirection.Intensity;
            //uDirectionXProperty.DataSetter = (value) => Filters.Scene["ModdersToolkit:TestScreenShader"].GetShader().UseDirection(value);
            //var uDirectionYProperty = new UIFloatRangedDataValue("uDirectionY:", 0, -1, 1);
            //var ui2DRange = new UI2DRange<float>(uDirectionXProperty, uDirectionYProperty);
            //uiRanges.Add(ui2DRange);
            //ui2DRange.Top.Set(top, 0f);
            //ui2DRange.Left.Set(200, 0f);
            //mainPanel.Append(ui2DRange);
            //top += 30;

            foreach (var uiRange in uiRanges)
            {
                uiRange.Top.Set(topTestShaderPanel, 0f);
                uiRange.Width.Set(0, 1f);
                testShaderPanel.Append(uiRange);
                topTestShaderPanel += 22;
            }

            updateneeded = true;
            Append(mainPanel);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        private UIPanel makeMainPanel()
        {
            UIPanel mainPanel = new UIPanel();

            mainPanel.BackgroundColor = Color.Green * 0.7f;

            int top      = 0;
            var uiRanges = new List <UIElement>();

            damageData            = new UIIntRangedDataValue("Damage:", 0, 0, 200);
            damageData.DataGetter = () => Main.LocalPlayer.HeldItem.damage;
            damageData.DataSetter = (value) => Main.LocalPlayer.HeldItem.damage = value;
            uiRanges.Add(new UIRange <int>(damageData));

            //var data = new UIIntRangedDataValue("Width:", 0, 60);
            //data.DataGetter = () => Main.LocalPlayer.HeldItem.width;
            //data.DataSetter = (value) => Main.LocalPlayer.HeldItem.width = value;
            //uiRanges.Add(new UIRange<int>(data));

            //data = new UIIntRangedDataValue("Height:", 0, 60);
            //data.DataGetter = () => Main.LocalPlayer.HeldItem.height;
            //data.DataSetter = (value) => Main.LocalPlayer.HeldItem.height = value;
            //uiRanges.Add(new UIRange<int>(data));

            var data = new UIIntRangedDataValue("UseStyle:", 0, 0, 6);

            data.DataGetter = () => Main.LocalPlayer.HeldItem.useStyle;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.useStyle = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("UseTime:", 2, 2, 80);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.useTime;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.useTime = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("UseAnimation:", 2, 2, 80);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.useAnimation;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.useAnimation = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("ReuseDelay:", 2, 2, 80);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.reuseDelay;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.reuseDelay = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("Pick:", 0, 0, 300);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.pick;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.pick = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("Axe:", 0, 0, 60);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.axe;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.axe = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("Hammer:", 0, 0, 150);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.hammer;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.hammer = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("Shoot:", 0, 0, TextureAssets.Projectile.Length - 1);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.shoot;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.shoot = value;
            uiRanges.Add(new UIRange <int>(data));

            var floatdata = new UIFloatRangedDataValue("ShootSpeed:", 0, 0, 32f);

            floatdata.DataGetter = () => Main.LocalPlayer.HeldItem.shootSpeed;
            floatdata.DataSetter = (value) => Main.LocalPlayer.HeldItem.shootSpeed = value;
            uiRanges.Add(new UIRange <float>(floatdata));

            floatdata            = new UIFloatRangedDataValue("KnockBack:", 0, 0, 12f);
            floatdata.DataGetter = () => Main.LocalPlayer.HeldItem.knockBack;
            floatdata.DataSetter = (value) => Main.LocalPlayer.HeldItem.knockBack = value;
            uiRanges.Add(new UIRange <float>(floatdata));

            data            = new UIIntRangedDataValue("UseAmmo:", 0, 0, Main.itemAnimations.Length - 1);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.useAmmo;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.useAmmo = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("Crit:", 0, 0, 100);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.crit;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.crit = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("Rare:", 0, 0, 11);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.rare;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.rare = value;
            uiRanges.Add(new UIRange <int>(data));

            data            = new UIIntRangedDataValue("Value:", 0, 0, 1000000);
            data.DataGetter = () => Main.LocalPlayer.HeldItem.value;
            data.DataSetter = (value) => Main.LocalPlayer.HeldItem.value = value;
            uiRanges.Add(new UIRange <int>(data));

            var check = new UIBoolDataValue("AutoReuse");

            check.DataGetter = () => Main.LocalPlayer.HeldItem.autoReuse;
            check.DataSetter = (value) => Main.LocalPlayer.HeldItem.autoReuse = value;
            uiRanges.Add(new UICheckbox2(check));

            check            = new UIBoolDataValue("UseTurn");
            check.DataGetter = () => Main.LocalPlayer.HeldItem.useTurn;
            check.DataSetter = (value) => Main.LocalPlayer.HeldItem.useTurn = value;
            uiRanges.Add(new UICheckbox2(check));


            foreach (var uiRange in uiRanges)
            {
                uiRange.Top.Set(top, 0f);
                uiRange.Width.Set(0, 1f);
                mainPanel.Append(uiRange);
                top += 22;
            }

            UITextPanel <string> setDefaultsButton = new UITextPanel <string>("SetDefaults");

            setDefaultsButton.SetPadding(4);
            setDefaultsButton.Width.Set(-10, 0.5f);
            //setDefaultsButton.HAlign = 0.5f;
            setDefaultsButton.Top.Set(top, 0f);
            setDefaultsButton.OnClick += SetDefaultsButton_OnClick;
            mainPanel.Append(setDefaultsButton);

            UITextPanel <string> prefixButton = new UITextPanel <string>("Prefix");

            prefixButton.SetPadding(4);
            prefixButton.Width.Set(-10, 0.5f);
            //prefixButton.Left.Set(0, 0.5f);
            prefixButton.HAlign = 1f;
            prefixButton.Top.Set(top, 0f);
            prefixButton.OnClick += PrefixButton_OnClick;
            mainPanel.Append(prefixButton);

            return(mainPanel);
        }
Esempio n. 9
0
        public override void OnInitialize()
        {
            Camera.fixedscreen = Main.LocalPlayer.position - new Vector2(Main.screenWidth / 2, Main.screenHeight / 2);

            TabPanel Menu = new TabPanel(400, 350,
                                         new Tab("Better Zoom", new BZUI()),
                                         new Tab(" Camera Control", this)
                                         );

            Menu.Left.Set(DragableUIPanel.lastPos.X, 0f);
            Menu.Top.Set(DragableUIPanel.lastPos.Y, 0f);
            Menu.OnCloseBtnClicked += () => ModContent.GetInstance <BetterZoom>().userInterface.SetState(null);
            Append(Menu);

            speed = new UIFloatRangedDataValue("Tracking Speed", 1, 0.1f, 100);
            var speedSldr = new UIRange <float>(speed);

            speedSldr.Width.Set(0, 1);
            speedSldr.MarginTop  = 50;
            speedSldr.MarginLeft = -20;
            Menu.Append(speedSldr);

            Menu.Append(new UIText("Control Trackers: ")
            {
                MarginTop = 130, MarginLeft = 210
            });

            UIHoverImageButton PathTrackerBtn = new UIHoverImageButton("BetterZoom/Assets/PathTrackerButton", "Place Path tracker");

            PathTrackerBtn.OnClick   += (evt, elm) => placing = TrackerID.PathTracker;
            PathTrackerBtn.MarginLeft = 245;
            PathTrackerBtn.MarginTop  = 155;
            Menu.Append(PathTrackerBtn);

            UIHoverImageButton EraseTrackerBtn = new UIHoverImageButton("BetterZoom/Assets/EraserButton", "Erase Trackers");

            EraseTrackerBtn.OnClick   += (evt, elm) => erasing = !erasing;
            EraseTrackerBtn.MarginLeft = 245;
            EraseTrackerBtn.MarginTop  = 190;
            Menu.Append(EraseTrackerBtn);

            UIHoverImageButton DelBtn = new UIHoverImageButton("BetterZoom/Assets/DelButton", "Delete all Trackers");

            DelBtn.OnClick   += DeleteAll;
            DelBtn.MarginLeft = 285;
            DelBtn.MarginTop  = 190;
            Menu.Append(DelBtn);

            UIHoverImageButton EntityBtn = new UIHoverImageButton("BetterZoom/Assets/EntityTrackerButton", "Place Entity Tracker");

            EntityBtn.OnClick   += ToggleEnityTracker;
            EntityBtn.MarginLeft = 285;
            EntityBtn.MarginTop  = 155;
            Menu.Append(EntityBtn);

            UIHoverImageButton MoveBtn = new UIHoverImageButton("BetterZoom/Assets/MoveButton", "Move Path Tracker");

            MoveBtn.OnClick   += (evt, elm) => moving = !moving;
            MoveBtn.MarginLeft = 325;
            MoveBtn.MarginTop  = 190;
            Menu.Append(MoveBtn);

            lockScreenBtn            = new UIToggleImage(TextureManager.Load("Images/UI/Settings_Toggle"), 13, 13, new Point(17, 1), new Point(1, 1));
            lockScreenBtn.MarginTop  = 100;
            lockScreenBtn.MarginLeft = 250;
            lockScreenBtn.OnClick   += (evt, elm) => Camera.ToggleLock();
            lockScreenBtn.Append(new UIText("Lock Screen", 0.9f)
            {
                MarginLeft = -230
            });
            Menu.Append(lockScreenBtn);

            Menu.Append(new UIText("Control Screen: ")
            {
                MarginTop = 130, MarginLeft = 20
            });

            // Dpad
            var Dpad = UIHelper.Dpad(60, 155);

            for (int i = 0; i < Dpad.Length; i++)
            {
                Menu.Append(Dpad[i]);
            }

            Dpad[0].OnMouseDown += (evt, elm) => Camera.MoveRelativeTo(new Vector2(0, -5f));
            Dpad[1].OnMouseDown += (evt, elm) => Camera.MoveRelativeTo(new Vector2(0, 5f));
            Dpad[2].OnMouseDown += (evt, elm) => Camera.MoveRelativeTo(new Vector2(-5f, 0));
            Dpad[3].OnMouseDown += (evt, elm) => Camera.MoveRelativeTo(new Vector2(5f, 0));

            var hideTrackersBtn = new UIToggleImage(TextureManager.Load("Images/UI/Settings_Toggle"), 13, 13, new Point(17, 1), new Point(1, 1));

            hideTrackersBtn.MarginTop  = 250;
            hideTrackersBtn.MarginLeft = 250;
            hideTrackersBtn.OnClick   += (evt, elm) => TrackerUI.hide = !TrackerUI.hide;
            hideTrackersBtn.Append(new UIText("Hide Trackers", 0.9f)
            {
                MarginLeft = -230
            });
            Menu.Append(hideTrackersBtn);

            // Control Buttons
            playButton          = new UITextPanel <string>("Play");
            playButton.VAlign   = 0.9f;
            playButton.HAlign   = 0.1f;
            playButton.OnClick += (evt, elm) => Camera.PlayStopTracking();
            Menu.Append(playButton);

            UITextPanel <string> pauseButton = new UITextPanel <string>("Pause");

            pauseButton.VAlign   = 0.9f;
            pauseButton.HAlign   = 0.5f;
            pauseButton.OnClick += (evt, elm) =>
            {
                Camera.PauseTracking();
                pauseButton.SetText(text: Camera.Playing ? "Pause" : "Resume");
            };
            Menu.Append(pauseButton);

            var repeatBtn = new UITextPanel <string>("Repeat");

            repeatBtn.VAlign   = 0.9f;
            repeatBtn.HAlign   = 0.9f;
            repeatBtn.OnClick += (evt, elm) =>
            {
                Camera.repeat = !Camera.repeat;
                repeatBtn.SetText(text: Camera.repeat ? "End" : "Repeat");
            };
            Menu.Append(repeatBtn);
        }
Esempio n. 10
0
        public override void OnInitialize()
        {
            mainPanel = new UIPanel();
            mainPanel.Left.Set(-350f, 1f);
            mainPanel.Top.Set(-620f, 1f);
            mainPanel.Width.Set(310f, 0f);
            mainPanel.Height.Set(520f, 0f);
            mainPanel.SetPadding(12);
            mainPanel.BackgroundColor = Color.Orange * 0.7f;

            int    top  = 0;
            UIText text = new UIText("Projectiles:", 0.85f);

            text.Top.Set(top, 0f);
            mainPanel.Append(text);
            top += 20;

            UIText text2 = new UIText("Filter:", 0.85f);

            text2.Top.Set(top, 0f);
            mainPanel.Append(text2);

            searchFilter = new NewUITextBox("Search", 0.85f);
            searchFilter.SetPadding(0);
            searchFilter.OnTextChanged += () => { ValidateInput(); updateneeded = true; };
            searchFilter.Top.Set(top, 0f);
            searchFilter.Left.Set(text2.GetInnerDimensions().Width, 0f);
            searchFilter.Width.Set(0, 1f);
            searchFilter.Height.Set(20, 0f);
            //searchFilter.VAlign = 0.5f;
            mainPanel.Append(searchFilter);
            top += 20;

            speedXDataProperty = new UIFloatRangedDataValue("SpeedX:", 0, -10, 10);
            speedYDataProperty = new UIFloatRangedDataValue("SpeedY:", 0, -10, 10);
            var ui2DRange = new UI2DRange <float>(speedXDataProperty, speedYDataProperty);

            ui2DRange.Top.Set(top, 0f);
            mainPanel.Append(ui2DRange);
            top += 30;

            ai0DataProperty = new UIFloatRangedDataValue("ai0:", 0, -10, 10);
            var uiRange = new UIRange <float>(ai0DataProperty);

            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            ai1DataProperty = new UIFloatRangedDataValue("ai1:", 0, -10, 10);
            uiRange         = new UIRange <float>(ai1DataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            knockbackDataProperty = new UIFloatRangedDataValue("Knockback:", 0, 0, 20);
            uiRange = new UIRange <float>(knockbackDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            damageDataProperty = new UIIntRangedDataValue("Damage:", 20, 0, 200);
            var uiRangeI = new UIRange <int>(damageDataProperty);

            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            aiStyleDataProperty = new UIIntRangedDataValue("AIStyle:", -1, -1, 145);
            uiRangeI            = new UIRange <int>(aiStyleDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            hostile = new UIBoolNDataValue("Hostile");
            var hostileCheckbox = new UITriStateCheckbox(hostile);

            hostileCheckbox.Top.Set(top, 0f);
            mainPanel.Append(hostileCheckbox);
            top += 30;

            friendly = new UIBoolNDataValue("Friendly");
            var friendlyCheckbox = new UITriStateCheckbox(friendly);

            friendlyCheckbox.Top.Set(top, 0f);
            mainPanel.Append(friendlyCheckbox);
            top += 30;

            projectileGrid            = new UIGrid(7);
            projectileGrid.Top.Pixels = top;
            //autoTrashGrid.Left.Pixels = spacing;
            projectileGrid.Width.Set(-25f, 1f);             // leave space for scroll?
            projectileGrid.Height.Set(-top, 1f);
            projectileGrid.ListPadding = 6f;
            mainPanel.Append(projectileGrid);

            // this will initialize grid
            updateneeded = true;

            var projectileGridScrollbar = new UIElements.FixedUIScrollbar(userInterface);

            projectileGridScrollbar.SetView(100f, 1000f);
            projectileGridScrollbar.Top.Pixels = top;            // + spacing;
            projectileGridScrollbar.Height.Set(-top /*- spacing*/, 1f);
            projectileGridScrollbar.HAlign = 1f;
            mainPanel.Append(projectileGridScrollbar);
            projectileGrid.SetScrollbar(projectileGridScrollbar);

            Append(mainPanel);
        }
Esempio n. 11
0
        internal void UpdateList()
        {
            if (!updateNeeded)
            {
                return;
            }
            updateNeeded = false;

            BindingFlags bindingFlags = QuickTweakTool.showPrivateFields ? BindingFlags.Public | BindingFlags.NonPublic : BindingFlags.Public;

            tweakList.Clear();
            foreach (var tweakEntry in QuickTweakTool.tweaks)
            {
                object tweakItem = tweakEntry.item;
                string label     = tweakEntry.label;

                List <(object, FieldInfo)> FieldsToDisplay = new List <(object, FieldInfo)>();
                if (tweakItem is Type type)
                {
                    foreach (var field in type.GetFields(bindingFlags | BindingFlags.Static))
                    {
                        FieldsToDisplay.Add((null, field));
                    }
                }
                else if (tweakItem is FieldInfo FieldInfo)
                {
                    FieldsToDisplay.Add((null, FieldInfo));
                }
                else if (tweakItem is ValueTuple <object, FieldInfo> tuple)
                {
                    FieldsToDisplay.Add(((object, FieldInfo))tweakItem);
                    //instance = tuple.Item1;
                    //item = tuple.Item2;
                }
                else if (tweakItem is ValueTuple <object, string> stringtuple)
                {
                    FieldInfo fieldInfo = stringtuple.Item1.GetType().GetField(stringtuple.Item2, bindingFlags | BindingFlags.Instance);
                    if (fieldInfo != null)
                    {
                        FieldsToDisplay.Add(((object, FieldInfo))(stringtuple.Item1, fieldInfo));
                    }
                    else
                    {
                        Main.NewText($"Field not found: {stringtuple.Item2} in {stringtuple.Item1.GetType().Name}");
                    }
                }
                else if (tweakItem is object)
                {
                    foreach (FieldInfo field in tweakItem.GetType().GetFields(bindingFlags | BindingFlags.Instance))
                    {
                        FieldsToDisplay.Add((tweakItem, field));
                    }
                }

                // Pass in "additionalOnChanged" probably, to handle UI updates?
                // CreateUIElementFromObjectAndField(instance, item);
                // -> object will do recursion.
                // place element on Panel or in List.

                // Need dictionary of expected/known ranges for various field names?

                var panel = new UIPanel();
                panel.SetPadding(6);
                panel.BackgroundColor = Color.LightCoral * 0.7f;
                int top = 0;

                var header = new UIText(label != "" ? label : tweakItem.ToString());
                panel.Append(header);

                UIImageButton removeButton = new UIHoverImageButton(ModContent.GetTexture("Terraria/UI/ButtonDelete"), "Remove");
                removeButton.OnClick += (a, b) => {
                    QuickTweakTool.tweaks.Remove(tweakEntry);
                    updateNeeded = true;
                };
                removeButton.Top.Set(top, 0f);
                removeButton.Left.Set(-22, 1f);
                panel.Append(removeButton);

                top += 20;

                foreach (var fieldToDisplay in FieldsToDisplay)
                {
                    object    instance  = fieldToDisplay.Item1;
                    FieldInfo fieldInfo = fieldToDisplay.Item2;

                    if (fieldInfo.FieldType == typeof(bool))
                    {
                        var dataElement = new UIBoolDataValue(fieldInfo.Name);
                        dataElement.DataGetter = () => (bool)fieldInfo.GetValue(instance);
                        dataElement.DataSetter = (value) => fieldInfo.SetValue(instance, value);
                        AppendToAndIncrement(panel, new UICheckbox2(dataElement), ref top);
                    }
                    else if (fieldInfo.FieldType == typeof(int))
                    {
                        RangeAttribute rangeAttribute = (RangeAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(RangeAttribute));
                        int            min            = 0;
                        int            max            = 100;
                        if (rangeAttribute != null && rangeAttribute.min is int && rangeAttribute.max is int)
                        {
                            min = (int)rangeAttribute.min;
                            max = (int)rangeAttribute.max;
                        }
                        var dataElement = new UIIntRangedDataValue(fieldInfo.Name, min: min, max: max);
                        dataElement.DataGetter = () => (int)fieldInfo.GetValue(instance);
                        dataElement.DataSetter = (value) => fieldInfo.SetValue(instance, value);
                        AppendToAndIncrement(panel, new UIRange <int>(dataElement), ref top);
                    }
                    else if (fieldInfo.FieldType == typeof(float))
                    {
                        RangeAttribute rangeAttribute = (RangeAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(RangeAttribute));
                        float          min            = -1f;
                        float          max            = 1f;
                        if (rangeAttribute != null && rangeAttribute.min is float && rangeAttribute.max is float)
                        {
                            max = (float)rangeAttribute.max;
                            min = (float)rangeAttribute.min;
                        }
                        if (rangeAttribute != null && rangeAttribute.min is int && rangeAttribute.max is int)
                        {
                            min = (int)rangeAttribute.min;
                            max = (int)rangeAttribute.max;
                        }
                        var dataElement = new UIFloatRangedDataValue(fieldInfo.Name, .4f, min, max);
                        dataElement.DataGetter = () => (float)fieldInfo.GetValue(instance);
                        dataElement.DataSetter = (value) => fieldInfo.SetValue(instance, value);
                        AppendToAndIncrement(panel, new UIRange <float>(dataElement), ref top);
                    }
                }
                panel.Height.Set(top + panel.PaddingBottom + PaddingTop, 0f);
                panel.Width.Set(0, 1f);
                tweakList.Add(panel);
            }
        }
Esempio n. 12
0
        public override void OnInitialize()
        {
            TabPanel Menu = new TabPanel(400, 400,
                                         new Tab("Better Zoom", this),
                                         new Tab(" Camera Control", new CCUI())
                                         );

            Menu.Left.Set(DragableUIPanel.lastPos.X, 0f);
            Menu.Top.Set(DragableUIPanel.lastPos.Y, 0f);
            Menu.OnCloseBtnClicked += () => ModContent.GetInstance <BetterZoom>().userInterface.SetState(null);
            Append(Menu);

            zoom                 = new UIFloatRangedDataValue("Zoom", 1, -1f, 10);
            zoomSldr             = new UIRange <float>(zoom);
            zoom.OnValueChanged += () => BetterZoom.zoom = zoom.Data;
            zoomSldr.Width.Set(0, 1);
            zoomSldr.MarginTop  = 50;
            zoomSldr.MarginLeft = -20;
            Menu.Append(zoomSldr);

            uiScale     = new UIFloatRangedDataValue("", 1, 0.2f, 2);
            uiScaleSldr = new UIRange <float>(uiScale);
            uiScaleSldr.Width.Set(0, 1);
            uiScaleSldr.MarginTop  = 100;
            uiScaleSldr.MarginLeft = -20;
            Menu.Append(uiScaleSldr);

            var uiScaleBtn = new UITextPanel <string>("UI Scale");

            uiScaleBtn.SetPadding(4);
            uiScaleBtn.MarginLeft = 40;
            uiScaleBtn.OnClick   += (evt, elm) => BetterZoom.uiScale = uiScale.Data;
            uiScaleSldr.Append(uiScaleBtn);

            UIToggleImage flipBgBtn = new UIToggleImage(TextureManager.Load("Images/UI/Settings_Toggle"), 13, 13, new Point(17, 1), new Point(1, 1));

            flipBgBtn.MarginTop  = 150;
            flipBgBtn.MarginLeft = 250;
            flipBgBtn.OnClick   += (evt, elm) => BetterZoom.flipBackground = !BetterZoom.flipBackground;
            flipBgBtn.SetState(BetterZoom.flipBackground);
            flipBgBtn.Append(new UIText("Flip Background", 0.9f)
            {
                MarginLeft = -230
            });
            Menu.Append(flipBgBtn);

            UIToggleImage zoomBgBtn = new UIToggleImage(TextureManager.Load("Images/UI/Settings_Toggle"), 13, 13, new Point(17, 1), new Point(1, 1));

            zoomBgBtn.MarginTop  = 200;
            zoomBgBtn.MarginLeft = 250;
            zoomBgBtn.OnClick   += (evt, elm) => BetterZoom.zoomBackground = !BetterZoom.zoomBackground;
            zoomBgBtn.SetState(BetterZoom.zoomBackground);
            zoomBgBtn.Append(new UIText("Zoom Background", 0.9f)
            {
                MarginLeft = -230
            });
            Menu.Append(zoomBgBtn);

            UIFloatRangedDataValue hotbarScale = new UIFloatRangedDataValue("Hotbar Scale", 1, 0.2f, 5);
            var hotbarScaleSldr = new UIRange <float>(hotbarScale);

            hotbarScaleSldr.Width.Set(0, 1);
            hotbarScaleSldr.MarginTop   = 250;
            hotbarScaleSldr.MarginLeft  = -20;
            hotbarScale.OnValueChanged += () => BetterZoom.hotbarScale = hotbarScale.Data;
            Menu.Append(hotbarScaleSldr);

            UIFloatRangedDataValue miniMapScale = new UIFloatRangedDataValue("Minimap Scale", 1, 0.2f, 5);
            var miniMapScaleSldr = new UIRange <float>(miniMapScale);

            miniMapScaleSldr.Width.Set(0, 1);
            miniMapScaleSldr.MarginTop   = 300;
            miniMapScaleSldr.MarginLeft  = -20;
            miniMapScale.OnValueChanged += () => BetterZoom.minimapScale = miniMapScale.Data;
            Menu.Append(miniMapScaleSldr);

            /*UIFloatRangedDataValue offScreenRange = new UIFloatRangedDataValue("offscreen Range", 192, -1000f, 1000);
             * var offScreenRangeSldr = new UIRange<float>(offScreenRange);
             * offScreenRangeSldr.Width.Set(0, 1);
             * offScreenRangeSldr.MarginTop = 350;
             * offScreenRangeSldr.MarginLeft = -20;
             * offScreenRange.OnValueChanged += () => BetterZoom.offscrnRange = offScreenRange.Data;
             * Menu.Append(offScreenRangeSldr);*/

            var resetBtn = new UITextPanel <string>("Set to Default");

            resetBtn.SetPadding(4);
            resetBtn.MarginLeft = 20;
            resetBtn.Top.Set(-40, 1);
            resetBtn.OnClick += (evt, elm) =>
            {
                zoom.ResetToDefaultValue();
                uiScale.ResetToDefaultValue();
                uiScale.SetValue(1);
                flipBgBtn.SetState(true);
                zoomBgBtn.SetState(false);
                hotbarScale.ResetToDefaultValue();
                miniMapScale.ResetToDefaultValue();
            };
            Menu.Append(resetBtn);
        }