![]() |
naev 0.10.4
|
Is a high-level API around toolkit.c for easy window creation. More...
#include "dialogue.h"#include "input.h"#include "log.h"#include "conf.h"#include "menu.h"#include "ndata.h"#include "nstring.h"#include "opengl.h"#include "pause.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 update) |
| Split main loop from main() for secondary loop hack in toolkit.c. More... | |
| static void | dialogue_close (unsigned int wid, const char *str) |
| Generic window close. More... | |
| static void | dialogue_cancel (unsigned int wid, const char *str) |
| Generic window cancel. More... | |
| static glFont * | dialogue_getSize (const char *title, const char *msg, int *width, int *height) |
| Gets the size needed for the dialogue. More... | |
| static void | dialogue_YesNoClose (unsigned int wid, const char *str) |
| Closes a yesno dialogue. More... | |
| static void | dialogue_inputClose (unsigned int wid, const char *str) |
| Closes an input dialogue. More... | |
| static void | dialogue_choiceClose (unsigned int wid, const char *str) |
| Closes a choice dialogue. More... | |
| 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. More... | |
| 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. More... | |
| int | dialogue_isOpen (void) |
| Checks to see if a dialogue is open. More... | |
| void | dialogue_alert (const char *fmt,...) |
| Displays an alert popup with only an ok button and a message. More... | |
| void | dialogue_msg (const char *caption, const char *fmt,...) |
| Opens a dialogue window with an ok button and a message. More... | |
| 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. More... | |
| void | dialogue_msgRaw (const char *caption, const char *msg) |
| Opens a dialogue window with an ok button and a fixed message. More... | |
| 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. More... | |
| int | dialogue_YesNo (const char *caption, const char *fmt,...) |
| Runs a dialogue with both yes and no options. More... | |
| int | dialogue_YesNoRaw (const char *caption, const char *msg) |
| Runs a dialogue with both yes and no options. More... | |
| char * | dialogue_input (const char *title, int min, int max, const char *fmt,...) |
| Creates a dialogue that allows the player to write a message. More... | |
| char * | dialogue_inputRaw (const char *title, int min, int max, const char *msg) |
| Creates a dialogue that allows the player to write a message. More... | |
| 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. More... | |
| int | dialogue_listRaw (const char *title, char **items, int nitems, const char *msg) |
| Creates a list dialogue with OK and Cancel button. More... | |
| 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. More... | |
| 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. More... | |
| void | dialogue_makeChoice (const char *caption, const char *msg, int opts) |
| Create the choice dialog. Need to add choices with below method. More... | |
| void | dialogue_addChoice (const char *caption, const char *msg, const char *opt) |
| Add a choice to the dialog. More... | |
| char * | dialogue_runChoice (void) |
| Run the dialog and return the clicked string. More... | |
| void | dialogue_custom (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 autofree) |
| Opens a custom dialogue window. More... | |
| int | dialogue_customFullscreen (int enable) |
| Converts a custom dialogue to fullscreen. More... | |
| int | dialogue_customResize (int width, int height) |
| Resizes a custom dialogue. More... | |
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 770 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 132 of file dialogue.c.
|
static |
Generic window cancel.
Definition at line 118 of file dialogue.c.
|
static |
Closes a choice dialogue.
| wid | Window being closed. |
| str | Stored to choice_result. |
Definition at line 812 of file dialogue.c.
|
static |
Generic window close.
Definition at line 106 of file dialogue.c.
| void dialogue_custom | ( | const char * | caption, |
| int | width, | ||
| int | height, | ||
| int(*)(double dt, void *data) | update, | ||
| void(*)(double x, double y, double w, double h, void *data) | render, | ||
| int(*)(unsigned int wid, SDL_Event *event, void *data) | event, | ||
| void * | data, | ||
| int | autofree | ||
| ) |
Opens a custom dialogue window.
| 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. |
| autofree | Should data be freed when the window is destroyed? |
Definition at line 863 of file dialogue.c.
|
static |
Definition at line 828 of file dialogue.c.
| int dialogue_customFullscreen | ( | int | enable | ) |
Converts a custom dialogue to fullscreen.
| enable | Whether or not to enable it. |
Definition at line 927 of file dialogue.c.
| int dialogue_customResize | ( | int | width, |
| int | height | ||
| ) |
Resizes a custom dialogue.
| width | Width to set to. |
| height | Height to set to. |
Definition at line 964 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 168 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 436 of file dialogue.c.
|
static |
Closes an input dialogue.
| wid | Unused. |
| str | Unused. |
Definition at line 532 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 465 of file dialogue.c.
| int dialogue_isOpen | ( | void | ) |
Checks to see if a dialogue is open.
Definition at line 98 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 576 of file dialogue.c.
|
static |
Definition at line 543 of file dialogue.c.
|
static |
Definition at line 548 of file dialogue.c.
| int dialogue_listPanel | ( | const char * | title, |
| char ** | items, | ||
| int | nitems, | ||
| int | extrawidth, | ||
| int | minheight, | ||
| void(*)(unsigned int wid, int x, int y, int w, int h) | add_widgets, | ||
| void(*)(unsigned int wid, const char *wgtname, int x, int y, int w, int h) | select_call, | ||
| 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 621 of file dialogue.c.
| int dialogue_listPanelRaw | ( | const char * | title, |
| char ** | items, | ||
| int | nitems, | ||
| int | extrawidth, | ||
| int | minheight, | ||
| void(*)(unsigned int wid, int x, int y, int w, int h) | add_widgets, | ||
| void(*)(unsigned int wid, const char *wgtname, int x, int y, int w, int h) | select_call, | ||
| 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 659 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 600 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 748 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 218 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 240 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 290 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 261 of file dialogue.c.
| char * dialogue_runChoice | ( | void | ) |
Run the dialog and return the clicked string.
Definition at line 792 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 344 of file dialogue.c.
|
static |
Closes a yesno dialogue.
| wid | Window being closed. |
| str | Unused. |
Definition at line 404 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 366 of file dialogue.c.
| void main_loop | ( | int | update | ) |
|
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 561 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 991 of file dialogue.c.
|
static |
Counter variable.
Definition at line 740 of file dialogue.c.
|
static |
Pointer to the choice result.
Definition at line 739 of file dialogue.c.
|
static |
Stores the choice window id.
Definition at line 738 of file dialogue.c.
|
static |
Definition at line 542 of file dialogue.c.
|
static |
Number of dialogues open.
Definition at line 38 of file dialogue.c.
|
static |
ID generator.
Definition at line 39 of file dialogue.c.
|
static |
Stores the input window id and callback.
Definition at line 424 of file dialogue.c.