예제 #1
0
파일: Font.cs 프로젝트: Jypeli-JYU/Jypeli
 private void DoLoad()
 {
     if (fontsystem == null)
     {
         if (settings == null)
         {
             settings = new FontSystemSettings();
         }
         fontsystem = new FontSystem(settings);
         if (source == ContentSource.GameContent)
         {
             fontsystem.AddFont(Game.Device.StreamContent(name, FontExtensions));
         }
         else
         {
             fontsystem.AddFont(Game.ResourceContent.StreamInternalFont(name));
         }
         font = fontsystem.GetFont(Size);
         GenerateCommonGlyphs();
     }
 }
예제 #2
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            KeyboardUtils.Begin();

            if (KeyboardUtils.IsPressed(Keys.Tab))
            {
                var i = 0;

                for (; i < _fontSystems.Length; ++i)
                {
                    if (_currentFontSystem == _fontSystems[i])
                    {
                        break;
                    }
                }

                ++i;
                if (i >= _fontSystems.Length)
                {
                    i = 0;
                }

                _currentFontSystem = _fontSystems[i];
            }

            if (KeyboardUtils.IsPressed(Keys.Enter))
            {
                _currentFontSystem.UseKernings = !_currentFontSystem.UseKernings;
            }

            if (KeyboardUtils.IsPressed(Keys.LeftShift))
            {
                _animatedScaling = !_animatedScaling;
            }

            KeyboardUtils.End();
        }
예제 #3
0
        protected override void OnKeyDown(IKeyboard sender, Key key, int n)
        {
            base.OnKeyDown(sender, key, n);

            switch (key)
            {
            case Key.Space:
                _drawBackground = !_drawBackground;
                break;

            case Key.Tab:
                var i = 0;

                for (; i < _fontSystems.Length; ++i)
                {
                    if (_currentFontSystem == _fontSystems[i])
                    {
                        break;
                    }
                }

                ++i;
                if (i >= _fontSystems.Length)
                {
                    i = 0;
                }

                _currentFontSystem = _fontSystems[i];
                break;

            case Key.Enter:
                _currentFontSystem.UseKernings = !_currentFontSystem.UseKernings;
                break;

            case Key.ShiftLeft:
                _animatedScaling = !_animatedScaling;
                break;
            }
        }
예제 #4
0
        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);

            //Create the different managers
            _chargeBar = new ChargeBar(this, SpriteBatch, Graphics, new Vector2((1900 * Window.ClientBounds.Width) / 1980, (1100 * Window.ClientBounds.Height) / 1080));

            _sound = new SoundManager(this);

            _manager = new GameManager(this);
            _manager.AddPlayer(new Player(this, "jojo", "ball_red", new Vector3(0, -20, 0)));
            _manager.LoadGame(1);

            //Create cameras responsible of following the ball
            CameraClassic = new Camera(Vector3.Zero, 0, 0,
                                       BEPUutilities.Matrix.CreatePerspectiveFieldOfViewRH(MathHelper.PiOver4,
                                                                                           Graphics.PreferredBackBufferWidth / (float)Graphics.PreferredBackBufferHeight, .1f, 10000));
            Camera = new ChaseCameraControlScheme(_manager.Space.Entities[0], new Vector3(0, 7, 0), false, 50f, CameraClassic,
                                                  this);

            //Adding event for sound managing
            _manager.MainPlayer.Ball.Form.CollisionInformation.Events.ContactCreated            += Events_ContactCreated;
            _manager.MainPlayer.Ball.Form.CollisionInformation.Events.DetectingInitialCollision += Events_DetectingInitialCollision;
            _manager.MainPlayer.Ball.Form.CollisionInformation.Events.CollisionEnded            += Events_CollisionEnded;

            //Loading font and background for HUD
            FontSystem fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048);

            fontSystem.AddFont(TitleContainer.OpenStream($"{Content.RootDirectory}/font-file.ttf"));

            _background = Content.Load <Texture2D>("Sprites/background_menu");

            //Setup the HUD
            GuiHelper.Setup(this, fontSystem);

            _hudFont = Content.Load <SpriteFont>("Hud");

            _ui = new IMGUI();
        }
예제 #5
0
        protected override void OnLoad()
        {
            graphicsDevice.ClearColor = new Vector4(0.3f, 0.6f, 0.9f, 1);

            var data = new byte[] { 255, 255, 255, 255 };

            _white = new Texture2D(graphicsDevice, 1, 1);
            _white.SetData <byte>(data, 0, 0, 1, 1, PixelFormat.Rgba);

            _renderer = new TrippyRenderer(graphicsDevice);

            var textureManager = new TrippyTexture2DManager(graphicsDevice);
            var fontSystems    = new List <FontSystem>();

            // Simple
            var fontSystem = new FontSystem(textureManager, 1024, 1024);

            LoadFontSystem(fontSystem);
            fontSystems.Add(fontSystem);

            // Blurry
            var blurryFontSystem = new FontSystem(textureManager, 1024, 1024, EffectAmount);

            LoadFontSystem(blurryFontSystem);
            fontSystems.Add(blurryFontSystem);

            // Stroked
            var strokedFontSystem = new FontSystem(textureManager, 1024, 1024, 0, EffectAmount);

            LoadFontSystem(strokedFontSystem);
            fontSystems.Add(strokedFontSystem);

            _fontSystems       = fontSystems.ToArray();
            _currentFontSystem = _fontSystems[0];

            GC.Collect();
        }
