示例#1
0
        public static void Setup(ContentManager content, GraphicsDevice graphicsDevice)
        {
            var FontSystem = FontSystemFactory.Create(graphicsDevice, 2048, 2048);

            FontSystem.AddFont(TitleContainer.OpenStream($"{content.RootDirectory}/source-code-pro-medium.ttf"));
            Font = FontSystem.GetFont(28);
        }
示例#2
0
        public void LoadContent(GraphicsDevice graphicsDevice)
        {
            fontSystem = FontSystemFactory.Create(graphicsDevice, 1024, 1024);
            fontSystem.AddFont(File.ReadAllBytes(@"C:\\Windows\\Fonts\arial.ttf"));

            coordinatesFont = fontSystem.GetFont(24);

            pixel = new Texture2D(graphicsDevice, 1, 1);
            pixel.SetData(new uint[] { 0xFFFFFFFF });
        }
示例#3
0
        protected override void LoadContent()
        {
            _s = new SpriteBatch(GraphicsDevice);

            _fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048);
            _fontSystem.AddFont(TitleContainer.OpenStream($"{Content.RootDirectory}/SourceCodePro-Medium.ttf"));

            GuiHelper.Setup(this, _fontSystem);

            _ui = new IMGUI();
        }
示例#4
0
文件: Fonts.cs 项目: sk-zk/NoisEvader
        private static FontSystem CreateFontSystem(GraphicsDevice gd, int textureWidth, int textureHeight,
                                                   params string[] fontPaths)
        {
            var system = FontSystemFactory.Create(gd, textureWidth, textureHeight);

            foreach (var font in fontPaths)
            {
                using var fs = new FileStream(font, FileMode.Open);
                system.AddFont(fs);
            }
            return(system);
        }
示例#5
0
文件: Font.cs 项目: giusdp/WForest
        /// <summary>
        /// Creates a Font by building a FontSystem with the arguments passed.
        /// </summary>
        /// <param name="graphicsDevice"></param>
        /// <param name="fontFiles"></param>
        /// <param name="textureWidth"></param>
        /// <param name="textureHeight"></param>
        public Font(GraphicsDevice graphicsDevice, IEnumerable <string> fontFiles,
                    int textureWidth  = 1024,
                    int textureHeight = 1024)
        {
            var fontSystem = FontSystemFactory.Create(graphicsDevice, textureWidth, textureHeight);

            foreach (var f in fontFiles)
            {
                fontSystem.AddFont(File.ReadAllBytes(f));
            }
            _fontSystem = fontSystem;
        }
示例#6
0
        private void SetupGui()
        {
            var fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048);

            fontSystem.AddFont(File.ReadAllBytes("Content/Fonts/Goldman-Regular.ttf"));
            GuiHelper.Setup(this, fontSystem);
            _screen = new ScreenPanel {
                Layout = new LayoutVerticalCenter()
            };
            _focus         = new ComponentFocus(_screen, Default.ConditionPrevFocus, Default.ConditionNextFocus);
            _menuGuiModule = new GuiModule(_focus);
            Components.Add(_menuGuiModule);
        }
示例#7
0
        protected override void LoadContent()
        {
            Batch   = new(GraphicsDevice);
            Watcher = new()
            {
                Path = "Content",
                IncludeSubdirectories = true,
                EnableRaisingEvents   = true
            };
            Fonts = FontSystemFactory.CreateStroked(GraphicsDevice, 1);
            Fonts.AddFont(File.ReadAllBytes("Content/fonts/Montserrat-Medium.ttf"));

            base.LoadContent();
        }
示例#8
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
            _fontSystem = FontSystemFactory.Create(GraphicsDevice, AtlasSize, AtlasSize);
            _fontSystem.AddFont(File.ReadAllBytes(@"Fonts/DroidSans.ttf"));

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

            GC.Collect();
        }
