Documentation - Hide XUI after loading etc

May 10, 2013 at 12:44 AM
Edited May 10, 2013 at 12:52 AM
Figured I post this as took me an hour to find navigating through the code.

In Game.cs you can remove XUI by:
UiLayer.DoRender = false;
UiLayer.DoUpdate = false;

Add it again starting with the start menu:
UiLayer.DoRender = true;
UiLayer.DoUpdate = true;

The important areas to know i.e. when starting a new game or loading from existing:
LevelSelect.cs > OnProcessInput();

I changed to: (talks to public UI.Screen_Loading loading; in Game.cs)
if ( input.ButtonJustPressed( (int)E_UiButton.A ) ) {
_G.Game.loading = new Screen_Loading(CurrentSelectionWorld, CurrentSelectionLevel, true);
_UI.Screen.SetNextScreen(_G.Game.loading); }

MainMenu.cs OnProcessMessage(); in the switch ( (E_PopupType)message.Data )
SetScreenTimers(0.0f, 0.5f);
Logo.TimelineActive("end_move", true, false);
_G.UI.SS_FromMainMenu = true;

_G.Game.loading = new Screen_Loading(-1, -1, true);

Note: I also remove the graphics.GraphicsDevice.Clear();
Also: Make sure to modify Loading.cs to public Screen_Loading(int _world, int _level, bool _active)

And Add...
public int world = -2;
public int level = -2;
public bool IsActive = false;

I now have a way to handle all my loading from Update in my Game.cs. via:
if (loading !=null && loading.IsActive) loading.IsActive = false;

Please advice if there is a better way to do this. I understand your not wanting to ugly up the code with a bunch of comments. Most of it is pretty self explanatory...and I also hold to the philosophy if your not willing to spend a little time reading through the free open source code that would take you weeks to do by yourself...well no one is making you use it. But the above seems like a good tip to put in docs, as it currently tells you what to do to setup the XUI...but nothing about how to finish the loading process or new game process.
May 11, 2013 at 11:38 AM
Erm ... I'm a little confused. =s
Can you explain what you're trying to do - what do you actually mean by "Hide XUI after loading"?

It sounds like you're wanting to actually implement the loading screen fully, so that the game will load in the content required for that particular level? I'm not sure why you're wanting to shutdown XUI completely and then load it all back up again (I would certainly advise against doing that), but personally, I would move your loading code out of Game.cs and into the loading screen.

The basic idea for a loading screen would go something like this ...
  • move to the loading screen (with a SetNextScreen call)
  • in the loading screen ...
    -- start the loading thread.
    -- poll in the update of the loading screen to determine when the loading has finished.
    -- when the loading has actually finished, move to the next screen (the HUD, for example).
May 15, 2013 at 5:41 PM
Thanks for the info.

To answer the above...

Why shutdown XUI?
  • I also am deploying to win phone so am really only using XUI for a nice dressed up UI for XBOX/PC. As it is very nice! But can only really use it for level navigation at this time and settings UI. The widgets and HUD would be sweet but need a solution for phone as well so have built a custom UI in mean time. If XUI has no footprint when running a setnextscreen() and then loading a blank screen...then I'll be sure to keep it running. The user will still be accessing XUI on XBOX whenever they want to try a different level or change a setting so it would be nice not to have to shut it down. I'll look into implementing as you suggested.
I had first tried using the setnextscreen without fully understanding the flow of thing and it just resulted in overlapping screens. Now that I've digested the code a bit and been working on other things what you say will probably make sense once I dive back in. The solution above was just my first ditch effort at a proof of concept etc that I would be able to use this fun library...Thanks again!