632 Chapter 23 ■ The Game Client
Client Interfaces
We are going to add code to allow users to run a server and to allow players to connect to a server. In order to make that connection, we will want to provide the user with an interface he can use to find servers, decide which one offers an interesting game, and then connect to the server.
Another thing we need to do is make sure that when the user quits a server, he returns to his selection interface rather than simply exiting as Koob does now.
Additionally, we need to add a capability to the playing interface to provide a chat window with a text entry where players can type in messages to send to other players. Maybe they'll want to exchange recipes or something. Yeah, that's it—recipes! It's not like they're going to taunt anyone anyway, is it?
In Chapter 6 you saw the MasterScreen interface module that combined these interfaces. In this chapter we'll look at the same issue but in a slightly different way, in order to show how easy it is to make different—yet equally valid—design decisions.
Also, we'll need to modify a few of the files, like the MainScreen interface, to more closely conform to our needs.
In a later section we'll add the code required to make these interfaces functional.
MenuScreen Interface
We will make some changes to our main menu screen so that it provides the user with the additional choices to
■view information about the games and credits
■play in single-player mode (as it already has)
■host a game
■connect to another server
Open your MenuScreen.gui file and locate the following line:
command = "LaunchGame();";
This line is a property statement in a GuiButtonCtrl. Delete the entire control, from where it says
new GuiButtonCtrl() {
down to the closing brace ("}").
In the place of the deleted control, insert the following: