Example #1
0
    void Start()
    {
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText( "prototype", "prototype.png" );

        // spawn new text instances showing off the relative positioning features by placing one text instance in each corner
        var x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        var y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f );
        text1 = text.addTextInstance( "hello man.  I have a line\nbreak", x, y );

        var textSize = text.sizeForText( "testing small bitmap fonts", 0.3f );
        x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y );
        text2 = text.addTextInstance( "testing small bitmap fonts", x, y, 0.3f );

        textSize = text.sizeForText( "with only\n1 draw call\nfor everything", 0.5f );
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x );
        y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f );
        text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", x, y, 0.5f, 5, Color.yellow );

        textSize = text.sizeForText( "kudos" );
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y );
        text4 = text.addTextInstance( "kudos", x, y );

        textSize = text.sizeForText( "Be sure to try this with\niPhone and iPad resolutions" );
        var center = UIRelative.center( textSize.x, textSize.y );
        text.addTextInstance( "Be sure to try this with\niPhone and iPad resolutions", center.x, center.y, 1f, 4, Color.red );

        StartCoroutine( waitThenRemoveText() );
    }
 public TimeTravel()
 {
     try
     {
         instantDelorean = new Delorean_class();
         Interval = 1;
         Tick += onTick;
         KeyUp += onKeyUp;
         KeyDown += onKeyDown;
         //loadscriptsettings();
         Game.Player.CanControlCharacter = true;
         if (Game.Player.Character.IsInVehicle())
         {
             Game.Player.Character.CurrentVehicle.IsVisible = true;
         }
     }
     catch (Exception e)
     {
         while(true)
         {
             UIText debug2 = new UIText(e.Message, new Point(200, 100), (float)0.6);
             debug2.Draw();
             Application.DoEvents();
         }
     }
 }
	void Start()
	{
		// create a vertical layout to house our buttons
		var vBox = new UIVerticalLayout( 10 );
		vBox.edgeInsets = new UIEdgeInsets( 10, 5, 10, 0 );
		
		// create some buttons to control the positioning. we will add text to them se create the UIText we will use as well
		var text = new UIText( textToolkit, "prototype", "prototype.png" );
		
		var positions = new string[] { "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right" };
		foreach( var pos in positions )
		{			
			// create the button
			var touchable = UIButton.create( "emptyUp.png", "emptyDown.png", 0, 0 );
			touchable.userData = pos;
			touchable.onTouchUpInside += onButtonTouched;

			// add the text
			var helloText = text.addTextInstance( pos, 0, 0, 0.5f, -1, Color.white, UITextAlignMode.Center, UITextVerticalAlignMode.Middle );
			helloText.parentUIObject = touchable;
			helloText.positionCenter();
			
			vBox.addChild( touchable );
		}
		
		
		// Scores button. we will use this to demo positioning
		_scoresButton = UIContinuousButton.create( buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0 );
		_scoresButton.positionCenter();
	}
Example #4
0
        private void glCanvas1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 'b')
            {
                BlendingSourceFactor source;
                BlendingDestinationFactor dest;
                this.blendFactorHelper.GetNext(out source, out dest);
                this.glText.BlendSwitch.SourceFactor = source;
                this.glText.BlendSwitch.DestFactor = dest;
                this.UpdateLabel();
            }
            else if (e.KeyChar == 'o')
            {
                if (this.openTextureDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string ttfFilename = this.openTextureDlg.FileName;
                    this.glText.Dispose();
                    FontResource fontResouce = FontResource.Load(ttfFilename, ' ', (char)126);
                    var glText = new UIText(AnchorStyles.Left | AnchorStyles.Top,
                        new Padding(3, 3, 3, 3), new Size(850, 50), -100, 100, fontResouce);
                    glText.Initialize();
                    glText.SwitchList.Add(new ClearColorSwitch());// show black back color to indicate glText's area.
                    glText.SetText("The quick brown fox jumps over the lazy dog!");
                    this.glText = glText;

                    uiRoot.Children.Add(glText);

                    this.formPropertyGrid.DisplayObject(glText);
                }
            }
        }
Example #5
0
    // Use this for initialization
    void Start()
    {
        PlayerScores = new UITextInstance[4];
        PlayerIcons = new UISprite[4];

        UIText fnt = new UIText("Pourquoi64", "Pourquoi64.png");

        yScale = Mathf.Clamp ((float)Screen.width / 1080, 0, 1);

        for (int i=0; i < 4; i++)
        {
            PlayerScores[i] = fnt.addTextInstance("00%", 0, 0);

            PlayerHUDPositions[i].GetComponent<HUDDogeMasterControllerUIT>().percentageDisplay = PlayerScores[i];

            PlayerScores[i].setColorForAllLetters(Color.yellow);
            PlayerScores[i].textScale = scoreTextScale * yScale;
            PlayerScores[i].text = i.ToString() + "00%";
            Debug.Log (i);

            //string dogeFileName = "dogePortrait0" + (i + 1).ToString();
            //PlayerIcons[i] = new UISprite(

        }
    }
Example #6
0
        private void Form_Load(object sender, EventArgs e)
        {
            {
                var camera = new Camera(
                    new vec3(0, 0, 1), new vec3(0, 0, 0), new vec3(0, 1, 0),
                    CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                var rotator = new SatelliteRotator(camera);
                this.rotator = rotator;
                this.scene = new Scene(camera);
            }
            {
                var glText = new UIText(AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right,
                    new Padding(10, 10, 10, 10), new Size(550, 50), -100, 100);
                glText.Initialize();
                glText.SwitchList.Add(new ClearColorSwitch());// show black back color to indicate glText's area.
                glText.SetText("The quick brown fox jumps over the lazy dog!");
                this.glText = glText;
                this.scene.UIRoot.Children.Add(glText);

                var glAxis = new UIAxis(AnchorStyles.Right | AnchorStyles.Bottom,
                    new Padding(3, 3, 3, 3), new Size(70, 70), -100, 100);
                glAxis.Initialize();
                this.scene.UIRoot.Children.Add(glAxis);

                this.UpdateLabel();
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.glText);
                frmPropertyGrid.Show();
                this.formPropertyGrid = frmPropertyGrid;
            }
        }
Example #7
0
	void Start()
	{
		// setup our text instance which will parse our .fnt file and allow us to
		var text = new UIText( "prototype", "prototype.png" );

		
		// spawn new text instances showing off the relative positioning features by placing one text instance in each corner
		// Uses default color, scale, alignment, and depth.
		text1 = text.addTextInstance( "hello man.  I have a line\nbreak.", 0, 0 );
        text1.pixelsFromTopLeft( 0, 0 );
		

		text2 = text.addTextInstance( "testing small bitmap fonts", 0, 0, 0.3f );
        text2.pixelsFromBottomLeft( 25, 0 );
		
		
		// Centering using alignment modes.
		text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", 0, 0, 0.5f, 5, Color.yellow, UITextAlignMode.Right, UITextVerticalAlignMode.Top );
        text3.positionFromTopLeft( 0.5f, 0.2f );

		
		// High Ascii forcing crash demo. To test this, 
		// Disable "Set Low ASCII Forcing Mode" in the TextManager inspector and see the crash.
		// Not as handy if you don't need to paste in large amounts of text from word.
		text.forceLowAscii = setLowAsciiForcingMode;

		text4 = text.addTextInstance( highAsciiString, 0, 0, 0.4f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Bottom );
        text4.positionFromBottomRight( 0f, 0f );
		
		
		// Centering using text size calculation offset and per-char color
		var centeredText = "Be sure to try this with\niPhone and iPad resolutions";
		var colors = new List<Color>();
		for( var i = 0; i < centeredText.Length; i++ )
			colors.Add( Color.Lerp( Color.white, Color.magenta, (float)i / centeredText.Length ) );
		
		text5 = text.addTextInstance( centeredText, 0, 0, 1f, 4, colors.ToArray(), UITextAlignMode.Left, UITextVerticalAlignMode.Middle );
        text5.positionFromLeft( -0.1f, 0f );
		
		
		// Now center on right side.
		text6 = text.addTextInstance( "Vert-Centering on right side", 0, 0, 0.5f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Middle );
        text6.positionFromTopRight( 0.3f, 0f );
		
		
		var wrapText = new UIText( "prototype", "prototype.png" );
		wrapText.wrapMode = UITextLineWrapMode.MinimumLength;
		wrapText.lineWrapWidth = 100.0f;
		textWrap1 = wrapText.addTextInstance( "Testing line wrap width with small words in multiple resolutions.\n\nAnd manual L/B.", 0, 0, 0.3f, 1, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Bottom );
        textWrap1.positionFromBottomLeft( 0.1f, 0.1f );
		
		wrapText.lineWrapWidth = 100.0f;
		wrapText.wrapMode = UITextLineWrapMode.AlwaysHyphenate;
		
		textWrap2 = wrapText.addTextInstance( "This should be hyphenated. Check baseline - tytyt", 0, 0, 0.5f, 1, Color.green, UITextAlignMode.Center, UITextVerticalAlignMode.Bottom );
        textWrap2.positionFromBottom( 0f );
		
		StartCoroutine( modifyTextInstances() );
	}
 // Use this for initialization
 void Start()
 {
     UIText fnt = new UIText("Pourquoi64", "Pourquoi64.png");
     text = fnt.addTextInstance("The quick brown fox", 20, 20);
     text.setColorForAllLetters(Color.yellow);
     text2 = fnt.addTextInstance("jumps over the lazy dog", 20, 60, 0.75f);
     text2.setColorForAllLetters(Color.red);
 }
 public UIText getLabelText()
 {
     if (labelText == null)
     {
         string fontTxtFile = "GameLabelFnt";
         labelText = new UIText(getToolkitManagerLabels(), fontTxtFile, "GameLabelFnt.png");
     }
     return labelText;
 }
Example #10
0
    void Start()
    {
        toolkitText = toolkitAssets.getLabelText();

        labelTimer = toolkitText.addTextInstance("0:00.0", 0, 0, 1f, 15);
        labelTimer.positionFromTopLeft(0.03f, 0.5f);

        //remove this if you will send restart level message
        // onRestartLevel();
    }
Example #11
0
 public UITextInstance( UIText parentText, string text, float xPos, float yPos, float scale, int depth, Color color )
 {
     _parentText = parentText;
     _text = text;
     this.xPos = xPos;
     this.yPos = yPos;
     this.scale = scale;
     this.depth = depth;
     this.textIndex = -1;
     this.color = color;
 }
Example #12
0
    void Start()
    {
        toolkitText = toolkitAssets.getLabelText();

        label = toolkitText.addTextInstance(initialText, 0, 0, fontScale, 15);
        label.positionFromTopLeft(posFromTop, posFromLeft);
        if (initiallyHidden)
        {
            label.hidden = true;
        }
    }
	void Start()
	{
		// setup our text instance which will parse our .fnt file and allow us to
		var text = new UIText( "prototype", "prototype.png" );
		text.alignMode = UITextAlignMode.Center;
		
		// add a text instance that we will animate later
		text1 = text.addTextInstance( "hello man.  I have a line\nbreak.", Screen.width / 2, 0 );
		text2 = text.addTextInstance( _counter.ToString(), Screen.width, 35, 1, 5, Color.black, UITextAlignMode.Right, UITextVerticalAlignMode.Middle );
		
		StartCoroutine( modifyTextInstance() );
	}
    void OnTick(object sender, EventArgs e)
    {
        if (firstrun && asd.IsOnMinimap)
        {
            firstrun = false;
            UI.Notify("Don't mind the loading online screen if you're seeing it, it just loads the map.");
            // KUDOS TO ISOFX FOR THE NATIVE \/
            Function.Call(Hash._LOAD_MP_DLC_MAPS);
            // KUDOS TO ISOFX FOR THE IPL \/
            Function.Call(Hash.REQUEST_IPL, "hei_sm_16_interior_v_bahama_milo_");
            UI.Notify("After it loads, just walk to the door of Bahama Mamas to be teleported inside.");
        }
           bool xf = Game.Player.Character.Position.X < -1386.75f && Game.Player.Character.Position.X > -1389f;
           bool yf = Game.Player.Character.Position.Y > -589.1f && Game.Player.Character.Position.Y < -587.35f;
           bool zf = Game.Player.Character.Position.Z > 29f && Game.Player.Character.Position.Z < 35f;

           if (xf && yf && zf)
           {
           if (Game.Player.Character.IsInVehicle())
           {
               Game.Player.Character.CurrentVehicle.Position = new Vector3(-1387.975f, -584.7377f, 30.35f);
           }
           else
           {
               Game.Player.Character.Position = new Vector3(-1387.975f, -584.7377f, 30.35f);
           }
            UI.Notify("Teleported you outside, walk to the door to be teleported inside.");
           }

           bool xf2 = Game.Player.Character.Position.X < -1387.7f && Game.Player.Character.Position.X > -1389f;
           bool yf2 = Game.Player.Character.Position.Y > -586.9f && Game.Player.Character.Position.Y < -585.35f;

           if (xf2 && yf2 && zf)
           {
           if (Game.Player.Character.IsInVehicle())
           {
               Game.Player.Character.CurrentVehicle.Position = new Vector3(-1391f, -591.54f, 30.35f);
           }
           else
           {
            Game.Player.Character.Position = new Vector3(-1391f, -591.54f, 30.35f);
           }
            UI.Notify("Teleported you inside, walk to the door to be teleported outside.");
           }

           if (debugmode)
           {
           UIText uIText = new UIText(xf2.ToString() + yf2.ToString() + " - " +xf.ToString() + yf.ToString() + zf.ToString() + " - " + Game.FPS.ToString() + " - " + (Game.Player.Character.Position.ToString()), new Point(10, 10), 0.4f, Color.Red);
           uIText.Draw();
           }
    }
Example #15
0
 /// <summary>
 /// Full constructor with per-instance alignment modes.
 /// </summary>
 public UITextInstance( UIText parentText, string text, float xPos, float yPos, float scale, int depth, Color[] colors, UITextAlignMode alignMode, UITextVerticalAlignMode verticalAlignMode )
 {
     this.alignMode = alignMode;
     this.verticalAlignMode = verticalAlignMode;
     _parentText = parentText;
     _text = text;
     this.xPos = xPos;
     this.yPos = yPos;
     this.scale = scale;
     this.depth = depth;
     this.textIndex = -1;
     this.colors = colors;
     _hidden = false;
 }
Example #16
0
    /// <summary>
    /// Full constructor with per-instance alignment modes.
    /// </summary>
    public UITextInstance( UIText parentText, string text, float xPos, float yPos, float scale, int depth, Color[] colors, UITextAlignMode alignMode, UITextVerticalAlignMode verticalAlignMode )
        : base()
    {
        client.transform.position = new Vector3( xPos, yPos, depth );

        this.alignMode = alignMode;
        this.verticalAlignMode = verticalAlignMode;
        _parentText = parentText;
        _text = text;
        this.xPos = xPos;
        this.yPos = yPos;
        this.scale = scale;
        this.depth = depth;
        this.colors = colors;
        _hidden = false;
    }
Example #17
0
        public void Draw()
        {
            if (startOffset != null)
                position += startOffset.Value;

            Function.Call(Hash.SET_DRAW_ORIGIN, position.X, position.Y, position.Z, 0);
            var uiText = new UIText(string.Format("x{0}", value), Point.Empty, 0.8f, mainColor, font, false);
            uiText.Draw();

            if (text != null)
            {
                uiText = new UIText(text, new Point(0, 29), 0.66F, textColor, Font.ChaletComprimeCologne, false);
                uiText.Draw();
            }

            Function.Call(Hash.CLEAR_DRAW_ORIGIN);
        }
Example #18
0
    private bool _tmpWorkaround; //OH GOD SOMEONE SHOOTME

    #endregion Fields

    #region Constructors

    public Vigilante()
    {
        KeyDown += OnKeyDown;
        Tick += OnTick;

        //this._debug = new UIText("debug goes here", new Point(10, 10), 0.5f, Color.White, 0, false);

        //CriminalGroup = World.AddRelationShipGroup("CRIMINALS_MOD"); //Wont work
        //OutputArgument outArg = new OutputArgument();
        //Function.Call(Hash.ADD_RELATIONSHIP_GROUP, "CRIMINALS_MOD", outArg);
        //CriminalGroup = outArg.GetResult<int>();

        _headsup = new UIText("Level: ~b~" + _level, new Point(2, 325), 0.7f, Color.WhiteSmoke, 1, false);
        _headsupRectangle = new UIRectangle(new Point(0, 320), new Size(200, 110), Color.FromArgb(100, 0, 0, 0));

        //World.SetRelationshipBetweenGroups(Relationship.Hate, CriminalGroup, PlayerGroup);
    }
    /// <summary>
    /// Full constructor with per-instance alignment modes.
    /// </summary>
    public UITextInstance( UIText parentText, string text, float xPos, float yPos, float scale, int depth, Color[] colors, UITextAlignMode alignMode, UITextVerticalAlignMode verticalAlignMode )
        : base()
    {
        _parentText = parentText;
        _text = text;
        _scale = scale;
        this.colors = colors;
        position = new Vector3( xPos, -yPos, depth );
        _hidden = false;

        // Set anchor alignment
        _alignMode = alignMode;
        switch( alignMode )
        {
            case UITextAlignMode.Left:
                _anchorInfo.OriginUIxAnchor = UIxAnchor.Left;
                break;
            case UITextAlignMode.Center:
                _anchorInfo.OriginUIxAnchor = UIxAnchor.Center;
                break;
            case UITextAlignMode.Right:
                _anchorInfo.OriginUIxAnchor = UIxAnchor.Right;
                break;
        }

        // Set anchor vertical alignment
        _verticalAlignMode = verticalAlignMode;
        switch( verticalAlignMode )
        {
            case UITextVerticalAlignMode.Top:
                _anchorInfo.OriginUIyAnchor = UIyAnchor.Top;
                break;
            case UITextVerticalAlignMode.Middle:
                _anchorInfo.OriginUIyAnchor = UIyAnchor.Center;
                break;
            case UITextVerticalAlignMode.Bottom:
                _anchorInfo.OriginUIyAnchor = UIyAnchor.Bottom;
                break;
        }

        _anchorInfo.OffsetX = xPos;
        _anchorInfo.OffsetY = yPos;

        updateSize();
    }
Example #20
0
        private void CreateDebugWindow()
        {
            _uiContainerDebug = new UIContainer(new Point(0, 0), new Size(1280, 720), Color.FromArgb(25, 237, 239, 241));
            _uiContainerDebug.Items.Add(new UIRectangle(new Point(0, 0), new Size(400, 30), Color.FromArgb(255, 26, 188, 156)));
            _uiContainerDebug.Items.Add(new UIText("Tobii Eye tracking", new Point(200, 4), 0.5f, Color.WhiteSmoke, 0, true));
            _uiContainerDebug.Items.Add(new UIRectangle(new Point(0, 30), new Size(400, 150), Color.FromArgb(135, 26, 187, 155)));

            DebugText1 = new UIText("Debug", new Point(200, 34), 0.4f, Color.Black, 0, true);
            _uiContainerDebug.Items.Add(DebugText1);
            DebugText2 = new UIText("Debug", new Point(200, 64), 0.4f, Color.Black, 0, true);
            _uiContainerDebug.Items.Add(DebugText2);
            DebugText3 = new UIText("Debug", new Point(200, 94), 0.4f, Color.Black, 0, true);
            _uiContainerDebug.Items.Add(DebugText3);
            DebugText4 = new UIText("Debug", new Point(200, 124), 0.4f, Color.Black, 0, true);
            _uiContainerDebug.Items.Add(DebugText4);
            DebugText5 = new UIText("Debug", new Point(200, 154), 0.4f, Color.Black, 0, true);
            _uiContainerDebug.Items.Add(DebugText5);
        }
    void Start()
    {
        // Scores button
        var scores = UIContinuousButton.create( buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0 );
        scores.positionFromBottomRight( .02f, .02f );
        scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );

        // Options button
        var optionsButton = UIButton.create( buttonToolkit, "optionsUp.png", "optionsDown.png", 0, 0 );
        optionsButton.positionFromBottomRight( .2f, .02f );

        // Text
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText( textToolkit, "prototype", "prototype.png" );

        var helloText = text.addTextInstance( "hello man.  I have a line\nbreak", 0, 0 );
        helloText.positionFromTopLeft( 0.1f, 0.05f );
    }
    void Start()
    {
        // Scores button
        var scores = UIContinuousButton.create( buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0 );
        scores.positionFromBottomRight( .02f, .02f );
        scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );

        // Options button
        var optionsButton = UIButton.create( buttonToolkit, "optionsUp.png", "optionsDown.png", 0, 0 );
        optionsButton.positionFromBottomRight( .2f, .02f );

        // Text
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText( textToolkit, "prototype", "prototype.png" );

        var x = UIRelative.xPercentFrom( UIxAnchor.Left, .05f );
        var y = UIRelative.yPercentFrom( UIyAnchor.Top, .1f );
        text.addTextInstance( "hello man.  I have a line\nbreak", x, y );
    }
