Ejemplo n.º 1
0
    public static UIGhostJoystick create( UIToolkit manager, string joystickFilename, Rect hitArea )
    {
        // create the joystrick sprite
        var joystick = manager.addSprite( joystickFilename, 0, 0, 1, true );

        return new UIGhostJoystick( manager, hitArea, 1, joystick);
    }
Ejemplo n.º 2
0
    public UIProgressBar( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UISprite bar, bool rotated )
        : base(frame, depth, uvFrame, rotated)
    {
        // Save the bar and make it a child of the container/border for organization purposes
        _bar = bar;
        _bar.parentUIObject = this;

        _barOriginalWidth = _bar.width;
        _barOriginalHeight = _bar.height;

        /*
        // Save the bars original size
        if (rotated)
        {
            _barOriginalWidth = _bar.width;
            _barOriginalHeight = _bar.height;
        }
        else
        {
            _barOriginalWidth = _bar.width;
            _barOriginalHeight = _bar.height;
        }
        */

        /*if (!_rotated)
                    normalFrame = new Rect( clientTransform.position.x, -clientTransform.position.y, width * touchesScale.x, height * touchesScale.y);
                else
                    normalFrame = new Rect( clientTransform.position.x, -clientTransform.position.y - (width * touchesScale.y), height * touchesScale.x, width * touchesScale.y);
                    */
        _barOriginalUVframe = _bar.uvFrame;

        manager.addSprite( this );
    }
Ejemplo n.º 3
0
    public UITexture( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame)
        : base(frame, depth, uvFrame)
    {
        _normalUVframe = uvFrame;

        manager.addSprite( this );
    }
Ejemplo n.º 4
0
    public static UITexture create( UIToolkit manager, string filename, int xPos, int yPos, int depth )
    {
        var normalTI = manager.textureInfoForFilename( filename );
        var frame = new Rect( xPos, yPos, normalTI.frame.width, normalTI.frame.height );

        return new UITexture( manager, frame, depth, normalTI.uvRect);
    }
    //constructor
    public UIPeaceMakerActor(UIToolkit toolkit, string actorName, string fileName)
    {
        //todo make this scalable
        _height = 50; //background image size
        _width = 50;

        _touchFrame = new Rect ( position.x, -position.y, _width, _height );

        //background image is always the same
        _actorBackground = toolkit.addSprite("actorBG.png", 0, 0);
        _actorBackground.parentUIObject = this;
        _actorBackground.positionFromTopLeft (0f, 0f);

        //gradient is always the same
        _actorGradient = toolkit.addSprite ("actor_gradient_white.png", 0, 0);
        _actorGradient.parentUIObject = this;
        _actorGradient.positionFromTopLeft (0f, 0f);

        //image and button
        _theButton = UIButton.create (toolkit, fileName, fileName, 0, 0);
        _theButton.parentUIObject = this;
        _theButton.onTouchUpInside += ( sender ) =>  randomAttitudeTest ();

        //up/down arrow is always the same
        _actorArrow = toolkit.addSprite ("up_arrow_anim_00.png", 0, 0);
        _actorArrow.parentUIObject = this;
        _actorArrow.positionFromTopRight (0f, 0f);

        _arrowUpAnim = _actorArrow.addSpriteAnimation ("arrowUpAnim", 0.1f, "up_arrow_anim_00.png", "up_arrow_anim_01.png", "up_arrow_anim_02.png", "up_arrow_anim_03.png", "up_arrow_anim_04.png", "up_arrow_anim_05.png", "up_arrow_anim_06.png", "up_arrow_anim_07.png", "up_arrow_anim_08.png", "up_arrow_anim_09.png");
        _arrowDownAnim = _actorArrow.addSpriteAnimation ("arrowDownAnim", 0.1f, "down_arrow_anim_00.png", "down_arrow_anim_01.png", "down_arrow_anim_02.png", "down_arrow_anim_03.png", "down_arrow_anim_04.png", "down_arrow_anim_05.png", "down_arrow_anim_06.png", "down_arrow_anim_07.png", "down_arrow_anim_08.png", "down_arrow_anim_09.png");
        _arrowUpAnim.loopReverse = true;
        _arrowDownAnim.loopReverse = true;

        hideAttitudeIndicators ();
    }
