Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _nuklearContext = new NuklearContext(GraphicsDevice);

            Nuklear.nk_font font;
            using (var stream = File.OpenRead(Path.Combine(Content.RootDirectory, "Fonts/Roboto-Regular.ttf")))
            {
                var fontAtlas = new FontAtlasWrapper(_nuklearContext);
                font = fontAtlas.AddFont(stream, 22);
                fontAtlas.Bake();
            }

            _nuklearContext.SetFont(font);

            IsMouseVisible           = true;
            Window.AllowUserResizing = true;
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            Window.Title = "Demo";

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _contextWrapper = new NuklearContext(GraphicsDevice);

            // Fonts
            var fontData  = File.ReadAllBytes(GetAssetPath("Fonts/Roboto-Regular.ttf"));
            var fontAtlas = new FontAtlasWrapper(_contextWrapper);

            using (var stream = new MemoryStream(fontData))
            {
                _media.font_14 = fontAtlas.AddFont(stream, 14);
            }

            using (var stream = new MemoryStream(fontData))
            {
                _media.font_18 = fontAtlas.AddFont(stream, 18);
            }

            using (var stream = new MemoryStream(fontData))
            {
                _media.font_20 = fontAtlas.AddFont(stream, 20);
            }

            using (var stream = new MemoryStream(fontData))
            {
                _media.font_22 = fontAtlas.AddFont(stream, 22);
            }

            _contextWrapper.ConvertConfig._null_ = fontAtlas.Bake();

            _media.uncheckd = LoadImage("Icons/unchecked.png");
            _media.checkd   = LoadImage("Icons/checked.png");
            _media.rocket   = LoadImage("Icons/rocket.png");
            _media.cloud    = LoadImage("Icons/cloud.png");
            _media.pen      = LoadImage("Icons/pen.png");
            _media.play     = LoadImage("Icons/play.png");
            _media.pause    = LoadImage("Icons/pause.png");
            _media.stop     = LoadImage("Icons/stop.png");
            _media.next     = LoadImage("Icons/next.png");
            _media.prev     = LoadImage("Icons/prev.png");
            _media.tools    = LoadImage("Icons/tools.png");
            _media.dir      = LoadImage("Icons/directory.png");
            _media.copy     = LoadImage("Icons/copy.png");
            _media.convert  = LoadImage("Icons/export.png");
            _media.del      = LoadImage("Icons/delete.png");
            _media.edit     = LoadImage("Icons/edit.png");
            _media.menu[0]  = LoadImage("Icons/home.png");
            _media.menu[1]  = LoadImage("Icons/phone.png");
            _media.menu[2]  = LoadImage("Icons/plane.png");
            _media.menu[3]  = LoadImage("Icons/wifi.png");
            _media.menu[4]  = LoadImage("Icons/settings.png");
            _media.menu[5]  = LoadImage("Icons/volume.png");

            for (var i = 0; i < _media.images.Length; ++i)
            {
                _media.images [i] = LoadImage("Images/image" + (i + 1) + ".png");
            }

            base.Initialize();
        }