Example #23
0
    void Start()
    {
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText( "prototype", "prototype.png" );

        // spawn new text instances showing off the relative positioning features by placing one text instance in each corner
        var x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        var y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f );
        text1 = text.addTextInstance( "hello man.  I have a line\nbreak", x, y );

        var textSize = text.sizeForText( "testing small bitmap fonts", 0.3f );
        x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y );
        text2 = text.addTextInstance( "testing small bitmap fonts", x, y, 0.3f );

        textSize = text.sizeForText( "with only\n1 draw call\nfor everything", 0.5f );
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x );
        y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f );
        text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", x, y, 0.5f, 5, Color.yellow );

        textSize = text.sizeForText( "kudos" );
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y );
        text4 = text.addTextInstance( "kudos", x, y );

        textSize = text.sizeForText( "Be sure to try this with\niPhone and iPad resolutions" );
        var center = UIRelative.center( textSize.x, textSize.y );
        text.addTextInstance( "Be sure to try this with\niPhone and iPad resolutions", center.x, center.y, 1f, 4, Color.red );

        x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y * 3 );
        var wrapText = new UIText( "prototype", "prototype.png");
        wrapText.wrapMode = UITextLineWrapMode.MinimumLength;
        wrapText.lineWrapWidth = 200.0f;
        textWrap1 = wrapText.addTextInstance( "Testing line wrap width with small words in multiple resolutions.", x, y, 0.3f);
        wrapText.lineWrapWidth = 100.0f;
        wrapText.wrapMode = UITextLineWrapMode.AlwaysHyphenate;
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, 200.0f );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y * 3 );
        textWrap2 = wrapText.addTextInstance( "This should be hyphenated.", x, y, 0.5f );

        StartCoroutine( waitThenRemoveText() );
    }
        private void Form_Load(object sender, EventArgs e)
        {
            {
                //this.glCanvas1.ShowSystemCursor = false;
            }
            {
                var camera = new Camera(
                    new vec3(0, 0, 1), new vec3(0, 0, 0), new vec3(0, 1, 0),
                    CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                var rotator = new SatelliteManipulater();
                rotator.Bind(camera, this.glCanvas1);
                this.rotator = rotator;
                this.scene = new Scene(camera, this.glCanvas1);
                this.scene.RootViewPort.ClearColor = Color.SkyBlue;
                this.glCanvas1.Resize += this.scene.Resize;
            }
            {
                var glText = new UIText(AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right,
                    new Padding(10, 10, 10, 10), new Size(550, 50), -100, 100);
                glText.StateList.Add(new ClearColorState());// show black back color to indicate glText's area.
                glText.Text = "The quick brown fox jumps over the lazy dog!";
                this.glText = glText;
                this.scene.RootUI.Children.Add(glText);
            }
            {
                var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom,
                    new Padding(3, 3, 3, 3), new Size(128, 128));
                this.scene.RootUI.Children.Add(uiAxis);

                this.UpdateLabel();
            }
            {
                var builder = new StringBuilder();
                builder.AppendLine("1: Scene's property grid.");
                builder.AppendLine("2: Cavas' property grid.");
                MessageBox.Show(builder.ToString());
            }
        }
        public override void OnInitialize()
        {
            mainPanel = new UIDragableElement(true, true, true);
            //mainPanel.SetPadding(0);
            //mainPanel.PaddingTop = 4;
            mainPanel.Left.Set(400f, 0f);
            mainPanel.Top.Set(400f, 0f);
            mainPanel.Width.Set(475f, 0f);             // + 30
            mainPanel.MinWidth.Set(415f, 0f);
            mainPanel.MaxWidth.Set(784f, 0f);
            mainPanel.Height.Set(350, 0f);
            mainPanel.MinHeight.Set(263, 0f);
            mainPanel.MaxHeight.Set(1000, 0f);
            //mainPanel.BackgroundColor = Color.LightBlue;

            sharedUI          = new SharedUI();
            recipeCatalogueUI = new RecipeCatalogueUI();
            craftUI           = new CraftUI();
            itemCatalogueUI   = new ItemCatalogueUI();
            bestiaryUI        = new BestiaryUI();
            helpUI            = new HelpUI();

            sharedUI.Initialize();

            var recipePanel = recipeCatalogueUI.CreateRecipeCataloguePanel();

            mainPanel.Append(recipePanel);

            var craftPanel = craftUI.CreateCraftPanel();

            mainPanel.Append(craftPanel);

            var cataloguePanel = itemCatalogueUI.CreateItemCataloguePanel();

            mainPanel.Append(cataloguePanel);

            var bestiaryPanel = bestiaryUI.CreateBestiaryPanel();

            mainPanel.Append(bestiaryPanel);

            var helpPanel = helpUI.CreateHelpPanel();

            //mainPanel.Append(helpPanel); // does this do anything?

            tabController = new TabController(mainPanel);
            tabController.AddPanel(recipePanel);
            tabController.AddPanel(craftPanel);
            tabController.AddPanel(cataloguePanel);
            tabController.AddPanel(bestiaryPanel);
            tabController.AddPanel(helpPanel);

            mainPanel.AddDragTarget(recipePanel);
            mainPanel.AddDragTarget(recipeCatalogueUI.recipeInfo);
            mainPanel.AddDragTarget(recipeCatalogueUI.RadioButtonGroup);
            mainPanel.AddDragTarget(craftPanel);
            craftUI.additionalDragTargets.ForEach(x => mainPanel.AddDragTarget(x));
            mainPanel.AddDragTarget(cataloguePanel);
            itemCatalogueUI.additionalDragTargets.ForEach(x => mainPanel.AddDragTarget(x));
            mainPanel.AddDragTarget(bestiaryPanel);
            mainPanel.AddDragTarget(helpPanel);
            mainPanel.AddDragTarget(helpUI.message);

            UIPanel button = new UIBottomlessPanel();

            button.SetPadding(0);
            button.Left.Set(10, 0);
            button.Width.Set(80, 0);
            button.Height.Set(22, 0);
            button.OnClick        += (a, b) => tabController.SetPanel(RecipeCatalogue);
            button.BackgroundColor = RecipeCatalogueUI.color;

            UIText text = new UIText(RBText("Recipes"), 0.85f);

            text.HAlign = 0.5f;
            text.VAlign = 0.5f;
            button.Append(text);
            mainPanel.Append(button);
            tabController.AddButton(button);

            button = new UIBottomlessPanel();
            button.SetPadding(0);
            button.Left.Set(85, 0);
            button.Width.Set(80, 0);
            button.Height.Set(22, 0);
            button.OnClick        += (a, b) => { tabController.SetPanel(Craft); };
            button.BackgroundColor = CraftUI.color;

            text        = new UIText(RBText("Craft"), 0.85f);
            text.HAlign = 0.5f;
            text.VAlign = 0.5f;
            button.Append(text);
            mainPanel.Append(button);
            tabController.AddButton(button);

            button = new UIBottomlessPanel();
            button.SetPadding(0);
            button.Left.Set(160, 0);
            button.Width.Set(80, 0);
            button.Height.Set(22, 0);
            button.OnClick        += (a, b) => { tabController.SetPanel(ItemCatalogue); itemCatalogueUI.updateNeeded = true; };
            button.BackgroundColor = ItemCatalogueUI.color;

            text        = new UIText(RBText("Items"), 0.85f);
            text.HAlign = 0.5f;
            text.VAlign = 0.5f;
            button.Append(text);
            mainPanel.Append(button);
            tabController.AddButton(button);

            button = new UIBottomlessPanel();
            button.SetPadding(0);
            button.Left.Set(235, 0);
            button.Width.Set(80, 0);
            button.Height.Set(22, 0);
            button.OnClick        += (a, b) => tabController.SetPanel(Bestiary);
            button.BackgroundColor = BestiaryUI.color;

            text        = new UIText(RBText("Bestiary"), 0.85f);
            text.HAlign = 0.5f;
            text.VAlign = 0.5f;
            button.Append(text);
            mainPanel.Append(button);
            tabController.AddButton(button);

            button = new UIBottomlessPanel();
            button.SetPadding(0);
            button.Left.Set(-155, 1);
            button.Width.Set(80, 0);
            button.Height.Set(22, 0);
            button.OnClick        += (a, b) => tabController.SetPanel(Help);
            button.BackgroundColor = HelpUI.color;

            text        = new UIText("Help", 0.85f);
            text.HAlign = 0.5f;
            text.VAlign = 0.5f;
            button.Append(text);
            mainPanel.Append(button);
            tabController.AddButton(button);

            // TODO: Help panel with expandable help topics.

            button = new UIBottomlessPanel();
            button.SetPadding(0);
            button.Left.Set(-80, 1);
            button.Width.Set(70, 0);
            button.Height.Set(22, 0);
            button.BackgroundColor = Color.DarkRed;

            var modFilterButton = new UIHoverImageButtonMod(RecipeBrowser.instance.GetTexture("Images/filterMod"), RBText("ModFilter") + ": " + RBText("All"));

            modFilterButton.Left.Set(-60, 1f);
            modFilterButton.Top.Set(-0, 0f);
            modFilterButton.OnClick       += ModFilterButton_OnClick;
            modFilterButton.OnRightClick  += ModFilterButton_OnRightClick;
            modFilterButton.OnMiddleClick += ModFilterButton_OnMiddleClick;
            button.Append(modFilterButton);

            Texture2D texture = RecipeBrowser.instance.GetTexture("UIElements/closeButton");

            closeButton          = new UIHoverImageButton(texture, RBText("Close"));
            closeButton.OnClick += CloseButtonClicked;
            closeButton.Left.Set(-26, 1f);
            closeButton.VAlign = 0.5f;
            button.Append(closeButton);
            mainPanel.Append(button);

            tabController.SetPanel(0);

            //favoritedRecipes = new List<int>();
            favoritePanel = new UIDragablePanel();
            favoritePanel.SetPadding(6);
            favoritePanel.Left.Set(-310f, 0f);
            favoritePanel.HAlign = 1f;
            favoritePanel.Top.Set(90f, 0f);
            favoritePanel.Width.Set(415f, 0f);
            favoritePanel.MinWidth.Set(50f, 0f);
            favoritePanel.MaxWidth.Set(600f, 0f);
            favoritePanel.Height.Set(350, 0f);
            favoritePanel.MinHeight.Set(50, 0f);
            favoritePanel.MaxHeight.Set(300, 0f);
            //favoritePanel.BackgroundColor = new Color(73, 94, 171);
            favoritePanel.BackgroundColor = Color.Transparent;
            //Append(favoritePanel);
        }
