Ejemplo n.º 1
0
        public void Init()
        {
            mRendered = false;
            XUI ui = XUI.Instance();

            mListenter_KeyUp = new XListener <XKeyInput.KeyUp>(1, eEventQueueFullBehaviour.Ignore, "WorldKeyUp");
            XKeyInput.Instance().GetBroadcaster_KeyUp().Subscribe(mListenter_KeyUp);

            mListener_Button = new XListener <XUI.ButtonUpEvent>(1, eEventQueueFullBehaviour.Ignore, "WorldButton");
            ui.GetBroadcaster_ButtonUpEvent().Subscribe(mListener_Button);

            mRegnerateMapButton = ui._CreateRectangularButton(new Vector2(30, 30), "Regenerate Map", XUI.eStyle.GameplayUI);
            mMapTypeButton      = ui._CreateRectangularButton(new Vector2(30, 125), "Change Map Type", XUI.eStyle.GameplayUI);
            mMapSizeButton      = ui._CreateRectangularButton(new Vector2(30, 220), "Change Map Size", XUI.eStyle.GameplayUI);

            /*
             * mMapSizeButton = ui.CreateRectangularButton( new Vector2( 30, 315 ),
             *      "Hy0123456789012345678901234567890123456789",
             *      XUI.eStyle.FontTest );
             */

            /*
             * String[] texts = { "Hello", "Goodbye", "Meatball Soup", "Four", "5" };
             * String[] controls = { "Back", "Exit Game", "Quit Program, not really, i'm having fun" };
             * mSelector = ui.CreateSelector(	new Vector2( 1000, 400 ), "missing everything", XUI.eStyle.Frontend, XUI.eStyle.FrontendButton,
             *                                      XUI.eStyle.FrontendTitle, XUI.eStyle.FrontendControl, texts, controls );
             */

            Generate();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="game_time">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime game_time)
        {
            // user controller app exit
            // TODO: get this into exit event framework below.
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            ExitGameEvent e = mListener_ExitGameEvent.GetMaxOne();

            if (e != null)
            {
                // elaborate shutdown code goes here.
                Exit();
            }

            // TODO: Add your update logic here
            XTouch.Instance().Update(game_time);
            XKeyInput.Instance().Update();
            XMouse.Instance().Update(game_time);
            XUI.Instance().Update(game_time);
            XRootDebugMenu.Instance().Update();
            XWorld.Instance().Update();

            base.Update(game_time);
        }
Ejemplo n.º 3
0
            public ScreenWidget()
            {
                xCoord screen_dim = XRenderManager.Instance().GetScreenDim();

                InitWidget(null, XUI.Instance().GetStyle(eStyle.Screen),
                           new xAABB2(Vector2.Zero, new Vector2(screen_dim.x, screen_dim.y)));
                SetInputEnabled(false);
            }
Ejemplo n.º 4
0
            private _IButton PositionAndCreateButton(Vector2 pos, float border_padding, float spacing,
                                                     float button_size_y, eStyle button_style, int button_num, String text)
            {
                Vector2 button_pos = pos;

                button_pos.X += border_padding;
                button_pos.Y += border_padding + (spacing + button_size_y) * button_num;
                return(XUI.Instance()._CreateRectangularButton(button_pos, text, button_style));
            }
Ejemplo n.º 5
0
            void _ISelector.Destroy()
            {
                XUI ui = XUI.Instance();

                ui._DestroyButton(mTitleButton);

                for (int i = 0; i < mSelections.Length; ++i)
                {
                    ui._DestroyButton(mSelections[i]);
                }
            }