예제 #6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            var fontSystems    = new List <FontSystem>();
            var textureCreator = new Texture2DManager(GraphicsDevice);

            _renderer = new Renderer(_spriteBatch);

            // Simple
            var fontSystem = new FontSystem(textureCreator, 1024, 1024);

            LoadFontSystem(fontSystem);
            fontSystems.Add(fontSystem);

            // Blurry
            var blurryFontSystem = new FontSystem(textureCreator, 1024, 1024, EffectAmount);

            LoadFontSystem(blurryFontSystem);
            fontSystems.Add(blurryFontSystem);

            // Stroked
            var strokedFontSystem = new FontSystem(textureCreator, 1024, 1024, 0, EffectAmount);

            LoadFontSystem(strokedFontSystem);
            fontSystems.Add(strokedFontSystem);

            _fontSystems       = fontSystems.ToArray();
            _currentFontSystem = _fontSystems[0];

            _white = new Texture2D(GraphicsDevice, 1, 1);
            _white.SetData(new[] { Color.White });

            GC.Collect();
        }
예제 #7
0
        public void CacheNull()
        {
            var fontSystem = new FontSystem();

            fontSystem.AddFont(TestsEnvironment.Assembly.ReadResourceAsBytes("Resources.DroidSans.ttf"));

            var font = fontSystem.GetFont(32);

            // Such symbol doesnt exist in ttf
            var codePoint = 12345678;

            // Shouldn't exist
            DynamicFontGlyph glyph;

            Assert.IsFalse(font.Glyphs.TryGetValue(codePoint, out glyph));

            glyph = (DynamicFontGlyph)font.GetGlyph(TestsEnvironment.GraphicsDevice, codePoint);

            // Now it should exist
            Assert.IsTrue(font.Glyphs.TryGetValue(codePoint, out glyph));

            // And should be equal to null too
            Assert.AreEqual(glyph, null);
        }
예제 #8
0
 /// <summary>
 /// Usually called once in a game's LoadContent.
 /// </summary>
 /// <param name="game">Game instance.</param>
 /// <param name="fontSystem">The font system to use for the UI.</param>
 public static void Setup(Game game, FontSystem fontSystem)
 {
     InputHelper.Setup(game);
     FontSystem  = fontSystem;
     SpriteBatch = new SpriteBatch(game.GraphicsDevice);
 }
예제 #9
0
 public AssetManager(ContentManager iContent)
 {
     _content   = iContent;
     FontSystem = new FontSystem();
     FontSystem.AddFont(TitleContainer.OpenStream($"{_content.RootDirectory}/Jura-Bold.ttf"));
 }
예제 #10
0
파일: Font.cs 프로젝트: giusdp/WForest
 /// <summary>
 /// Creates a Font with a FontSystem.
 /// </summary>
 /// <param name="fontSystem"></param>
 public Font(FontSystem fontSystem)
 {
     _fontSystem = fontSystem;
 }
예제 #11
0
        private static FontSystem InternalCreate(int textureWidth, int textureHeight, int blurAmount, int strokeAmount, bool premultiplyAlpha)
        {
            var result = new FontSystem(StbTrueTypeSharpFontLoader.Instance, MyraEnvironment.Platform, textureWidth, textureHeight, blurAmount, strokeAmount, premultiplyAlpha);

            return(result);
        }
예제 #12
0
 public static void LoadFonts(ContentManager content, GraphicsDevice graphicsDevice)
 {
     FontSystem = FontSystemFactory.Create(graphicsDevice, 2048, 2048);
     FontSystem.AddFont(TitleContainer.OpenStream($"{content.RootDirectory}/source-code-pro-medium.ttf"));
 }
 protected override void OnStartRunning()
 {
     base.OnStartRunning();
     fontSystem = World.GetExistingSystem <FontSystem>();
 }
예제 #14
0
        public override void Initialize()
        {
            base.Initialize();

            FontSystem = new FontSystem(GraphicsDevice);
        }
예제 #15
0
 private void LoadFontSystem(FontSystem result)
 {
     result.AddFont(File.ReadAllBytes(@"Fonts/DroidSans.ttf"));
     result.AddFont(File.ReadAllBytes(@"Fonts/DroidSansJapanese.ttf"));
     result.AddFont(File.ReadAllBytes(@"Fonts/Symbola-Emoji.ttf"));
 }
예제 #16
0
 public GameFontSystem(IServiceRegistry registry)
     : base(registry)
 {
     Visible    = true;
     FontSystem = new FontSystem();
 }
예제 #17
0
 public DynamicSpriteFont GetFont(float size)
 {
     return(FontSystem.GetFont((int)size));
 }