Example #26
0
        //private void ChangeVariation(int obj)
        //{
        //    var index = Mennu.SelectedIndex;
        //    var kvp = variations.ElementAt(index);
        //    var component = kvp.Key;
        //    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character, component, obj, 0,0);
        //}
        //private Menu Mennu;
        //Dictionary<int, int> variations = new Dictionary<int, int>();
        //
        //
        //private void SelectTile(int obj)
        //{
        //    throw new NotImplementedException();
        //}
        public override void Update()
        {
            if(Game.IsKeyPressed(Keys.F5))
            {
                //try
                //{

                    //RPG.PlayerData.AddMoney(20120324);
                    //var mmmmmenu = new TiledMenu("Select Your Gender",
                    //    new TiledPanel("Male", new GTASprite("mptattoos1", "tattoo_drugdeal", Color.Red), Color.DodgerBlue, SelectTile, "Play as an XY chromosome."),
                    //    new TiledPanel("Female", new GTASprite("mptattoos", "killplayerbountyhead", Color.Purple),Color.Pink, SelectTile, "Play as an XX chromosome."));
                    //View.AddMenu(mmmmmenu);

                    //variations = new Dictionary<int, int>();
                    //for (int i = 0; i < 10 ; i++)
                    //{
                    //    var a = Function.Call<int>(Hash._0x5FAF9754E789FB47, Game.Player.Character, i);
                    //    //if(a > 1)
                    //    //{
                    //    //    variations.Add(i,a);
                    //        RPGLog.Log("Tried " + i + " got variations: " + a);
                    //    //}
                    //}
                    //Function.Call(Hash.SET_PED_RANDOM_PROPS, Game.Player.Character);
                    //Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character, 0, adasdasdasdij);
                    //adasdasdasdij++;

            //
            //                    View.MenuPosition = new Point(UI.WIDTH/2 -  150, UI.HEIGHT - 300);
            //                    Mennu.Width = 300;
            //                    RPGUI.FormatMenu(Mennu);
            //                    View.AddMenu(Mennu);

                //}
                //catch (Exception ex)
                //{
                //    RPGLog.Log(ex);
                //}

                //Wait(500);
                //try
                //{
                //    var outArg = new OutputArgument();
                //    var a =  Function.Call<Vector3>(Hash.GET_HUD_COMPONENT_POSITION, 15, outArg);
                //    RPG.Notify("a: " + a);
                //    RPG.Notify("a: " + outArg.GetResult<Vector3>());
                //
                //}
                //catch
                //{
                //
                //}

                //string s = Game.GetUserInput(100);
                //try
                //{
                //    var propName = s;
                //    Model m = propName;
                //    var p = World.CreateProp(m, Game.Player.Character.Position + Game.Player.Character.ForwardVector * 2, true, true);
                //    Wait(5000);
                //    if (p.Exists())
                //    {
                //        p.Delete();
                //    }
                //}
                //catch (Exception)
                //{
                //    RPG.Notify("err");
                //}
            }

            if (!Debug) return;
            var c = new UIContainer(new Point(UI.WIDTH - 305, UI.HEIGHT - 305), new Size(300, 300), Color.FromArgb(180, 50, 50, 50));

            var debug = "";
            debug += "player co-ordinates: " + VecStr(Game.Player.Character.Position) + "\n";
            debug += "- heading: " + Game.Player.Character.Heading + "\n";
            debug += "- rotation: " + VecStr(Game.Player.Character.Rotation) + "\n";
            debug += "- model hash: " + Game.Player.Character.Model.Hash + "\n";
             var v = new UIText(debug,new Point(0, 0), 0.25f, Color.White);

            var cardebug = "";
             if (Game.Player.Character.IsInVehicle())
             {
                 cardebug += "vehicle model: " + Game.Player.Character.CurrentVehicle.Model.Hash + "\n";
                 cardebug += "- heading: " + Game.Player.Character.CurrentVehicle.Heading + "\n";
                 cardebug += "- rotation: " + VecStr(Game.Player.Character.CurrentVehicle.Rotation) + "\n";
             }
             var x = new UIText(cardebug, new Point(0, 200), 0.25f, Color.White);

            c.Items.Add(v);
            c.Items.Add(x);
            c.Draw();
        }
        protected override void Initialize(UIAdvPanel WindowPanel)
        {
            WindowPanel.MainTexture = ServerSideCharacter2.ModTexturesTable["AdvInvBack1"];
            WindowPanel.Left.Set(Main.screenWidth / 2 - WINDOW_WIDTH / 2, 0f);
            WindowPanel.Top.Set(Main.screenHeight / 2 - WINDOW_HEIGHT / 2, 0f);
            WindowPanel.Width.Set(WINDOW_WIDTH, 0f);
            WindowPanel.Height.Set(WINDOW_HEIGHT, 0f);
            WindowPanel.Color = Color.White * 0.8f;

            outerContentPanel = new UIAdvPanel(ServerSideCharacter2.ModTexturesTable["Box"])
            {
                CornerSize = new Vector2(8, 8),
                Color      = new Color(33, 43, 79) * 0.8f
            };
            outerContentPanel.Top.Set(-UNIONLIST_HEIGHT / 2 + UNIONLIST_OFFSET_TOP, 0.5f);
            outerContentPanel.Left.Set(-UNIONLIST_WIDTH / 2 + UNIONLIST_OFFSET_RIGHT, 0.5f);
            outerContentPanel.Width.Set(UNIONLIST_WIDTH, 0f);
            outerContentPanel.Height.Set(UNIONLIST_HEIGHT + ITEMSLOT_HEIGHT, 0f);
            outerContentPanel.SetPadding(10f);
            WindowPanel.Append(outerContentPanel);


            mailContentPanel = new UIAdvPanel(ServerSideCharacter2.ModTexturesTable["Box"])
            {
                CornerSize     = new Vector2(8, 8),
                OverflowHidden = true,
                Color          = new Color(33, 43, 79) * 0.8f
            };
            mailContentPanel.Top.Set(-UNIONLIST_HEIGHT / 2 + UNIONLIST_OFFSET_TOP, 0.5f);
            mailContentPanel.Left.Set(-UNIONLIST_WIDTH / 2 + UNIONLIST_OFFSET_RIGHT, 0.5f);
            mailContentPanel.Width.Set(UNIONLIST_WIDTH, 0f);
            mailContentPanel.Height.Set(UNIONLIST_HEIGHT, 0f);
            mailContentPanel.SetPadding(10f);
            mailContentPanel.Visible = false;

            WindowPanel.Append(mailContentPanel);

            _mailContent = new UIMessageBox(GameLanguage.GetText("rankannouncement"));
            _mailContent.Width.Set(-25f, 1f);
            _mailContent.Height.Set(0f, 1f);
            mailContentPanel.Append(_mailContent);

            UIAdvScrollBar uiscrollbar = new UIAdvScrollBar();

            uiscrollbar.SetView(100f, 1000f);
            uiscrollbar.Height.Set(-20f, 1f);
            uiscrollbar.VAlign = 0.5f;
            uiscrollbar.HAlign = 1f;
            mailContentPanel.Append(uiscrollbar);
            _mailContent.SetScrollbar(uiscrollbar);

            AddItemSlots();

            // 上方标题
            _uiTitle = new UIText("标题", 0.6f, true);
            _uiTitle.Top.Set(-70f, 0f);
            _uiTitle.SetPadding(15f);
            outerContentPanel.Append(_uiTitle);



            mailHeadPanel = new UIAdvPanel(ServerSideCharacter2.ModTexturesTable["Box"])
            {
                CornerSize     = new Vector2(8, 8),
                OverflowHidden = true,
                Color          = new Color(33, 43, 79) * 0.8f
            };
            mailHeadPanel.Top.Set(-UNIONLIST_HEIGHT / 2 + UNIONLIST_OFFSET_TOP, 0.5f);
            mailHeadPanel.Left.Set(-UNIONLIST_WIDTH / 2 + UNIONLIST_OFFSET_RIGHT - 260, 0.5f);
            mailHeadPanel.Width.Set(240, 0f);
            mailHeadPanel.Height.Set(UNIONLIST_HEIGHT + ITEMSLOT_HEIGHT, 0f);
            mailHeadPanel.SetPadding(10f);
            WindowPanel.Append(mailHeadPanel);

            _mailList = new UIAdvList();
            _mailList.Width.Set(-25f, 1f);
            _mailList.Height.Set(0f, 1f);
            _mailList.ListPadding = 5f;
            mailHeadPanel.Append(_mailList);

            // ScrollBar设定
            var uiscrollbar2 = new UIAdvScrollBar();

            uiscrollbar2.SetView(100f, 1000f);
            uiscrollbar2.Height.Set(0f, 1f);
            uiscrollbar2.HAlign = 1f;
            mailHeadPanel.Append(uiscrollbar2);
            _mailList.SetScrollbar(uiscrollbar2);


            refreshButton = new UICDButton(ServerSideCharacter2.ModTexturesTable["Refresh"], false);
            refreshButton.Top.Set(-UNIONLIST_HEIGHT / 2 + UNIONLIST_OFFSET_TOP - 50, 0.5f);
            refreshButton.Left.Set(UNIONLIST_OFFSET_RIGHT + UNIONLIST_WIDTH / 2 - 35, 0.5f);
            refreshButton.Width.Set(35, 0f);
            refreshButton.Height.Set(35, 0f);
            refreshButton.ButtonDefaultColor = new Color(200, 200, 200);
            refreshButton.ButtonChangeColor  = Color.White;
            refreshButton.UseRotation        = true;
            refreshButton.TextureScale       = 0.2f;
            refreshButton.Tooltip            = "刷新";
            refreshButton.OnClick           += RefreshButton_OnClick;
            WindowPanel.Append(refreshButton);
        }
    void Start()
    {
        var scrollable = new UIScrollableVerticalLayout(10);

        scrollable.alignMode = UIAbstractContainer.UIContainerAlignMode.Center;
        scrollable.position  = new Vector3(0, -50, 0);
        var width = UI.isHD ? 300 : 150;

        scrollable.setSize(width, Screen.height / 1.4f);

        for (var i = 0; i < 20; i++)
        {
            UITouchableSprite touchable;
            if (i == 4)              // text sprite
            {
                touchable = UIButton.create("emptyUp.png", "emptyDown.png", 0, 0);
            }
            else if (i % 3 == 0)
            {
                touchable = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
            }
            else if (i % 2 == 0)
            {
                touchable = UIButton.create("playUp.png", "playDown.png", 0, 0);
            }
            else
            {
                touchable = UIButton.create("optionsUp.png", "optionsDown.png", 0, 0);
            }


            // extra flair added by putting some child objects in some of the buttons created above
            if (i == 1)
            {
                // add a toggle button to the first element in the list
                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = touchable;
                ch.pixelsFromRight(0);
                ch.client.name = "TEST THINGY";
                ch.scale       = new Vector3(0.5f, 0.5f, 1);
            }
            else if (i == 4)
            {
                // add some text to the 4th element in the list
                var text = new UIText(textManager, "prototype", "prototype.png");

                var helloText = text.addTextInstance("Child Text", 0, 0, 0.5f, -1, Color.black, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
                helloText.parentUIObject = touchable;
                helloText.positionCenter();

                // add a scaled down toggle button as well but this will be parented to the text
                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = helloText;
                ch.pixelsFromRight(-16);
                ch.client.name = "subsub";
                ch.scale       = new Vector3(0.25f, 0.25f, 0);
            }


            // only add a touchUpInside handler for buttons
            if (touchable is UIButton)
            {
                var button = touchable as UIButton;

                // store i locally so we can put it in the closure scope of the touch handler
                var j = i;
                button.onTouchUpInside += (sender) => Debug.Log("touched button: " + j);
            }

            scrollable.addChild(touchable);
        }


        // click to scroll to a specific offset
        var scores = UIButton.create("scoresUp.png", "scoresDown.png", 0, 0);

        scores.positionFromTopRight(0, 0);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.onTouchUpInside        += (sender) =>
        {
            scrollable.scrollTo(-10, true);
        };


        scores = UIButton.create("scoresUp.png", "scoresDown.png", 0, 0);
        scores.positionFromBottomRight(0, 0);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.onTouchUpInside        += (sender) =>
        {
            scrollable.scrollTo(-600, true);
        };


        scores = UIButton.create("scoresUp.png", "scoresDown.png", 0, 0);
        scores.centerize();
        scores.positionFromTopRight(0.5f, 0);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.onTouchUpInside        += (sender) =>
        {
            var target = scrollable.position;
            var moveBy = _movedContainer ? -100 : 100;
            if (!UI.isHD)
            {
                moveBy /= 2;
            }
            target.x += moveBy * 2;
            target.y += moveBy;
            scrollable.positionTo(0.4f, target, Easing.Quintic.easeIn);
            _movedContainer = !_movedContainer;
        };
    }
Example #29
0
        public UIModItem(LocalMod mod)
        {
            this.mod               = mod;
            this.BorderColor       = new Color(89, 116, 213) * 0.7f;
            this.dividerTexture    = TextureManager.Load("Images/UI/Divider");
            this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            this.Height.Set(90f, 0f);
            this.Width.Set(0f, 1f);
            base.SetPadding(6f);
            //base.OnClick += this.ToggleEnabled;
            string text = mod.DisplayName + " v" + mod.modFile.version;

            if (mod.modFile.tModLoaderVersion < new Version(0, 10))
            {
                text += " [c/FF0000:(Old mod, enable at own risk)]";
            }

            if (mod.modFile.HasFile("icon.png"))
            {
                var modIconTexture = Texture2D.FromStream(Main.instance.GraphicsDevice, new MemoryStream(mod.modFile.GetFile("icon.png")));
                if (modIconTexture.Width == 80 && modIconTexture.Height == 80)
                {
                    modIcon = new UIImage(modIconTexture);
                    modIcon.Left.Set(0f, 0f);
                    modIcon.Top.Set(0f, 0f);
                    Append(modIcon);
                    modIconAdjust += 85;
                }
            }
            this.modName = new UIText(text, 1f, false);
            this.modName.Left.Set(modIconAdjust + 10f, 0f);
            this.modName.Top.Set(5f, 0f);
            base.Append(this.modName);
            UITextPanel <string> button = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo"), 1f, false);

            button.Width.Set(100f, 0f);
            button.Height.Set(30f, 0f);
            button.Left.Set(430f, 0f);
            button.Top.Set(40f, 0f);
            button.PaddingTop    -= 2f;
            button.PaddingBottom -= 2f;
            button.OnMouseOver   += UICommon.FadedMouseOver;
            button.OnMouseOut    += UICommon.FadedMouseOut;
            button.OnClick       += this.Moreinfo;
            base.Append(button);
            button2 = new UITextPanel <string>(mod.Enabled ? Language.GetTextValue("tModLoader.ModsDisable") : Language.GetTextValue("tModLoader.ModsEnable"), 1f, false);
            button2.Width.Set(100f, 0f);
            button2.Height.Set(30f, 0f);
            button2.Left.Set(button.Left.Pixels - button2.Width.Pixels - 5f, 0f);
            button2.Top.Set(40f, 0f);
            button2.PaddingTop    -= 2f;
            button2.PaddingBottom -= 2f;
            button2.OnMouseOver   += UICommon.FadedMouseOver;
            button2.OnMouseOut    += UICommon.FadedMouseOut;
            button2.OnClick       += this.ToggleEnabled;
            base.Append(button2);

            var modRefs = mod.properties.modReferences.Select(x => x.mod).ToArray();

            if (modRefs.Length > 0 && !mod.Enabled)
            {
                string    refs = String.Join(", ", mod.properties.modReferences);
                Texture2D icon = Texture2D.FromStream(Main.instance.GraphicsDevice,
                                                      Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonExclamation.png"));
                UIHoverImage modReferenceIcon = new UIHoverImage(icon, "This mod depends on: " + refs + "\n (click to enable)");
                modReferenceIcon.Left.Set(button2.Left.Pixels - 24f, 0f);
                modReferenceIcon.Top.Set(47f, 0f);
                modReferenceIcon.OnClick += (a, b) =>
                {
                    var modList = ModLoader.FindMods();
                    var missing = new List <string>();
                    foreach (var modRef in modRefs)
                    {
                        ModLoader.EnableMod(modRef);
                        if (!modList.Any(m => m.Name == modRef))
                        {
                            missing.Add(modRef);
                        }
                    }

                    Main.menuMode = Interface.modsMenuID;
                    if (missing.Any())
                    {
                        Interface.infoMessage.SetMessage("The following mods were not found: " + String.Join(",", missing));
                        Interface.infoMessage.SetGotoMenu(Interface.modsMenuID);
                        Main.menuMode = Interface.infoMessageID;
                    }
                };
                base.Append(modReferenceIcon);
            }
            if (mod.modFile.ValidModBrowserSignature)
            {
                keyImage = new UIHoverImage(Main.itemTexture[ID.ItemID.GoldenKey], Language.GetTextValue("tModLoader.ModsOriginatedFromModBrowser"));
                keyImage.Left.Set(-20, 1f);
                base.Append(keyImage);
            }
            if (mod.properties.beta)
            {
                keyImage = new UIHoverImage(Main.itemTexture[ID.ItemID.ShadowKey], "This mod was built on beta version and can't be published");
                keyImage.Left.Set(-10, 1f);
                Append(keyImage);
            }
            Mod loadedMod = ModLoader.GetMod(mod.Name);

            if (loadedMod != null)
            {
                loaded = true;
                int[]    values  = { loadedMod.items.Count, loadedMod.npcs.Count, loadedMod.tiles.Count, loadedMod.walls.Count, loadedMod.buffs.Count, loadedMod.mountDatas.Count };
                string[] strings = { " items", " NPCs", " tiles", " walls", " buffs", " mounts" };
                int      xOffset = -40;
                for (int i = 0; i < values.Length; i++)
                {
                    if (values[i] > 0)
                    {
                        Texture2D iconTexture = Main.instance.infoIconTexture[i];
                        keyImage = new UIHoverImage(iconTexture, values[i] + strings[i]);
                        keyImage.Left.Set(xOffset, 1f);
                        base.Append(keyImage);
                        xOffset -= 18;
                    }
                }
            }
        }
Example #30
0
    // Token: 0x06001AA0 RID: 6816 RVA: 0x002D42FC File Offset: 0x002D24FC
    private void LoadInfo()
    {
        switch (this.OpenDigType)
        {
        case 1:
        {
            UIText component = this.AGS_Form.GetChild(6).GetChild(8).GetComponent <UIText>();
            component.text = this.DM.mStringTable.GetStringByID(3990u);
            component      = this.AGS_Form.GetChild(6).GetChild(9).GetComponent <UIText>();
            component.text = this.DM.mStringTable.GetStringByID(4058u);
            break;
        }

        case 2:
        {
            UIText component = this.AGS_Form.GetChild(6).GetChild(8).GetComponent <UIText>();
            component.text = this.DM.mStringTable.GetStringByID(3991u);
            component      = this.AGS_Form.GetChild(6).GetChild(9).GetComponent <UIText>();
            component.text = this.DM.mStringTable.GetStringByID(4059u);
            break;
        }

        case 3:
        {
            UIText component = this.AGS_Form.GetChild(6).GetChild(8).GetComponent <UIText>();
            component.text = this.DM.mStringTable.GetStringByID(3992u);
            component      = this.AGS_Form.GetChild(6).GetChild(9).GetComponent <UIText>();
            component.text = this.DM.mStringTable.GetStringByID(4060u);
            break;
        }
        }
        if (this.DM.m_CryptData.money == 0)
        {
            this.interest = 1.0 + GameConstants.cryptInterest[(int)this.OpenDigType] + this.DM.AttribVal.GetEffectBaseValByEffectID(277) / 10000.0;
            if (this.funds < 10000)
            {
                this.funds = 10000;
            }
            this.profit   = (uint)Math.Floor((double)this.funds * this.interest);
            this.MaxFunds = (ushort)this.DM.AttribVal.GetEffectBaseValByEffectID(278);
            UIText component = this.AGS_Form.GetChild(6).GetChild(10).GetComponent <UIText>();
            this.interestText.ClearString();
            this.interestText.FloatToFormat(this.DM.AttribVal.GetEffectBaseValByEffectID(277) / 100u, 2, false);
            if (!GUIManager.Instance.IsArabic)
            {
                this.interestText.AppendFormat("+{0}%");
            }
            else
            {
                this.interestText.AppendFormat("%{0}+");
            }
            component.text = this.interestText.ToString();
            component.SetAllDirty();
            component.cachedTextGenerator.Invalidate();
            RectTransform rectTransform;
            if (this.slider == null)
            {
                GameObject gameObject = new GameObject("Slider");
                rectTransform = gameObject.AddComponent <RectTransform>();
                rectTransform.anchoredPosition = new Vector2(-110f, -215f);
                gameObject.transform.SetParent(this.AGS_Form.GetChild(9), false);
                this.slider = gameObject.AddComponent <UnitResourcesSlider>();
                GUIManager.Instance.InitUnitResourcesSlider(gameObject.transform, eUnitSlider.Crypt, 10000u, (uint)this.MaxFunds, 1f);
                this.slider.m_Handler = this;
                this.slider.m_ID      = 1;
                this.slider.BtnInputText.m_Handler = this;
                this.slider.BtnInputText.m_BtnID1  = 4;
            }
            this.slider.MaxValue          = (long)this.MaxFunds;
            this.slider.m_slider.maxValue = (double)this.MaxFunds;
            this.MaxFundText.ClearString();
            this.MaxFundText.IntToFormat((long)this.MaxFunds, 1, true);
            this.MaxFundText.AppendFormat("{0}");
            this.slider.m_TotalText.text = this.MaxFundText.ToString();
            this.slider.m_TotalText.SetAllDirty();
            this.slider.m_TotalText.cachedTextGenerator.Invalidate();
            StringManager.IntToStr(this.fundsText, (long)this.funds, 1, true);
            this.slider.m_inputText.text = this.fundsText.ToString();
            this.slider.m_inputText.SetAllDirty();
            this.slider.m_inputText.cachedTextGenerator.Invalidate();
            rectTransform = this.AGS_Form.GetChild(9).GetChild(1).GetComponent <RectTransform>();
            rectTransform.anchoredPosition = new Vector2(-110f, -281f);
            rectTransform = this.AGS_Form.GetChild(9).GetChild(0).GetComponent <RectTransform>();
            rectTransform.anchoredPosition = new Vector2(-170f, -213f);
            rectTransform = this.AGS_Form.GetChild(9).GetChild(2).GetComponent <RectTransform>();
            rectTransform.anchoredPosition = new Vector2(54f, -223f);
            this.AGS_SuperBtn_SA.SetSpriteIndex(0);
            this.AGS_Form.GetChild(10).GetChild(0).gameObject.SetActive(false);
            this.AGS_Form.GetChild(10).GetChild(2).gameObject.SetActive(false);
            this.AGS_Form.GetChild(10).GetChild(1).GetComponent <UIText>().text = this.DM.mStringTable.GetStringByID(4089u);
            this.AGS_Form.GetChild(10).GetComponent <UIButton>().m_BtnID1       = 1;
            component       = this.AGS_Form.GetChild(6).GetChild(12).GetComponent <UIText>();
            component.color = new Color32(0, byte.MaxValue, 0, byte.MaxValue);
            this.AGS_Form.GetChild(9).gameObject.SetActive(true);
            this.AGS_Form.GetChild(10).gameObject.SetActive(true);
            this.AGS_Form.GetChild(9).GetChild(1).gameObject.SetActive(true);
            this.AGS_Form.GetChild(9).GetChild(2).gameObject.SetActive(true);
        }
        else
        {
            if (this.DM.m_CryptData.kind == this.OpenDigType)
            {
                BuildLevelRequest buildLevelRequestData = GUIManager.Instance.BuildingData.GetBuildLevelRequestData(16, this.DM.m_CryptData.level);
                this.interest = 1.0 + GameConstants.cryptInterest[(int)this.DM.m_CryptData.kind] + buildLevelRequestData.Value2 / 10000.0;
                this.funds    = this.DM.m_CryptData.money;
                this.profit   = (uint)Math.Floor((double)this.funds * this.interest);
                UIText component = this.AGS_Form.GetChild(6).GetChild(10).GetComponent <UIText>();
                this.interestText.ClearString();
                this.interestText.FloatToFormat(buildLevelRequestData.Value2 / 100u, 2, false);
                if (!GUIManager.Instance.IsArabic)
                {
                    this.interestText.AppendFormat("+{0}%");
                }
                else
                {
                    this.interestText.AppendFormat("%{0}+");
                }
                component.text = this.interestText.ToString();
                component.SetAllDirty();
                component.cachedTextGenerator.Invalidate();
                component       = this.AGS_Form.GetChild(6).GetChild(12).GetComponent <UIText>();
                component.color = Color.yellow;
                this.AGS_Form.GetChild(8).gameObject.SetActive(true);
                this.AGS_Form.GetChild(10).gameObject.SetActive(true);
                component = this.AGS_Form.GetChild(8).GetChild(3).GetComponent <UIText>();
                this.profitText.ClearString();
                this.profitText.IntToFormat((long)((ulong)this.profit), 1, true);
                this.profitText.AppendFormat("{0}");
                component.text = this.profitText.ToString();
                this.updateTimeBar();
            }
            else
            {
                this.interest = 1.0 + GameConstants.cryptInterest[(int)this.OpenDigType] + this.DM.AttribVal.GetEffectBaseValByEffectID(277) / 10000.0;
                this.funds    = 0;
                this.profit   = 0u;
                UIText component = this.AGS_Form.GetChild(6).GetChild(10).GetComponent <UIText>();
                this.interestText.ClearString();
                this.interestText.FloatToFormat(this.DM.AttribVal.GetEffectBaseValByEffectID(277) / 100u, 2, false);
                if (!GUIManager.Instance.IsArabic)
                {
                    this.interestText.AppendFormat("+{0}%");
                }
                else
                {
                    this.interestText.AppendFormat("%{0}+");
                }
                component.text = this.interestText.ToString();
                component.SetAllDirty();
                component.cachedTextGenerator.Invalidate();
                component       = this.AGS_Form.GetChild(6).GetChild(12).GetComponent <UIText>();
                component.color = Color.yellow;
                component       = this.AGS_Form.GetChild(7).GetChild(0).GetComponent <UIText>();
                component.text  = this.DM.mStringTable.GetStringByID(4092u);
                component.transform.parent.gameObject.SetActive(true);
                component.gameObject.SetActive(true);
            }
            this.AGS_Form.GetChild(9).GetChild(1).gameObject.SetActive(false);
            this.AGS_Form.GetChild(9).GetChild(2).gameObject.SetActive(false);
        }
        this.SetNumbers();
    }
Example #31
0
        public UIRange(string labeltext, Func <float> getProportion, Action <float> setProportion, Action validateInput, bool fine = false)
        {
            this.Height.Set(20f, 0f);
            this._GetProportion = getProportion ?? (() => 0f);
            this._SetProportion = setProportion ?? ((s) => { });

            if (fine)
            {
                label = new UIText(labeltext, 0.85f);
                label.Width.Set(0, .25f);
                label.VAlign = 0.5f;
                label.HAlign = 0;
                Append(label);

                slider = new UISlider(null, _GetProportion, _SetProportion, null, 0, Color.AliceBlue);
                slider.Height.Set(16, 0f);
                slider.Width.Set(0, .25f);
                slider.Left.Set(0, .25f);
                slider.VAlign = 0.5f;
                //slider.HAlign = .25f;
                Append(slider);

                minus          = new UIImageButton(ModdersToolkit.Instance.GetTexture("UIElements/ButtonMinus"));
                minus.OnClick += Minus_OnClick;
                //minus.Height.Set(16, 0f);
                minus.Width.Set(0, .125f);
                minus.Left.Set(2, .5f);
                //minus.Left.Set(0, .5f);
                //minus.HAlign = .5f;
                //minus.HAlign = .625f;
                Append(minus);

                plus          = new UIImageButton(ModdersToolkit.Instance.GetTexture("UIElements/ButtonPlus"));
                plus.OnClick += Plus_OnClick;
                //plus.Height.Set(16, 0f);
                plus.Width.Set(0, .125f);
                plus.Left.Set(2, .625f);
                plus.VAlign = 0.5f;
                //plus.HAlign = .75f;
                Append(plus);

                input = new NewUITextBox("input:", 0.85f);
                input.SetPadding(0);
                input.OnUnfocus += validateInput;
                //input.PaddingLeft = 12;
                input.Width.Set(0, .25f);
                input.Left.Set(0, .75f);
                input.VAlign = 0.5f;
                //input.HAlign = 1f;
                Append(input);
            }
            else
            {
                label = new UIText(labeltext, 0.85f);
                label.Width.Set(0, .33f);
                label.VAlign = 0.5f;
                //label.HAlign = -0.5f;
                Append(label);

                slider = new UISlider(null, _GetProportion, _SetProportion, null, 0, Color.AliceBlue);
                slider.Height.Set(16, 0f);
                slider.Width.Set(0, .33f);
                //slider.Left.Precent = 0.5f;
                slider.Left.Precent = 0.33f;
                slider.VAlign       = 0.5f;
                //slider.HAlign = .5f;
                Append(slider);

                input = new NewUITextBox("input:", 0.85f);
                input.SetPadding(0);
                input.OnUnfocus += validateInput;
                //input.PaddingLeft = 12;
                input.Width.Set(0, .33f);
                //input.HAlign = 1f;
                input.VAlign       = 0.5f;
                input.Left.Precent = 0.66f;
                Append(input);
            }
        }
Example #32
0
    // Token: 0x06001A9B RID: 6811 RVA: 0x002D3C10 File Offset: 0x002D1E10
    public override void OnOpen(int arg1, int arg2)
    {
        this.DM           = DataManager.Instance;
        this.door         = (Door)GUIManager.Instance.FindMenu(EGUIWindow.Door);
        this.OpenDigType  = (byte)arg1;
        this.interestText = StringManager.Instance.SpawnString(50);
        this.fundsText    = StringManager.Instance.SpawnString(50);
        this.profitText   = StringManager.Instance.SpawnString(50);
        this.timeText     = StringManager.Instance.SpawnString(50);
        this.MaxFundText  = StringManager.Instance.SpawnString(50);
        Font ttffont = GUIManager.Instance.GetTTFFont();

        this.AGS_Form = base.transform;
        UIText component = this.AGS_Form.GetChild(1).GetChild(0).GetComponent <UIText>();

        component.font = ttffont;
        component.text = this.DM.mStringTable.GetStringByID(3986u + (uint)this.OpenDigType - 1u);
        Image component2 = this.AGS_Form.GetChild(4).GetComponent <Image>();

        component2.sprite   = this.door.LoadSprite("UI_main_close_base");
        component2.material = this.door.LoadMaterial();
        component2.enabled  = !GUIManager.Instance.bOpenOnIPhoneX;
        component2          = this.AGS_Form.GetChild(4).GetChild(0).GetComponent <Image>();
        component2.sprite   = this.door.LoadSprite("UI_main_close");
        component2.material = this.door.LoadMaterial();
        UIButton component3 = this.AGS_Form.GetChild(4).GetChild(0).GetComponent <UIButton>();

        component3.m_Handler    = this;
        component3.m_EffectType = e_EffectType.e_Scale;
        this.AGS_Icon           = this.AGS_Form.GetChild(6).GetChild(1).GetComponent <UISpritesArray>();
        this.AGS_Icon.SetSpriteIndex((int)(this.OpenDigType - 1));
        component               = this.AGS_Form.GetChild(6).GetChild(3).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = this.DM.mStringTable.GetStringByID(3993u);
        component               = this.AGS_Form.GetChild(6).GetChild(4).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = this.DM.mStringTable.GetStringByID(3994u);
        component               = this.AGS_Form.GetChild(6).GetChild(5).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = this.DM.mStringTable.GetStringByID(3995u);
        component               = this.AGS_Form.GetChild(6).GetChild(6).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = this.DM.mStringTable.GetStringByID(3996u);
        component               = this.AGS_Form.GetChild(6).GetChild(7).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = this.DM.mStringTable.GetStringByID(3930u);
        component               = this.AGS_Form.GetChild(6).GetChild(8).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = string.Empty;
        component               = this.AGS_Form.GetChild(6).GetChild(9).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = string.Empty;
        component               = this.AGS_Form.GetChild(6).GetChild(10).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = string.Empty;
        component.color         = new Color32(0, byte.MaxValue, 0, byte.MaxValue);
        component               = this.AGS_Form.GetChild(6).GetChild(11).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = string.Empty;
        component               = this.AGS_Form.GetChild(6).GetChild(12).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = string.Empty;
        component               = this.AGS_Form.GetChild(7).GetChild(0).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = string.Empty;
        component               = this.AGS_Form.GetChild(8).GetChild(2).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = this.DM.mStringTable.GetStringByID(4055u);
        component               = this.AGS_Form.GetChild(8).GetChild(3).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = string.Empty;
        component               = this.AGS_Form.GetChild(8).GetChild(4).GetChild(1).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = string.Empty;
        component               = this.AGS_Form.GetChild(9).GetChild(1).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = this.DM.mStringTable.GetStringByID(3934u);
        component               = this.AGS_Form.GetChild(9).GetChild(2).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = this.DM.mStringTable.GetStringByID(5897u);
        component3              = this.AGS_Form.GetChild(10).GetComponent <UIButton>();
        component3.m_Handler    = this;
        component3.m_EffectType = e_EffectType.e_Scale;
        this.AGS_SuperBtn_SA    = this.AGS_Form.GetChild(10).GetComponent <UISpritesArray>();
        component               = this.AGS_Form.GetChild(10).GetChild(1).GetComponent <UIText>();
        component.font          = ttffont;
        component.text          = string.Empty;
        component.gameObject.AddComponent <Outline>();
        component       = this.AGS_Form.GetChild(10).GetChild(2).GetComponent <UIText>();
        component.font  = ttffont;
        component.text  = this.DM.mStringTable.GetStringByID(4090u);
        component.color = new Color32(209, 192, 165, byte.MaxValue);
        this.AGS_Form.GetChild(9).gameObject.SetActive(false);
        this.Light = this.AGS_Form.GetChild(10).GetChild(0).GetComponent <Image>();
        this.LoadInfo();
        GUIManager.Instance.UpdateUI(EGUIWindow.Door, 1, 2);
    }
Example #33
0
    // Token: 0x06001AA8 RID: 6824 RVA: 0x002D5530 File Offset: 0x002D3730
    public void Refresh_FontTexture()
    {
        UIText component = this.AGS_Form.GetChild(1).GetChild(0).GetComponent <UIText>();

        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(3).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(4).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(5).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(6).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(7).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(8).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(9).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(10).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(11).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(6).GetChild(12).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(7).GetChild(0).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(8).GetChild(2).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(8).GetChild(3).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(8).GetChild(4).GetChild(1).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(9).GetChild(1).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(9).GetChild(2).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(10).GetChild(1).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        component = this.AGS_Form.GetChild(10).GetChild(2).GetComponent <UIText>();
        if (component != null && component.enabled)
        {
            component.enabled = false;
            component.enabled = true;
        }
        if (this.slider != null)
        {
            this.slider.Refresh_FontTexture();
        }
    }
Example #34
0
        public UIModDownloadItem(string displayName, string name, string version, string author, string modReferences, ModSide modSide, string modIconUrl, string downloadUrl, int downloads, int hot, string timeStamp, bool hasUpdate, bool updateIsDowngrade, LocalMod installed, string modloaderversion)
        {
            ModName          = name;
            DisplayName      = displayName;
            DisplayNameClean = string.Join("", ChatManager.ParseMessage(displayName, Color.White).Where(x => x.GetType() == typeof(TextSnippet)).Select(x => x.Text));
            DownloadUrl      = downloadUrl;

            _author        = author;
            _modReferences = modReferences;
            _modSide       = modSide;
            _modIconUrl    = modIconUrl;
            if (UIModBrowser.AvoidImgur)
            {
                _modIconUrl = null;
            }
            _downloads        = downloads;
            _hot              = hot;
            _timeStamp        = timeStamp;
            HasUpdate         = hasUpdate;
            UpdateIsDowngrade = updateIsDowngrade;
            Installed         = installed;

            BorderColor        = new Color(89, 116, 213) * 0.7f;
            _dividerTexture    = UICommon.DividerTexture;
            _innerPanelTexture = UICommon.InnerPanelTexture;
            Height.Pixels      = 90;
            Width.Percent      = 1f;
            SetPadding(6f);

            float leftOffset = HasModIcon ? ModIconAdjust : 0f;

            _modName = new UIText(displayName)
            {
                Left = new StyleDimension(leftOffset + PADDING, 0f),
                Top  = { Pixels = 5 }
            };
            Append(_modName);

            _moreInfoButton = new UIImage(UICommon.ButtonModInfoTexture)
            {
                Width  = { Pixels = 36 },
                Height = { Pixels = 36 },
                Left   = { Pixels = leftOffset },
                Top    = { Pixels = 40 }
            };
            _moreInfoButton.OnClick += ViewModInfo;
            Append(_moreInfoButton);

            if (modloaderversion != null)
            {
                tMLUpdateRequired = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MBRequiresTMLUpdate", modloaderversion)).WithFadedMouseOver(Color.Orange, Color.Orange * 0.7f);
                tMLUpdateRequired.BackgroundColor = Color.Orange * 0.7f;
                tMLUpdateRequired.CopyStyle(_moreInfoButton);
                tMLUpdateRequired.Width.Pixels = 340;
                tMLUpdateRequired.Left.Pixels += 36 + PADDING;
                tMLUpdateRequired.OnClick     += (a, b) => {
                    Process.Start("https://github.com/tModLoader/tModLoader/releases/latest");
                };
                Append(tMLUpdateRequired);
            }
            else if (hasUpdate || installed == null)
            {
                _updateButton = new UIImage(UpdateIsDowngrade ? UICommon.ButtonDowngradeTexture : UICommon.ButtonDownloadTexture);
                _updateButton.CopyStyle(_moreInfoButton);
                _updateButton.Left.Pixels += 36 + PADDING;
                _updateButton.OnClick     += DownloadMod;
                Append(_updateButton);

                if (_modReferences.Length > 0)
                {
                    _updateWithDepsButton = new UIImage(UICommon.ButtonDownloadMultipleTexture);
                    _updateWithDepsButton.CopyStyle(_updateButton);
                    _updateWithDepsButton.Left.Pixels += 36 + PADDING;
                    _updateWithDepsButton.OnClick     += DownloadWithDeps;
                    Append(_updateWithDepsButton);
                }
            }

            if (modReferences.Length > 0)
            {
                var icon             = UICommon.ButtonExclamationTexture;
                var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.MBClickToViewDependencyMods", string.Join("\n", modReferences.Split(',').Select(x => x.Trim()))))
                {
                    Left = { Pixels = -icon.Width() - PADDING, Percent = 1f }
                };
                modReferenceIcon.OnClick += ShowModDependencies;
                Append(modReferenceIcon);
            }

            OnDoubleClick += ViewModInfo;
        }
 public MaxSpeedWidget()
 {
     State        = MaxSpeedState.Off;
     maxSpeedText = new UIText("", new Point(UI.WIDTH / 2, UI.HEIGHT / 2 + 50), 0.5f, Color.White, 0, true);
     maxSpeed     = 0;
 }
Example #36
0
        public static Tuple <UIElement, UIElement> WrapIt(UIElement parent, ref int top, PropertyFieldWrapper memberInfo, object item, int order, object array = null, Type arrayType = null, int index = -1)
        {
            int  elementHeight = 0;
            Type type          = memberInfo.Type;

            if (arrayType != null)
            {
                type = arrayType;
            }
            UIElement e = null;

            // TODO: Other common structs? -- Rectangle, Point
            CustomModConfigItemAttribute customUI = ConfigManager.GetCustomAttribute <CustomModConfigItemAttribute>(memberInfo, null, null);

            if (customUI != null)
            {
                Type            customUIType = customUI.t;
                ConstructorInfo ctor         = customUIType.GetConstructor(new[] { typeof(PropertyFieldWrapper), typeof(object), typeof(int), typeof(IList), typeof(int) });
                if (ctor != null)
                {
                    object[] arguments = new object[] { memberInfo, item, 0, array, index };
                    object   instance  = ctor.Invoke(arguments);
                    e = instance as UIElement;
                    if (e != null)
                    {
                        //e.Recalculate();
                        //elementHeight = (int)e.GetOuterDimensions().Height;
                        //elementHeight = 400; //e.GetHeight();
                    }
                    else
                    {
                        e = new UIText($"CustomUI for {memberInfo.Name} does not inherit from UIElement.");
                    }
                }
                else
                {
                    e = new UIText($"CustomUI for {memberInfo.Name} does not have the correct constructor.");
                }
            }
            else if (item.GetType() == typeof(HeaderAttribute))
            {
                //e = new UIText($"{memberInfo.GetValue(item)}", .4f, true);
                //e.SetPadding(6);
                e = new HeaderElement((string)memberInfo.GetValue(item));
            }
            else if (type == typeof(ItemDefinition))
            {
                e = new ItemDefinitionElement(memberInfo, item, (IList <ItemDefinition>)array, index);
            }
            else if (type == typeof(Color))
            {
                e = new ColorElement(memberInfo, item, (IList <Color>)array, index);
                //elementHeight = (int)(e as UIModConfigColorItem).GetHeight();
            }
            else if (type == typeof(Vector2))
            {
                e = new Vector2Element(memberInfo, item, (IList <Vector2>)array, index);
            }
            else if (type == typeof(bool))             // isassignedfrom?
            {
                e = new BooleanElement(memberInfo, item, (IList <bool>)array, index);
            }
            else if (type == typeof(float))
            {
                e = new FloatElement(memberInfo, item, (IList <float>)array, index);
            }
            else if (type == typeof(byte))
            {
                e = new ByteElement(memberInfo, item, (IList <byte>)array, index);
            }
            else if (type == typeof(uint))
            {
                e = new UIntElement(memberInfo, item, (IList <uint>)array, index);
            }
            else if (type == typeof(int))
            {
                RangeAttribute rangeAttribute = ConfigManager.GetCustomAttribute <RangeAttribute>(memberInfo, item, array);
                if (rangeAttribute != null)
                {
                    e = new IntRangeElement(memberInfo, item, (IList <int>)array, index);
                }
                else
                {
                    e = new IntInputElement(memberInfo, item, (IList <int>)array, index);
                }
            }
            else if (type == typeof(string))
            {
                OptionStringsAttribute ost = ConfigManager.GetCustomAttribute <OptionStringsAttribute>(memberInfo, item, array);
                if (ost != null)
                {
                    e = new StringOptionElement(memberInfo, item, (IList <string>)array, index);
                }
                else
                {
                    e = new StringInputElement(memberInfo, item, (IList <string>)array, index);
                }
            }
            else if (type.IsEnum)
            {
                if (array != null)
                {
                    e = new UIText($"{memberInfo.Name} not handled yet ({type.Name}).");
                }
                else
                {
                    e = new EnumElement(memberInfo, item);
                }
            }
            else if (type.IsArray)
            {
                e = new ArrayElement(memberInfo, item);
                //elementHeight = 225;
            }
            else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List <>))
            {
                e = new ListElement(memberInfo, item);
                //elementHeight = 225;
            }
            else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(HashSet <>))
            {
                e = new SetElement(memberInfo, item);
            }
            else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary <,>))
            {
                e = new DictionaryElement(memberInfo, item);
                //elementHeight = 300;
            }
            else if (type.IsClass)
            {
                e = new ObjectElement(memberInfo, item, (IList)array, index /*, ignoreSeparatePage: ignoreSeparatePage*/);
            }
            else if (type.IsValueType && !type.IsPrimitive)
            {
                e = new UIText($"{memberInfo.Name} not handled yet ({type.Name}) Structs need special UI.");
                //e.Top.Pixels += 6;
                e.Height.Pixels += 6;
                e.Left.Pixels   += 4;

                object subitem = memberInfo.GetValue(item);
            }
            else
            {
                e              = new UIText($"{memberInfo.Name} not handled yet ({type.Name})");
                e.Top.Pixels  += 6;
                e.Left.Pixels += 4;
            }
            if (e != null)
            {
                e.Recalculate();
                elementHeight = (int)e.GetOuterDimensions().Height;

                var container = GetContainer(e, index == -1 ? order : index);
                container.Height.Pixels = elementHeight;
                UIList list = parent as UIList;
                if (list != null)
                {
                    list.Add(container);
                    float p = list.GetTotalHeight();
                }
                else
                {
                    // Only Vector2 and Color use this I think, but modders can use the non-UIList approach for custom UI and layout.
                    container.Top.Pixels   = top;
                    container.Width.Pixels = -20;
                    container.Left.Pixels  = 20;
                    top += elementHeight + 4;
                    parent.Append(container);
                    parent.Height.Set(top, 0);
                }

                return(new Tuple <UIElement, UIElement>(container, e));
            }
            return(null);
        }
