Psi GUI - GUI controls for XNA 4.0

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

31 Replies - 4918 Views - Last Post: 13 January 2011 - 05:11 PM

#16 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Psi GUI - GUI controls for XNA 4.0

Posted 05 January 2011 - 03:53 PM

What I can see from managing it on our own is that input handling is hidden from the end programmer. They just need to know that the control manager takes care of all controls they want to use at a given time. Not giving them direct access to input handling means there is less chance of things happening that you don't want.

If you require the end programmer to implement the input handler they could forget to implement it, dispose of it, etc. It goes against encapsulation, the inner workings of our objects needs to be known to an extent. It would be easier for the control manager to be broken.

Having an interface for public access to the input handler would be a good idea. It could be added as a game service and if the end programmers needs access to it they have a well defined public interface to use. I think that the input handling class should also be sealed so it can't be inherited from. Probably even internal to the assembly.
Was This Post Helpful? 0
  • +
  • -

#17 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: Psi GUI - GUI controls for XNA 4.0

Posted 05 January 2011 - 06:06 PM

I have to agree with you here. Too many risks if the input handling is left up to the end programmer. I assume you're planning on implementing your input manager, Xin, into this project, is that a safe assumption?
Was This Post Helpful? 0
  • +
  • -

#18 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Psi GUI - GUI controls for XNA 4.0

Posted 06 January 2011 - 06:05 AM

A version of it yes. I added a class called InputHandler to the project for handling input. I'm planning on adding an interface of methods, properties, and events.

One thing I'm trying to work out is that the constructor for game components require a Game parameter to be constructed. I'm trying to devise a way to get a Game object to the library. Any thoughts on that?
Was This Post Helpful? 0
  • +
  • -

#19 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: Psi GUI - GUI controls for XNA 4.0

Posted 06 January 2011 - 07:39 AM

Maybe I'm reading the question wrong, but any GameComponent and DrawableGameComponent derived classes have access to the Game property of the GameComponent class. Unless you mean something else and it's just too early for me to understand right now. Perhaps we could look into enforcing the singleton pattern and create a static instance in the Game1 class.
Was This Post Helpful? 0
  • +
  • -

#20 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Psi GUI - GUI controls for XNA 4.0

Posted 06 January 2011 - 02:45 PM

What I was trying to say that when you create a GameComponent, or DrawableGameComponent, you need to pass in a Game parameter. Input handlers work best as GameComponents. The class that manages controls works well as a DrawableGameComponent. So, someway we need to get the Game object from the programmer's game into the library. I was trying to figure out the best way to do that. I do have an idea, let me bounce it around a little. Singleton pattern may work but again, how to get the current Game object form the game to the library.
Was This Post Helpful? 0
  • +
  • -

#21 lesPaul456  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 173
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: Psi GUI - GUI controls for XNA 4.0

Posted 06 January 2011 - 09:46 PM

What if you created your own class that derived from Game? That class could contain its own instance of the InputHandler, and the other managers. That way you could initialize the managers internally and the end-user would just have to make sure that their game class derives from yours.
Was This Post Helpful? 2
  • +
  • -

#22 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Psi GUI - GUI controls for XNA 4.0

Posted 07 January 2011 - 06:15 AM

Good idea. I'm going to play around with that idea a bit and see what happens. The more I think about it the more I like it.
Was This Post Helpful? 0
  • +
  • -

#23 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Psi GUI - GUI controls for XNA 4.0

Posted 08 January 2011 - 08:29 AM

I plan on trying to get some work done on this today. this past week I was so busy with things to do. I've been thinking of adding in some sort of drawing order to drawable controls. I also want to add in a tab order to controls that can be selected. What you think?
Was This Post Helpful? 0
  • +
  • -

#24 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: Psi GUI - GUI controls for XNA 4.0

Posted 08 January 2011 - 11:09 AM

Tab order would definitely be nice. I'm one of those people that tabs through selectable controls constantly.
Was This Post Helpful? 0
  • +
  • -

#25 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Psi GUI - GUI controls for XNA 4.0

Posted 08 January 2011 - 01:54 PM

There is a basic tab order built into the control manager. However, it does need a lot of work. :) The order at the moment is dependent on the way controls are added to the control manager. Since it was mostly used for the Xbox moving between controls is based off the left thumb stick and the direction pad. I plan to work on the project now that I'm home for the evening. :)
Was This Post Helpful? 0
  • +
  • -

#26 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Psi GUI - GUI controls for XNA 4.0

Posted 08 January 2011 - 05:07 PM

The idea that I'm going to go with is that I have a GameComponent, PsiGUIComponent, that needs to be created and added to the list of components for the system to work. This component has a static field for the InputHandler and a Game object. I made it a sealed class as well so it can't be inherited from.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace PsiGUILibrary
{
    public sealed class PsiGUIComponent : GameComponent
    {
        #region Field Region

        internal static Game GameRef;
        internal static InputHandler InputHandler;

        #endregion

        #region Property Region
        #endregion

        #region Constructor Region

        public PsiGUIComponent(Game game)
            : base(game)
        {
            if (GameRef == null)
                GameRef = game;

            if (InputHandler == null)
                InputHandler = new InputHandler(GameRef);
        }

        #endregion

        #region Method Region

        public sealed override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            InputHandler.Update(gameTime);
        }

        #endregion
    }
}


Was This Post Helpful? 1
  • +
  • -

#27 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Psi GUI - GUI controls for XNA 4.0

Posted 11 January 2011 - 05:14 PM

I hope to have some time to devote to this tomorrow. I've been busy with my tutorials the past few days but trying to work a few things out in my head at the same time.
Was This Post Helpful? 0
  • +
  • -

#28 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: Psi GUI - GUI controls for XNA 4.0

Posted 11 January 2011 - 06:30 PM

I've been really busy lately too, and the fact that the weather has been utterly horrible lately, I've been even busier trying to keep the ice and snow away as much as possible. Looks like it's finally going to start thawing out, so maybe I can let mother nature deal with it from this point on. I really do want to help with this project, but I don't even know where to start. Any areas that you'd suggest I work on in the meantime?
Was This Post Helpful? 0
  • +
  • -

#29 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Psi GUI - GUI controls for XNA 4.0

Posted 12 January 2011 - 10:10 AM

Right now what would be useful is to decide what controls to implement. From there we can look and see if any new interfaces need to be added to implement them.

So far I've created the following controls, in other projects, and I'm happy with them.
  • Label
  • LinkLabel (or Button)
  • LeftRightSelector
  • PictureBox


Controls that I've been work on, though not satisfied with.
  • TextBox
  • ListBox
  • Timer


Controls I've been thinking of adding.
  • CheckBox
  • RadioButton
  • ComboBox


Anybody have thoughts on other controls that could be added?
Was This Post Helpful? 0
  • +
  • -

#30 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: Psi GUI - GUI controls for XNA 4.0

Posted 12 January 2011 - 10:22 AM

Any plans on turning that TextBox control into a RichTextBox control, or maybe make them separate controls?

I could see a progress bar coming in handy if you're planning on implementing experience points in an RPG, or possibly a racing game using the progress bar to keep track of how far from the end of the race the player is.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3