Ejemplo n.º 6
0
	// 
	public static UIJoystick create( UIToolkit manager, string joystickFilename, Rect hitAreaFrame, float xPos, float yPos )
	{
		// create the joystrick sprite
		var joystick = manager.addSprite( joystickFilename, 0, 0, 1, true );
		
		return new UIJoystick( manager, hitAreaFrame, 1, joystick, xPos, yPos );
	}
	// Default constructor
	public UIAbstractTouchableContainer( UIToolkit manager, UILayoutType layoutType, int spacing ) : base( layoutType )
	{
		_spacing = spacing;
		_manager = manager;
		
		_manager.addToTouchables( this );
	}
	public UIZoomButton( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UIUVRect highlightedUVframe ):base( manager, frame, depth, uvFrame, highlightedUVframe )
	{
		centerize();
		autoRefreshPositionOnScaling = false;
		_zoomInAnimation = new UIAnimation( this, 0.3f, UIAnimationProperty.Scale, new Vector3( 1, 1, 1 ), new Vector3( 1.3f, 1.3f, 1.3f ), Easing.Quartic.easeInOut );
		_zoomOutAnimation = new UIAnimation( this, 0.3f, UIAnimationProperty.Scale, new Vector3( 1.3f, 1.3f, 1.3f ), new Vector3( 1, 1, 1 ), Easing.Quartic.easeInOut );
	}
Ejemplo n.º 9
0
 public UIColorPicker( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, Vector2 textureCoords )
     : base(frame, depth, uvFrame)
 {
     //We store the coordinates of the top left of the subtexture
     this.textureCoords = textureCoords;
     manager.addTouchableSprite( this );
 }
	// Default constructor
	public UIAbstractTouchableContainer( UIToolkit manager, UILayoutType layoutType, int spacing ) : base( layoutType )
	{
		TOUCH_MAX_DELTA_FOR_ACTIVATION *= UI.scaleFactor;
		_spacing = spacing * UI.scaleFactor;
		_manager = manager;
		
		_manager.addToTouchables( this );
	}
Ejemplo n.º 11
0
	/// <summary>
	/// Creates a swipe detector with no related UI
	/// </summary>
	public static UISwipeDetector create( UIToolkit manager, Rect frame, int depth )
	{
		// create the swipe detector
		var detector = new UISwipeDetector( frame, depth, UIUVRect.zero );
		manager.addTouchableSprite( detector );
		
		return detector;
	}
	public UIBackgroundLayout( UIToolkit manager, string filename ) : base( UILayoutType.BackgroundLayout ) 
	{
		background = manager.addSprite( filename, 0, 0, 2 );
		addChild( background );
		
		// set dimensions of container based on background texture dimensions
		_width = background.width;
		_height = background.height;
	}
Ejemplo n.º 13
0
	public static UIToggleButton create( UIToolkit manager, string filename, string selectedFilename, string highlightedFilename, int xPos, int yPos )
	{
		var textureInfo = manager.textureInfoForFilename( filename );
		var frame = new Rect( xPos, yPos, textureInfo.frame.width, textureInfo.frame.height );
		
		var selectedTI = manager.textureInfoForFilename( selectedFilename );
		var highlightedTI = manager.textureInfoForFilename( highlightedFilename );
		
		return new UIToggleButton( manager, frame, 1, textureInfo.uvRect, selectedTI.uvRect, highlightedTI.uvRect );
	}
Ejemplo n.º 14
0
	public UIButton( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UIUVRect highlightedUVframe ):base( frame, depth, uvFrame )
	{
		// If a highlighted frame has not yet been set use the normalUVframe
		if( highlightedUVframe == UIUVRect.zero )
			highlightedUVframe = uvFrame;
		
		this.highlightedUVframe = highlightedUVframe;
		
		manager.addTouchableSprite( this );
	}
	// Default constructor
	public UIAbstractTouchableContainer( UIToolkit manager, UILayoutType layoutType, int spacing ) : base( layoutType )
	{
		_spacing = spacing;
		_manager = manager;
		
		_manager.addToTouchables( this );
		
		// listen to changes to our own transform so we can move the touchFrame
		this.onTransformChanged += transformChanged;
	}
Ejemplo n.º 16
0
	protected override void Awake()
	{
		// Set instance to this so we can be accessed from anywhere
		instance = this;
		
		base.Awake();

		_spriteSelected = new ITouchable[12];
		for( int i = 0; i < 12; ++i )
			_spriteSelected[i] = null;
	}
Ejemplo n.º 17
0
    public static UIColorPicker create( UIToolkit manager, string filename, int xPos, int yPos, int depth )
    {
        // grab the texture details for the normal state
        var normalTI = manager.textureInfoForFilename( filename );
        Vector2 textureCoords = new Vector2(normalTI.frame.x, normalTI.frame.y);

        var frame = new Rect( xPos, yPos, normalTI.frame.width, normalTI.frame.height );

        // create the button
        return new UIColorPicker( manager, frame, depth, normalTI.uvRect, textureCoords );
    }
	public static UIProgressBar create( UIToolkit manager, string barFilename, int xPos, int yPos, bool rightToLeft, int depth )
	{
		var textureInfo = manager.textureInfoForFilename( barFilename );
		var frame = new Rect( xPos, yPos, textureInfo.frame.width, textureInfo.frame.height );
		
		if( rightToLeft )
			frame.x = xPos + (int)textureInfo.frame.width;

		var progressBar = new UIProgressBar( manager, frame, depth, textureInfo.uvRect, rightToLeft );
		
		return progressBar;
	}
Ejemplo n.º 19
0
    public static new UIContinuousButton create( UIToolkit manager, string filename, string highlightedFilename, int xPos, int yPos, int depth )
    {
        // grab the texture details for the normal state
        var normalTI = manager.textureInfoForFilename( filename );
        var frame = new Rect( xPos, yPos, normalTI.frame.width, normalTI.frame.height );

        // get the highlighted state
        var highlightedTI = manager.textureInfoForFilename( highlightedFilename );

        // create the button
        return new UIContinuousButton( manager, frame, depth, normalTI.uvRect, highlightedTI.uvRect );
    }
Ejemplo n.º 20
0
    public UIProgressBar(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UISprite bar) : base(frame, depth, uvFrame)
    {
        // Save the bar and make it a child of the container/border for organization purposes
        _bar = bar;
        _bar.parentUIObject = this;

        // Save the bars original size
        _barOriginalWidth   = _bar.width;
        _barOriginalUVframe = _bar.uvFrame;

        manager.addSprite(this);
    }
Ejemplo n.º 21
0
	/// <summary>
	/// Creates a swipe detector with a texture backing the hit area
	/// </summary>
	public static UISwipeDetector create( UIToolkit manager, string filename, int xPos, int yPos, int depth )
	{
		// grab the texture details
		var normalTI = manager.textureInfoForFilename( filename );
		var frame = new Rect( xPos, yPos, normalTI.frame.width, normalTI.frame.height );

		// create the swipe detector
		var detector = new UISwipeDetector( frame, depth, normalTI.uvRect );
		manager.addTouchableSprite( detector );
		
		return detector;
	}
	public static UISlider create( UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout, int depth = 2, bool knobInFront = true )
	{
		// create the track first so we can use its dimensions to position the knob		
		var trackTI = manager.textureInfoForFilename( trackFilename );
		var trackFrame = new Rect( trackxPos, trackyPos, trackTI.frame.width, trackTI.frame.height );

		// create a knob using our cacluated position
		var knobDepth = knobInFront ? depth - 1 : depth + 1;
		var knob = manager.addSprite( knobFilename, trackxPos, trackyPos, knobDepth, true );
		
		return new UISlider( manager, trackFrame, depth, trackTI.uvRect, knob, layout );
	}
Ejemplo n.º 23
0
    public static UISlider create(UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout, int depth = 2, bool knobInFront = true)
    {
        // create the track first so we can use its dimensions to position the knob
        var trackTI    = manager.textureInfoForFilename(trackFilename);
        var trackFrame = new Rect(trackxPos, trackyPos, trackTI.frame.width, trackTI.frame.height);

        // create a knob using our cacluated position
        var knobDepth = knobInFront ? depth - 1 : depth + 1;
        var knob      = manager.addSprite(knobFilename, trackxPos, trackyPos, knobDepth, true);

        return(new UISlider(manager, trackFrame, depth, trackTI.uvRect, knob, layout));
    }
Ejemplo n.º 24
0
    public static UIButton create(UIToolkit manager, string filename, string highlightedFilename, int xPos, int yPos, int depth)
    {
        // grab the texture details for the normal state
        var normalTI = manager.textureInfoForFilename(filename);
        var frame    = new Rect(xPos, yPos, normalTI.frame.width, normalTI.frame.height);

        // get the highlighted state
        var highlightedTI = manager.textureInfoForFilename(highlightedFilename);

        // create the button
        return(new UIButton(manager, frame, depth, normalTI.uvRect, highlightedTI.uvRect));
    }
Ejemplo n.º 25
0
    public UIButton(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UIUVRect highlightedUVframe) : base(frame, depth, uvFrame)
    {
        // If a highlighted frame has not yet been set use the normalUVframe
        if (highlightedUVframe == UIUVRect.zero)
        {
            highlightedUVframe = uvFrame;
        }

        this.highlightedUVframe = highlightedUVframe;

        manager.addTouchableSprite(this);
    }
Ejemplo n.º 26
0
    public UISlider(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UISprite sliderKnob, UISliderLayout layout) : base(frame, depth, uvFrame)
    {
        this.layout = layout;

        // save the sliderKnob and make it a child of the slider for organization purposes
        _sliderKnob = sliderKnob;
        _sliderKnob.parentUIObject = this;

        // setup the min/max position values for the sliderKnob
        updateSliderKnobConstraints();

        manager.addTouchableSprite(this);
    }
Ejemplo n.º 27
0
	public UISlider( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UISprite sliderKnob, UISliderLayout layout, bool rotated ):base( frame, depth, uvFrame, rotated )
	{
		this.layout = layout;
		
		// save the sliderKnob and make it a child of the slider for organization purposes
		_sliderKnob = sliderKnob;
		_sliderKnob.parentUIObject = this;
		
		// setup the min/max position values for the sliderKnob
		updateSliderKnobConstraints();
		
		manager.addTouchableSprite( this );
	}
