Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
dialogBox.h
Go to the documentation of this file.
1
74#ifndef _DIALOG_BOX_H_
75#define _DIALOG_BOX_H_
76
77//==============================================================================
78// Includes
79//==============================================================================
80#include <stdint.h>
81#include "linked_list.h"
82#include "font.h"
83#include "wsg.h"
84#include "palette.h"
85#include "hdw-btn.h"
86
87//==============================================================================
88// Defines
89//==============================================================================
91#define DIALOG_CENTER (1 << 15)
92
94#define DIALOG_AUTO (1 << 15)
95
96typedef void (*dialogBoxCbFn_t)(const char* label);
97
98//==============================================================================
99// Enums
100//==============================================================================
122
123//==============================================================================
124// Structs
125//==============================================================================
126typedef struct
127{
129 const char* label;
130
132 const wsg_t* icon;
133
137
138typedef struct
139{
141 const wsg_t* icon;
142
144 const char* title;
145
147 const char* detail;
148
151
154
157
159 bool holdA;
160
162 bool holdB;
164
165//==============================================================================
166// Function Declarations
167//==============================================================================
168dialogBox_t* initDialogBox(const char* title, const char* detail, const wsg_t* icon, dialogBoxCbFn_t cbFn);
169void deinitDialogBox(dialogBox_t* dialogBox);
170void dialogBoxAddOption(dialogBox_t* dialogBox, const char* label, const wsg_t* icon, dialogOptionHint_t hints);
171void dialogBoxReset(dialogBox_t* dialogBox);
172void drawDialogBox(const dialogBox_t* dialogBox, const font_t* titleFont, const font_t* detailFont, uint16_t x,
173 uint16_t y, uint16_t w, uint16_t h, uint16_t r);
174void dialogBoxButton(dialogBox_t* dialogBox, const buttonEvt_t* evt);
175
176#endif
dialogOptionHint_t hints
The rendering hints for the option button.
Definition dialogBox.h:135
dialogBox_t * initDialogBox(const char *title, const char *detail, const wsg_t *icon, dialogBoxCbFn_t cbFn)
Allocate and return a new dialogBox_t with the given settings.
Definition dialogBox.c:127
void(* dialogBoxCbFn_t)(const char *label)
Definition dialogBox.h:96
bool holdA
Whether A is being held.
Definition dialogBox.h:159
node_t * selectedOption
The currently-selected option.
Definition dialogBox.h:153
const char * detail
The text in the body of the dialog box.
Definition dialogBox.h:147
dialogOptionHint_t
Hints for the dialog box renderer. Multiple options can be combined with bitwise OR.
Definition dialogBox.h:106
@ OPTHINT_DISABLED
This option should be shown, but should not be selectable.
Definition dialogBox.h:120
@ OPTHINT_NORMAL
No special options for this dialog option.
Definition dialogBox.h:108
@ OPTHINT_OK
This option is the "OK" option.
Definition dialogBox.h:111
@ OPTHINT_CANCEL
This option is the "Cancel" option, and will be selected if the user presses B.
Definition dialogBox.h:114
@ OPTHINT_DEFAULT
This option should be selected by default when the dialog resets.
Definition dialogBox.h:117
list_t options
The linked list of dialog box options.
Definition dialogBox.h:150
const wsg_t * icon
The icon, if any, to draw inside the option button.
Definition dialogBox.h:132
const char * title
The title of the dialog box to draw at the top.
Definition dialogBox.h:144
void deinitDialogBox(dialogBox_t *dialogBox)
Deallocate all memory associated with the given dialog box.
Definition dialogBox.c:144
void drawDialogBox(const dialogBox_t *dialogBox, const font_t *titleFont, const font_t *detailFont, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t r)
Draw the dialog box.
Definition dialogBox.c:426
const char * label
The text to draw in the dialog.
Definition dialogBox.h:129
bool holdB
Whether B is being held.
Definition dialogBox.h:162
void dialogBoxReset(dialogBox_t *dialogBox)
Clear all options from the given dialog box.
Definition dialogBox.c:179
void dialogBoxButton(dialogBox_t *dialogBox, const buttonEvt_t *evt)
Handle button presses for the dialog box.
Definition dialogBox.c:537
dialogBoxCbFn_t cbFn
The callback function for when an item is selected.
Definition dialogBox.h:156
void dialogBoxAddOption(dialogBox_t *dialogBox, const char *label, const wsg_t *icon, dialogOptionHint_t hints)
Add an option button to a dialog box.
Definition dialogBox.c:158
Definition dialogBox.h:127
Definition dialogBox.h:139
A font is a collection of font_ch_t for all ASCII characters. Each character has the same height and ...
Definition font.h:66
A button event containing the button that triggered the event, whether it was pressed or released,...
Definition hdw-btn.h:117
A doubly linked list with pointers to the first and last nodes.
Definition linked_list.h:87
A node in a doubly linked list with pointers to the previous and next values (which may be NULL),...
Definition linked_list.h:77
A sprite using paletteColor_t colors that can be drawn to the display.
Definition wsg.h:57