-
Notifications
You must be signed in to change notification settings - Fork 0
Info windows
Information windows are created using the two (global?) create_win()
methods in simwin.cc/.h.
Here is a simple example:
create_win( display_get_width()/2-128, 80, new news_img("This is placeholder text.\nThis is on a new line."), w_info, magic_none);
Width. The display_get_width function provides the width of the display (I guess that if this game is full-screen at 1080P, then the width would be 1080?). The game must be playable on small screens, so keep the number of characters per line low.
Height. Apparently 40 per line of text.
Those two parameters can be omitted (together). It is not clear how the window size is determined if this is done.
Actual text.
w_info. This is the line that makes it an info window.
Magic pointers. I think is a system to ensure that there is no more than one instance of toolbars, the Line Window, etc. magic_none seems to be a safe default.
We might want to to do this in order to print the ID of a convoy in a message, for example.
A simple example:
static char err_str[512];
sprintf( err_str, translator::translate("Error during saving:\n%s"), success );
create_win( new news_img(err_str), w_info, magic_none);
The first line declares a string variable of sufficient length to store the message that we want.
The second line contains the message and the variable that we want to insert into it (in this case, 'success'). We must refer to the variable in the string using its type specifier, as per this list. Presumably this must be a variable that is known in this method.
The third line actually creates the info window. Instead of using the text of the message, we use the string variable.