Ejemplo n.º 28
0
	public UIButton( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UIUVRect highlightedUVframe ):base( frame, depth, uvFrame )
	{
		// Save a copy of our uvFrame here so that when highlighting turns off we have the original UVs
		_normalUVframe = uvFrame;
		
		// If a highlighted frame has not yet been set use the normalUVframe
		if( highlightedUVframe == UIUVRect.zero )
			highlightedUVframe = uvFrame;
		
		this.highlightedUVframe = highlightedUVframe;
		
		manager.addTouchableSprite( this );
	}
    public static UIStateSprite create(UIToolkit manager, string[] filenames, int xPos, int yPos, int depth)
    {
        // Grab the texture details for the initial state
        UITextureInfo firstNormalTI = manager.textureInfoForFilename(filenames[0]);
        Rect frame = new Rect(xPos, yPos, firstNormalTI.frame.width, firstNormalTI.frame.height);

        // create the button
        UIStateSprite sprite = new UIStateSprite(manager, frame, depth, firstNormalTI.uvRect);
        // Add frames
        sprite.addFrames(filenames);

        return sprite;
    }
Ejemplo n.º 30
0
    protected override void Awake()
    {
        // Set instance to this so we can be accessed from anywhere
        instance = this;

        base.Awake();

        _spriteSelected = new ITouchable[12];
        for (int i = 0; i < 12; ++i)
        {
            _spriteSelected[i] = null;
        }
    }
Ejemplo n.º 31
0
    /// <summary>
    /// Creates a swipe detector with a texture backing the hit area
    /// </summary>
    public static UISwipeDetector create(UIToolkit manager, string filename, int xPos, int yPos, int depth)
    {
        // grab the texture details
        var normalTI = manager.textureInfoForFilename(filename);
        var frame    = new Rect(xPos, yPos, normalTI.frame.width, normalTI.frame.height);

        // create the swipe detector
        var detector = new UISwipeDetector(frame, depth, normalTI.uvRect);

        manager.addTouchableSprite(detector);

        return(detector);
    }
Ejemplo n.º 32
0
    public UIProgressBar( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UISprite bar )
        : base(frame, depth, uvFrame)
    {
        // Save the bar and make it a child of the container/border for organization purposes
        _bar = bar;
        _bar.parentUIObject = this;

        // Save the bars original size
        _barOriginalWidth = _bar.width;
        _barOriginalUVframe = _bar.uvFrame;

        manager.addSprite( this );
    }
    public static UIProgressBar create(UIToolkit manager, string barFilename, int xPos, int yPos, bool rightToLeft, int depth)
    {
        var textureInfo = manager.textureInfoForFilename(barFilename);
        var frame       = new Rect(xPos, yPos, textureInfo.frame.width, textureInfo.frame.height);

        if (rightToLeft)
        {
            frame.x = xPos + (int)textureInfo.frame.width;
        }

        var progressBar = new UIProgressBar(manager, frame, depth, textureInfo.uvRect, rightToLeft);

        return(progressBar);
    }
Ejemplo n.º 34
0
    public static UIStateSprite create(UIToolkit manager, string[] filenames, int xPos, int yPos, int depth)
    {
        // Grab the texture details for the initial state
        UITextureInfo firstNormalTI = manager.textureInfoForFilename(filenames[0]);
        Rect          frame         = new Rect(xPos, yPos, firstNormalTI.frame.width, firstNormalTI.frame.height);

        // create the button
        UIStateSprite sprite = new UIStateSprite(manager, frame, depth, firstNormalTI.uvRect);

        // Add frames
        sprite.addFrames(filenames);

        return(sprite);
    }
Ejemplo n.º 35
0
    public UIButton(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UIUVRect highlightedUVframe) : base(frame, depth, uvFrame)
    {
        // Save a copy of our uvFrame here so that when highlighting turns off we have the original UVs
        _normalUVframe = uvFrame;

        // If a highlighted frame has not yet been set use the normalUVframe
        if (highlightedUVframe == UIUVRect.zero)
        {
            highlightedUVframe = uvFrame;
        }

        this.highlightedUVframe = highlightedUVframe;

        manager.addTouchableSprite(this);
    }
	public UIProgressBar( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, bool rightToLeft ):base( frame, depth, uvFrame )
	{
		manager.addSprite( this );
		
		// Save the bars original size
		_barOriginalWidth = frame.width;
		_barOriginalUVframe = uvFrame;
		this.rightToLeft = rightToLeft;

		// Update the bar size based on the value
		if( rightToLeft )
			setSize( _value * -_barOriginalWidth, frame.height );
		else
			setSize( _value * _barOriginalWidth, frame.height );
	}