Ejemplo n.º 6
0
            private void Test_Panel()
            {
                XUI ui = XUI.Instance();

                XUI.Panel panel_1 = new XUI.Panel(ui.GetScreenWidget(), ui.GetStyle(eStyle.FrontendTest),
                                                  new xAABB2(new Vector2(200, 600), new Vector2(1500, 1100)));

                XUI.Panel panel_2 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest),
                                                  new xAABB2(new Vector2(210, 220), new Vector2(450, 440)));

                XUI.Panel panel_3 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest), new Vector2(100, 50),
                                                  ePlacement.Centered);

                XUI.Panel panel_4 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest), new Vector2(80, 50),
                                                  ePlacement.TopLeft);

                XUI.Panel panel_5 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest), new Vector2(100, 150),
                                                  ePlacement.CenteredTop);

                XUI.Panel panel_6 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest), new Vector2(90, 150),
                                                  ePlacement.TopRight);

                XUI.Panel panel_7 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest), new Vector2(70, 120),
                                                  ePlacement.CenteredRight);

                XUI.Panel panel_8 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest), new Vector2(90, 120),
                                                  ePlacement.BottomRight);

                XUI.Panel panel_9 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest), new Vector2(110, 80),
                                                  ePlacement.CenteredBottom);

                XUI.Panel panel_10 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest), new Vector2(60, 110),
                                                   ePlacement.BottomLeft);

                XUI.Panel panel_11 = new XUI.Panel(panel_1, ui.GetStyle(eStyle.FrontendTest), new Vector2(120, 150),
                                                   ePlacement.CenteredLeft);

                XUI.Panel panel_12 = new XUI.Panel(panel_2, ui.GetStyle(eStyle.FrontendTest), new Vector2(70, 50),
                                                   ePlacement.CenteredLeft);

                panel_1.AddChild(panel_2);
                panel_1.AddChild(panel_3);
                panel_1.AddChild(panel_4);
                panel_1.AddChild(panel_5);
                panel_1.AddChild(panel_6);
                panel_1.AddChild(panel_7);
                panel_1.AddChild(panel_8);
                panel_1.AddChild(panel_9);
                panel_1.AddChild(panel_10);
                panel_1.AddChild(panel_11);
                panel_2.AddChild(panel_12);

                ui.AddRootWidget(panel_1);
            }
Ejemplo n.º 7
0
            public override void Render(XSimpleDraw simple_draw)
            {
                base.Render(simple_draw);
                xAABB2 aabb = GetPosition().GetScreenAABB();

                XUI.Instance().Util_DrawBox(simple_draw, GetStyle(), aabb);

                for (int i = 0; i < mChildren.Count; ++i)
                {
                    mChildren[i].Render(simple_draw);
                }
            }
Ejemplo n.º 8
0
        private XRootDebugMenu()
        {
            mListener_FiveContacts      = new XListener <XTouch.FiveContacts>(1, eEventQueueFullBehaviour.Assert, "5contacts");
            mListener_SelectorSelection = new XListener <XUI.SelectorSelectionEvent>(1, eEventQueueFullBehaviour.Assert, "dmss");
            mBroadcaster_MenuSelection  = new XBroadcaster <MenuSelectionEvent>();
            mRootSelector = null;
            String spacer = XUI.Instance().GetSpacerString();

            mOptions = new String[5] {
                "Map", spacer, "Exit", spacer, "Quit"
            };
        }
Ejemplo n.º 9
0
            private void Test_Button()
            {
                XUI ui = XUI.Instance();

                XUI.Button bap_1 = new XUI.Button(ui.GetScreenWidget(), ui.GetStyle(eStyle.GameplayUI),
                                                  "Button As Panel 1", ePlacement.Centered);

                XUI.Button bap_2 = new XUI.Button(ui.GetScreenWidget(), ui.GetStyle(eStyle.FrontendTest),
                                                  "Button As Panel 2", new Vector2(100, 800));
                ui.AddRootWidget(bap_1);
                ui.AddRootWidget(bap_2);
            }