Example #37
0
 public override void OnInitialize()
 {
     UIPanel1 = new UIPanel();
     UIPanel1.SetPadding(0);
     UIPanel1.Left.Set(Main.screenWidth / 2 - 300, 0f);
     UIPanel1.Top.Set(Main.screenHeight / 2 - 210, 0f);
     UIPanel1.Width.Set(600f, 0f);
     UIPanel1.Height.Set(420f, 0f);
     //UIPanel1.BorderColor = Color.Black;
     UIPanel1.BackgroundColor = new Color(63, 82, 151) * 0.7f;
     UIText1 = new UIText(Language.GetTextValue("Mods.Revolutions.UI.RevoSets"), 0.7f, true);
     UIText1.Top.Set(25, 0f);
     UIText1.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, UIText1.Text, 0.7f), 0f);
     UIPanel1.Append(UIText1);
     BlurSet = new UIText(Language.GetTextValue("Mods.Revolutions.UI.Blur" + Revolutions.Settings.blur.ToString()));
     BlurSet.Top.Set(80, 0f);
     BlurSet.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, BlurSet.Text, 0.4f), 0f);
     BlurSet.OnClick     += Click;
     BlurSet.OnMouseOver += Hover;
     UIPanel1.Append(BlurSet);
     AutoDoorSet = new UIText(Language.GetTextValue("Mods.Revolutions.UI.AutoDoor" + Revolutions.Settings.autodoor.ToString()));
     AutoDoorSet.Top.Set(120, 0f);
     AutoDoorSet.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, AutoDoorSet.Text, 0.4f), 0f);
     AutoDoorSet.OnClick     += Click;
     AutoDoorSet.OnMouseOver += Hover;
     UIPanel1.Append(AutoDoorSet);
     MutterSet = new UIText(Language.GetTextValue("Mods.Revolutions.UI.Mutter" + Revolutions.Settings.mutter.ToString()));
     MutterSet.Top.Set(160, 0f);
     MutterSet.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, MutterSet.Text, 0.4f), 0f);
     MutterSet.OnClick     += Click;
     MutterSet.OnMouseOver += Hover;
     UIPanel1.Append(MutterSet);
     AutoReuseSet = new UIText(Language.GetTextValue("Mods.Revolutions.UI.AutoReuse" + Revolutions.Settings.autoreuse.ToString()));
     AutoReuseSet.Top.Set(200, 0f);
     AutoReuseSet.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, AutoReuseSet.Text, 0.4f), 0f);
     AutoReuseSet.OnClick     += Click;
     AutoReuseSet.OnMouseOver += Hover;
     UIPanel1.Append(AutoReuseSet);
     HthBarSet = new UIText(Language.GetTextValue("Mods.Revolutions.UI.HealthBar" + Revolutions.Settings.hthbar.ToString()));
     HthBarSet.Top.Set(320, 0f);
     HthBarSet.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, HthBarSet.Text, 0.4f), 0f);
     HthBarSet.OnClick     += Click;
     HthBarSet.OnMouseOver += Hover;
     UIPanel1.Append(HthBarSet);
     RangeIndexSet = new UIText(Language.GetTextValue("Mods.Revolutions.UI.RangeIndex" + Revolutions.Settings.rangeIndex.ToString()));
     RangeIndexSet.Top.Set(280, 0f);
     RangeIndexSet.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, RangeIndexSet.Text, 0.4f), 0f);
     RangeIndexSet.OnClick     += Click;
     RangeIndexSet.OnMouseOver += Hover;
     UIPanel1.Append(RangeIndexSet);
     SpColorSet = new UIText(Language.GetTextValue("Mods.Revolutions.UI.SpColor" + Revolutions.Settings.spcolor.ToString()));
     SpColorSet.Top.Set(360, 0f);
     SpColorSet.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, SpColorSet.Text, 0.4f), 0f);
     SpColorSet.OnClick     += Click;
     SpColorSet.OnMouseOver += Hover;
     if (Helper.Name2Specialname(Main.LocalPlayer.name) != "none")
     {
         UIPanel1.Append(SpColorSet);
     }
     ExtraAISet = new UIText(Language.GetTextValue("Mods.Revolutions.UI.ExtraAI" + Revolutions.Settings.extraAI.ToString()));
     ExtraAISet.Top.Set(240, 0f);
     ExtraAISet.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, ExtraAISet.Text, 0.4f), 0f);
     ExtraAISet.OnClick     += Click;
     ExtraAISet.OnMouseOver += Hover;
     UIPanel1.Append(ExtraAISet);
     Exit = new UIText(Language.GetTextValue("LegacyMenu.118"), 0.4f, true);
     Exit.Top.Set(440, 0f);
     Exit.Left.Set(300 - 0.5f * Helper.GetStringLength(Main.fontDeathText, Exit.Text, 0.4f), 0f);
     Exit.OnClick     += Click;
     Exit.OnMouseOver += Hover;
     UIPanel1.Append(Exit);
     if (Revolutions.Settings.hthbar)
     {
         MyStatus = true; MyOffset = 50;
     }
     Append(UIPanel1);
 }