Ejemplo n.º 37
0
    private UIToolkit _manager; // we need this for getting at texture details after the constructor

    #endregion Fields

    #region Constructors

    public UIGhostJoystick( UIToolkit manager, Rect frame, int depth, UISprite joystickSprite)
        : base(frame, depth, UIUVRect.zero)
    {
        // Save out the uvFrame for the sprite so we can highlight
        _tempUVframe = joystickSprite.uvFrame;

        // Save the joystickSprite and make it a child of the us for organization purposes
        _joystickSprite = joystickSprite;
        _joystickSprite.parentUIObject = this;

        resetJoystick();

        manager.addTouchableSprite( this );
        _manager = manager;
    }
Ejemplo n.º 38
0
    public UIGhostJoystick(UIToolkit manager, Rect frame, int depth, UISprite joystickSprite)
        : base(frame, depth, UIUVRect.zero)
    {
        // Save out the uvFrame for the sprite so we can highlight
        _tempUVframe = joystickSprite.uvFrame;

        // Save the joystickSprite and make it a child of the us for organization purposes
        _joystickSprite = joystickSprite;
        _joystickSprite.parentUIObject = this;

        resetJoystick();

        manager.addTouchableSprite(this);
        _manager = manager;
    }
Ejemplo n.º 39
0
    public UIText(UIToolkit manager, string fontFilename, string textureFilename)
    {
        _manager     = manager;
        _fontDetails = new UIFontCharInfo[256];
        for (int i = 0; i < _fontDetails.Length; i++)
        {
            _fontDetails[i] = new UIFontCharInfo();
        }

        loadConfigfile(fontFilename);

        // grab the texture offset from the UI
        var rect = _manager.frameForFilename(textureFilename);

        this._textureOffset = new Vector2(rect.x, rect.y);
    }
Ejemplo n.º 40
0
	public static UISlider create( UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout )
	{
		// create the track first so we can use its dimensions to position the knob		
		var trackTI = manager.textureInfoForFilename( trackFilename );
		var trackFrame = new Rect( trackxPos, trackyPos, trackTI.frame.width, trackTI.frame.height );
		
		// position the knob based on the knobs size, layout and the track size
		if( layout == UISliderLayout.Horizontal )
			trackyPos += (int)trackTI.frame.height / 2;
		else
			trackxPos += (int)trackTI.frame.width / 2;

		// create a knob using our cacluated position
		var knob = manager.addSprite( knobFilename, trackxPos, trackyPos, 1, true );
		
		return new UISlider( manager, trackFrame, 2, trackTI.uvRect, knob, layout, trackTI.rotated );
	}
	public UIVerticalPanel( UIToolkit manager, string topFilename, string middleFilename, string bottomFilename ) : base( UILayoutType.Vertical )
	{
		var texInfo = manager.textureInfoForFilename( topFilename );
		_topStrip = manager.addSprite( topFilename, 0, 0, 5 );
		_topStrip.parentUIObject = this;
		_topStripHeight = (int)texInfo.frame.height;
		_width = texInfo.frame.width;
		
		// we overlap the topStrip 1 pixel to ensure we get a good blend here
		_middleStrip = manager.addSprite( middleFilename, 0, _topStripHeight , 5 );
		_middleStrip.parentUIObject = this;
		
		texInfo = manager.textureInfoForFilename( middleFilename );
		_bottomStrip = manager.addSprite( bottomFilename, 0, 0, 5 );
		_bottomStrip.parentUIObject = this;
		_bottomStripHeight = (int)texInfo.frame.height;
	}
Ejemplo n.º 42
0
	public UIText( UIToolkit manager, string fontFilename, string textureFilename )
	{
		_manager = manager;
		_fontDetails = new UIFontCharInfo[256];
		for( int i = 0; i < _fontDetails.Length; i++ )
			_fontDetails[i] = new UIFontCharInfo();
		
		loadConfigfile( fontFilename );
		
		// grab the texture offset from the UI
		var rect = _manager.frameForFilename( textureFilename );
		
		// Since the font config data adjusts for padding, but TexturePacker trimming removes it,
		// We need to sub out the trimmed amount coming back from the manager.
		var info = _manager.textureInfoForFilename( textureFilename );
		
		this._textureOffset = new Vector2( rect.x - info.spriteSourceSize.x, rect.y - info.spriteSourceSize.y );
	}
