Game Development Reference
every application that has a significant waiting period during startup uses a loading
screen to display the status of long-running processes. Typically, these loading screens
run as modal dialogs that appear centered on top of the underlying application
windows and do not allow the user to interact with anything in the application
until the processing is finished and the loading screen closes.
This chapter will describe some fundamental aspects of loading screens, and then
will focus on implementing a reusable component that will display process status
to the user when an application first starts. The component will also support the
concept of splash screens.
The general idea is to build a reusable form that has a variety of customization
options depending on the needs of the project. Splash dialogs can be designed in
virtually any way, so this chapter will cover the features found in the example on
the Companion Web site. The main feature is the ability to specify a background
image that defines the width and height of the form.
There are a couple of properties that must be customized on the default form. The
starting position of the form should be set to center screen, the form should be
displayed without a title box, and the border style should be set to none. Another
good flag to enable is top most , which causes the splash dialog to be shown on top
of all other windows. Lastly, specify the splash dialog to not show up in the task
bar. Splash dialogs should not create additional window entries in the task bar
because they should be considered part of the main window.
The framework presented in this chapter makes use of a class that contains all the
settings and handles the launching of the splash screen dialog. The settings class
passes itself as a reference to the dialog constructor so that the splash screen can
configure the appropriate settings as it launches. The splash dialog is an internal
class within the library, so consumers of the library cannot access the dialog directly,
and must do so through the settings and launcher class.
The following code describes the settings and launcher class in its entirety. I will
not yet explain what each property does, but they will be discussed when needed
as you read on in the chapter. You will need to make sure that you reference the
System.Drawing and System.Collections.Generic namespaces as well.
public class SplashScreen
private List<ILoadingJob> _loadingJobs = new List<ILoadingJob>();