예제 #1
0
 public void ChangeTexture( int slot, ref SpriteTexture texture )
 {
     Textures[ slot ] = texture;
 }
예제 #2
0
 public void AddTexture(int slot, SpriteTexture texture)
 {
     AddTexture(slot, texture.TextureIndex, ref texture.PUV, ref texture.SUV);
 }
예제 #3
0
 // ChangeTexture
 public void ChangeTexture( int slot, string name, ref Vector2 puv, ref Vector2 suv )
 {
     Textures[ slot ] = new SpriteTexture( name, ref puv, ref suv );
 }
예제 #4
0
 public void ChangeTexture( int slot, string name, float pu, float pv, float su, float sv )
 {
     Textures[ slot ] = new SpriteTexture( name, pu, pv, su, sv );
 }
예제 #5
0
        // OnRender
        protected override void OnRender()
        {
            if (Textures.Count == 0)
            {
                return;
            }

            if (!ColorFinal.HasAlpha() && ((RenderState.BlendState == E_BlendState.AlphaBlend) || (RenderState.BlendState == E_BlendState.NonPremultiplied)))
            {
                return;
            }

            using (new AutoTransform(this))
            {
                // align
                Vector2 offset = _UI.Sprite.GetVertexOffsetAligned(0, Align);
                Vector3 pos    = Position;
                pos.X -= offset.X * Size.X;
                pos.Y -= offset.Y * Size.Y * UpY;

                // vertex positions
                float x0 = pos.X;
                float x1 = x0 + CornerSize.X;
                float x2 = x1 + Size.X - (CornerSize.X * 2.0f);
                float x3 = x2 + CornerSize.X;

                float y0 = pos.Y;
                float y1 = pos.Y + (CornerSize.Y * UpY);
                float y2 = y1 + (Size.Y - (CornerSize.Y * 2.0f)) * UpY;
                float y3 = y2 + (CornerSize.Y * UpY);

                // sizes
                float sx1x0 = x1 - x0;
                float sx2x1 = x2 - x1;
                float sx3x2 = x3 - x2;

                float sy1y0 = (y1 - y0) * UpY;
                float sy2y1 = (y2 - y1) * UpY;
                float sy3y2 = (y3 - y2) * UpY;

                // uvs
                SpriteTexture tex = Textures[0];

                float u0 = tex.PUV.X + (CornerPuv01.X / tex.SUV.X);
                float u1 = u0 + (CornerSuv01.X / tex.SUV.X);
                float u3 = tex.PUV.X + tex.SUV.X - (CornerPuv01.X / tex.SUV.X);
                float u2 = u3 - (CornerSuv01.X / tex.SUV.X);

                float v0 = tex.PUV.Y + (CornerPuv01.Y / tex.SUV.Y);
                float v1 = u0 + (CornerSuv01.Y / tex.SUV.Y);
                float v3 = tex.PUV.Y + tex.SUV.Y - (CornerPuv01.Y / tex.SUV.Y);
                float v2 = u3 - (CornerSuv01.Y / tex.SUV.Y);

                // uv sizes
                float su1u0 = u1 - u0;
                float su2u1 = u2 - u1;
                float su3u2 = u3 - u2;

                float sv1v0 = v1 - v0;
                float sv2v1 = v2 - v1;
                float sv3v2 = v3 - v2;

                // TL
                _UI.Sprite.AddSprite(RenderPass, Layer, x0, y0, pos.Z, sx1x0, sy1y0, E_Align.TopLeft, ref ColorFinal, ref RenderState);
                _UI.Sprite.AddTexture(0, tex.TextureIndex, u0, v0, su1u0, sv1v0);

                // TC
                _UI.Sprite.AddSprite(RenderPass, Layer, x1, y0, pos.Z, sx2x1, sy1y0, E_Align.TopLeft, ref ColorFinal, ref RenderState);
                _UI.Sprite.AddTexture(0, tex.TextureIndex, u1, v0, su2u1, sv1v0);

                // TR
                _UI.Sprite.AddSprite(RenderPass, Layer, x2, y0, pos.Z, sx3x2, sy1y0, E_Align.TopLeft, ref ColorFinal, ref RenderState);
                _UI.Sprite.AddTexture(0, tex.TextureIndex, u2, v0, su3u2, sv1v0);

                // ML
                _UI.Sprite.AddSprite(RenderPass, Layer, x0, y1, pos.Z, sx1x0, sy2y1, E_Align.TopLeft, ref ColorFinal, ref RenderState);
                _UI.Sprite.AddTexture(0, tex.TextureIndex, u0, v1, su1u0, sv2v1);

                // MC
                _UI.Sprite.AddSprite(RenderPass, Layer, x1, y1, pos.Z, sx2x1, sy2y1, E_Align.TopLeft, ref ColorFinal, ref RenderState);
                _UI.Sprite.AddTexture(0, tex.TextureIndex, u1, v1, su2u1, sv2v1);

                // MR
                _UI.Sprite.AddSprite(RenderPass, Layer, x2, y1, pos.Z, sx3x2, sy2y1, E_Align.TopLeft, ref ColorFinal, ref RenderState);
                _UI.Sprite.AddTexture(0, tex.TextureIndex, u2, v1, su3u2, sv2v1);

                // BL
                _UI.Sprite.AddSprite(RenderPass, Layer, x0, y2, pos.Z, sx1x0, sy3y2, E_Align.TopLeft, ref ColorFinal, ref RenderState);
                _UI.Sprite.AddTexture(0, tex.TextureIndex, u0, v2, su1u0, sv3v2);

                // BC
                _UI.Sprite.AddSprite(RenderPass, Layer, x1, y2, pos.Z, sx2x1, sy3y2, E_Align.TopLeft, ref ColorFinal, ref RenderState);
                _UI.Sprite.AddTexture(0, tex.TextureIndex, u1, v2, su2u1, sv3v2);

                // BR
                _UI.Sprite.AddSprite(RenderPass, Layer, x2, y2, pos.Z, sx3x2, sy3y2, E_Align.TopLeft, ref ColorFinal, ref RenderState);
                _UI.Sprite.AddTexture(0, tex.TextureIndex, u2, v2, su3u2, sv3v2);
            }     // auto transform
        }
예제 #6
0
 protected override void OnChange(float valueDiff)
 {
     SpriteTexture t = Widget.GetTexture(Slot); t.SUV.Y += valueDiff; Widget.ChangeTexture(Slot, ref t);
 }
예제 #7
0
 public void ChangeTexture(int slot, ref SpriteTexture texture)
 {
     Textures[slot] = texture;
 }
예제 #8
0
 public void ChangeTexture(int slot, string name, float pu, float pv, float su, float sv)
 {
     Textures[slot] = new SpriteTexture(name, pu, pv, su, sv);
 }
예제 #9
0
 // ChangeTexture
 public void ChangeTexture(int slot, string name, ref Vector2 puv, ref Vector2 suv)
 {
     Textures[slot] = new SpriteTexture(name, ref puv, ref suv);
 }
예제 #10
0
	public void AddTexture( int slot, SpriteTexture texture )
	{
		AddTexture( slot, texture.TextureIndex, ref texture.PUV, ref texture.SUV );
	}
예제 #11
0
    // Startup
    public override void Startup( ContentManager content )
    {
        _UI.Startup( _G.Game, _G.GameInput );

        // load textures
        int bundleIndex = _UI.Texture.CreateBundle();

        _UI.Texture.Add( bundleIndex, "Textures\\UI_Box", "box" );
        _UI.Texture.Add( bundleIndex, "Textures\\UI_Shine", "shine" );
        _UI.Texture.Add( bundleIndex, "Textures\\UI_Buttons", "buttons" );
        _UI.Texture.Add( bundleIndex, "Textures\\UI_FontMult", "font_mult" );
        _UI.Texture.Add( bundleIndex, "Textures\\UI_DebugMenu", "debug_menu" );
        _UI.Texture.Add( bundleIndex, "Textures\\tick", "tick" );

        _UI.Texture.Add( bundleIndex, "Textures\\World_1", "world_1" );
        _UI.Texture.Add( bundleIndex, "Textures\\World_2", "world_2" );
        _UI.Texture.Add( bundleIndex, "Textures\\World_3", "world_3" );
        _UI.Texture.Add( bundleIndex, "Textures\\World_4", "world_4" );

        _UI.Texture.Add( bundleIndex, "Textures\\MM_NewGame", "mm_newgame" );
        _UI.Texture.Add( bundleIndex, "Textures\\MM_LevelSelect", "mm_levelselect" );
        _UI.Texture.Add( bundleIndex, "Textures\\MM_Options", "mm_options" );
        _UI.Texture.Add( bundleIndex, "Textures\\MM_Quit", "mm_quit" );

        _UI.Texture.Add( bundleIndex, "Textures\\CompanyLogo", "company_logo" );
        _UI.Texture.Add( bundleIndex, "Textures\\GameLogo", "game_logo" );

        // load fonts
        _UI.Font.Add( "Fonts\\", "Verdana" );
        _UI.Font.Add( "Fonts\\", "Impact" );

        // everyone has initial control
        _UI.PrimaryPad = -1;

        // setup colors
        _UI.Store_Color.Add( "Blue", 0xff0000ff );
        _UI.Store_Color.Add( "Red", 0xffff0000 );

        // setup timelines
        UI.Timeline timelineText = new UI.Timeline( "selected", false, 0.0f, 0.25f, UI.E_TimerType.Stop, UI.E_RestType.Start );
        timelineText.AddEffect( new UI.TimelineEffect_ColorLerp( Color.Orange, UI.E_LerpType.SmoothStep ) );
        _UI.Store_Timeline.Add( "text_selected_color", timelineText );

        UI.Timeline timeline_StartAlpha = new UI.Timeline( "start", false, 0.0f, 0.25f, UI.E_TimerType.Stop, UI.E_RestType.Start );
        timeline_StartAlpha.AddEffect( new UI.TimelineEffect_Alpha( -1.0f, 0.0f, UI.E_LerpType.SmoothStep ) );
        _UI.Store_Timeline.Add( "text_start_alpha", timeline_StartAlpha );

        // setup textures
        UI.SpriteTexture texture = new UI.SpriteTexture( "buttons", 0.0f, 0.0f, 0.5f, 1.0f );
        _UI.Store_Texture.Add( "buttons_half", texture );

        // setup font styles
        UI.FontStyle fontStyle = new UI.FontStyle( "Impact" );
        fontStyle.AddRenderPass( new UI.FontStyleRenderPass() );
        _UI.Store_FontStyle.Add( "Default", fontStyle );

        UI.FontStyle fontStyleDS = new UI.FontStyle( "Impact" );
        UI.FontStyleRenderPass renderPassDS = new UI.FontStyleRenderPass();
        renderPassDS.ColorOverride = Color.Black;
        renderPassDS.AlphaMult = 0.5f;
        renderPassDS.Offset = new Vector3( 0.05f, -0.05f, 0.0f );
        renderPassDS.OffsetProportional = true;
        fontStyleDS.AddRenderPass( renderPassDS );
        fontStyleDS.AddRenderPass( new UI.FontStyleRenderPass() );
        _UI.Store_FontStyle.Add( "DefaultDS", fontStyleDS );

        // setup font effects
        UI.FontEffect fontEffect = new UI.FontEffect_Scale( 0.0625f, 0.25f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f, UI.E_LerpType.Sin );
        _UI.Store_FontEffect.Add( "menu_item_scale", fontEffect );

        // setup font icons
        _UI.Store_FontIcon.Add( "A", new UI.FontIcon( _UI.Texture.Get( "buttons" ), 0.0f, 0.0f, ( 64.0f / 820.0f ), 1.0f ) );
        _UI.Store_FontIcon.Add( "B", new UI.FontIcon( _UI.Texture.Get( "buttons" ), ( 63.0f / 820.0f ), 0.0f, ( 64.0f / 820.0f ), 1.0f ) );
        _UI.Store_FontIcon.Add( "X", new UI.FontIcon( _UI.Texture.Get( "buttons" ), ( 126.0f / 820.0f ), 0.0f, ( 64.0f / 820.0f ), 1.0f ) );
        _UI.Store_FontIcon.Add( "Y", new UI.FontIcon( _UI.Texture.Get( "buttons" ), ( 189.0f / 820.0f ), 0.0f, ( 64.0f / 820.0f ), 1.0f ) );

        // setup widgets
        UI.WidgetText text = new UI.WidgetText();
        text.ColorBase = Color.White;
        text.Align = UI.E_Align.TopCentre;
        text.Position = new Vector3( 0.0f, 18.0f, 0.0f );
        text.Size = new Vector3( 0.0f, 3.0f, 0.0f );
        text.Alpha = 0.5f;
        text.FontStyleName = "Default";
        text.AddTimeline( "text_start_alpha" );
        text.RenderPass = 1;
        _UI.Store_Widget.Add( "font_effect_text", text );

        // set initial screen
        PlayState = E_PlayState.TestUI;

        if ( PlayState == E_PlayState.GameWorld )
        {
            _G.Game.DoLayerUpdate( E_Layer.LevelEditor, false );
            _G.Game.DoLayerRender( E_Layer.LevelEditor, false );
            _UI.Screen.AddScreen( new UI.HUD() );
        }
        else
        if ( PlayState == E_PlayState.LevelEditor )
        {
            _G.Game.DoLayerUpdate( E_Layer.GameWorld, false );
            _G.Game.DoLayerRender( E_Layer.GameWorld, false );
            _UI.Screen.AddScreen( new UI.LevelEditorHUD() );
        }
        else
        if ( PlayState == E_PlayState.TestUI )
        {
            _G.Game.DoLayerUpdate( E_Layer.GameWorld, false );
            _G.Game.DoLayerRender( E_Layer.GameWorld, false );
            _G.Game.DoLayerUpdate( E_Layer.LevelEditor, false );
            _G.Game.DoLayerRender( E_Layer.LevelEditor, false );
            _UI.Screen.AddScreen( new UI.Test() );
        }
    }