Ejemplo n.º 43
0
    public UIVerticalPanel(UIToolkit manager, string topFilename, string middleFilename, string bottomFilename) : base(UILayoutType.Vertical)
    {
        var texInfo = manager.textureInfoForFilename(topFilename);

        _topStrip = manager.addSprite(topFilename, 0, 0, 5);
        _topStrip.parentUIObject = this;
        _topStripHeight          = (int)texInfo.frame.height;
        _width = texInfo.frame.width;

        // we overlap the topStrip 1 pixel to ensure we get a good blend here
        _middleStrip = manager.addSprite(middleFilename, 0, _topStripHeight, 5);
        _middleStrip.parentUIObject = this;

        texInfo      = manager.textureInfoForFilename(middleFilename);
        _bottomStrip = manager.addSprite(bottomFilename, 0, 0, 5);
        _bottomStrip.parentUIObject = this;
        _bottomStripHeight          = (int)texInfo.frame.height;
    }
	public UIText( UIToolkit manager, string fontFilename, string textureFilename )
	{
		_manager = manager;
		_fontDetails = new UIFontCharInfo[256];
		for( int i = 0; i < _fontDetails.Length; i++ )
			_fontDetails[i] = new UIFontCharInfo();
		
		loadConfigfile( fontFilename );
		
		// grab the texture offset from the UI
		var rect = _manager.frameForFilename( textureFilename );
		
		// Since the font config data adjusts for padding, but TexturePacker trimming removes it,
		// We need to sub out the trimmed amount coming back from the manager.
		var info = _manager.textureInfoForFilename( textureFilename );
		
		this._textureOffset = new Vector2( rect.x - info.spriteSourceSize.x, rect.y - info.spriteSourceSize.y );
	}
    public UIProgressBar(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, bool rightToLeft) : base(frame, depth, uvFrame)
    {
        manager.addSprite(this);

        // Save the bars original size
        _barOriginalWidth   = frame.width;
        _barOriginalUVframe = uvFrame;
        this.rightToLeft    = rightToLeft;

        // Update the bar size based on the value
        if (rightToLeft)
        {
            setSize(_value * -_barOriginalWidth, frame.height);
        }
        else
        {
            setSize(_value * _barOriginalWidth, frame.height);
        }
    }
Ejemplo n.º 46
0
    public UIJoystick(UIToolkit manager, Rect frame, int depth, UISprite joystickSprite, float xPos, float yPos) : base(frame, depth, UIUVRect.zero)
    {
        // Save out the uvFrame for the sprite so we can highlight
        _normalUVframe = joystickSprite.uvFrame;

        // Save the joystickSprite and make it a child of the us for organization purposes
        _joystickSprite = joystickSprite;
        _joystickSprite.parentUIObject = this;

        // Move the joystick to its default position after converting the offset to a vector3
        _joystickOffset = new Vector3(xPos, yPos);

        // Set the maxMovement which will in turn calculate the _joystickBoundary
        this.maxJoystickMovement = _maxJoystickMovement;

        resetJoystick();

        manager.addTouchableSprite(this);
        _manager = manager;
    }
Ejemplo n.º 47
0
    public static UIStateButton create(UIToolkit manager, string[] filenames, string[] highlightedFilenames, int xPos, int yPos, int depth)
    {
        // grab the texture details for the initial state
        var firstNormalTI = manager.textureInfoForFilename(filenames[0]);
        var frame         = new Rect(xPos, yPos, firstNormalTI.frame.width, firstNormalTI.frame.height);

        // get the initial highlighted state
        var firstHighlightedTI = firstNormalTI;

        if (highlightedFilenames.Length > 0)
        {
            manager.textureInfoForFilename(highlightedFilenames[0]);
        }

        var button = new UIStateButton(manager, frame, depth, firstNormalTI.uvRect, firstHighlightedTI.uvRect);

        button.addFrames(filenames, highlightedFilenames);

        return(button);
    }
Ejemplo n.º 48
0
    public static UISprite createTextWrapper(UIToolkit uiTools, UITextInstance text, UIAbstractContainer layout)
    {
        // Get the right wrapping for the text
        setTextLayoutWrap(layout, text);

        // Create the wrapper and scale it
        // TODO: Check if empty.png exists if not then throw a clear error.
        UISprite textWrapper = uiTools.addSprite("empty.png", 0, 0);

        textWrapperScale(layout, textWrapper, text);

        // Make the text a child of the wrapper
        text.parentUIObject  = textWrapper;
        textWrapper.userData = text;

        textPositionInWrapper(text);

        // Return the wrapper
        return(textWrapper);
    }
Ejemplo n.º 49
0
    public static UIScrollableVerticalLayout createScrollableLayout(UIToolkit toolkit, Vector2 size)
    {
        UIScrollableVerticalLayout layout = new UIScrollableVerticalLayout(0);

        layout.alignMode = UIAbstractContainer.UIContainerAlignMode.Left;
        layout.positionFromBottom(0);           // Position it at the bottom of the screen to keep it out of the view.
        layout.edgeInsets = new UIEdgeInsets(0, 0, 0, 10);
        layout.setSize(size.x, size.y);

        // Create the scrollbar
        UIVerticalPanel scrollbar  = UIVerticalPanel.create(toolkit, "scrollbar_top.png", "scrollbar_mid.png", "scrollbar_bottom.png");
        int             spacerSize = 16;

        hd(ref spacerSize);
        UISpacer spacer = new UISpacer(spacerSize, spacerSize);

        scrollbar.addChild(spacer);

        layout.addScrollBar(scrollbar, spacer);
        return(layout);
    }
