コード例 #1
0
ファイル: Label.cs プロジェクト: barronds/XNARTS
            private static Vector2 CalcSize(String text, Style style)
            {
                Vector2 font_size  = XFontDraw.Instance().GetFontInfo(style.mNormalFont).mSize;
                Vector2 label_size = new Vector2(font_size.X * text.Length, font_size.Y);

                return(label_size);
            }
コード例 #2
0
            private void CalcPadding(float button_padding_scalar, float placement_padding_scalar)
            {
                Vector2 font_size      = XFontDraw.Instance().GetFontInfo(mNormalFont).mSize;
                float   heuristic_size = font_size.X + font_size.Y;

                mButtonPadding    = button_padding_scalar * heuristic_size;
                mPlacementPadding = placement_padding_scalar * heuristic_size;
            }
コード例 #3
0
ファイル: Buttons.cs プロジェクト: barronds/XNARTS
 public void Draw(XSimpleDraw simple_draw)
 {
     // draw the text
     if (mText.Length > 50)
     {
         Console.WriteLine(mTextOffset + ", " + mText);
     }
     XFontDraw.Instance().DrawString(mStyle.mNormalFont, mPos + mTextOffset, mStyle.mTextColor, mText);
 }
コード例 #4
0
ファイル: Buttons.cs プロジェクト: barronds/XNARTS
        public _IButton _CreateRectangularButton(Vector2 pos,
                                                 String text,
                                                 eStyle style)
        {
            Style s = XUI.Instance().GetStyle(style);

            XFontDraw.FontInfo info      = XFontDraw.Instance().GetFontInfo(s.mNormalFont);
            Vector2            font_size = info.mSize;
            _IButton           button    = new _RectangularButton(pos, text, s, NextUID(), font_size);

            _mButtons.Add(button.GetID(), button);
            return(button);
        }
コード例 #5
0
ファイル: Button2.cs プロジェクト: barronds/XNARTS
            public Button(Widget parent, Style style, String text, ePlacement placement)
            {
                // optimize later
                Vector2 label_size = Label.GetSizeOfText(text, style);
                eFont   font       = style.mNormalFont;
                Vector2 font_size  = XFontDraw.Instance().GetFontInfo(font).mSize;
                float   padding    = style.mButtonPadding;
                Vector2 size       = label_size + 2.0f * new Vector2(padding, padding);

                InitPanel(parent, style, size, placement);

                Label label = new Label(this, text, style, ePlacement.Centered);

                AddChild(label);
            }
コード例 #6
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()
        {
            XBulletinBoard.Instance().Init();
            XTouch.Instance().Init();
            XKeyInput.Instance().Init();
            XWorld.Instance().Init();
            XMouse.Instance().Init();
            XFontDraw.Instance().Init(GraphicsDevice, Content);
            XRenderManager.Instance().Initialize(GraphicsDevice, mGraphicsDeviceManager, Content);
            XUI.Instance().Init();
            XRootDebugMenu.Instance().Init();

            base.Initialize();

            XBulletinBoard.Instance().mBroadcaster_ExitGameEvent.Subscribe(mListener_ExitGameEvent);
        }
コード例 #7
0
ファイル: RenderManager.cs プロジェクト: barronds/XNARTS
        public void LoadContent()
        {
            // world space rendering setup
            mBasicEffect_World       = new BasicEffect(mGraphicsDevice);
            mBasicEffect_World.World = Matrix.Identity;

            // screen space rendering setup
            mBasicEffect_Screen       = new BasicEffect(mGraphicsDevice);
            mBasicEffect_Screen.World = Matrix.Identity;

            // sprite batch, not used yet
            mSpriteBatch = new SpriteBatch(mGraphicsDevice);

            XFontDraw.Instance().LoadContent();

            UpdateCameras();
        }
コード例 #8
0
ファイル: RenderManager.cs プロジェクト: barronds/XNARTS
        public void Draw(GameTime game_time)
        {
            mGraphicsDevice.Clear(Color.CornflowerBlue);

            RasterizerState rasterizerState = new RasterizerState();

            rasterizerState.CullMode        = CullMode.None;
            mGraphicsDevice.RasterizerState = rasterizerState;

            // maybe not the best place for this
            // also, screen cam not updating anywhere
            mMainWorldCam.Update(game_time);
            UpdateCameras();

            // simple draw only clients
            XWorld.Instance().RenderWorld(game_time, mMainWorldCam.GetViewAABB());
            XMouse mouse = XMouse.Instance();

            mouse.RenderWorld(game_time);
            mouse.RenderScreen(game_time);
            XUI.Instance().Draw();

            mBasicEffect_World.VertexColorEnabled = true;

            XSimpleDraw simple_draw_world_transient      = XSimpleDraw.Instance(xeSimpleDrawType.WorldSpace_Transient);
            XSimpleDraw simple_draw_world_persistent     = XSimpleDraw.Instance(xeSimpleDrawType.WorldSpace_Persistent);
            XSimpleDraw simple_draw_screen_transient     = XSimpleDraw.Instance(xeSimpleDrawType.ScreenSpace_Transient);
            XSimpleDraw simple_draw_screen_persistent    = XSimpleDraw.Instance(xeSimpleDrawType.ScreenSpace_Persistent);
            XSimpleDraw simple_draw_world_map_persistent = XSimpleDraw.Instance(xeSimpleDrawType.WorldSpace_Persistent_Map);

            foreach (EffectPass pass in mBasicEffect_World.CurrentTechnique.Passes)
            {
                pass.Apply();

                // actually render simple draw stuff.  possible layers needed.
                simple_draw_world_map_persistent.DrawAllPrimitives();
                simple_draw_world_persistent.DrawAllPrimitives();
                simple_draw_world_transient.DrawAllPrimitives();

                // render clients who do their own rendering.  they should probably have pre-renders like simple draw, especially if there is more than one pass.
            }

            // simple draw screen
            mBasicEffect_Screen.VertexColorEnabled = true;

            //foreach ( EffectPass pass in effectPassCollection )
            foreach (EffectPass pass in mBasicEffect_Screen.CurrentTechnique.Passes)
            {
                pass.Apply();

                // actually render simple draw stuff.  possible layers needed.
                simple_draw_screen_persistent.DrawAllPrimitives();
                simple_draw_screen_transient.DrawAllPrimitives();

                // render clients who do their own rendering.  they should probably have pre-renders like simple draw, especially if there is more than one pass.
            }

            //mSpriteBatch.Begin();
            // do sprite batch rendering here
            //mSpriteBatch.End();

            XFontDraw.Instance().Draw();
        }
コード例 #9
0
ファイル: Label.cs プロジェクト: barronds/XNARTS
 public override void Render(XSimpleDraw simple_draw)
 {
     base.Render(simple_draw);
     XFontDraw.Instance().DrawString(GetStyle().mNormalFont, GetPosition().GetScreenAABB().GetMin(),
                                     GetStyle().mTextColor, mText);
 }