Saturday 20 November 2010

Wrestling with the dialog

I have just managed to complete the code for the Dialog class. It wasn't quite as simple as I thought it was going to be.

In a sudden flash of inspiration, I decided to give the dialog class the ability to appear on screen using transitions. These are sliding, fading or a combination of both. However, these were not my first issues...

I often use particle effects on my cursor to make it look 'pretty'. Unfortunately, these were being masked by the new dialogs, so I have to create a new type of effect called a PersistantEffect. these effects are not paused by the system, and as they are drawn over everything else, except the cursor, they are drawn on top of the dialogs. Like I said, that was issue number one.

Issue number two was the fact that I cause the game to pause when a dialog is  displayed. This had the adverse effect of pausing all triggers. Again, this was overcome with the new PersistantTriggers, which operate the entire time a scene is active.

The next issue was the sliding effect. When I created the GUI Subsystem, I never imagined that I would need to move the controls on screen. I had a number of approaches for this, and my first was to rewrite part of the GUI, however, I did not want to mess about with something that I knew worked. So the next thing is to get the dialog to control the movement of the GUIElements. As it turned out, this solution was quite simple, it was just the exploration of 'how' to do this that frazzled my brain.

In order for the dialogs to interact with the Scene, I have also added a new event handler: OnDialogReturn. This has one parameter passed back to it, the return code of the dialog. It is also to inspect the fields of the dialog in this handler, if required, as the dialog is removed from memory after this event is triggered.

So, the upshot is: I now have a dialog system that utilises the existing GUISubsystem, handling the GUI events in exactly the same way as the main scene. he dialog can appear to slide into the screen (and out after the dialog is closed) or fade in and fade out, or a combination of both of these transitions. However, some graphical care has to be taken when using the fade transition.

It's quite amazing at how much I am adding to the framework, when all I am working on is a simple puzzle game. but I'm sure that the additions i am making will only help in the future.

No comments:

Post a Comment