Example #38
0
    // Token: 0x06001C74 RID: 7284 RVA: 0x00324974 File Offset: 0x00322B74
    public override void OnOpen(int arg1, int arg2)
    {
        Font ttffont = GUIManager.Instance.GetTTFFont();

        this.AGS_Form = base.transform;
        UIButton component = this.AGS_Form.GetChild(0).GetComponent <UIButton>();

        component.m_Handler = this;
        component.gameObject.SetActive(false);
        component.image.color = new Color(1f, 1f, 1f, 0.5f);
        component.m_BtnID1    = 1;
        UIText component2 = this.AGS_Form.GetChild(1).GetChild(0).GetComponent <UIText>();

        component2.font = ttffont;
        component2.resizeTextForBestFit = true;
        component2.resizeTextMinSize    = 12;
        component2.resizeTextMaxSize    = 22;
        component2          = this.AGS_Form.GetChild(1).GetChild(1).GetChild(0).GetComponent <UIText>();
        component2.font     = ttffont;
        component           = this.AGS_Form.GetChild(7).GetComponent <UIButton>();
        component.m_Handler = this;
        component.gameObject.SetActive(false);
        component.m_BtnID1 = 2;
        component2         = this.AGS_Form.GetChild(7).GetChild(0).GetComponent <UIText>();
        component2.font    = ttffont;
        component2.text    = DataManager.Instance.mStringTable.GetStringByID(1050u);
        Vector3 localPosition = this.AGS_Form.GetChild(1).localPosition;

        localPosition.z = -1000f;
        this.AGS_Form.GetChild(1).localPosition = localPosition;
        this.AGS_Form.GetChild(1).gameObject.SetActive(false);
        localPosition   = this.AGS_Form.GetChild(5).localPosition;
        localPosition.z = -1000f;
        this.AGS_Form.GetChild(5).localPosition = localPosition;
        uTweenPosition component3 = this.AGS_Form.GetChild(6).GetComponent <uTweenPosition>();

        component3.from.z            = -1000f;
        component3.to.z              = -1000f;
        this.Pos3D1                  = this.AGS_Form.GetChild(2).transform;
        localPosition                = this.Pos3D1.localPosition;
        localPosition.z              = -500f;
        this.Pos3D1.localPosition    = localPosition;
        this.Pos3D1.localEulerAngles = new Vector3(0f, 340f, 0f);
        this.Pos3D1.GetComponent <RectTransform>().anchoredPosition = new Vector2(0f, -28f);
        this.Pos3D2                  = this.AGS_Form.GetChild(3).transform;
        localPosition                = this.Pos3D2.localPosition;
        localPosition.z              = -500f;
        this.Pos3D2.localPosition    = localPosition;
        this.Pos3D2.localEulerAngles = new Vector3(0f, 20f, 0f);
        this.Pos3D2.GetComponent <RectTransform>().anchoredPosition = new Vector2(0f, -28f);
        this.AGS_Form.GetChild(0).gameObject.SetActive(true);
        this.LightGroup = this.AGS_Form.GetChild(4);
        this.PosLight1  = this.AGS_Form.GetChild(4).GetChild(0);
        this.PosLight2  = this.AGS_Form.GetChild(4).GetChild(1);
        GameObject gameObject = new GameObject("Light3");

        gameObject.transform.SetParent(this.LightGroup, false);
        this.PosLight3 = gameObject.transform;
        gameObject.AddComponent <Light>();
        Light component4 = this.PosLight1.GetComponent <Light>();

        component4.range            = 15f;
        component4.spotAngle        = 10f;
        component4.color            = new Color32(195, 87, 54, byte.MaxValue);
        component4.type             = LightType.Spot;
        component4.intensity        = 8f;
        component4                  = this.PosLight2.GetComponent <Light>();
        component4.type             = LightType.Spot;
        component4.range            = 20f;
        component4.spotAngle        = 10f;
        component4.color            = new Color32(242, 224, 205, byte.MaxValue);
        component4.intensity        = 8f;
        component4                  = this.PosLight3.GetComponent <Light>();
        component4.range            = 15f;
        component4.spotAngle        = 10f;
        component4.color            = new Color32(148, 107, 107, byte.MaxValue);
        component4.type             = LightType.Spot;
        component4.intensity        = 5.5f;
        this.EvoLight               = RenderSettings.ambientLight;
        RenderSettings.ambientLight = new Color32(197, 178, 178, byte.MaxValue);
        this.startTalkId            = (ushort)arg1;
        if (this.startTalkId == 13)
        {
            component.gameObject.SetActive(NewbieManager.IsNewbie);
        }
        else
        {
            component.gameObject.SetActive(false);
        }
        if (arg2 != 0)
        {
            UIHeroTalk.HeroID1 = (ushort)arg2;
        }
        this.talkString = StringManager.Instance.SpawnString(500);
        ushort num = 0;

        while ((int)num < DataManager.Instance.HeroTalkTable.TableCount)
        {
            HeroTalkTbl recordByIndex = DataManager.Instance.HeroTalkTable.GetRecordByIndex((int)num);
            if (recordByIndex.TalkGroup == this.startTalkId)
            {
                this.startTalkId = recordByIndex.ID;
                break;
            }
            num += 1;
        }
        this.SetTalk(this.startTalkId);
        GUIManager.Instance.m_WindowsTransform.gameObject.SetActive(false);
        this.Create3DObjects();
    }
        public QETankPanel(QETank tank) : base(tank)
        {
            Width.Percent = 408;
            Height.Pixels = 172;


            UIText textLabel = new UIText(Language.GetText("Mods.QuantumStorage.MapObject.QETank"))
            {
                X = { Percent = 50 },
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Add(textLabel);

            UITextButton buttonReset = new UITextButton("R")
            {
                Size        = new Vector2(20),
                RenderPanel = false,
                Padding     = Padding.Zero,
                HoverText   = Language.GetText("Mods.QuantumStorage.UI.Reset")
            };

            buttonReset.OnClick += args =>
            {
                if (!Container.frequency.IsSet)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        Main.LocalPlayer.PutItemInInventory(Utility.ColorToItem(Container.frequency[i]));
                    }

                    Container.frequency = new Frequency();
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, Container.ID, Container.Position.X, Container.Position.Y);
                    }
                }
                else
                {
                    for (int i = 0; i < 3; i++)
                    {
                        Main.LocalPlayer.PutItemInInventory(Utility.ColorToItem(Container.frequency[i]));
                    }

                    Container.frequency = new Frequency();
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, Container.ID, Container.Position.X, Container.Position.Y);
                    }

                    Remove(TankFluid);

                    InitializeFrequencySelection();
                    for (int i = 0; i < 3; i++)
                    {
                        Add(buttonsFrequency[i]);
                    }
                    Add(buttonInitialize);
                }
            };
            Add(buttonReset);

            UITextButton buttonClose = new UITextButton("X")
            {
                Size        = new Vector2(20),
                X           = { Percent = 100 },
                RenderPanel = false,
                Padding     = Padding.Zero,
                HoverText   = Language.GetText("Mods.BaseLibrary.UI.Close")
            };

            buttonClose.OnClick += args => PanelUI.Instance.CloseUI(Container);
            Add(buttonClose);

            if (!Container.frequency.IsSet)
            {
                InitializeFrequencySelection();

                for (int i = 0; i < 3; i++)
                {
                    Add(buttonsFrequency[i]);
                }
                Add(buttonInitialize);
            }
            else
            {
                Add(TankFluid);
            }
        }
Example #40
0
        void Onkeyup(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.F12) && (Game.Player.WantedLevel > 1))
            {
                hours = 10 + (Game.Player.WantedLevel * 10);
                Game.Player.WantedLevel = 0;
                intial1();
            }
            if ((e.KeyCode == Keys.E) && arrested)
            {
                if ((Game.Player.Character.Position.DistanceTo(new Vector3(1691.709f, 2565.036f, 45.56487f)) < 2f) && (Game.Player.Money > 0x4c4b40))
                {
                    bail.Remove();
                    roit.Remove();
                    Game.Player.Character.Position = new Vector3(1849.555f, 2586.085f, 45.67202f);
                    Game.Player.Character.Heading  = 258.4564f;
                    Player player = Game.Player;
                    player.Money -= 0x4c4b40;
                    Function.Call(Hash.SET_MAX_WANTED_LEVEL, 5);
                    Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character);
                    arrested          = false;
                    _headsup          = null;
                    _headsupRectangle = null;
                }
                if ((Game.Player.Character.Position.DistanceTo(new Vector3(1625.474f, 2491.485f, 45.62026f)) < 4f) && !escape)
                {
                    stop_scripts();
                    bail.Remove();
                    roit.Remove();
                    Player player2 = Game.Player;
                    player2.Money -= 0x4c4b40;
                    stop_scripts();
                    arrested          = false;
                    _headsup          = null;
                    _headsupRectangle = null;

                    Model mod = new Model(VehicleHash.Valkyrie);
                    mod.Request();
                    while (!mod.IsLoaded)
                    {
                        stop_scripts();
                        Script.Wait(0);
                    }
                    escape_veh3              = World.CreateVehicle(mod, new Vector3(-1179.25f, -2845.386f, 13.5665f));
                    escape_veh3.Heading      = 325.6199f;
                    escape_veh3.IsPersistent = true;
                    mod.MarkAsNoLongerNeeded();
                    //============================================================================================================
                    mod = new Model(VehicleHash.Comet2);
                    mod.Request();
                    while (!mod.IsLoaded)
                    {
                        stop_scripts();
                        Script.Wait(0);
                    }
                    escape_veh1              = World.CreateVehicle(mod, new Vector3(-1729.416f, -1109.523f, 12.7468f));
                    escape_veh1.Heading      = 321.1888f;
                    escape_veh1.IsPersistent = true;
                    mod.MarkAsNoLongerNeeded();
                    //===========================================================================================================
                    mod = new Model(VehicleHash.Insurgent2);
                    mod.Request();
                    while (!mod.IsLoaded)
                    {
                        stop_scripts();
                        Script.Wait(0);
                    }
                    escape_veh2              = World.CreateVehicle(mod, new Vector3(1373.179f, -2077.577f, 51.6181f));
                    escape_veh2.Heading      = 332.3142f;
                    escape_veh2.IsPersistent = true;
                    mod.MarkAsNoLongerNeeded();

                    int hash = Function.Call <int>(Hash.GET_ENTITY_MODEL, new InputArgument[] { Game.Player.Character });
                    if (hash == Function.Call <int>(Hash.GET_HASH_KEY, new InputArgument[] { "player_zero" })) //m
                    {
                        mod = new Model(PedHash.Franklin);
                        mod.Request();
                        while (!mod.IsLoaded)
                        {
                            stop_scripts();
                            Script.Wait(0);
                        }
                        escape_ped1              = World.CreatePed(mod, new Vector3(-1726.644f, -1112.538f, 13.2474f));
                        escape_ped1.Heading      = 42.1536f;
                        escape_ped1.IsPersistent = true;
                        mod.MarkAsNoLongerNeeded();

                        mod = new Model(PedHash.Trevor);
                        mod.Request();
                        while (!mod.IsLoaded)
                        {
                            stop_scripts();
                            Script.Wait(0);
                        }
                        escape_ped2              = World.CreatePed(mod, new Vector3(1376.8f, -2076.873f, 51.9985f));
                        escape_ped2.Heading      = 47.19263f;
                        escape_ped2.IsPersistent = true;
                        mod.MarkAsNoLongerNeeded();
                    }
                    else if (hash == Function.Call <int>(Hash.GET_HASH_KEY, new InputArgument[] { "player_one" })) //f
                    {
                        mod = new Model(PedHash.Michael);
                        mod.Request();
                        while (!mod.IsLoaded)
                        {
                            stop_scripts();
                            Script.Wait(0);
                        }
                        escape_ped1              = World.CreatePed(mod, new Vector3(-1726.644f, -1112.538f, 13.2474f));
                        escape_ped1.Heading      = 42.1536f;
                        escape_ped1.IsPersistent = true;
                        mod.MarkAsNoLongerNeeded();

                        mod = new Model(PedHash.Trevor);
                        mod.Request();
                        while (!mod.IsLoaded)
                        {
                            stop_scripts();
                            Script.Wait(0);
                        }
                        escape_ped2              = World.CreatePed(mod, new Vector3(1376.8f, -2076.873f, 51.9985f));
                        escape_ped2.Heading      = 47.19263f;
                        escape_ped2.IsPersistent = true;
                        mod.MarkAsNoLongerNeeded();
                    }
                    else if (hash == Function.Call <int>(Hash.GET_HASH_KEY, new InputArgument[] { "player_two" }))//tr
                    {
                        mod = new Model(PedHash.Michael);
                        mod.Request();
                        while (!mod.IsLoaded)
                        {
                            stop_scripts();
                            Script.Wait(0);
                        }
                        escape_ped1              = World.CreatePed(mod, new Vector3(-1726.644f, -1112.538f, 13.2474f));
                        escape_ped1.Heading      = 42.1536f;
                        escape_ped1.IsPersistent = true;
                        mod.MarkAsNoLongerNeeded();

                        mod = new Model(PedHash.Franklin);
                        mod.Request();
                        while (!mod.IsLoaded)
                        {
                            stop_scripts();
                            Script.Wait(0);
                        }
                        escape_ped2              = World.CreatePed(mod, new Vector3(1376.8f, -2076.873f, 51.9985f));
                        escape_ped2.Heading      = 47.19263f;
                        escape_ped2.IsPersistent = true;
                        mod.MarkAsNoLongerNeeded();
                    }
                    original_ped = Game.Player.Character;

                    Game.FadeScreenOut(3000);
                    while (!Function.Call <bool>(Hash.IS_SCREEN_FADED_OUT))
                    {
                        Script.Wait(0);
                    }
                    Function.Call(Hash.CHANGE_PLAYER_PED, Game.Player, escape_ped1, 1, 0);
                    Game.FadeScreenIn(3000);
                    while (!Function.Call <bool>(Hash.IS_SCREEN_FADED_IN))
                    {
                        Script.Wait(0);
                    }
                    current_ped = 1;
                    vehb        = escape_veh1.AddBlip();
                    vehb.Color  = BlipColor.Blue;
                    UI.ShowSubtitle("Get in the ~b~ Vehicle", 3000);
                    steps = 0;

                    player_status = status.In_escape;
                    Function.Call(Hash.SET_MAX_WANTED_LEVEL, 5);

                    escape = true;
                }
            }
            if (e.KeyCode == Keys.E && steps == 5)
            {
                if (current_ped == 1)
                {
                    Function.Call(Hash.CHANGE_PLAYER_PED, Game.Player, escape_ped2, 1, 0);
                    //drive task

                    current_ped = 2;
                }
                else
                {
                    Function.Call(Hash.CHANGE_PLAYER_PED, Game.Player, escape_ped1, 1, 0);
                    //shot task
                    escape_ped2.Task.FightAgainstHatedTargets(150f);
                    escape_ped2.AlwaysKeepTask = true;
                    current_ped = 1;
                }
            }
            if (((e.KeyCode == Keys.Y) && arrested) && (Game.Player.Character.Position.DistanceTo(escape_Ped.Position) < 4f))
            {
                time = Game.GameTime;
                int i;
                for (i = 0; i < prisoner.Count; i++)
                {
                    GiveWeapons_prisoner(prisoner[i]);
                    prisoner[i].CanSwitchWeapons = true;
                }
                for (i = 0; i < garde.Count; i++)
                {
                    GiveWeapons_Garde(garde[i]);
                    garde[i].CanSwitchWeapons = true;
                    //Function.Call(Hash.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS, garde[i], true);
                }
                GiveWeapons_prisoner(Game.Player.Character);
                Player player3 = Game.Player;
                player3.Money -= 0x4c4b40;
                Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, new InputArgument[] { 5, 0x7ea26372, -183807561 });
                Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, new InputArgument[] { 5, -183807561, 0x7ea26372 });
            }


            if (((e.KeyCode == Keys.E) && (player_status == status.In_road)) && !sciped)
            {
                try
                {
                    Game.FadeScreenOut(3000);
                    while (!Function.Call <bool>(Hash.IS_SCREEN_FADED_OUT))
                    {
                        Script.Wait(0);
                    }

                    policecar.Position = new Vector3(2124.503f, 2760.919f, 49.1893f);
                    policecar.Heading  = 130.5902f;

                    Game.FadeScreenIn(3000);
                    sciped = true;
                }
                catch (Exception ex)
                {
                    SimpleLog.Error(ex);
                    throw;
                }
            }
        }
Example #41
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);
        }
        public override void OnInitialize()
        {
            mainPanel = new UIPanel();
            mainPanel.BackgroundColor = new Color(28, 36, 66) * 0.95f;
            mainPanel.Width.Set(440, 0f);
            mainPanel.Height.Set(310, 0f);
            mainPanel.HAlign = 0.5f;
            mainPanel.VAlign = 0.5f;

            Append(mainPanel);

            spriteContainer = new UIPanel();
            spriteContainer.BackgroundColor = new Color(20, 25, 46) * 1f;
            spriteContainer.Width.Set(148, 0f);
            spriteContainer.Height.Set(110, 0f);
            spriteContainer.HAlign = 0.1f;
            spriteContainer.VAlign = 0.46f;

            gender = new SummaryImage(ModContent.GetTexture("Terramon/UI/Summary/" + "Male"), "Male");
            gender.Top.Set(-4, 0f);
            gender.Left.Set(-14, 1f);

            spriteContainer.Append(gender);

            caughtBall = new SummaryImage(ModContent.GetTexture("Terramon/Minisprites/Ball1"), "Caught in a Poké Ball");
            caughtBall.Top.Set(-12, 1f);
            caughtBall.Left.Set(-14, 1f);

            spriteContainer.Append(caughtBall);

            Texture2D overworldTexture = ModContent.GetTexture($"Terramon/Pokemon/FirstGeneration/Normal/{target}/{target}");

            overworldSprite        = new SummarySprite(overworldTexture);
            overworldSprite.HAlign = 0.5f;
            overworldSprite.VAlign = 0.5f;

            spriteContainer.Append(overworldSprite);

            name = new UIText("Charmeleon", 0.55f, true);
            name.Top.Set(-41, 0f);
            name.Left.Set(-2, 0f);

            lv = new UIText("Lv 16", 0.75f, false);

            spriteContainer.Append(name);
            spriteContainer.Append(lv);

            trainerMemoHeader        = new UIText("Trainer Memo", 0.35f, true);
            trainerMemoHeader.HAlign = 0.5f;
            trainerMemoHeader.Top.Set(34, 1f);
            spriteContainer.Append(trainerMemoHeader);

            memo1        = new UIText("Adamant nature.", 0.3f, true);
            memo1.HAlign = 0.5f;
            memo1.Top.Set(54, 1f);
            spriteContainer.Append(memo1);

            memo2        = new UIText("Caught in the cavern layer", 0.3f, true);
            memo2.HAlign = 0.5f;
            memo2.Top.Set(68, 1f);
            spriteContainer.Append(memo2);

            memo3        = new UIText("at Lv 5.", 0.3f, true);
            memo3.HAlign = 0.5f;
            memo3.Top.Set(82, 1f);
            spriteContainer.Append(memo3);

            mainPanel.Append(spriteContainer);

            headingPanel = new UIPanel();
            headingPanel.BackgroundColor = new Color(63, 82, 151) * 1f;
            headingPanel.Width.Set(340, 0f);
            headingPanel.Height.Set(64, 0f);
            headingPanel.HAlign = 0.5f;
            headingPanel.Top.Set(-38, 0f);

            UIText text = new UIText("Pokémon Summary", 0.8f, true);

            text.HAlign = 0.5f;
            text.VAlign = 0.5f;
            headingPanel.Append(text);

            mainPanel.Append(headingPanel);

            Append(TerramonMod.ZoomAnimator = new Animator());

            base.OnInitialize();
        }
Example #43
0
        private void onTick(object sender, EventArgs e)
        {
            Bitmap   bmp;
            Graphics g;

            bmp = new Bitmap(gameScreen.Width, gameScreen.Height, PixelFormat.Format32bppArgb);
            g   = Graphics.FromImage(bmp);
            int steering = GTA.Game.GetControlValue(1, GTA.Control.VehicleMoveLeft);
            int acc      = GTA.Game.GetControlValue(1, GTA.Control.VehicleAccelerate);
            int brake    = GTA.Game.GetControlValue(1, GTA.Control.VehicleBrake);

            Ped           p  = Game.Player.Character;
            List <Entity> Vs = (from v in World.GetNearbyVehicles(World.RenderingCamera.Position, 100)
                                where
                                v != p.CurrentVehicle &&
                                v.IsOnScreen &&
                                v.IsVisible
                                select(Entity) v).ToList();

            Vs.AddRange((from v in World.GetNearbyPeds(World.RenderingCamera.Position, 100)
                         where
                         v != p.CurrentVehicle &&
                         v.IsOnScreen &&
                         v.IsVisible &&
                         !v.IsAttached()
                         select(Entity) v).ToList());
            List <Entity>     Vs2      = new List <Entity>();
            List <Pedestrian> Peds     = new List <Pedestrian>();
            List <Car>        Vehicles = new List <Car>();
            //Vector3 d = GTAFuncs.RotationToDirection(World.RenderingCamera.Rotation);
            //Vector3 m = new Vector3(d.X * 1000, d.Y * 1000, d.Z * 1000);
            RaycastResult r;// = World.Raycast(World.RenderingCamera.Position, World.RenderingCamera.Position + d * 200, IntersectOptions.Everything);

            //if (r.DitHitAnything)
            //{
            //    Vector2 P = GTAFuncs.WorldToScreen(r.HitCoords);
            //    float distance = (World.RenderingCamera.Position - r.HitCoords).Length();
            //    UIText statusText = new UIText(string.Format("{0}", brake), new Point((int)P.X, (int)P.Y), 0.2f, Color.FromArgb((int)(255 - 255 * (distance / 200)), (int)(255 * (distance / 200)), 0), GTA.Font.ChaletLondon, false, true, false);
            //    statusText.Draw();
            //}
            //else
            //{
            //    Vector2 P = GTAFuncs.WorldToScreen(r.HitCoords);
            //    UIText statusText = new UIText(string.Format("{0}", r.HitCoords), new Point(2, 2), 0.2f, Color.Red, GTA.Font.ChaletLondon, false, true, false);
            //    statusText.Draw();
            //}
            //Parallel.ForEach(Vs, (v) =>
            foreach (Entity v in Vs)
            {
                float x = 0, y = 0;
                r = World.Raycast(World.RenderingCamera.Position, World.RenderingCamera.Position + (v.Position - World.RenderingCamera.Position).Normalized * 1000, IntersectOptions.Everything);
                #region Check if raycast hit desired object
                if (r.DitHitAnything)
                {
                    if (r.DitHitEntity)
                    {
                        if (r.HitEntity.Equals(v))
                        {
                            if (getScreenPoint(r.HitCoords, ref x, ref y))
                            {
                                Vs2.Add(v);
                                float distance = (World.RenderingCamera.Position - r.HitCoords).Length();
                                //(v.Position - World.RenderingCamera.Position).Length() - distance,
                                //UIText statusText = new UIText(string.Format("{0}",Vs2.IndexOf(v)),  new Point((int)x, (int)y), 0.2f, Color.FromArgb((int)(255 - 255 * (distance / 200)), (int)(255 * (distance / 200)), 0), GTA.Font.ChaletLondon, false, true, false);
                                //DrawEntBox(v, Color.FromArgb((int)(255 - 255 * ((v.Position - World.RenderingCamera.Position).Length() / 200)), (int)(255 * ((p.Position - World.RenderingCamera.Position).Length() / 200)), 0));
                                //statusText.Draw();
                                getScreenPoint(v.Position, ref x, ref y);
                                if (v.GetType().Equals(typeof(Vehicle)))
                                {
                                    #region Add Vehicle
                                    Vehicles.Add(new Car((Vehicle)v, getScreenBounds(v), distance, new Point((int)x, (int)y)));
                                    #endregion
                                }
                                else
                                {
                                    #region Add Pedestrian
                                    Peds.Add(new Pedestrian
                                    {
                                        CenterCamPosition = new Point((int)x, (int)y),
                                        DistanceToCam     = distance,
                                        Handle            = v.Handle,
                                        Position          = v.Position,
                                        ScreenBounds      = getScreenBounds(v)
                                    });
                                    #endregion
                                }
                            }
                        }
                    }
                }
                #endregion
            }//);
            Screenshot ss = new Screenshot
            {
                Acc           = acc,
                Brake         = brake,
                Cars          = Vehicles,
                Peds          = Peds,
                Position      = World.RenderingCamera.Position,
                Rotation      = World.RenderingCamera.Rotation,
                Steering      = steering,
                Time          = Game.GameTime,
                LastFrameTime = Game.LastFrameTime,
                Weather       = World.Weather.ToString(),
                DayTime       = World.CurrentDayTime.ToString(),
                MyCar         = new Car(Game.Player.LastVehicle, new List <Point>(), 0, new Point((int)0, (int)0))
            };
            g.CopyFromScreen(gameScreen.Left, gameScreen.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);

            if (Save)
            {
                Thread ts = new Thread(() => save(bmp, ss));
                ts.Start();
            }
            else
            {
                UIText text = new UIText("Press R to start streaming", new Point(UI.WIDTH / 2, 15), 0.4f, Color.Blue, GTA.Font.ChaletLondon, true);
                text.Draw();
                Draw(Vs2.ToArray(), World.RenderingCamera.Position);
            }
        }
