Пример #1
0
	void HandlePipsOnSelect (UIRadioButtonGroup sender, UIToggleButton selected)
	{
		print ("pips selection changed");	
		
		int pageIndex = Mathf.RoundToInt( 20f / sender.NumberOfChildren * sender.IndexOfCurrentlySelected );
		m_scrollable.scrollToPage(pageIndex);
	}
Пример #2
0
    void HandlePipsOnSelect(UIRadioButtonGroup sender, UIToggleButton selected)
    {
        print("pips selection changed");

        int pageIndex = Mathf.RoundToInt(20f / sender.NumberOfChildren * sender.IndexOfCurrentlySelected);

        m_scrollable.scrollToPage(pageIndex);
    }
Пример #3
0
	void CreateScrollableMenuWithPips()
	{
		m_scrollable = new UIScrollableHorizontalLayout( 20 );
		
		// we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
		m_scrollable.beginUpdates();
		
			// if you plan on making the scrollable wider than the item width you need to set your edgeInsets so that the
			// left + right inset is equal to the extra width you set
			float itemWidth = 250f;
			float leftInset;
			float rightInset;
			leftInset = rightInset = (Screen.width - itemWidth) / 2;
			
			m_scrollable.edgeInsets = new UIEdgeInsets( 0, Mathf.RoundToInt(leftInset), 0, Mathf.RoundToInt(rightInset) );
			
			var scrollerHeight 	= UI.scaleFactor * itemWidth;
			var scrollerWidth 	= UI.scaleFactor * ( itemWidth + leftInset + rightInset ); // item width + 150 extra width
			m_scrollable.setSize( scrollerWidth, scrollerHeight );
			
			// paging will snap to the nearest page when scrolling
			m_scrollable.pagingEnabled = true;
			m_scrollable.pageWidth = itemWidth * UI.scaleFactor;
			
			// center the scrollable horizontally
			m_scrollable.position = new Vector3( ( Screen.width - scrollerWidth ) / 2, -Screen.height + scrollerHeight, 0 );
			
			for( var i = 0; i < 20; i++ )
			{
				var button = UIButton.create( "marioPanel.png", "marioPanel.png", 0, 0 );
				m_scrollable.addChild( button );
			}
			
		m_scrollable.endUpdates();
		m_scrollable.endUpdates(); // this is a bug. it shouldnt need to be called twice
		
		//pips
		var pips = new UIRadioButtonGroup(0, UIAbstractContainer.UILayoutType.Horizontal);
		
		int pageCount = Mathf.CeilToInt(20 * itemWidth / scrollerWidth);
		for (int i = 0; i < pageCount; i++)
		{		
			var toggle = UIToggleButton.create("emptyUp.png", "emptyDown.png", "emptyUp.png", 0, 0);
			
			pips.addChild(toggle);
		}
		
		pips.beginUpdates();
			float screenUnits = 1.0f / Screen.width;
			float halfWidth = 140 * pageCount / 2;
			float offset = halfWidth * screenUnits;
			pips.positionFromCenter(-50 * screenUnits, -offset);
		pips.endUpdates();
		
		pips.OnSelect += HandlePipsOnSelect;
		pips.IndexOfCurrentlySelected = 1;
	}
Пример #4
0
    void CreateScrollableMenuWithPips()
    {
        m_scrollable = new UIScrollableHorizontalLayout(20);

        // we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
        m_scrollable.beginUpdates();

        // if you plan on making the scrollable wider than the item width you need to set your edgeInsets so that the
        // left + right inset is equal to the extra width you set
        float itemWidth = 250f;
        float leftInset;
        float rightInset;

        leftInset = rightInset = (Screen.width - itemWidth) / 2;

        m_scrollable.edgeInsets = new UIEdgeInsets(0, Mathf.RoundToInt(leftInset), 0, Mathf.RoundToInt(rightInset));

        var scrollerHeight = UI.scaleFactor * itemWidth;
        var scrollerWidth  = UI.scaleFactor * (itemWidth + leftInset + rightInset);                        // item width + 150 extra width

        m_scrollable.setSize(scrollerWidth, scrollerHeight);

        // paging will snap to the nearest page when scrolling
        m_scrollable.pagingEnabled = true;
        m_scrollable.pageWidth     = itemWidth * UI.scaleFactor;

        // center the scrollable horizontally
        m_scrollable.position = new Vector3((Screen.width - scrollerWidth) / 2, -Screen.height + scrollerHeight, 0);

        for (var i = 0; i < 20; i++)
        {
            var button = UIButton.create("marioPanel.png", "marioPanel.png", 0, 0);
            m_scrollable.addChild(button);
        }

        m_scrollable.endUpdates();
        m_scrollable.endUpdates();         // this is a bug. it shouldnt need to be called twice

        //pips
        var pips = new UIRadioButtonGroup(0, UIAbstractContainer.UILayoutType.Horizontal);

        int pageCount = Mathf.CeilToInt(20 * itemWidth / scrollerWidth);

        for (int i = 0; i < pageCount; i++)
        {
            var toggle = UIToggleButton.create("emptyUp.png", "emptyDown.png", "emptyUp.png", 0, 0);

            pips.addChild(toggle);
        }

        pips.beginUpdates();
        float screenUnits = 1.0f / Screen.width;
        float halfWidth   = 140 * pageCount / 2;
        float offset      = halfWidth * screenUnits;

        pips.positionFromCenter(-50 * screenUnits, -offset);
        pips.endUpdates();

        pips.OnSelect += HandlePipsOnSelect;
        pips.IndexOfCurrentlySelected = 1;
    }
Пример #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);
        }
Пример #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);
        }