示例#9
0
        public override void Init(GraphicsDeviceManager _graphics, ContentManager Content, GraphicsDevice GraphicsDevice, ScreenManager screenManager, Game game)
        {
            this.game = game;
            FPS       = new Vector2(10, 10);
            font      = Content.Load <SpriteFont>("File");
            FontSystem fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048);

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

            GuiHelper.Setup(game, fontSystem);

            _ui  = new IMGUI();
            Text = new Vector2(30, 30);
            base.Init(_graphics, Content, GraphicsDevice, screenManager, game);
        }
示例#10
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);

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

            // Font
            var data = File.ReadAllBytes("Fonts/DroidSans.ttf");

            _fontSystem = FontSystemFactory.Create(GraphicsDevice);
            _fontSystem.AddFont(data);
        }
示例#11
0
 private static FontSystem FromFile(string file, GraphicsDevice device)
 {
     try
     {
         using (var stream = File.OpenRead(file))
         {
             var fontSystem = FontSystemFactory.Create(device, 1024, 1024, true);
             fontSystem.UseKernings = false;
             fontSystem.AddFont(stream);
             return(fontSystem);
         }
     }
     catch { }
     return(null);
 }
示例#12
0
        protected override void LoadContent()
        {
            _s = new SpriteBatch(GraphicsDevice);

            FontSystem fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048);

            fontSystem.AddFont(TitleContainer.OpenStream($"{Content.RootDirectory}/source-code-pro-medium.ttf"));

            GuiHelper.Setup(this, fontSystem);
            _ui = new IMGUI();
            GuiHelper.CurrentIMGUI = _ui;

            var texture = Content.Load <Texture2D>("apos");

            _apos = new TextureRegion2D(texture, 0, 0, texture.Width, texture.Height);
        }
示例#13
0
        protected override void LoadContent()
        {
            InputHelper.Setup(this);

            _apos   = Content.Load <Texture2D>("apos");
            _s      = new SpriteBatch(GraphicsDevice);
            _effect = Content.Load <Effect>("batch");
            _custom = Content.Load <Effect>("custom");
            _b      = new Batch(GraphicsDevice, _effect);

            _random = new Random();
            _fps    = new FPSCounter();

            _fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048);
            _fontSystem.AddFont(TitleContainer.OpenStream($"{Content.RootDirectory}/source-code-pro-medium.ttf"));
            _font = _fontSystem.GetFont(24);
        }
示例#14
0
        public FontSystem Load(AssetLoaderContext context, string assetName)
        {
            var parts = assetName.Split(':');

            var fontType = FontType.Regular;
            var amount   = 1;

            if (parts.Length > 1)
            {
                fontType = (FontType)Enum.Parse(typeof(FontType), parts[1]);

                if (fontType != FontType.Regular)
                {
                    if (parts.Length < 3)
                    {
                        throw new Exception("Missing amount");
                    }

                    amount = int.Parse(parts[2]);
                }
            }

            FontSystem fontSystem = null;

            switch (fontType)
            {
            case FontType.Regular:
                fontSystem = FontSystemFactory.Create(context.GraphicsDevice, 1024, 1024);
                break;

            case FontType.Blurry:
                fontSystem = FontSystemFactory.CreateBlurry(context.GraphicsDevice, 1024, 1024, amount);
                break;

            case FontType.Stroked:
                fontSystem = FontSystemFactory.CreateStroked(context.GraphicsDevice, 1024, 1024, amount);
                break;
            }

            var data = context.Load <byte[]>(parts[0]);

            fontSystem.AddFont(data);

            return(fontSystem);
        }
示例#15
0
        protected override Task LoadContent()