Ejemplo n.º 50
0
    public UIVerticalPanel(UIToolkit manager, string topFilename, string middleFilename, string bottomFilename) : base(UILayoutType.Vertical)
    {
        var texInfo = manager.textureInfoForFilename(topFilename);

        _topStrip = manager.addSprite(topFilename, 0, 0, 5);
        _topStrip.parentUIObject = this;
        _topStripHeight          = (int)texInfo.frame.height;
        _width = texInfo.frame.width;

        // we overlap the topStrip 1 pixel to ensure we get a good blend here
        _middleStrip = manager.addSprite(middleFilename, 0, _topStripHeight, 5);
        _middleStrip.parentUIObject = this;

        texInfo      = manager.textureInfoForFilename(middleFilename);
        _bottomStrip = manager.addSprite(bottomFilename, 0, 0, 5);
        _bottomStrip.parentUIObject = this;
        _bottomStripHeight          = (int)texInfo.frame.height;

        // HACK: Gabo edit. Adding the sprites uiChildArray so they can be deleted
        addUIChild(_topStrip, _middleStrip, _bottomStrip);
    }
Ejemplo n.º 51
0
    // the knobs x/y coordinates should be relative to the tracks and it is measured from the center of the knob
    public static UISlider create(UIToolkit manager, string knobFilename, string trackFilename, int trackxPos, int trackyPos, UISliderLayout layout)
    {
        // create the track first so we can use its dimensions to position the knob
        var trackTI    = manager.textureInfoForFilename(trackFilename);
        var trackFrame = new Rect(trackxPos, trackyPos, trackTI.size.x, trackTI.size.y);

        // position the knob based on the knobs size, layout and the track size
        if (layout == UISliderLayout.Horizontal)
        {
            trackyPos += (int)trackTI.size.y / 2;
        }
        else
        {
            trackxPos += (int)trackTI.size.x / 2;
        }

        // create a knob using our cacluated position
        var knob = manager.addSprite(knobFilename, trackxPos, trackyPos, 1, true);

        return(new UISlider(manager, trackFrame, 2, trackTI.uvRect, knob, layout));
    }
    //constructor
    public UIPeaceMakerActor(UIToolkit toolkit, string actorName, string fileName)
    {
        //todo make this scalable
        _height = 50;         //background image size
        _width  = 50;

        _touchFrame = new Rect(position.x, -position.y, _width, _height);


        //background image is always the same
        _actorBackground = toolkit.addSprite("actorBG.png", 0, 0);
        _actorBackground.parentUIObject = this;
        _actorBackground.positionFromTopLeft(0f, 0f);


        //gradient is always the same
        _actorGradient = toolkit.addSprite("actor_gradient_white.png", 0, 0);
        _actorGradient.parentUIObject = this;
        _actorGradient.positionFromTopLeft(0f, 0f);


        //image and button
        _theButton = UIButton.create(toolkit, fileName, fileName, 0, 0);
        _theButton.parentUIObject   = this;
        _theButton.onTouchUpInside += (sender) => randomAttitudeTest();


        //up/down arrow is always the same
        _actorArrow = toolkit.addSprite("up_arrow_anim_00.png", 0, 0);
        _actorArrow.parentUIObject = this;
        _actorArrow.positionFromTopRight(0f, 0f);

        _arrowUpAnim               = _actorArrow.addSpriteAnimation("arrowUpAnim", 0.1f, "up_arrow_anim_00.png", "up_arrow_anim_01.png", "up_arrow_anim_02.png", "up_arrow_anim_03.png", "up_arrow_anim_04.png", "up_arrow_anim_05.png", "up_arrow_anim_06.png", "up_arrow_anim_07.png", "up_arrow_anim_08.png", "up_arrow_anim_09.png");
        _arrowDownAnim             = _actorArrow.addSpriteAnimation("arrowDownAnim", 0.1f, "down_arrow_anim_00.png", "down_arrow_anim_01.png", "down_arrow_anim_02.png", "down_arrow_anim_03.png", "down_arrow_anim_04.png", "down_arrow_anim_05.png", "down_arrow_anim_06.png", "down_arrow_anim_07.png", "down_arrow_anim_08.png", "down_arrow_anim_09.png");
        _arrowUpAnim.loopReverse   = true;
        _arrowDownAnim.loopReverse = true;

        hideAttitudeIndicators();
    }
Ejemplo n.º 53
0
    // the bars x/y coordinates should be relative to the borders
    public static UIProgressBar create(UIToolkit manager, string barFilename, string borderFilename, int barxPos, int baryPos, int borderxPos, int borderyPos, bool rightToLeft)
    {
        var borderTI = manager.textureInfoForFilename(borderFilename);

        var borderFrame = new Rect(borderxPos, borderyPos, borderTI.frame.width, borderTI.frame.height);

        UISprite bar;

        if (rightToLeft)
        {
            bar = manager.addSprite(barFilename, borderxPos - barxPos + ((int)borderTI.frame.width), borderyPos + baryPos, 2);
        }
        else
        {
            bar = manager.addSprite(barFilename, borderxPos + barxPos, borderyPos + baryPos, 2);
        }

        var progressBar = new UIProgressBar(manager, borderFrame, 1, borderTI.uvRect, bar);

        progressBar.rightToLeft = rightToLeft;

        return(progressBar);
    }
