Srekel

Hi
I just started looking at XNA, and I've assembled a small team for the DBP contest. The first thing I'm trying to do is to make the game run inside an editor, because I'm pretty sure it'll be very useful.

However, looking around at the different solutions that people have come up with for running XNA in a control, it seems none of them are using the Game class. And on Shawn's (who is a developer of the XNA framework ) blog, he writes:

"If you want to render into a custom window, don't use the Game class. It will be much easier and more reliable to directly create your own GraphicsDevice object."

This, in turn, makes it impossible to use GameComponents. But it would be nice to use GameComponents that other people have created on the web, so that kind of sucks. Am I missing something Can I somehow create my own Game class and use it in a way that doesn't conflict with Windows Forms Or can I use GameComponents without a Game

More information on what Game exactly does would be nice too (so I won't miss implementing some detail when I write an alternative class).



Re: XNA Framework Using Game (and GameComponents) in a Windows Forms editor?

thedo

One potential way to do it would be to have 2 windows open - 1 your Game window, and 1 which is your Editor panel. Pretty easy to set up - just get the Main method in program.cs to create a second regular Winform (obviously you'd need to add a reference to System.Windows.Forms if you start with a Windows XNA Game template). You simply then add methods which allow the 2 classes to interact. Is it ideal - not really, as you end up with code tieing the 2 forms together, but it should at least allow you to use GameComponents and Services.

N






Re: XNA Framework Using Game (and GameComponents) in a Windows Forms editor?

Jeff Weber

I am using this technique in my editor. I know it's not the ideal way to do things, but it works pretty well.

I just create a new "MainForm" just before calling "Run" on the game class.

namespace FarseerGames.SeerEditor {
static class Program {
using (SeerEditor.Instance) {
Application.EnableVisualStyles();
MainForm.Instance.Show();
SeerEditor.Instance.Run();
}
}
}

note: SeerEditor inherits from the Game object.

Then, I just use the main form as a jumping off point to all my individual edit forms (landscape, tilemap...) etc. The edit windows are all just floating forms that can interact with anything in the "Game" class.






Re: XNA Framework Using Game (and GameComponents) in a Windows Forms editor?

theTroll527

There is another solution that everyone seems to forget. How about windows controls on the gamewindow That is how I am doing, works really well and you have the advantage that your game objects will act the same as in your game becuase you are using the same game class.

theTroll