Big up for Volca ... slowdown the busy icon
[open-ps2-loader.git] / include / gui.h
blob1db03e50267d16c3d75ee08e45eaab3adc35dab1
1 #ifndef __GUI_H
2 #define __GUI_H
4 #include "include/iosupport.h"
5 #include "include/usbld.h"
6 #include "include/texcache.h"
7 #include "include/dialogs.h"
8 #include "include/menusys.h"
10 typedef enum {
11 // Informs gui that init is over and main gui can be rendered
12 GUI_INIT_DONE = 1,
13 GUI_OP_ADD_MENU,
14 GUI_OP_APPEND_MENU,
15 GUI_OP_SELECT_MENU,
16 GUI_OP_CLEAR_SUBMENU,
17 GUI_OP_SORT,
18 GUI_OP_ADD_HINT
19 } gui_op_type_t;
21 /** a single GUI update in a package form */
22 struct gui_update_t {
23 gui_op_type_t type;
25 struct {
26 menu_item_t *menu;
27 submenu_list_t **subMenu;
28 } menu;
30 union {
31 struct {
32 int icon_id;
33 char *text;
34 int id;
35 int text_id;
36 int selected;
37 } submenu;
39 struct { // hint for the given menu
40 int icon_id;
41 int text_id;
42 } hint;
46 typedef void (*gui_callback_t)(void);
48 int guiInactiveFrames;
49 int guiFrameId;
51 #define GUI_SCREEN_MAIN 0
52 #define GUI_SCREEN_MENU 1
53 #define GUI_SCREEN_INFO 2
55 #define TRANSITION_LEFT 0
56 #define TRANSITION_RIGHT 1
57 #define TRANSITION_UP 2
58 #define TRANSITION_DOWN 3
60 void guiSwitchScreen(int target, int transition);
62 void guiReloadScreenExtents();
64 /** Initializes the GUI */
65 void guiInit();
67 /** Clean-up the GUI */
68 void guiEnd();
70 /** Locks gui for direct gui data updates */
71 void guiLock();
73 /** Unlocks gui after direct gui data updates */
74 void guiUnlock();
76 /** invokes the intro loop */
77 void guiIntroLoop();
79 /** invokes the main loop */
80 void guiMainLoop();
82 /** Hooks a single per-frame callback */
83 void guiSetFrameHook(gui_callback_t cback);
85 // Deffered update handling:
86 /* Note:
87 All the GUI operation requests can be deffered to the proper time
88 when rendering is not going on. This allows us, for example, to schedule
89 updates of the menu from another thread without stalls.
92 /** Detects if a given deffered operation is already complete
93 * @param opid The operation id, as returned from guiDeferUpdate
94 * @return 1 if the operation was already completed, 0 otherwise */
95 int guiGetOpCompleted(int opid);
97 /** Defers the given update to an appropriate time.
98 * @param op The operation to defer
99 * @return int The operation serial id
101 int guiDeferUpdate(struct gui_update_t *op);
103 /** Allocates a new deffered operation */
104 struct gui_update_t *guiOpCreate(gui_op_type_t type);
106 /** For completeness, the deffered operations are destroyed automatically */
107 void guiDestroyOp(struct gui_update_t *op);
109 int guiShowCompatConfig(int id, item_list_t *support, config_set_t* configSet);
110 int guiShowKeyboard(char* value, int maxLength);
111 int guiMsgBox(const char* text, int addAccept, struct UIItem *ui);
113 void guiUpdateScrollSpeed(void);
114 void guiUpdateScreenScale(void);
116 void guiDrawBGPlasma();
117 int guiDrawIconAndText(int iconId, int textId, int font, int x, int y, u64 color);
119 void guiShowAbout();
120 void guiShowConfig();
121 void guiShowUIConfig();
122 void guiShowIPConfig();
124 /** Renders the given string on screen for the given function until it's io finishes
125 * @note The ptr pointer is watched for it's value. The IO is considered finished when the value becomes zero.
126 * @param ptr The finished state pointer (1 unfinished, 0 finished)
127 * @param message The message to display while working
128 * @param type the io operation type
129 * @param data the data for the operation
131 void guiHandleDeferedIO(int *ptr, const unsigned char* message, int type, void *data);
133 /** Renders a single frame with a specified message on the screen
135 void guiRenderTextScreen(const unsigned char* message);
137 int guiAltStartupNameHandler(char* text, int maxLen);
139 #ifdef VMC
140 int guiVmcNameHandler(char* text, int maxLen);
141 #endif
143 #endif