// CONSTRUCTOR ----------------------------------------------------------------------------
        public ButtonEntity( string pLabel, Scene pScene, GamePhysics pGamePhysics, TextureInfo pTextureInfo, Vector2i pTileIndex2D )
            : base(pScene, pGamePhysics, pTextureInfo, pTileIndex2D, null)
        {
            halfWidth = Width / 2.0f;
            halfHeight = Height / 2.0f;
            labelOffset = new Vector2(0.1f, 0.25f);
            this.setPivot(0.5f,0.5f);

            font = Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25);
            map = Crystallography.UI.FontManager.Instance.GetMap( font );
            if ( pLabel != null ) {
                label = new Label( pLabel, map );
                label.Pivot = new Vector2(0.15f, 0.25f );
                label.Scale = new Vector2(1.0f/this.Width,1.0f/this.Height);
            }

            this.getNode().AddChild(label);

            labelOffset = Vector2.Zero;
            status = NORMAL;
            _onToggle = false;
            _pressed = false;
            _initialized = false;

            #if DEBUG
            Console.WriteLine(GetType().ToString() + " created" );
            #endif
        }
 // OVERRIDES -----------------------------------------------------------------------------------------------------------------------
 public override void OnExit()
 {
     base.OnExit ();
     this.RemoveAllChildren(true);
     BenIcon = null;
     MegIcon = null;
     NixIcon = null;
     BenText = null;
     MegText = null;
     NixText = null;
     Map = null;
 }
Esempio n. 3
0
        // EVENT HANDLERS -----------------------------------------------------------------------
        // OVERRIDES ----------------------------------------------------------------------------
        public override void OnExit()
        {
            Background = null;
            for( int i=0; i<Icons.Length; i++) {
                Icons[i] = null;
            }
            Icons = null;
            LevelNumberText = null;
            //			Label TapToDismiss = null;
            map = null;
            QualityNames.Clear();

            base.OnExit ();
            RemoveAllChildren(true);
        }
        // CONSTRUCTOR ---------------------------------------------------------------------------------------------------------------------
        public CreditsPanel()
        {
            Map = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Regular") );

            BenIcon = Support.SpriteFromFile("/Application/assets/images/UI/icons/tie.png");
            BenIcon.Position = new Vector2(302.0f, 184.0f);
            this.AddChild( BenIcon );

            BenText = new Label(){
                Text = "ben johnson",
                Position = new Vector2(113.0f, 186.0f),
                Color = Colors.White,
                FontMap = Map
            };
            this.AddChild( BenText );

            MegIcon = Support.SpriteFromFile("/Application/assets/images/UI/icons/phones.png");
            MegIcon.Position = new Vector2(536.0f, 96.0f);
            this.AddChild( MegIcon );

            MegText = new Label(){
                Text = "margaret schedel",
                Position = new Vector2(272.0f, 100.0f),
                Color = Colors.White,
                FontMap = Map
            };
            this.AddChild( MegText );

            NixIcon = Support.SpriteFromFile("/Application/assets/images/UI/icons/glasses.png");
            NixIcon.Position = new Vector2(595.0f, 184.0f);
            this.AddChild( NixIcon );

            NixText = new Label(){
                Text = "phoenix perry",
                Position = new Vector2(385.0f, 186.0f),
                Color = Colors.White,
                FontMap = Map
            };
            this.AddChild( NixText );
        }
Esempio n. 5
0
        public ScorePanel( ICrystallonEntity pEntity, int pPoints )
        {
            InitializeWidget();

            ScoreLabel = new Sce.PlayStation.HighLevel.GameEngine2D.Label() {
                Text = pPoints.ToString()
            };
            var font = new Font("Application/assets/fonts/Bariol_Regular.otf", 25, FontStyle.Regular);
            var map = new FontMap(font);
            ScoreLabel.FontMap = map;
            ScoreLabel.Position = new Vector2(-4.0f, 10.0f);
            ScoreLabel.Color = Colors.White;
            ScoreLabel.HeightScale = 1.0f;
            ScoreLabel.Pivot = new Vector2(0.5f, 0.5f);
            Sequence sequence = new Sequence();
            sequence.Add( new DelayTime( 0.5f ) );
            sequence.Add ( new CallFunc( () => { pEntity.getNode().Parent.AddChild(ScoreLabel); } ) );

            //			ScoreText.Font = FontManager.Instance.Get ("Bariol", 20, "Bold");
            //			ScoreText.Text = pPoints.ToString();
            //			ScoreText.Alpha = 0.0f;
            //			_scoreTexture = new Texture2D((int)ScoreText.Width, (int)ScoreText.Height, false, PixelFormat.Rgba);
            //			ScoreText.RenderToTexture(_scoreTexture);
            //			_scoreTextureInfo = new TextureInfo(_scoreTexture);
            //			_scoreSprite = new SpriteUV(_scoreTextureInfo);
            //			_scoreSprite.Pivot = new Vector2(0.5f, 0.5f);
            //			pEntity.getNode().AddChild(_scoreSprite);
            //			_scoreSprite.Position = new Vector2(0.0f, 20.0f);
            //			Vector2 v = ConvertScreenToLocal( pPosition );
            //			this.SetPosition( v.X - ScoreText.Width/2, Director.Instance.GL.Context.GetViewport().Height - (v.Y + 40) );
            //			Sequence sequence = new Sequence();
            //			sequence.Add( new DelayTime( 3.0f ) );
            //			sequence.Add ( new CallFunc( () => {
            //				ScoreText.Visible = false;
            //				this.Dispose();
            //			} ) );
            Director.Instance.CurrentScene.RunAction(sequence);
        }