#endif
        {
            // 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>();

            // Simple
            var fontSystem = FontSystemFactory.Create(GraphicsDevice);

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

            // Blurry
            var blurryFontSystem = FontSystemFactory.CreateBlurry(GraphicsDevice, EffectAmount);

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

            // Stroked
            var strokedFontSystem = FontSystemFactory.CreateStroked(GraphicsDevice, EffectAmount);

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

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

#if MONOGAME || FNA
            _white = new Texture2D(GraphicsDevice, 1, 1);
            _white.SetData(new[] { Color.White });
#elif STRIDE
            _white = Texture2D.New2D(GraphicsDevice, 1, 1, false, PixelFormat.R8G8B8A8_UNorm_SRgb, TextureFlags.ShaderResource);
            _white.SetData(GraphicsContext.CommandList, new[] { Color.White });
#endif

            GC.Collect();

#if STRIDE
            return(base.LoadContent());
#endif
        }
        //-------------------------------------------------
        #region Initialize Method's Region
        /// <summary>
        /// Initializ the components.
        /// </summary>
        private void InitializeComponents()
        {
            //---------------------------------------------
            //news:
            this.MyRes                  = new WotoRes(typeof(FontManager));
            this._ranges                = _getRanges();
            this._old_story_bold        = _generate();
            this._old_story_bold_italic = _generate();
            this._LTW_bold              = _generate();
            this._LTW_regular           = _generate();
            this._noto_sans_regular     = _generate();
            byte[] _old_story_bold_        = _fromRes(OSBFileInRes);
            byte[] _old_story_bold_italic_ = _fromRes(OSBIFileInRes);
            byte[] _LTW_bold_          = _fromRes(LTWTTBoldFileInRes);
            byte[] _LTW_regular_       = _fromRes(LTWTTRFileInRes);
            byte[] _noto_sans_regular_ = _fromRes(NSRFileInRes);
            //---------------------------------------------
            //add colection fonts:
            this._old_story_bold?.AddFont(_old_story_bold_);
            this._old_story_bold?.AddFont(_noto_sans_regular_);
            this._old_story_bold_italic?.AddFont(_old_story_bold_italic_);
            this._old_story_bold_italic?.AddFont(_noto_sans_regular_);
            this._LTW_bold?.AddFont(_LTW_bold_);
            this._LTW_bold?.AddFont(_noto_sans_regular_);
            this._LTW_regular?.AddFont(_LTW_regular_);
            this._LTW_regular?.AddFont(_noto_sans_regular_);
            this._noto_sans_regular?.AddFont(_noto_sans_regular_);
            this._noto_sans_regular?.AddFont(_LTW_bold_);
            //---------------------------------------------
            //localFunctions:
            FontSystem _generate()
            {
                return(FontSystemFactory.CreateStroked(this.Client.GraphicsDevice,
                                                       STROKE_AMOUNT,
                                                       this.GraphicsLevel * FontBitmapWidth,
                                                       this.GraphicsLevel * FontBitmapHeight));;
            }

            //---------------------------------------------
        }
示例#17
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();
        }
示例#18
0
        public FontSystem Load(AssetLoaderContext context, string assetName)
        {
            var parts = assetName.Split(':');

            var fontType = FontType.Regular;
            var amount   = 1;

            if (parts.Length > 1)
            {
                fontType = (FontType)Enum.Parse(typeof(FontType), parts[1]);

                if (fontType != FontType.Regular)
                {
                    if (parts.Length < 3)
                    {
                        throw new Exception("Missing amount");
                    }

                    amount = int.Parse(parts[2]);
                }
            }

            FontSystem fontSystem = null;

#if MONOGAME || FNA || STRIDE
            switch (fontType)
            {
            case FontType.Regular:
                fontSystem = FontSystemFactory.Create(MyraEnvironment.GraphicsDevice, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;

            case FontType.Blurry:
                fontSystem = FontSystemFactory.CreateBlurry(MyraEnvironment.GraphicsDevice, amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;

            case FontType.Stroked:
                fontSystem = FontSystemFactory.CreateStroked(MyraEnvironment.GraphicsDevice, amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;
            }
#else
            switch (fontType)
            {
            case FontType.Regular:
                fontSystem = FontSystemFactory.Create(MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;

            case FontType.Blurry:
                fontSystem = FontSystemFactory.CreateBlurry(amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;

            case FontType.Stroked:
                fontSystem = FontSystemFactory.CreateStroked(amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;
            }
#endif

            var data = context.Load <byte[]>(parts[0]);
            fontSystem.AddFont(data);

            return(fontSystem);
        }