![]() |
naev 0.12.6
|
Is a high-level API around toolkit.c for easy window creation. More...
#include "dialogue.h"#include "conf.h"#include "input.h"#include "log.h"#include "menu.h"#include "ndata.h"#include "opengl.h"#include "toolkit.h"
Go to the source code of this file.
Data Structures | |
| struct | dialogue_update_t |
| struct | dialogue_custom_data_s |
| struct | InputDialogue |
| Used to store information for input dialogues. More... | |
Functions | |
| static int | dialogue_custom_event (unsigned int wid, SDL_Event *event) |
| void | main_loop (int nested) |
| Split main loop from main() for secondary loop hack in toolkit.c. | |
| static void | dialogue_close (unsigned int wid, const char *str) |
| Generic window close. | |
| static void | dialogue_cancel (unsigned int wid, const char *str) |
| Generic window cancel. | |
| static glFont * | dialogue_getSize (const char *title, const char *msg, int *width, int *height) |
| Gets the size needed for the dialogue. | |
| static void | dialogue_YesNoClose (unsigned int wid, const char *str) |
| Closes a yesno dialogue. | |
| static void | dialogue_inputClose (unsigned int wid, const char *str) |
| Closes an input dialogue. | |
| static void | dialogue_choiceClose (unsigned int wid, const char *str) |
| Closes a choice dialogue. | |
| static void | dialogue_listClose (unsigned int wid, const char *str) |
| static void | dialogue_listCancel (unsigned int wid, const char *str) |
| static int | toolkit_loop (int *loop_done, dialogue_update_t *du) |
| Creates a secondary loop until loop_done is set to 1 or the toolkit closes. | |
| static void | select_call_wrapper (unsigned int wid, const char *wgtname) |
| used to pass appropriate information to the method that handles updating the extra information area in the dialogue listpanel. | |
| int | dialogue_isOpen (void) |
| Checks to see if a dialogue is open. | |
| void | dialogue_alert (const char *fmt,...) |
| Displays an alert popup with only an ok button and a message. | |
| void | dialogue_alertRaw (const char *msg) |
| Displays an alert popup with only an ok button and a message. | |
| void | dialogue_msg (const char *caption, const char *fmt,...) |
| Opens a dialogue window with an ok button and a message. | |
| void | dialogue_msgImg (const char *caption, const char *img, const char *fmt,...) |
| Opens a dialogue window with an ok button, a message and an image. | |
| void | dialogue_msgRaw (const char *caption, const char *msg) |
| Opens a dialogue window with an ok button and a fixed message. | |
| void | dialogue_msgImgRaw (const char *caption, const char *msg, const char *img, int width, int height) |
| Opens a dialogue window with an ok button, a fixed message and an image. | |
| int | dialogue_YesNo (const char *caption, const char *fmt,...) |
| Runs a dialogue with both yes and no options. | |
| int | dialogue_YesNoRaw (const char *caption, const char *msg) |
| Runs a dialogue with both yes and no options. | |
| char * | dialogue_input (const char *title, int min, int max, const char *fmt,...) |
| Creates a dialogue that allows the player to write a message. | |
| char * | dialogue_inputRaw (const char *title, int min, int max, const char *msg) |
| Creates a dialogue that allows the player to write a message. | |
| int | dialogue_list (const char *title, char **items, int nitems, const char *fmt,...) |
| Creates a list dialogue with OK and Cancel button with a fixed message. | |
| int | dialogue_listRaw (const char *title, char **items, int nitems, const char *msg) |
| Creates a list dialogue with OK and Cancel button. | |
| int | dialogue_listPanel (const char *title, char **items, int nitems, int extrawidth, int minheight, void(*add_widgets)(unsigned int wid, int x, int y, int w, int h), void(*select_call)(unsigned int wid, const char *wgtname, int x, int y, int w, int h), const char *fmt,...) |
| Creates a list dialogue with OK and Cancel buttons, with a fixed message, as well as a small extra area for the list to react to item selected events. | |
| int | dialogue_listPanelRaw (const char *title, char **items, int nitems, int extrawidth, int minheight, void(*add_widgets)(unsigned int wid, int x, int y, int w, int h), void(*select_call)(unsigned int wid, const char *wgtname, int x, int y, int w, int h), const char *msg) |
| Creates a list dialogue with OK and Cancel buttons, with a fixed message, as well as a small extra area for the list to react to item selected events. | |
| void | dialogue_makeChoice (const char *caption, const char *msg, int opts) |
| Create the choice dialog. Need to add choices with below method. | |
| void | dialogue_addChoice (const char *caption, const char *msg, const char *opt) |
| Add a choice to the dialog. | |
| char * | dialogue_runChoice (void) |
| Run the dialog and return the clicked string. | |
| void | dialogue_custom (const char *wdwname, const char *caption, int width, int height, int(*update)(double dt, void *data), void(*render)(double x, double y, double w, double h, void *data), int(*event)(unsigned int wid, SDL_Event *event, void *data), void *data, int dynamic, void(*freefunc)(void *data)) |
| Opens a custom dialogue window. | |
| int | dialogue_customFullscreen (unsigned int wid, int enable) |
| Converts a custom dialogue to fullscreen. | |
| int | dialogue_customResize (unsigned int wid, int width, int height) |
| Resizes a custom dialogue. | |
Variables | |
| static int | dialogue_open |
| static int | dlgid = 0 |
| static InputDialogue | input_dialogue |
| static int | dialogue_listSelected = -1 |
| static unsigned int | choice_wid = 0 |
| static char * | choice_result |
| static int | choice_nopts |
Is a high-level API around toolkit.c for easy window creation.
Only one dialogue may be open at once or behaviour is unspecified.
All these dialogues use what I call the secondary main loop hack. Basically they spawn another main loop identical to the primary whose only difference is that it breaks on loop_done. Therefore this loop hijacks the main loop until it's over, making these functions seem to be blocking without really being blocking.
Definition in file dialogue.c.
| void dialogue_addChoice | ( | const char * | caption, |
| const char * | msg, | ||
| const char * | opt ) |
Add a choice to the dialog.
| caption | Caption to use for the dialogue (for sizing). |
| msg | Message to display (for sizing). |
| *opt | The value of the option. |
Definition at line 796 of file dialogue.c.
| void dialogue_alert | ( | const char * | fmt, |
| ... ) |
Displays an alert popup with only an ok button and a message.
| fmt | Printf style message to display. |
Definition at line 130 of file dialogue.c.
| void dialogue_alertRaw | ( | const char * | msg | ) |
Displays an alert popup with only an ok button and a message.
| msg | String to display. |
Definition at line 149 of file dialogue.c.
|
static |
Generic window cancel.
Definition at line 116 of file dialogue.c.
|
static |
Closes a choice dialogue.
| wid | Window being closed. |
| str | Stored to choice_result. |
Definition at line 837 of file dialogue.c.
|
static |
Generic window close.
Definition at line 104 of file dialogue.c.
| void dialogue_custom | ( | const char * | wdwname, |
| const char * | caption, | ||
| int | width, | ||
| int | height, | ||
| int(* | update )(double dt, void *data), | ||
| void(* | render )(double x, double y, double w, double h, void *data), | ||
| int(* | event )(unsigned int wid, SDL_Event *event, void *data), | ||
| void * | data, | ||
| int | dynamic, | ||
| void(* | freefunc )(void *data) ) |
Opens a custom dialogue window.
| wdwname | Window name. |
| caption | Window title. |
| width | Width of the widget. |
| height | Height of the widget. |
| update | Custom render callback. |
| render | Custom render callback. |
| event | Custom event callback. |
| data | Custom data. |
| dynamic | Whether or not the custom is dynamic. |
| freefunc | Function to be run when cleaning the custom data. |
Definition at line 890 of file dialogue.c.
|
static |
Definition at line 853 of file dialogue.c.
| int dialogue_customFullscreen | ( | unsigned int | wid, |
| int | enable ) |
Converts a custom dialogue to fullscreen.
| wid | Window ID to use. |
| enable | Whether or not to enable it. |
Definition at line 956 of file dialogue.c.
| int dialogue_customResize | ( | unsigned int | wid, |
| int | width, | ||
| int | height ) |
Resizes a custom dialogue.
| wid | Window ID. |
| width | Width to set to. |
| height | Height to set to. |
Definition at line 992 of file dialogue.c.
|
static |
Gets the size needed for the dialogue.
| title | Title of the dialogue. | |
| msg | Message of the dialogue. | |
| [out] | width | Gets the width needed. |
| [out] | height | Gets the height needed. |
Definition at line 177 of file dialogue.c.
| char * dialogue_input | ( | const char * | title, |
| int | min, | ||
| int | max, | ||
| const char * | fmt, | ||
| ... ) |
Creates a dialogue that allows the player to write a message.
You must free the result if it's not null.
| title | Title of the dialogue window. |
| min | Minimum length of the message (must be non-zero). |
| max | Maximum length of the message (must be non-zero). |
| fmt | Printf style message to display on the dialogue. |
Definition at line 441 of file dialogue.c.
|
static |
Closes an input dialogue.
| wid | Unused. |
| str | Unused. |
Definition at line 542 of file dialogue.c.
| char * dialogue_inputRaw | ( | const char * | title, |
| int | min, | ||
| int | max, | ||
| const char * | msg ) |
Creates a dialogue that allows the player to write a message.
You must free the result if it's not null.
| title | Title of the dialogue window. |
| min | Minimum length of the message (must be non-zero). |
| max | Maximum length of the message (must be non-zero). |
| msg | Message to be displayed. |
Definition at line 470 of file dialogue.c.
| int dialogue_isOpen | ( | void | ) |
Checks to see if a dialogue is open.
Definition at line 96 of file dialogue.c.
| int dialogue_list | ( | const char * | title, |
| char ** | items, | ||
| int | nitems, | ||
| const char * | fmt, | ||
| ... ) |
Creates a list dialogue with OK and Cancel button with a fixed message.
| title | Title of the dialogue. |
| items | Items in the list (should be all malloced, automatically freed). |
| nitems | Number of items. |
| fmt | printf formatted string with text to display. |
Definition at line 588 of file dialogue.c.
|
static |
Definition at line 553 of file dialogue.c.
|
static |
Definition at line 558 of file dialogue.c.
| int dialogue_listPanel | ( | const char * | title, |
| char ** | items, | ||
| int | nitems, | ||
| int | extrawidth, | ||
| int | minheight, | ||
| void(* | add_widgets )(unsigned int wid, int x, int y, int w, int h), | ||
| void(* | select_call )(unsigned int wid, const char *wgtname, int x, int y, int w, int h), | ||
| const char * | fmt, | ||
| ... ) |
Creates a list dialogue with OK and Cancel buttons, with a fixed message, as well as a small extra area for the list to react to item selected events.
| title | Title of the dialogue. |
| items | Items in the list (should be all malloced, automatically freed). |
| nitems | Number of items. |
| extrawidth | Width of area to add for select_call callback. |
| minheight | Minimum height for the window. |
| add_widgets | This function is called with the new window as an argument allowing for initial population of the extra area. |
| select_call | This function is called when a new item in the list is selected, receiving the window's id and the selected widgets name as arguments. |
| fmt | printf formatted string with text to display. |
Definition at line 639 of file dialogue.c.
| int dialogue_listPanelRaw | ( | const char * | title, |
| char ** | items, | ||
| int | nitems, | ||
| int | extrawidth, | ||
| int | minheight, | ||
| void(* | add_widgets )(unsigned int wid, int x, int y, int w, int h), | ||
| void(* | select_call )(unsigned int wid, const char *wgtname, int x, int y, int w, int h), | ||
| const char * | msg ) |
Creates a list dialogue with OK and Cancel buttons, with a fixed message, as well as a small extra area for the list to react to item selected events.
| title | Title of the dialogue. |
| items | Items in the list (should be all malloced, automatically freed). |
| nitems | Number of items. |
| extrawidth | Width of area to add for select_call callback. |
| minheight | Minimum height for the window. |
| add_widgets | This function is called with the new window as an argument allowing for initial population of the extra area. |
| select_call | (optional) This function is called when a new item in the list is selected, receiving the window's id and the selected widgets name as arguments. |
| msg | string with text to display. |
Definition at line 681 of file dialogue.c.
| int dialogue_listRaw | ( | const char * | title, |
| char ** | items, | ||
| int | nitems, | ||
| const char * | msg ) |
Creates a list dialogue with OK and Cancel button.
| title | Title of the dialogue. |
| items | Items in the list (should be all malloced, automatically freed). |
| nitems | Number of items. |
| msg | string with text to display. |
Definition at line 614 of file dialogue.c.
| void dialogue_makeChoice | ( | const char * | caption, |
| const char * | msg, | ||
| int | opts ) |
Create the choice dialog. Need to add choices with below method.
| caption | Caption to use for the dialogue. |
| msg | Message to display. |
| opts | The number of options. |
Definition at line 773 of file dialogue.c.
| void dialogue_msg | ( | const char * | caption, |
| const char * | fmt, | ||
| ... ) |
Opens a dialogue window with an ok button and a message.
| caption | Window title. |
| fmt | Printf style message to display. |
Definition at line 227 of file dialogue.c.
| void dialogue_msgImg | ( | const char * | caption, |
| const char * | img, | ||
| const char * | fmt, | ||
| ... ) |
Opens a dialogue window with an ok button, a message and an image.
| caption | Window title. |
| img | Path of the image file to display. |
| fmt | Printf style message to display. |
Definition at line 248 of file dialogue.c.
| void dialogue_msgImgRaw | ( | const char * | caption, |
| const char * | msg, | ||
| const char * | img, | ||
| int | width, | ||
| int | height ) |
Opens a dialogue window with an ok button, a fixed message and an image.
| caption | Window title. |
| msg | Message to display. |
| img | Path of the image file to display. |
| width | Width of the image. Negative uses image width. |
| height | Height of the image. Negative uses image height. |
Definition at line 296 of file dialogue.c.
| void dialogue_msgRaw | ( | const char * | caption, |
| const char * | msg ) |
Opens a dialogue window with an ok button and a fixed message.
| caption | Window title. |
| msg | Message to display. |
Definition at line 269 of file dialogue.c.
| char * dialogue_runChoice | ( | void | ) |
Run the dialog and return the clicked string.
Definition at line 817 of file dialogue.c.
| int dialogue_YesNo | ( | const char * | caption, |
| const char * | fmt, | ||
| ... ) |
Runs a dialogue with both yes and no options.
| caption | Caption to use for the dialogue. |
| fmt | Printf style message. |
Definition at line 352 of file dialogue.c.
|
static |
Closes a yesno dialogue.
| wid | Window being closed. |
| str | Unused. |
Definition at line 408 of file dialogue.c.
| int dialogue_YesNoRaw | ( | const char * | caption, |
| const char * | msg ) |
Runs a dialogue with both yes and no options.
| caption | Caption to use for the dialogue. |
| msg | Message to display. |
Definition at line 373 of file dialogue.c.
|
extern |
|
static |
used to pass appropriate information to the method that handles updating the extra information area in the dialogue listpanel.
| wid | Window id |
| wgtname | name of the widget that raised the event. |
Definition at line 571 of file dialogue.c.
|
static |
Creates a secondary loop until loop_done is set to 1 or the toolkit closes.
Almost identical to the main loop in naev.c.
Definition at line 1019 of file dialogue.c.
|
static |
Counter variable.
Definition at line 765 of file dialogue.c.
|
static |
Pointer to the choice result.
Definition at line 764 of file dialogue.c.
|
static |
Stores the choice window id.
Definition at line 763 of file dialogue.c.
|
static |
Definition at line 552 of file dialogue.c.
|
static |
Number of dialogues open.
Definition at line 36 of file dialogue.c.
|
static |
ID generator.
Definition at line 37 of file dialogue.c.
|
static |
Stores the input window id and callback.
Definition at line 429 of file dialogue.c.