Esempio n. 6
0
        public UI()
        {
            // アドホックに描画する関数を指定する
            this.AdHocDraw += this.Draw;

            // ラベルの作成
            BossDamage = new Sce.PlayStation.HighLevel.GameEngine2D.Label ();
            PlayerDamage = new Sce.PlayStation.HighLevel.GameEngine2D.Label ();

            // TrueTypeフォントの読み込み
            Font = new Font ("/Application/assets/IndieFlower.ttf", 48, FontStyle.Bold);
            FontMap = new FontMap (Font);

            // フォントの設定
            BossDamage.FontMap = FontMap;
            PlayerDamage.FontMap = FontMap;

            // ラベル表示位置設定
            BossDamage.Position = new Vector2 (120.0f, Game.Instance.ScreenSize.Y - 40);
            PlayerDamage.Position = new Vector2 (120.0f, Game.Instance.ScreenSize.Y - 80);

            // ラベルをNodeに追加(ラベルが表示される)
            this.AddChild (BossDamage);
            this.AddChild (PlayerDamage);
        }
 protected void CheckMapCache( string pKey, Font font )
 {
     if (fontMapDict.ContainsKey( pKey ) ) {
         return;
     } else {
         var map = new FontMap( font );
         fontMapDict.Add( pKey, map );
     }
 }
Esempio n. 8
0
 /// <summary>This text draw function uses a FontMap object and SpriteRenderer's DefaultShader.</summary>
 /// <param name="str">The text to draw.</param>
 /// <param name="bottom_left_start_pos">The bottom left of the text rectangle, in world space/units.</param>
 /// <param name="char_height">The character height in world space/units.</param>
 /// <param name="draw">If false, don't draw anything, just return the Bounds2 used by the text.</param>
 /// <param name="fontmap">the fontmap object (that holds the texture).</param>
 public Bounds2 DrawTextWithFontMap(
     string str,
     Vector2 bottom_left_start_pos,
     float char_height,
     bool draw,
     FontMap fontmap
     )
 {
     return DrawTextWithFontMap(
         str,
         bottom_left_start_pos,
         char_height,
         draw,
         fontmap,
         (ISpriteShader)DefaultFontShader
         );
 }
Esempio n. 9
0
        /// <summary>This text draw function uses a FontMap object.</summary>
        /// <param name="str">The text to draw.</param>
        /// <param name="bottom_left_start_pos">The bottom left of the text rectangle, in world space/units.</param>
        /// <param name="char_height">The character height in world space/units.</param>
        /// <param name="draw">If false, don't draw anything, just return the Bounds2 used by the text.</param>
        /// <param name="fontmap">the fontmap object (that holds the texture).</param>
        /// <param name="shader">The shader defaults to SpriteRenderer.DefaultFontShader.</param>
        public Bounds2 DrawTextWithFontMap(
            string str,
            Vector2 bottom_left_start_pos,
            float char_height,
            bool draw,
            FontMap fontmap,
            ISpriteShader shader
            )
        {
            float scale = ( char_height / fontmap.CharPixelHeight );

            Vector2 spacing_in_pixels = new Vector2( 1.0f, 1.0f );
            Vector2 spacing = spacing_in_pixels * scale;

            Vector2 turtle = bottom_left_start_pos;

            Vector2 max = bottom_left_start_pos;
            float left = bottom_left_start_pos.X;

            if ( draw )
            {
                shader.SetUVTransform( ref Math.UV_TransformFlipV );
                BeginSprites( new TextureInfo( fontmap.Texture ), shader, str.Length );
            }

            for ( int i=0; i < str.Length; ++i )
            {
                if ( str[i] == '\n' )
                {
                    turtle -= new Vector2( 0.0f, char_height + spacing.Y );
                    turtle.X = left;
                    continue;
                }

                FontMap.CharData cdata;
                if ( !fontmap.TryGetCharData( str[i], out cdata ) )
                    continue;

                Vector2 scaled_char_size = cdata.PixelSize * scale;

                if ( draw )
                    AddSprite( turtle, new Vector2(scaled_char_size.X,0.0f), cdata.UV );

                turtle += new Vector2( scaled_char_size.X + spacing.X, 0.0f );

                max.X = FMath.Max( turtle.X, max.X );
                max.Y = FMath.Min( turtle.Y, max.Y );
            }

            if ( draw )
                EndSprites();

            return Bounds2.SafeBounds( bottom_left_start_pos + new Vector2( 0.0f, char_height ), max );
        }