Example #44
0
 public AccelerationTimerWidget()
 {
     State     = AccelerationTimerState.Off;
     timerText = new UIText("", new Point(UI.WIDTH / 2, UI.HEIGHT / 2), 0.5f, Color.White, 0, true);
 }
Example #45
0
        public MyUIWorldListItem(WorldFileData data, bool mentalMode)
        {
            MentalMode                     = mentalMode;
            BorderColor                    = new Color(89, 116, 213) * 0.7f;
            _dividerTexture                = TextureManager.Load("Images/UI/Divider");
            _innerPanelTexture             = TextureManager.Load("Images/UI/InnerPanelBackground");
            _buttonCloudActiveTexture      = TextureManager.Load("Images/UI/ButtonCloudActive");
            _buttonCloudInactiveTexture    = TextureManager.Load("Images/UI/ButtonCloudInactive");
            _buttonFavoriteActiveTexture   = TextureManager.Load("Images/UI/ButtonFavoriteActive");
            _buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive");
            _buttonPlayTexture             = TextureManager.Load("Images/UI/ButtonPlay");
            _buttonDeleteTexture           = TextureManager.Load("Images/UI/ButtonDelete");
            Height.Set(96f, 0f);
            Width.Set(0f, 1f);
            base.SetPadding(6f);
            _data      = data;
            _worldIcon = new UIImage(GetIcon());
            _worldIcon.Left.Set(4f, 0f);
            _worldIcon.OnDoubleClick += new UIElement.MouseEvent(PlayGame);
            base.Append(_worldIcon);
            UIImageButton uIImageButton = new UIImageButton(_buttonPlayTexture);

            uIImageButton.VAlign = 1f;
            uIImageButton.Left.Set(4f, 0f);
            uIImageButton.OnClick     += new UIElement.MouseEvent(PlayGame);
            base.OnDoubleClick        += new UIElement.MouseEvent(PlayGame);
            uIImageButton.OnMouseOver += new UIElement.MouseEvent(PlayMouseOver);
            uIImageButton.OnMouseOut  += new UIElement.MouseEvent(ButtonMouseOut);
            base.Append(uIImageButton);
            UIImageButton uIImageButton2 = new UIImageButton(_data.IsFavorite ? _buttonFavoriteActiveTexture : _buttonFavoriteInactiveTexture);

            uIImageButton2.VAlign = 1f;
            uIImageButton2.Left.Set(28f, 0f);
            uIImageButton2.OnClick     += new UIElement.MouseEvent(FavoriteButtonClick);
            uIImageButton2.OnMouseOver += new UIElement.MouseEvent(FavoriteMouseOver);
            uIImageButton2.OnMouseOut  += new UIElement.MouseEvent(ButtonMouseOut);
            uIImageButton2.SetVisibility(1f, _data.IsFavorite ? 0.8f : 0.4f);
            base.Append(uIImageButton2);
            if (SocialAPI.Cloud != null)
            {
                UIImageButton uIImageButton3 = new UIImageButton(_data.IsCloudSave ? _buttonCloudActiveTexture : _buttonCloudInactiveTexture);
                uIImageButton3.VAlign = 1f;
                uIImageButton3.Left.Set(52f, 0f);
                uIImageButton3.OnClick     += new UIElement.MouseEvent(CloudButtonClick);
                uIImageButton3.OnMouseOver += new UIElement.MouseEvent(CloudMouseOver);
                uIImageButton3.OnMouseOut  += new UIElement.MouseEvent(ButtonMouseOut);
                base.Append(uIImageButton3);
            }
            UIImageButton uIImageButton4 = new UIImageButton(_buttonDeleteTexture);

            uIImageButton4.VAlign       = 1f;
            uIImageButton4.HAlign       = 1f;
            uIImageButton4.OnClick     += new UIElement.MouseEvent(DeleteButtonClick);
            uIImageButton4.OnMouseOver += new UIElement.MouseEvent(DeleteMouseOver);
            uIImageButton4.OnMouseOut  += new UIElement.MouseEvent(DeleteMouseOut);
            _deleteButton = uIImageButton4;
            if (!_data.IsFavorite)
            {
                base.Append(uIImageButton4);
            }
            _buttonLabel        = new UIText("", 1f, false);
            _buttonLabel.VAlign = 1f;
            _buttonLabel.Left.Set(80f, 0f);
            _buttonLabel.Top.Set(-3f, 0f);
            base.Append(_buttonLabel);
            _deleteButtonLabel        = new UIText("", 1f, false);
            _deleteButtonLabel.VAlign = 1f;
            _deleteButtonLabel.HAlign = 1f;
            _deleteButtonLabel.Left.Set(-30f, 0f);
            _deleteButtonLabel.Top.Set(-3f, 0f);
            base.Append(_deleteButtonLabel);
        }
 public void keyset(Keys key)
 {
     UIText debug = new UIText("datecount: " + datecount , new Point(400, 300), (float)0.6);
     debug.Draw();
     switch (key)
     {
         case Keys.NumPad0:
             num0.Play();
             timeinput(0, datecount);
             break;
         case Keys.D0:
             num0.Play();
             timeinput(0, datecount);
             break;
         case Keys.NumPad1:
             num1.Play();
             timeinput(1, datecount);
             break;
         case Keys.D1:
             num1.Play();
             timeinput(1, datecount);
             break;
         case Keys.NumPad2:
             num2.Play();
             timeinput(2, datecount);
             break;
         case Keys.D2:
             num2.Play();
             timeinput(2, datecount);
             break;
         case Keys.NumPad3:
             num3.Play();
             timeinput(3, datecount);
             break;
         case Keys.D3:
             num3.Play();
             timeinput(3, datecount);
             break;
         case Keys.NumPad4:
             num4.Play();
             timeinput(4, datecount);
             break;
         case Keys.D4:
             num4.Play();
             timeinput(4, datecount);
             break;
         case Keys.NumPad5:
             num5.Play();
             timeinput(5, datecount);
             break;
         case Keys.D5:
             num5.Play();
             timeinput(5, datecount);
             break;
         case Keys.NumPad6:
             num6.Play();
             timeinput(6, datecount);
             break;
         case Keys.D6:
             num6.Play();
             timeinput(6, datecount);
             break;
         case Keys.NumPad7:
             num7.Play();
             timeinput(7, datecount);
             break;
         case Keys.D7:
             num7.Play();
             timeinput(7, datecount);
             break;
         case Keys.NumPad8:
             num8.Play();
             timeinput(8, datecount);
             break;
         case Keys.D8:
             num8.Play();
             timeinput(8, datecount);
             break;
         case Keys.NumPad9:
             num9.Play();
             timeinput(9, datecount);
             break;
         case Keys.D9:
             num9.Play();
             timeinput(9, datecount);
             break;
         case Keys.Enter:
             timeinputstring = "";
             if (datecount == 12)
             {
                 inputenter.Play();
                 Settime(tday1, tday2, tmonth1, tmonth2, ty1, ty2, ty3, ty4, th1, th2, tm1, tm2, tampm);
                 datecount = 0;
                 tday1 = 0;
                 tday2 = 0;
                 tmonth1 = 0;
                 tmonth2 = 0;
                 ty1 = 0;
                 ty2 = 0;
                 ty3 = 0;
                 ty4 = 0;
                 th1 = 0;
                 th2 = 0;
                 tm1 = 0;
                 tm2 = 0;
                 tampm = "am";
                 datecount = 0;
             }
             else if (datecount == 8)
             {
                 inputenter.Play();
                 Settime(tday1, tday2, tmonth1, tmonth2, ty1, ty2, ty3, ty4, fh1, fh2, fm1, fm2, fampm);
                 datecount = 0;
                 tday1 = 0;
                 tday2 = 0;
                 tmonth1 = 0;
                 tmonth2 = 0;
                 ty1 = 0;
                 ty2 = 0;
                 ty3 = 0;
                 ty4 = 0;
                 th1 = 0;
                 th2 = 0;
                 tm1 = 0;
                 tm2 = 0;
                 tampm = "am";
                 datecount = 0;
             }
             else if (datecount == 4)
             {
                 inputenter.Play();
                 Settime(fday1, fday2, fmonth1, fmonth2, fy1, fy2, fy3, fy4, tmonth1, tmonth2, tday1, tday2, tampm);
                 datecount = 0;
                 tday1 = 0;
                 tday2 = 0;
                 tmonth1 = 0;
                 tmonth2 = 0;
                 ty1 = 0;
                 ty2 = 0;
                 ty3 = 0;
                 ty4 = 0;
                 th1 = 0;
                 th2 = 0;
                 tm1 = 0;
                 tm2 = 0;
                 tampm = "am";
                 datecount = 0;
             }
             else
             {
                 inputerror.Play();
                 datecount = 0;
             }
             break;
     }
 }
    void Start()
    {
        // add two scrollables: one with paging enabled and one without
        var scrollable = new UIScrollableHorizontalLayout(10);

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

        var height = UI.scaleFactor * 50f;
        var width  = Screen.width / 1.4f;

        scrollable.setSize(width, height);
        scrollable.position = new Vector3((Screen.width - width) / 2, -Screen.height + height, 0);
        scrollable.zIndex   = 3;

        for (var i = 0; i < 20; i++)
        {
            UITouchableSprite touchable;
            if (i == 4)              // text sprite
            {
                touchable = UIButton.create("emptyUp.png", "emptyDown.png", 0, 0);
            }
            else if (i % 3 == 0)
            {
                touchable = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
            }
            else if (i % 2 == 0)
            {
                touchable = UIButton.create("playUp.png", "playDown.png", 0, 0);
            }
            else
            {
                touchable = UIButton.create("optionsUp.png", "optionsDown.png", 0, 0);
            }

            if (i == 1)
            {
                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = touchable;
                ch.pixelsFromRight(0);
                ch.client.name = "TEST THINGY";
                ch.scale       = new Vector3(0.5f, 0.5f, 1);
            }
            else if (i == 4)
            {
                var text = new UIText(textManager, "prototype", "prototype.png");

                var helloText = text.addTextInstance("Child Text", 0, 0, 0.5f, -1, Color.blue, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
                helloText.parentUIObject = touchable;
                helloText.positionCenter();

                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = helloText;
                ch.pixelsFromRight(-16);
                ch.client.name = "subsub";
                ch.scale       = new Vector3(0.25f, 0.25f, -2);
            }


            // only add a touchUpInside handler for buttons
            if (touchable is UIButton)
            {
                var button = touchable as UIButton;

                // store i locally so we can put it in the closure scope of the touch handler
                var j = i;
                button.onTouchUpInside += (sender) => Debug.Log("touched button: " + j);
            }

            // add random spacers every so often
            if (i % 3 == 0)
            {
                scrollable.addChild(new UISpacer(Random.Range(10, 100), 40));
            }

            scrollable.addChild(touchable);
        }
        scrollable.endUpdates();
        scrollable.endUpdates();         // this is a bug. it shouldnt need to be called twice



        // add another scrollable, this one with paging enabled.
        scrollable = new UIScrollableHorizontalLayout(20);

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

        height = UI.scaleFactor * 250f;

        // 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
        scrollable.edgeInsets = new UIEdgeInsets(0, 75, 0, 75);
        width = UI.scaleFactor * (250f + 150f);           // item width + 150 extra width
        scrollable.setSize(width, height);

        // paging will snap to the nearest page when scrolling
        scrollable.pagingEnabled = true;
        scrollable.pageWidth     = 250f * UI.scaleFactor;

        // center the scrollable horizontally
        scrollable.position = new Vector3((Screen.width - width) / 2, 0, 0);

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

        scrollable.endUpdates();
        scrollable.endUpdates();         // this is a bug. it shouldnt need to be called twice
    }
Example #48
0
 public override void OnInitialize()
 {
     base.OnInitialize();
     text = new UIText("(-1, -1)");
     this.Append(text);
 }
Example #49
0
        public static Tuple <UIElement, UIElement> WrapIt(UIElement parent, ref int top, PropertyFieldWrapper memberInfo, object item, int order, object list = null, Type arrayType = null, int index = -1)
        {
            int  elementHeight = 0;
            Type type          = memberInfo.Type;

            if (arrayType != null)
            {
                type = arrayType;
            }
            UIElement e;

            // TODO: Other common structs? -- Rectangle, Point
            CustomModConfigItemAttribute customUI = ConfigManager.GetCustomAttribute <CustomModConfigItemAttribute>(memberInfo, null, null);

            if (customUI != null)
            {
                Type customUIType = customUI.t;
                if (typeof(ConfigElement).IsAssignableFrom(customUIType))
                {
                    ConstructorInfo ctor = customUIType.GetConstructor(new Type[0]);
                    if (ctor != null)
                    {
                        object instance = ctor.Invoke(new object[0]);
                        e = instance as UIElement;
                    }
                    else
                    {
                        e = new UIText($"{customUIType.Name} specified via CustomModConfigItem for {memberInfo.Name} does not have an empty constructor.");
                    }
                }
                else
                {
                    e = new UIText($"{customUIType.Name} specified via CustomModConfigItem for {memberInfo.Name} does not inherit from ConfigElement.");
                }
            }
            else if (item.GetType() == typeof(HeaderAttribute))
            {
                e = new HeaderElement((string)memberInfo.GetValue(item));
            }
            else if (type == typeof(ItemDefinition))
            {
                e = new ItemDefinitionElement();
            }
            else if (type == typeof(Color))
            {
                e = new ColorElement();
            }
            else if (type == typeof(Vector2))
            {
                e = new Vector2Element();
            }
            else if (type == typeof(bool))             // isassignedfrom?
            {
                e = new BooleanElement();
            }
            else if (type == typeof(float))
            {
                e = new FloatElement();
            }
            else if (type == typeof(byte))
            {
                e = new ByteElement();
            }
            else if (type == typeof(uint))
            {
                e = new UIntElement();
            }
            else if (type == typeof(int))
            {
                SliderAttribute sliderAttribute = ConfigManager.GetCustomAttribute <SliderAttribute>(memberInfo, item, list);
                if (sliderAttribute != null)
                {
                    e = new IntRangeElement();
                }
                else
                {
                    e = new IntInputElement();
                }
            }
            else if (type == typeof(string))
            {
                OptionStringsAttribute ost = ConfigManager.GetCustomAttribute <OptionStringsAttribute>(memberInfo, item, list);
                if (ost != null)
                {
                    e = new StringOptionElement();
                }
                else
                {
                    e = new StringInputElement();
                }
            }
            else if (type.IsEnum)
            {
                if (list != null)
                {
                    e = new UIText($"{memberInfo.Name} not handled yet ({type.Name}).");
                }
                else
                {
                    e = new EnumElement();
                }
            }
            else if (type.IsArray)
            {
                e = new ArrayElement();
            }
            else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List <>))
            {
                e = new ListElement();
            }
            else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(HashSet <>))
            {
                e = new SetElement();
            }
            else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary <,>))
            {
                e = new DictionaryElement();
            }
            else if (type.IsClass)
            {
                e = new ObjectElement(/*, ignoreSeparatePage: ignoreSeparatePage*/);
            }
            else if (type.IsValueType && !type.IsPrimitive)
            {
                e = new UIText($"{memberInfo.Name} not handled yet ({type.Name}) Structs need special UI.");
                //e.Top.Pixels += 6;
                e.Height.Pixels += 6;
                e.Left.Pixels   += 4;

                object subitem = memberInfo.GetValue(item);
            }
            else
            {
                e              = new UIText($"{memberInfo.Name} not handled yet ({type.Name})");
                e.Top.Pixels  += 6;
                e.Left.Pixels += 4;
            }
            if (e != null)
            {
                if (e is ConfigElement configElement)
                {
                    configElement.Bind(memberInfo, item, (IList)list, index);
                    configElement.OnBind();
                }
                e.Recalculate();
                elementHeight = (int)e.GetOuterDimensions().Height;

                var container = GetContainer(e, index == -1 ? order : index);
                container.Height.Pixels = elementHeight;
                UIList uiList = parent as UIList;
                if (uiList != null)
                {
                    uiList.Add(container);
                    float p = uiList.GetTotalHeight();
                }
                else
                {
                    // Only Vector2 and Color use this I think, but modders can use the non-UIList approach for custom UI and layout.
                    container.Top.Pixels   = top;
                    container.Width.Pixels = -20;
                    container.Left.Pixels  = 20;
                    top += elementHeight + 4;
                    parent.Append(container);
                    parent.Height.Set(top, 0);
                }

                return(new Tuple <UIElement, UIElement>(container, e));
            }
            return(null);
        }
Example #50
0
        public override void OnInitialize()
        {
            _baseElement = new UIElement {
                Width    = { Percent = 0.8f },
                MaxWidth = UICommon.MaxPanelWidth,
                Top      = { Pixels = 220 },
                Height   = { Pixels = -220, Percent = 1f },
                HAlign   = 0.5f
            };
            Append(_baseElement);

            var mainPanel = new UIPanel {
                Width           = { Percent = 1f },
                Height          = { Pixels = -110, Percent = 1f },
                BackgroundColor = UICommon.MainPanelBackground,
                PaddingTop      = 0f
            };

            _baseElement.Append(mainPanel);

            var uITextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.MSCreateMod"), 0.8f, true)
            {
                HAlign          = 0.5f,
                Top             = { Pixels = -35 },
                BackgroundColor = UICommon.DefaultUIBlue
            }.WithPadding(15);

            _baseElement.Append(uITextPanel);

            _messagePanel = new UITextPanel <string>(Language.GetTextValue(""))
            {
                Width  = { Percent = 1f },
                Height = { Pixels = 25 },
                VAlign = 1f,
                Top    = { Pixels = -20 }
            };
            // Appended dynamically

            var buttonBack = new UITextPanel <string>(Language.GetTextValue("UI.Back"))
            {
                Width  = { Pixels = -10, Percent = 0.5f },
                Height = { Pixels = 25 },
                VAlign = 1f,
                Top    = { Pixels = -65 }
            }.WithFadedMouseOver();

            buttonBack.OnClick += BackClick;
            _baseElement.Append(buttonBack);

            var buttonCreate = new UITextPanel <string>(Language.GetTextValue("LegacyMenu.28"));            // Create

            buttonCreate.CopyStyle(buttonBack);
            buttonCreate.HAlign = 1f;
            buttonCreate.WithFadedMouseOver();
            buttonCreate.OnClick += OKClick;
            _baseElement.Append(buttonCreate);

            // TODO localisations
            float top = 16;

            _modName = createAndAppendTextInputWithLabel("ModName (no spaces)", "Type here");
            _modName.OnTextChange += (a, b) => { _modName.SetText(_modName.CurrentString.Replace(" ", "")); };
            _modDiplayName         = createAndAppendTextInputWithLabel("Mod DisplayName", "Type here");
            _modAuthor             = createAndAppendTextInputWithLabel("Mod Author", "Type here");
            _basicSword            = createAndAppendTextInputWithLabel("BasicSword (no spaces)", "Leave Blank to Skip");
            _modName.OnTab        += (a, b) => _modDiplayName.Focused = true;
            _modDiplayName.OnTab  += (a, b) => _modAuthor.Focused = true;
            _modAuthor.OnTab      += (a, b) => _basicSword.Focused = true;
            _basicSword.OnTab     += (a, b) => _modName.Focused = true;

            UIFocusInputTextField createAndAppendTextInputWithLabel(string label, string hint)
            {
                var panel = new UIPanel();

                panel.SetPadding(0);
                panel.Width.Set(0, 1f);
                panel.Height.Set(40, 0f);
                panel.Top.Set(top, 0f);
                top += 46;

                var modNameText = new UIText(label)
                {
                    Left = { Pixels = 10 },
                    Top  = { Pixels = 10 }
                };

                panel.Append(modNameText);

                var textBoxBackground = new UIPanel();

                textBoxBackground.SetPadding(0);
                textBoxBackground.Top.Set(6f, 0f);
                textBoxBackground.Left.Set(0, .5f);
                textBoxBackground.Width.Set(0, .5f);
                textBoxBackground.Height.Set(30, 0f);
                panel.Append(textBoxBackground);

                var uIInputTextField = new UIFocusInputTextField(hint)
                {
                    UnfocusOnTab = true
                };

                uIInputTextField.Top.Set(5, 0f);
                uIInputTextField.Left.Set(10, 0f);
                uIInputTextField.Width.Set(-20, 1f);
                uIInputTextField.Height.Set(20, 0);
                textBoxBackground.Append(uIInputTextField);

                mainPanel.Append(panel);

                return(uIInputTextField);
            }
        }
        static public void tick()
        {
            UIText Instruct = new UIText("delay: " + delay.getdelay(), new Point(400, 300), (float)0.9);
            //Instruct.Draw();

            try
            {
                if (isintruck)
                {
                    if (TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.IsInRangeOf(Docstruck.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), (float)2.6))
                    {
                        Docstruck.CloseDoor(VehicleDoor.Trunk, true);
                        isintruck = false;
                        DocsExparamentstart = true;
                        delay.Reset();
                    }
                    else
                    {
                        if (!driveonce)
                        {
                            Doc.Task.DriveTo(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, Docstruck.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), 1, 10);
                            driveonce = true;
                        }
                    }
                }
            }
            catch
            {

            }

            if (DocsExparamentstart)
            {
                if (!tasksent)
                {
                    if (Game.Player.Character.IsInRangeOf(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), (float)20.8))
                    {
                        if (!runonce)
                        {
                            loction.Remove();
                            loction = null;
                            tasksent = true;
                            runonce = true;
                            delay.Start();
                            DeloreonEnter.Play();
                        }
                    }
                    if (Game.Player.Character.IsInRangeOf(Doc.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), (float)24.8))
                    {
                        Einstein.Task.RunTo(Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0, 2, 0)));
                    }
                }
                else if (tasksent)
                {
                    tasksent = false;
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Repair();
                }

                if (delay.getdelay() == 24.5)
                {
                    Docstruck.OpenDoor(VehicleDoor.Trunk, false, false);
                }
                else if (delay.getdelay() >= 74)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.EngineRunning = false;
                    if (delay.getdelay() >= 68)
                    {
                        Doc.Task.LeaveVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, false);
                        DocsExparamentstart = false;
                        runonce = false;
                        //sayshi = true;
                        delay.Stop();
                        delay.Reset();
                    }
                }
                else if (delay.getdelay() >= 38 && delay.getdelay() <= 60)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed = (float)-0.9;
                }
            }
            else if (sayshi)
            {
                if (Game.Player.Character.IsInRangeOf(Doc.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), (float)3.8))
                {
                    Doc.Task.LookAt(Game.Player.Character);
                    if (!runonce)
                    {
                        Experimentstart.Play();
                        runonce = true;
                        delay.Start();
                    }
                }

                if (delay.getdelay() >= 7)
                {
                    delay.Stop();
                    delay.Reset();
                    runonce = false;
                    ExperimentwithEinstein = true;
                    sayshi = false;
                }
            }
            else if (ExperimentwithEinstein)
            {
                UI.ShowSubtitle("Experiment with Einstein is on");
                if (Game.IsKeyPressed(Keys.Up))
                {
                    Doc.Task.LookAt(Game.Player.Character);
                    if (!runonce)
                    {
                        runonce = true;
                        delay.Start();
                    }
                }

                if (delay.getdelay() == 0)
                {
                    UIText Instruct2 = new UIText("Take out phone and open the camera app", new Point(400, 300), (float)0.9);
                    Instruct2.Draw();
                }
                else if (delay.getdelay() == 5)
                {
                    Experimentstartintro.Play();
                }
                else if (delay.getdelay() < 35)
                {
                    if (delay.getdelay() == 18)
                    {
                        Einstein.Task.RunTo(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-5, -4, 0)), true, 10);
                        Einstein.Task.RunTo(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-3, 0, 0)), true, 10);
                    }
                    else if (delay.getdelay() == 24)
                    {
                        if (Einstein.IsInVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon))
                        {
                            delay.Resume();
                            Einstein.Task.ClearAll();
                        }
                        else
                        {
                            delay.Pause();
                            Einstein.Task.ClearAll();
                            Einstein.Task.WarpIntoVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, VehicleSeat.Driver);
                        }
                    }
                }
                else if (delay.getdelay() >= 36)
                {
                    delay.Stop();
                    delay.Reset();
                    runonce = false;
                    //Docwithremote = true;
                    ExperimentwithEinstein = false;
                    Einstein.Task.ClearAll();
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.EngineRunning = true;
                }
            }
            else if (Docwithremote)
            {
                UI.ShowSubtitle("Remote with doc is on");
                try
                {
                    if (!pressede)
                        if (!TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].RCmode)
                        {
                            UIText Instruct2 = new UIText("Switch to Remote Control Mode in the menu. Have it set the Car " + TimeTravel.instantDelorean.Deloreanlist.Count, new Point(400, 300), (float)0.9);
                            Instruct2.Draw();
                        }
                        else if (TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].RCmode)
                        {
                            if (!runonce)
                            {
                                posblip = World.CreateBlip(Docstruck.GetOffsetInWorldCoords(new Vector3(0, -250, 0)), 5);
                                posblip.Color = BlipColor.Yellow;
                                runonce = true;
                            }
                            UIText Instruct2 = new UIText("Press E when Ready", new Point(400, 300), (float)0.9);
                            Instruct2.Draw();
                        }

                    if (Game.IsKeyPressed(Keys.E))
                    {
                        if (runonce)
                        {
                            runonce = false;
                            Experimentstartwithremote.Play();
                            delay.Start();
                        }
                    }
                    else if (delay.getdelay() >= 10 && delay.getdelay() <= 24)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed = 0;
                    }
                    else if (delay.getdelay() >= 25 && delay.getdelay() <= 62)
                    {
                        if (TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed < 46)
                        {
                            TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.PlaceOnGround();
                            TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed += (float)0.1;
                        }
                    }
                    else if (delay.getdelay() == 58)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.IsVisible = false;
                    }
                    else if (delay.getdelay() == 59)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed = 0;
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].ifwentoutoffcar = true;
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].RCmode = false;
                    }
                    else if (delay.getdelay() == 60)
                    {
                        Experimentsuccess.Play();
                    }
                    else if (delay.getdelay() == 62)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].RCmodeenabled = true;
                    }
                    else if (delay.getdelay() == 114)
                    {
                        Einstein = TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.CreatePedOnSeat(VehicleSeat.Driver, PedHash.Chop);
                        delay.Stop();
                        delay.Reset();
                        Experimentstartwithreentry.Play();
                        Docwithremote = false;
                        reentry = true;
                    }
                }
                catch (Exception e)
                {
                    UI.ShowSubtitle(e.Message + " " + e.Source);
                }

                
            }
            else if (reentry)
            {
                if (delay.getdelay() == 0)
                {
                    delay.Start();
                }
                else if (delay.getdelay() == 3)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Position = Doc.GetOffsetInWorldCoords(new Vector3(3, -18, 0));
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Rotation = Docstruck.Rotation;
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed = 30;
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.IsVisible = true;
                }
                else if (delay.getdelay() < 4 && delay.getdelay() > 26)
                {
                    if (TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed > 0)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed -= (float)0.1;
                    }
                    World.AddExplosion(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-1, -2, 0)), ExplosionType.Car, 10, 0);
                }
                else if (delay.getdelay() == 26)
                {
                    World.AddExplosion(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-1, -2, 0)), ExplosionType.Car, 14, 0);

                    World.AddExplosion(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(1, -2, 0)), ExplosionType.Car, 14, 0);

                }
                else if (delay.getdelay() < 40)
                {
                    World.AddExplosion(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-1, -2, 0)), ExplosionType.Car, 10, 0);
                }
                else if (delay.getdelay() == 40)
                {
                    Doc.Task.RunTo(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3((float)-2.5, 0, 0)));
                }
                else if (delay.getdelay() == 51)
                {
                    Doc.Task.EnterVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, VehicleSeat.Driver);
                }
                else if (delay.getdelay() == 52)
                {
                    Doc.Task.ClearAll();
                }
                else if (delay.getdelay() == 58)
                {
                    Einstein.Task.LeaveVehicle();
                }
                else if (delay.getdelay() == 80)
                {
                    Doc.Task.EnterVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, VehicleSeat.Driver);
                }
                else if (delay.getdelay() >= 84 && delay.getdelay() < 124)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].toggletimecurcuits = true;

                    if (delay.getdelay() >= 98)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Settime(0, 4, 0, 7, 1, 7, 7, 6, 0, 8, 1, 2, "am");
                    }
                    if (delay.getdelay() >= 103)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Settime(2, 5, 1, 2, 0, 0, 0, 0, 1, 1, 1, 2, "am");
                    }
                    if (delay.getdelay() >= 110)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Settime(0, 5, 0, 9, 1, 9, 5, 5, 1, 1, 1, 2, "am");
                    }
                }
                else if (delay.getdelay() == 124)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].toggletimecurcuits = false;
                    delay.Stop();
                    delay.Reset();
                    reentry = false;
                    Libeadsappear = true;
                    Doc.Task.LeaveVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, true);
                }
            }
            else if (Libeadsappear)
            {

            }
            delay.Delay_changer();
        }
Example #52
0
        public override void OnInitialize()
        {
            UnitsUIPanel        = new DragableUIPanel();
            UnitsUIPanel.HAlign = 0.9f;
            UnitsUIPanel.VAlign = 0.9f;
            UnitsUIPanel.Width.Set(180f, 0f);
            UnitsUIPanel.Height.Set(180f, 0f);

            unitsLeftText = new UIText("Units Left: ");
            unitsLeftText.Top.Set(0f, 0f);
            unitsLeftText.Left.Set(20f, 0f);
            unitsLeftText.Width.Set(40f, 0f);
            unitsLeftText.Height.Set(20f, 0f);
            UnitsUIPanel.Append(unitsLeftText);

            Texture2D soldierTextureImage = ModContent.GetTexture("JoJoStands/Projectiles/PlayerStands/BadCompany/BadCompanySoldier_Prone");

            soldierTexture        = new UIImage(soldierTextureImage);
            soldierTexture.HAlign = 0.1f;
            soldierTexture.VAlign = 0.5f;
            soldierTexture.Width.Set(soldierTextureImage.Width, 0f);
            soldierTexture.Height.Set(soldierTextureImage.Height, 0f);
            UnitsUIPanel.Append(soldierTexture);

            soldiersActiveText        = new UIText("0");
            soldiersActiveText.HAlign = soldierTexture.HAlign;
            soldiersActiveText.VAlign = soldierTexture.VAlign + textDistanceFromTexture;
            soldiersActiveText.Width.Set(20f, 0f);
            soldiersActiveText.Height.Set(20f, 0f);
            UnitsUIPanel.Append(soldiersActiveText);

            Texture2D leftButtonTexture = ModContent.GetTexture("JoJoStands/Extras/LeftArrow");

            subtractSoldierButton        = new UIImageButton(leftButtonTexture);
            subtractSoldierButton.HAlign = soldiersActiveText.HAlign - buttonPadding;
            subtractSoldierButton.VAlign = soldiersActiveText.VAlign;
            subtractSoldierButton.Width.Set(leftButtonTexture.Width, 0f);
            subtractSoldierButton.Height.Set(leftButtonTexture.Height, 0f);
            subtractSoldierButton.OnClick += OnClickSubtractSoldierButton;
            UnitsUIPanel.Append(subtractSoldierButton);

            Texture2D rightButtonTexture = ModContent.GetTexture("JoJoStands/Extras/RightArrow");

            addSoldierButton        = new UIImageButton(rightButtonTexture);
            addSoldierButton.HAlign = soldiersActiveText.HAlign + buttonPadding;
            addSoldierButton.VAlign = soldiersActiveText.VAlign;
            addSoldierButton.Width.Set(rightButtonTexture.Width, 0f);
            addSoldierButton.Height.Set(rightButtonTexture.Height, 0f);
            addSoldierButton.OnClick += OnClickAddSoldierButton;
            UnitsUIPanel.Append(addSoldierButton);

            Texture2D tankTextureImage = ModContent.GetTexture("JoJoStands/Projectiles/PlayerStands/BadCompany/BadCompanyTank");

            tankTexture        = new UIImage(tankTextureImage);
            tankTexture.HAlign = 0.5f;
            tankTexture.VAlign = 0.5f;
            tankTexture.Width.Set(tankTextureImage.Width, 0f);
            tankTexture.Height.Set(tankTextureImage.Height, 0f);
            UnitsUIPanel.Append(tankTexture);

            tanksActiveText        = new UIText("0");
            tanksActiveText.HAlign = tankTexture.HAlign;
            tanksActiveText.VAlign = tankTexture.VAlign + textDistanceFromTexture;
            tanksActiveText.Width.Set(20f, 0f);
            tanksActiveText.Height.Set(20f, 0f);
            UnitsUIPanel.Append(tanksActiveText);

            subtractTankButton        = new UIImageButton(leftButtonTexture);
            subtractTankButton.HAlign = tanksActiveText.HAlign - buttonPadding;
            subtractTankButton.VAlign = tanksActiveText.VAlign;
            subtractTankButton.Width.Set(leftButtonTexture.Width, 0f);
            subtractTankButton.Height.Set(leftButtonTexture.Height, 0f);
            subtractTankButton.OnClick += OnClickSubtractTankButton;
            UnitsUIPanel.Append(subtractTankButton);

            addTankButton        = new UIImageButton(rightButtonTexture);
            addTankButton.HAlign = tanksActiveText.HAlign + buttonPadding;
            addTankButton.VAlign = tanksActiveText.VAlign;
            addTankButton.Width.Set(rightButtonTexture.Width, 0f);
            addTankButton.Height.Set(rightButtonTexture.Height, 0f);
            addTankButton.OnClick += OnClickAddTankButton;
            UnitsUIPanel.Append(addTankButton);

            Texture2D chopperTextureImage = ModContent.GetTexture("JoJoStands/Extras/UnitsUIChopper");

            chopperTexture        = new UIImage(chopperTextureImage);
            chopperTexture.HAlign = 0.9f;
            chopperTexture.VAlign = 0.5f;
            chopperTexture.Width.Set(chopperTextureImage.Width, 0f);
            chopperTexture.Height.Set(chopperTextureImage.Height, 0f);
            UnitsUIPanel.Append(chopperTexture);

            choppersActiveText        = new UIText("0");
            choppersActiveText.HAlign = chopperTexture.HAlign;
            choppersActiveText.VAlign = chopperTexture.VAlign + textDistanceFromTexture;
            choppersActiveText.Width.Set(20f, 0f);
            choppersActiveText.Height.Set(20f, 0f);
            UnitsUIPanel.Append(choppersActiveText);

            subtractChopperButton        = new UIImageButton(leftButtonTexture);
            subtractChopperButton.HAlign = choppersActiveText.HAlign - buttonPadding;
            subtractChopperButton.VAlign = choppersActiveText.VAlign;
            subtractChopperButton.Width.Set(leftButtonTexture.Width, 0f);
            subtractChopperButton.Height.Set(leftButtonTexture.Height, 0f);
            subtractChopperButton.OnClick += OnClickSubtractChopperButton;
            UnitsUIPanel.Append(subtractChopperButton);

            addChopperButton        = new UIImageButton(rightButtonTexture);
            addChopperButton.HAlign = choppersActiveText.HAlign + buttonPadding;
            addChopperButton.VAlign = choppersActiveText.VAlign;
            addChopperButton.Width.Set(rightButtonTexture.Width, 0f);
            addChopperButton.Height.Set(rightButtonTexture.Height, 0f);
            addChopperButton.OnClick += OnClickAddChopperButton;
            UnitsUIPanel.Append(addChopperButton);

            Append(UnitsUIPanel);
        }
        protected override List <UIComponent> GenerateComponents()
        {
            return(new List <UIComponent>()
            {
                new UIPanel()
                {
                    Name = "pnlFriendsSearch",
                    Idle = new UIIdlePanel()
                    {
                        Float = Float.TOP_CENTER,
                        Width = Styles.Screen_Width,
                        Height = Styles.Height_Bar_Medium,
                        BackgroundColor = Media.colorWhite
                    },
                    Components = new List <UIComponent>()
                    {
                        new UIText()
                        {
                            Name = "txtFriendsSearch",
                            Idle = new UIIdleText()
                            {
                                Float = Float.MIDDLE_CENTER,
                                Width = Styles.Width_Page,
                                Alignment = TextAnchor.MiddleLeft,
                                Font = Media.fontExoLight,
                                FontColor = Media.colorGrey,
                                FontSize = Styles.Font_Size_Medium,
                                LineHeight = 1,
                                Text = "Find a friend by Name...",
                                FurtherAccess = true
                            }
                        }
                    },
                    OnTouchInitialization = (component) =>
                    {
                        return new List <OnTouchListener>()
                        {
                            new OnTouchListener()
                            {
                                Owner = component.Name,
                                Target = component.Name,
                                Enabled = true,
                                Released = true,
                                OnRelease = (go) =>
                                {
                                    Directives.Sense_Touch = false;

                                    new KeyboardOpener()
                                    {
                                        Material = new KeyboardOpenerMaterial()
                                        {
                                            Owner = this.Name,
                                            Listeners = new List <string>()
                                            {
                                                "clckFriendsBack", "%clckRemove_"
                                            },
                                            Initial_Text = "",
                                            Model = Variables.UI["txtFriendsSearch"] as UIText,
                                            OnMask = (text) =>
                                            {
                                                string masked = "";

                                                if (!string.IsNullOrEmpty(text))
                                                {
                                                    if (text.Contains(' ') && text.Last() != ' ')
                                                    {
                                                        string reformed = "";
                                                        string[] parts = text.Split(' ');
                                                        foreach (string part in parts)
                                                        {
                                                            reformed += part[0].ToString().ToUpper() + part.Substring(1) + " ";
                                                        }

                                                        reformed = reformed.Substring(0, reformed.Length - 1);

                                                        masked = reformed;
                                                    }
                                                    else
                                                    {
                                                        masked = text[0].ToString().ToUpper() + text.Substring(1);
                                                    }
                                                }

                                                return masked;
                                            },
                                            OnClose = () =>
                                            {
                                                if (Variables.Keyboard_Text == "")
                                                {
                                                    UIText txtSearch = Variables.UI["txtFriendsSearch"] as UIText;
                                                    txtSearch.Element.text = "Find a friend by Name...";

                                                    return;
                                                }

                                                (Variables.UI["txtTopRight"] as UIText).Element.text = "Searching...";

                                                new UIListRenderer <listFriendsItem>()
                                                {
                                                    Material = new UIListRendererMaterial <listFriendsItem>()
                                                    {
                                                        List = "listFriends",
                                                        ListUrl = Config.URLs.Friend_Search,
                                                        ListFields = new Dictionary <string, string>()
                                                        {
                                                            { "text", Variables.Keyboard_Text }
                                                        },
                                                        OnConversion = (json) =>
                                                        {
                                                            UIText txtTopRight = Variables.UI["txtTopRight"] as UIText;

                                                            List <JsonUser> listUsers = JsonConvert.DeserializeObject <List <JsonUser> >(json);
                                                            List <listFriendsItem> items = new List <listFriendsItem>();

                                                            if (listUsers.Count == 0)
                                                            {
                                                                (Variables.UI["txtTopRight"] as UIText).Element.text = "No users found";

                                                                new Suspender()
                                                                {
                                                                    Suspension = 3,
                                                                    OnFinish = () =>
                                                                    {
                                                                        txtTopRight.Element.text = "Find your Friends";

                                                                        UIText txtSearch = Variables.UI["txtFriendsSearch"] as UIText;
                                                                        txtSearch.Element.text = "Find a friend by Name...";
                                                                    }
                                                                }
                                                                .Suspend();
                                                            }
                                                            else
                                                            {
                                                                if (listUsers.Count == 1)
                                                                {
                                                                    txtTopRight.Element.text = listUsers.Count + " user found";
                                                                }
                                                                else
                                                                {
                                                                    txtTopRight.Element.text = listUsers.Count + " users found";
                                                                }

                                                                foreach (JsonUser user in listUsers)
                                                                {
                                                                    items.Add(new listFriendsItem()
                                                                    {
                                                                        user = user
                                                                    });
                                                                }
                                                            }

                                                            return items;
                                                        }
                                                    },
                                                    OnFinish = () =>
                                                    {
                                                        new Suspender()
                                                        {
                                                            Suspension = 3,
                                                            OnFinish = () =>
                                                            {
                                                                UIText txtSearch = Variables.UI["txtFriendsSearch"] as UIText;
                                                                txtSearch.Element.text = "Find a friend by Name...";
                                                            }
                                                        }
                                                        .Suspend();
                                                    }
                                                }
                                                .Render();
                                            }
                                        }
                                    }
                                    .Open();
                                }
                            }
                        };
                    }
                },
                new listFriends(),
                new UIPanel()
                {
                    Name = "clckNoFriends",
                    Idle = new UIIdlePanel()
                    {
                        Float = Float.TOP_CENTER,
                        Width = Styles.Width_Bar_Wide,
                        Height = Styles.Height_Bar_Medium,
                        Top = Styles.Height_Bar_Medium * 3f,
                        BackgroundColor = Media.colorWhite,
                        FurtherAccess = true
                    },
                    Components = new List <UIComponent>()
                    {
                        new UIText()
                        {
                            Name = "txtNewHere",
                            Idle = new UIIdleText()
                            {
                                Float = Float.MIDDLE_CENTER,
                                Width = Styles.Width_Bar_Wide,
                                Bottom = Styles.Height_Bar_Medium * 1.25f,
                                Alignment = TextAnchor.MiddleCenter,
                                Font = Media.fontExoLight,
                                FontColor = Media.colorGrey,
                                FontSize = Styles.Font_Size_Large,
                                LineHeight = 1,
                                Text = "Seems like you're new here :/"
                            }
                        },
                        new UIText()
                        {
                            Name = "txtNoFriends",
                            Idle = new UIIdleText()
                            {
                                Float = Float.MIDDLE_CENTER,
                                Width = Styles.Width_Bar_Wide,
                                Alignment = TextAnchor.MiddleCenter,
                                Font = Media.fontExoLight,
                                FontColor = Media.colorGrey,
                                FontSize = Styles.Font_Size_Large,
                                LineHeight = 1,
                                Text = "Let's make some friends"
                            }
                        },
                        new UIImage()
                        {
                            Name = "imgArrow",
                            Idle = new UIIdleImage()
                            {
                                Float = Float.MIDDLE_RIGHT,
                                Width = Styles.Height_Bar_Medium * 0.3f,
                                Height = Styles.Height_Bar_Medium * 0.3f,
                                Right = Styles.Height_Bar_Medium * 0.15f,
                                BackgroundColor = Media.colorGreyDark,
                                Url = "Images/icon_arrow"
                            }
                        }
                    },
                    OnTouchInitialization = (component) =>
                    {
                        return new List <OnTouchListener>()
                        {
                            new OnTouchListener()
                            {
                                Owner = component.Name,
                                Target = component.Name,
                                Enabled = true,
                                Released = true,
                                OnRelease = (go) =>
                                {
                                    Directives.Sense_Touch = false;

                                    new UIPageRenderer <listForeignFriendsItem>()
                                    {
                                        Material = new UIPageRendererMaterial <listForeignFriendsItem>()
                                        {
                                            Page = new pageAddFriend(UIDirection.FROM_RIGHT, UIPageHeight.TALL)
                                        }
                                    }
                                    .Render();
                                }
                            }
                        };
                    }
                },
                new UIPanel()
                {
                    Name = "clckFriendsBack",
                    Idle = new UIIdlePanel()
                    {
                        Float = Float.BOTTOM_CENTER,
                        Width = Styles.Screen_Width,
                        Height = Styles.Height_Bar_Medium,
                        BackgroundColor = Media.colorGrey
                    },
                    Components = new List <UIComponent>()
                    {
                        new UIText()
                        {
                            Name = "txtBack",
                            Idle = new UIIdleText()
                            {
                                Float = Float.MIDDLE_CENTER,
                                Width = Styles.Screen_Width,
                                Height = Styles.Height_Bar_Medium,
                                Alignment = TextAnchor.MiddleCenter,
                                Font = Media.fontExoLight,
                                FontColor = Media.colorWhite,
                                FontSize = Styles.Font_Size_Larger,
                                LineHeight = 1,
                                Text = "Back"
                            }
                        }
                    },
                    OnTouchInitialization = (component) =>
                    {
                        return new List <OnTouchListener>()
                        {
                            new OnTouchListener()
                            {
                                Owner = component.Name,
                                Target = component.Name,
                                Enabled = true,
                                Released = true,
                                OnRelease = (go) =>
                                {
                                    Directives.Sense_Touch = false;

                                    new UIPageRenderer <listItem>()
                                    {
                                        Material = new UIPageRendererMaterial <listItem>()
                                        {
                                            Page = new pageProfile(UIDirection.FROM_LEFT, UIPageHeight.NORMAL),
                                            Url = Config.URLs.Profile_Page,
                                            OnPageLoad = (text) => { Variables.Friend_Request_Count = int.Parse(text); },
                                            OnPageRegeneration = () => { return new pageProfile(UIDirection.FROM_LEFT, UIPageHeight.NORMAL); }
                                        }
                                    }
                                    .Render();
                                }
                            }
                        };
                    }
                }
            });
        }