Ejemplo n.º 54
0
Archivo: UI.cs Proyecto: tadej/enkidu
 protected void OnDestroy()
 {
     instance     = null;
     firstToolkit = null;
 }
Ejemplo n.º 55
0
Archivo: UI.cs Proyecto: tadej/enkidu
 // Ensures that the instance is destroyed when the game is stopped
 protected void OnApplicationQuit()
 {
     instance     = null;
     firstToolkit = null;
 }
Ejemplo n.º 56
0
 public UIStateButton(UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UIUVRect highlightedUVframe) : base(manager, frame, depth, uvFrame, highlightedUVframe)
 {
 }
Ejemplo n.º 57
0
 public static UIStateButton create(UIToolkit manager, string[] filenames, string[] highlightedFilenames, int xPos, int yPos)
 {
     return(UIStateButton.create(manager, filenames, highlightedFilenames, xPos, yPos, 1));
 }
Ejemplo n.º 58
0
 public static new UIContinuousButton create(UIToolkit manager, string filename, string highlightedFilename, int xPos, int yPos)
 {
     return(create(manager, filename, highlightedFilename, xPos, yPos, 1));
 }
Ejemplo n.º 59
0
Archivo: UI.cs Proyecto: tadej/enkidu
    private void Awake()
    {
        // Set instance to this so we can be accessed from anywhere
        instance = this;

        // add the audio source if we dont have one and cache it
        _audioSource = GetComponent <AudioSource>();
        if (_audioSource == null)
        {
            _audioSource = gameObject.AddComponent <AudioSource>();
        }

        // Create the camera
        _uiCameraHolder = new GameObject();
        _uiCameraHolder.transform.parent = gameObject.transform;
        _uiCameraHolder.AddComponent <Camera>(  );

        _uiCamera                  = _uiCameraHolder.GetComponent <Camera>();
        _uiCamera.name             = "UICamera";
        _uiCamera.clearFlags       = CameraClearFlags.Depth;
        _uiCamera.nearClipPlane    = 0.3f;
        _uiCamera.farClipPlane     = 50.0f;
        _uiCamera.depth            = drawDepth;
        _uiCamera.rect             = new Rect(0.0f, 0.0f, 1.0f, 1.0f);
        _uiCamera.orthographic     = true;
        _uiCamera.orthographicSize = Screen.height / 2;

        // Set the camera position based on the screenResolution/orientation
        _uiCamera.transform.position = new Vector3(Screen.width / 2, -Screen.height / 2, -10.0f);
        _uiCamera.cullingMask        = UILayer;

        // Cache the layer for later use when adding sprites
        // UILayer.value is a mask, find which bit is set
        for (int i = 0; i < sizeof(int) * 8; i++)
        {
            if ((UILayer.value & (1 << i)) == (1 << i))
            {
                layer = i;
                break;
            }
        }

        // setup the HD flag
        // handle texture loading if required
#if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER || UNITY_ANDROID || UNITY_STANDALONE_LINUX
        var deviceAllowsHD = true;
#else
        var deviceAllowsHD = (allowPod4GenHD && iPhone.generation == iPhoneGeneration.iPodTouch4Gen) || iPhone.generation != iPhoneGeneration.iPodTouch4Gen;
#endif
        if (autoTextureSelectionForHD && deviceAllowsHD)
        {
            // are we loading up a 4x texture?
            if (Screen.width >= maxWidthOrHeightForHD || Screen.height >= maxWidthOrHeightForHD)
            {
#if UNITY_EDITOR
                Debug.Log("switching to 4x GUI texture");
#endif
                isHD        = true;
                scaleFactor = 4;
                hdExtension = "4x";
            }
            // are we loading up a 2x texture?
            else if (Screen.width >= maxWidthOrHeightForSD || Screen.height >= maxWidthOrHeightForSD)
            {
#if UNITY_EDITOR
                Debug.Log("switching to 2x GUI texture");
#endif
                isHD        = true;
                scaleFactor = 2;
            }
        }

        // grab all our child UIToolkits
        _toolkitInstances = GetComponentsInChildren <UIToolkit>();
        firstToolkit      = _toolkitInstances[0];
#if UNITY_EDITOR
        if (_toolkitInstances.Length == 0)
        {
            throw new System.Exception("Could not find any UIToolkit instances in children of UI");
        }
#endif

        // kick off the loading of texture for any UIToolkits we have
        foreach (var toolkit in _toolkitInstances)
        {
            toolkit.loadTextureAndPrepareForUse();
        }
    }
Ejemplo n.º 60
0
 public static UIVerticalPanel create(UIToolkit manager, string topFilename, string middleFilename, string bottomFilename)
 {
     return(new UIVerticalPanel(manager, topFilename, middleFilename, bottomFilename));
 }