Ejemplo n.º 10
0
            private void Test_Label()
            {
                XUI ui = XUI.Instance();

                XUI.Label label_1 = new XUI.Label(ui.GetScreenWidget(), "Test Widget 1", ui.GetStyle(eStyle.Frontend),
                                                  new Vector2(500, 700));
                ui.AddRootWidget(label_1);

                XUI.Label label_2 = new XUI.Label(ui.GetScreenWidget(), "Test Widget 2", ui.GetStyle(eStyle.Frontend),
                                                  ePlacement.Centered);
                ui.AddRootWidget(label_2);
            }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        public void Update()
        {
            // check for create menu
            var enumerator_fiveContacts = mListener_FiveContacts.CreateEnumerator();

            if (enumerator_fiveContacts.MoveNext())
            {
                if (mRootSelector == null)
                {
                    mRootSelector = XUI.Instance().CreateSelector(new XUI._Position(), "Debug Menu",
                                                                  XUI.eStyle.Frontend, XUI.eStyle.FrontendButton,
                                                                  XUI.eStyle.FrontendTitle, mOptions);
                }
            }

            // check for menu selection
            var selection_data = mListener_SelectorSelection.GetMaxOne();

            if (selection_data != null)
            {
                if (selection_data.mSelectorID == mRootSelector.GetID())
                {
                    // destroy this selector
                    XUI.Instance().DestroySelector(mRootSelector.GetID());
                    mRootSelector = null;

                    switch (selection_data.mIndexSelected)
                    {
                    case 0:
                        // map selected, sent message for that system to do what it wants
                        Console.WriteLine("map selected");
                        mBroadcaster_MenuSelection.Post(new MenuSelectionEvent(selection_data.mSelectorID, mOptions[0]));
                        break;

                    case 2:
                        // exit selected, do nothing, menu will close
                        break;

                    case 4:
                        // quit selected, send message to end program.  this menu will close
                        XBulletinBoard.Instance().mBroadcaster_ExitGameEvent.Post(new Game1.ExitGameEvent());
                        break;

                    default:
                        // problem
                        XUtils.Assert(false);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        public Game1()
        {
            mGraphicsDeviceManager = new GraphicsDeviceManager(this);
            Content.RootDirectory  = "Content";

            mListener_ExitGameEvent = new XListener <ExitGameEvent>(1, eEventQueueFullBehaviour.Ignore, "ExitGame");

            XBulletinBoard.CreateInstance();
            XFontDraw.CreateInstance();
            XRenderManager.CreateInstance();
            XTouch.CreateInstance();
            XKeyInput.CreateInstance();
            XWorld.CreateInstance();
            XMouse.CreateInstance();
            XUI.CreateInstance();
            XRootDebugMenu.CreateInstance();
        }
Ejemplo n.º 15
0
            private void PositionAndCreateButtons(String[] strings, _IButton[] dest, float border_padding, float spacing,
                                                  float button_size_y, eStyle style, int offset)
            {
                String       spacer             = XUI.Instance().GetSpacerString();
                const String spacer_replacement = " ";

                for (int i = 0; i < strings.Length; ++i)
                {
                    bool is_spacer = spacer == strings[i];

                    if (is_spacer)
                    {
                        dest[i] = PositionAndCreateButton(mPos, border_padding, spacing, button_size_y,
                                                          style, i + offset, spacer_replacement);

                        dest[i].SetActive(false);
                    }
                    else
                    {
                        dest[i] = PositionAndCreateButton(mPos, border_padding, spacing, button_size_y,
                                                          style, i + offset, strings[i]);
                    }
                }
            }
Ejemplo n.º 16
0
            void _ISelector.Draw(XSimpleDraw simple_draw)
            {
                if (mRenderEnabled)
                {
                    // draw the title and background, buttons will draw themselves
                    Style style        = XUI.Instance().GetStyle(mStyle);
                    Color widget_color = style.mBackgroundColor;
                    Color border_color = style.mBorderColor;

                    Vector3 lo_x_lo_y = new Vector3(mAABB.GetMin(), 1);
                    Vector3 hi_x_hi_y = new Vector3(mAABB.GetMax(), 1);

                    Vector2 size      = mAABB.GetSize();
                    Vector3 lo_x_hi_y = lo_x_lo_y + new Vector3(0, size.Y, 0);
                    Vector3 hi_x_lo_y = lo_x_lo_y + new Vector3(size.X, 0, 0);

                    simple_draw.DrawQuad(lo_x_lo_y, hi_x_hi_y, widget_color);

                    simple_draw.DrawLine(lo_x_lo_y, hi_x_lo_y, border_color);
                    simple_draw.DrawLine(hi_x_lo_y, hi_x_hi_y, border_color);
                    simple_draw.DrawLine(hi_x_hi_y, lo_x_hi_y, border_color);
                    simple_draw.DrawLine(lo_x_hi_y, lo_x_lo_y, border_color);
                }
            }
Ejemplo n.º 17
0
        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();
        }
Ejemplo n.º 18
0
 private Style GetStyle()
 {
     return((mParent != null) ? mParent.GetStyle() : XUI.Instance().GetStyle(eStyle.Screen));
 }
Ejemplo n.º 19
0
            public Selector(_Position pos, String title, eStyle style, eStyle button_style, eStyle title_style,
                            long id, String[] texts)
            {
                mRenderEnabled   = true;
                mID              = id;
                mPos             = pos.GetPosition();
                mPosition        = pos;
                mTitle           = title;
                mStyle           = style;
                mButtonStyle     = button_style;
                mTitleStyle      = title_style;
                this.mSelections = new _IButton[texts.Length];

                // create a default button to see how big it is vertically
                // size and position border accordingly, factoring in width of largest button including title
                // destroy that button
                // create all the proper buttons in the right spot
                // create title 'button' as disabled button
                XUI xui_inst = XUI.Instance();

                _IButton test          = xui_inst._CreateRectangularButton(Vector2.Zero, "Test", style);
                xAABB2   button_size   = test.GetAABB();
                float    button_size_y = button_size.GetSize().Y;

                xui_inst._DestroyButton(test);

                const float k_border_padding_scalar = 0.5f;
                float       border_padding          = k_border_padding_scalar * button_size_y;

                const float k_spacing_scalar = 0.2f;
                float       spacing          = k_spacing_scalar * button_size_y;

                // pad out the text strings so the buttons can be wide if the text is small
                int longest = GetLongestString(texts);

                PadButtonTexts(texts, longest);

                // create buttons
                PositionAndCreateButtons(texts, mSelections, border_padding, spacing, button_size_y, button_style, 0);

                // track largest
                float largest_x = GetWidest(mSelections);

                // create title button (non-functional) and see if it's the largest
                Vector2 title_pos = mPos + new Vector2(border_padding, border_padding);

                mTitleButton = xui_inst._CreateRectangularButton(title_pos, title, title_style);
                mTitleButton.SetActive(false);
                largest_x = Math.Max(largest_x, mTitleButton.GetAABB().GetSize().X);

                // calculate aabb
                const float title_padding_scalar = 4.0f;
                float       title_padding        = border_padding * title_padding_scalar;
                Vector2     title_padding_v      = new Vector2(0, title_padding);
                float       full_width           = largest_x + 2 * border_padding;

                float full_height = button_size_y * (mSelections.Length) +
                                    (mSelections.Length - 1) * spacing +
                                    2 * border_padding +
                                    title_padding;

                mAABB.Set(mPos, mPos + new Vector2(full_width, full_height));

                // translate each button to be centered, and account for title
                CenterButtons(mSelections, largest_x, title_padding);
                CenterButton(mTitleButton, largest_x, 0);

                // if the selector has a non-trivial Position, fix it
                if (mPosition.IsCentered())
                {
                    // see where it is now, figure out where it should be, translate.
                    // apply to aabb for selector plus translate all the buttons
                    xCoord  screen_dim     = XRenderManager.Instance().GetScreenDim();
                    Vector2 span           = mAABB.GetSize();
                    Vector2 screen_dim_vec = new Vector2(screen_dim.x, screen_dim.y);
                    Vector2 edge           = 0.5f * (screen_dim_vec - span);
                    Translate(edge);
                }
            }
Ejemplo n.º 20
0
 public void Init()
 {
     XBulletinBoard.Instance().mBroadcaster_FiveContacts.Subscribe(mListener_FiveContacts);
     XUI.Instance().GetBroadcaster_SelectorSelectionEvent().Subscribe(mListener_SelectorSelection);
 }
Ejemplo n.º 21
0
 public Widget()
 {
     mUID         = XUI.Instance().NextUID();
     mInitialized = false;
 }