Example #54
0
        // In OnInitialize, we place various UIElements onto our UIState (this class).
        // UIState classes have width and height equal to the full screen, because of this, usually we first define a UIElement that will act as the container for our UI.
        // We then place various other UIElement onto that container UIElement positioned relative to the container UIElement.
        public override void OnInitialize()
        {
            // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features.
            // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features.


            //pokemon icons



            // Next, we create another UIElement that we will place. Since we will be calling `mainPanel.Append(playButton);`, Left and Top are relative to the top left of the mainPanel UIElement.
            // By properly nesting UIElements, we can position things relatively to each other easily.

            mainPanel = new SidebarPanel();
            mainPanel.SetPadding(0);
            // We need to place this UIElement in relation to its Parent. Later we will be calling `base.Append(mainPanel);`.
            // This means that this class, ExampleUI, will be our Parent. Since ExampleUI is a UIState, the Left and Top are relative to the top left of the screen.
            mainPanel.HAlign = 1.05f;
            mainPanel.VAlign = 1.05f;
            mainPanel.Width.Set(190, 0f);
            mainPanel.Height.Set(135f, 0f);
            mainPanel.BackgroundColor = new Color(50, 50, 50) * 0.5f;

            Texture2D firstmovetexture = ModContent.GetTexture("Terramon/UI/Moveset/NormalType");

            firstmove        = new SidebarClass(firstmovetexture, "Normal Type | PP: 35/35");
            firstmove.HAlign = 0.05f; // 1
            firstmove.VAlign = 0.1f;  // 1
            firstmove.Width.Set(16, 0);
            firstmove.Height.Set(16, 0);
            mainPanel.Append(firstmove);

            firstmovename        = new UIText("0/0");
            firstmovename.HAlign = 0.25f;
            firstmovename.VAlign = 0.1f;
            firstmovename.SetText("Scratch");
            mainPanel.Append(firstmovename);

            Texture2D secondmovetexture = ModContent.GetTexture("Terramon/UI/Moveset/EmptyType");

            secondmove        = new SidebarClass(secondmovetexture, "");
            secondmove.HAlign = 0.05f; // 1
            secondmove.VAlign = 0.3f;  // 1
            secondmove.Width.Set(16, 0);
            secondmove.Height.Set(16, 0);
            mainPanel.Append(secondmove);

            Texture2D thirdmovetexture = ModContent.GetTexture("Terramon/UI/Moveset/EmptyType");

            thirdmove        = new SidebarClass(thirdmovetexture, "");
            thirdmove.HAlign = 0.05f; // 1
            thirdmove.VAlign = 0.5f;  // 1
            thirdmove.Width.Set(16, 0);
            thirdmove.Height.Set(16, 0);
            mainPanel.Append(thirdmove);

            Texture2D fourthmovetexture = ModContent.GetTexture("Terramon/UI/Moveset/EmptyType");

            fourthmove        = new SidebarClass(fourthmovetexture, "");
            fourthmove.HAlign = 0.05f; // 1
            fourthmove.VAlign = 0.7f;  // 1
            fourthmove.Width.Set(16, 0);
            fourthmove.Height.Set(16, 0);
            mainPanel.Append(fourthmove);

            Append(mainPanel);
            // As a recap, ExampleUI is a UIState, meaning it covers the whole screen. We attach mainPanel to ExampleUI some distance from the top left corner.
            // We then place playButton, closeButton, and moneyDiplay onto mainPanel so we can easily place these UIElements relative to mainPanel.
            // Since mainPanel will move, this proper organization will move playButton, closeButton, and moneyDiplay properly when mainPanel moves.
        }
	void Start()
	{
		var scrollable = new UIScrollableVerticalLayout( 10 );
		scrollable.position = new Vector3( 0, -50, 0 );
		var width = UI.instance.isHD ? 300 : 150;
		scrollable.setSize( width, Screen.height / 1.4f );
		
		for( var i = 0; i < 20; i++ )
		{
			UITouchableSprite touchable;
			if( i % 3 == 0 )
			{
				touchable = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
			}
			else if( i % 2 == 0 )
			{
				touchable = UIButton.create( "playUp.png", "playDown.png", 0, 0 );
			}
			else
			{
				touchable = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 );
			}
			if (i == 1) {
				var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
				ch.parentUIObject = touchable;
				ch.pixelsFromRight(0);
				ch.client.name = "TEST THINGY";
				ch.scale = new Vector3(0.5f, 0.5f, 1);
			}
			if (i == 4) {
				var text = new UIText(TextManager, "prototype", "prototype.png");

				var helloText = text.addTextInstance("Child Text", 0, 0,0.5f,-1,Color.cyan,UITextAlignMode.Center,UITextVerticalAlignMode.Middle);
				helloText.parentUIObject = touchable;
				helloText.positionCenter();

				var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
				ch.parentUIObject = helloText;
				ch.pixelsFromRight(-16);
				ch.client.name = "subsub";
				ch.scale = new Vector3(0.25f, 0.25f, -2);
			}

			
			// only add a touchUpInside handler for buttons
			if( touchable is UIButton )
			{
				var button = touchable as UIButton;
				
				// store i locally so we can put it in the closure scope of the touch handler
				var j = i;
				button.onTouchUpInside += ( sender ) => Debug.Log( "touched button: " + j );
			}

			
			scrollable.addChild( touchable );
		}
		
		
		// click to scroll to a specific offset
		var scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromTopRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -10, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromBottomRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -600, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.centerize();
		scores.positionFromTopRight( 0.5f, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			var target = scrollable.position;
			var moveBy = _movedContainer ? -100 : 100;
			if( !UI.instance.isHD )
				moveBy /= 2;
			target.x += moveBy * 2;
			target.y += moveBy;
			scrollable.positionTo( 0.4f, target, Easing.Quintic.easeIn );
			_movedContainer = !_movedContainer;
		};
	}
Example #56
0
 public void Initalize()
 {
     m_bRealease = true;
     text        = Utility.GameUtility.FindDeepChild <UIText>(gameObject, "UIText");
     gameObject.SetActive(false);
 }
Example #57
0
 /// <summary>
 /// Call the full constructor with default alignment modes brought from the parent UIText object.
 /// </summary>
 public UITextInstance( UIText parentText, string text, float xPos, float yPos, float scale, int depth, Color color )
     : this(parentText, text, xPos, yPos, scale, depth, new Color[] { color }, parentText.alignMode, parentText.verticalAlignMode)
 {
 }
        ////////////////

        private void InitializeComponents()
        {
            var mymod = ModHelpersMod.Instance;
            UIModControlPanelTab self  = this;
            ModControlPanelLogic logic = this.Logic;
            float top = 0;

            this.Theme.ApplyPanel(this);


            ////////

            var tip = new UIText("To enable issue reports for your mod, ");

            this.Append((UIElement)tip);

            this.TipUrl = new UIWebUrl(this.Theme, "read this.",
                                       "https://forums.terraria.org/index.php?threads/mod-helpers.63670/#modders",
                                       false, 1f);
            this.TipUrl.Left.Set(tip.GetInnerDimensions().Width, 0f);
            this.TipUrl.Top.Set(-2f, 0f);
            this.Append((UIElement)this.TipUrl);

            top += 24f;

            ////

            var modListPanel = new UIPanel();

            {
                modListPanel.Top.Set(top, 0f);
                modListPanel.Width.Set(0f, 1f);
                modListPanel.Height.Set(UIModControlPanelTab.ModListHeight, 0f);
                modListPanel.HAlign = 0f;
                modListPanel.SetPadding(4f);
                modListPanel.PaddingTop      = 0.0f;
                modListPanel.BackgroundColor = this.Theme.ListBgColor;
                modListPanel.BorderColor     = this.Theme.ListEdgeColor;
                this.Append((UIElement)modListPanel);

                this.ModListElem = new UIList();
                {
                    this.ModListElem.Width.Set(-25, 1f);
                    this.ModListElem.Height.Set(0f, 1f);
                    this.ModListElem.HAlign      = 0f;
                    this.ModListElem.ListPadding = 4f;
                    this.ModListElem.SetPadding(0f);
                    modListPanel.Append((UIElement)this.ModListElem);

                    top += UIModControlPanelTab.ModListHeight + this.PaddingTop;

                    UIScrollbar scrollbar = new UIScrollbar();
                    {
                        scrollbar.Top.Set(8f, 0f);
                        scrollbar.Height.Set(-16f, 1f);
                        scrollbar.SetView(100f, 1000f);
                        scrollbar.HAlign = 1f;
                        modListPanel.Append((UIElement)scrollbar);
                        this.ModListElem.SetScrollbar(scrollbar);
                    }
                }
            }

            ////

            this.IssueTitleInput = new UITextArea(this.Theme, "Enter title of mod issue", 128);
            this.IssueTitleInput.Top.Set(top, 0f);
            this.IssueTitleInput.Width.Set(0f, 1f);
            this.IssueTitleInput.Height.Pixels = 36f;
            this.IssueTitleInput.HAlign        = 0f;
            this.IssueTitleInput.SetPadding(8f);
            this.IssueTitleInput.Disable();
            this.IssueTitleInput.OnPreChange += delegate(StringBuilder newText) {
                self.RefreshIssueSubmitButton();
            };
            this.Append((UIElement)this.IssueTitleInput);

            top += 40f;

            this.IssueBodyInput = new UITextArea(this.Theme, "Describe mod issue");
            this.IssueBodyInput.Top.Set(top, 0f);
            this.IssueBodyInput.Width.Set(0f, 1f);
            this.IssueBodyInput.Height.Pixels = 36f;
            this.IssueBodyInput.HAlign        = 0f;
            this.IssueBodyInput.SetPadding(8f);
            this.IssueBodyInput.Disable();
            this.IssueBodyInput.OnPreChange += delegate(StringBuilder newText) {
                self.RefreshIssueSubmitButton();
            };
            this.Append((UIElement)this.IssueBodyInput);

            top += 40f;

            ////

            this.IssueSubmitButton = new UITextPanelButton(this.Theme, "Submit Issue");
            this.IssueSubmitButton.Top.Set(top, 0f);
            this.IssueSubmitButton.Left.Set(0f, 0f);
            this.IssueSubmitButton.Width.Set(200f, 0f);
            this.IssueSubmitButton.Disable();
            this.IssueSubmitButton.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement) {
                if (self.AwaitingReport || !self.IssueSubmitButton.IsEnabled)
                {
                    return;
                }
                self.SubmitIssue();
            };
            this.Append(this.IssueSubmitButton);

            this.ApplyConfigButton = new UITextPanelButton(this.Theme, "Apply Config Changes");
            this.ApplyConfigButton.Top.Set(top, 0f);
            this.ApplyConfigButton.Left.Set(0f, 0f);
            this.ApplyConfigButton.Width.Set(200f, 0f);
            this.ApplyConfigButton.HAlign = 1f;
            if (Main.netMode != 0)
            {
                this.ApplyConfigButton.Disable();
            }
            this.ApplyConfigButton.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement) {
                if (!self.ApplyConfigButton.IsEnabled)
                {
                    return;
                }
                self.ApplyConfigChanges();
            };
            this.Append(this.ApplyConfigButton);

            top += 30f;

            this.ModLockButton = new UITextPanelButton(this.Theme, UIModControlPanelTab.ModLockTitle);
            this.ModLockButton.Top.Set(top, 0f);
            this.ModLockButton.Left.Set(0f, 0f);
            this.ModLockButton.Width.Set(0f, 1f);
            if (Main.netMode != 0 || !mymod.Config.WorldModLockEnable)
            {
                this.ModLockButton.Disable();
            }
            this.ModLockButton.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement) {
                if (!self.ModLockButton.IsEnabled)
                {
                    return;
                }
                self.ToggleModLock();
                Main.PlaySound(SoundID.Unlock);
            };
            this.Append(this.ModLockButton);

            this.RefreshModLockButton();

            top += 36f;

            ////

            /*var modrec_url = new UIWebUrl( this.Theme, "Need mods?", "https://sites.google.com/site/terrariamodsuggestions/" );
             * modrecUrl.Top.Set( top, 0f );
             * modrecUrl.Left.Set( 0f, 0f );
             * this.InnerContainer.Append( modrecUrl );
             *
             * var serverbrowser_url = new UIWebUrl( this.Theme, "Lonely?", "https://forums.terraria.org/index.php?threads/server-browser-early-beta.68346/" );
             * serverbrowser_url.Top.Set( top, 0f );
             * this.InnerContainer.Append( serverbrowser_url );
             * serverbrowser_url.Left.Set( -serverbrowser_url.GetDimensions().Width * 0.5f, 0.5f );*/

            string supportMsg = UIModControlPanelTab.SupportMessages[this.RandomSupportTextIdx];

            this.SupportUrl = new UIWebUrl(this.Theme, supportMsg, "https://www.patreon.com/hamstar0", false);
            this.SupportUrl.Top.Set(top, 0f);
            this.Append(this.SupportUrl);
            //this.SupportUrl.Left.Set( -this.SupportUrl.GetDimensions().Width, 1f );
            this.SupportUrl.Left.Set(-this.SupportUrl.GetDimensions().Width * 0.5f, 0.5f);
        }
Example #59
0
 public CustomDraw(String text, int x, int y, Color color, GTA.Font font, float size)
 {
     UIText ui = new UIText(text, new Point(checked((int)Math.Round(unchecked((double)UI.WIDTH / x))), y), size, color, font, false);
     ui.Draw();
 }
Example #60
0
        public override void OnInitialize()
        {
            this.Panel = new DragableUIPanel();
            this.Panel.Left.Set(((Main.screenWidth - this.PanelWidth) / 2) + this.OffsetX, 0f);
            this.Panel.Width.Set(this.PanelWidth, 0f);
            this.Panel.BorderColor = new Color(0, 0, 0, 0);

            var textHeight = ChatManager.GetStringSize(Main.fontMouseText, Constants.ToolCategories[0], new Vector2(0, 0)).Y;

            var currentY = 0f;
            var currentX = this.Padding;

            var uiTitle = new UIText("Electronics Manual", 1.5f);

            uiTitle.Height.Set(textHeight, 0f);
            uiTitle.Top.Set(currentY, 0f);
            this.Panel.Append(uiTitle);

            currentY += 40;

            for (var cat = 0; cat < Constants.ToolCategories.Count; cat++)
            {
                var uiCatTitle = new UIText(Constants.ToolCategories[cat]);
                uiCatTitle.Height.Set(textHeight, 0f);
                uiCatTitle.Top.Set(currentY, 0f);
                this.Panel.Append(uiCatTitle);

                var i = 0;
                foreach (var tool in Constants.Tools[cat])
                {
                    if (i % this.PerRow == 0)
                    {
                        currentY += this.ButtonSize + this.InnerPadding;
                        currentX  = 0;
                    }
                    else
                    {
                        currentX += this.ButtonSize + this.InnerPadding;
                    }

                    // TODO: Issue #6: Remove need for separate device icons
                    var button = new ElectronicsManualButton(tool, WireMod.Instance.GetTexture($"Images/Icons/{tool}Icon"))
                    {
                        ToolCat = cat,
                        Tool    = i
                    };

                    button.Height.Set(this.ButtonSize, 0f);
                    button.Width.Set(this.ButtonSize, 0f);
                    button.Left.Set(currentX, 0f);
                    button.Top.Set(currentY - (this.ButtonSize / 2), 0f);
                    button.SetVisibility(0f, 0.25f);

                    this.Panel.Append(button);

                    i++;
                }

                currentY += this.Padding + this.InnerPadding;
                currentX  = this.Padding;
            }

            this.Panel.Height.Set(currentY + this.Padding, 0f);
            this.Panel.Top.Set(((Main.screenHeight - this.PanelHeight) / 2) + this.OffsetY, 0f);

            this.Append(this.Panel);
            Recalculate();
        }