Esempio n. 10
0
 /// <summary>Label constructor.</summary>
 /// <param name="text">The text to render.</param>
 /// <param name="fontmap">The font data used for rendering the text. If null, an embedded debug font will be used.</param>
 public Label( string text, FontMap fontmap = null )
 {
     Text = text;
     FontMap = fontmap;
 }
Esempio n. 11
0
        // METHODS ------------------------------------------------------------------------------
        protected void Initialize()
        {
            _initialized = true;

            Background = Support.SpriteFromFile("/Application/assets/images/LevelTitleBG.png");
            Background.Position = new Vector2(0.0f, 0.0f);
            this.AddChild(Background);

            this.Height = Background.CalcSizeInPixels().Y;
            this.Width = Background.CalcSizeInPixels().X;

            QualityNames = new List<Label>();
            map = Crystallography.UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 18, "Regular"));
            LevelNumberText = new Label(){
                Text = "00",
                FontMap = Crystallography.UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 102, "Bold")),
                Position = new Vector2( 44.0f, 250.0f),
            //				Color = new Vector4( 0.16078431f, 0.88627451f, 0.88627451f, 1.0f)
            };
            LevelNumberText.RegisterPalette(0);

            Background.AddChild(LevelNumberText);

            TapToDismissText = new Label() {
                Text = "tap to dismiss",
                FontMap = map,
                Position = new Vector2( 39.0f, 20.0f)
            };
            TapToDismissText.RegisterPalette(0);
            Background.AddChild(TapToDismissText);

            Icons = new SpriteTile[4];
            for( int i=0; i < Icons.Length; i++) {
                Icons[i] = Support.TiledSpriteFromFile("/Application/assets/images/icons/icons.png", 4, 2);
                float y = 176.0f - 88.0f * (float)System.Math.Floor(i/2.0f);
                Icons[i].Position = new Vector2( 44.0f + 68.0f*(i%2), y);
                Background.AddChild(Icons[i]);
                Icons[i].Visible = false;
            }
        }
 // OVERRIDES -----------------------------------------------------------------------------------------------------------------------
 public override void OnExit()
 {
     base.OnExit ();
     this.RemoveAllChildren(true);
     ThanksToText = null;
     ThanksNamesText = null;
     ColophonText = null;
     BigMap = null;
     MidMap = null;
     SmMap = null;
 }
        public ThanksPanel()
        {
            BigMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Bold") );
            MidMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25) );
            SmMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 14, "Regular") );

            ThanksToText = new Label() {
                Text = "thanks to",
                Position = new Vector2(32.0f, 245.0f),
                Color = Colors.White,
                FontMap = BigMap
            };
            this.AddChild( ThanksToText );

            ThanksNamesText = new Label() {
                Text = "indiecade, matt parker, nicolas fortugno, jim wallace and the psm team.",
                Position = new Vector2(32.0f, 205.0f),
                Color = Colors.White,
                FontMap = MidMap
            };
            this.AddChild( ThanksNamesText );

            ColophonText = new Label() {
            //				Text = "colophon: crystallon uses bariol and bariol bold by ismael gonzález gonzález & raúl garcía del pomar",
                Text = "colophon: crystallon uses bariol regular and bariol bold by ismael gonzalez gonzalez & raul garcia del pomar",
                Position = new Vector2(32.0f, 137.0f),
                Color = Colors.White,
                FontMap = SmMap
            };
            this.AddChild( ColophonText );
        }