Make in-game a GUI a bit simpler to work with by reducing the need to manually calculate max vertices for screens

This commit is contained in:
UnknownShadow200 2023-12-16 14:42:06 +11:00
parent 83e331c500
commit 0def08bfd4
6 changed files with 86 additions and 70 deletions

View File

@ -590,7 +590,7 @@ static void BlockEditCommand_Execute(const cc_string* args, int argsCount__) {
Chat_AddRaw("&eEditable block properties (page 2):"); Chat_AddRaw("&eEditable block properties (page 2):");
Chat_AddRaw("&a walksound &e- Sets walk/step sound of the block"); Chat_AddRaw("&a walksound &e- Sets walk/step sound of the block");
Chat_AddRaw("&a breaksound &e- Sets break sound of the block"); Chat_AddRaw("&a breaksound &e- Sets break sound of the block");
Chat_AddRaw("&a emitslight &e- Sets whether the block emits light"); Chat_AddRaw("&a fullbright &e- Sets whether the block is fully lit");
Chat_AddRaw("&a blockslight &e- Sets whether the block stops light"); Chat_AddRaw("&a blockslight &e- Sets whether the block stops light");
return; return;
} }
@ -670,8 +670,8 @@ static void BlockEditCommand_Execute(const cc_string* args, int argsCount__) {
if (!BlockEditCommand_GetInt(value, "Sound", &v, 0, SOUND_COUNT - 1)) return; if (!BlockEditCommand_GetInt(value, "Sound", &v, 0, SOUND_COUNT - 1)) return;
Blocks.DigSounds[block] = v; Blocks.DigSounds[block] = v;
} else if (String_CaselessEqualsConst(prop, "emitslight")) { } else if (String_CaselessEqualsConst(prop, "fullbright")) {
if (!BlockEditCommand_GetBool(value, "Emits light", &b)) return; if (!BlockEditCommand_GetBool(value, "Full brightness", &b)) return;
Blocks.FullBright[block] = b; Blocks.FullBright[block] = b;
} else if (String_CaselessEqualsConst(prop, "blockslight")) { } else if (String_CaselessEqualsConst(prop, "blockslight")) {

View File

@ -480,6 +480,20 @@ int Screen_Index(void* screen, void* widget) {
return -1; return -1;
} }
int Screen_CalcDefaultMaxVertices(void* screen) {
struct Screen* s = (struct Screen*)screen;
struct Widget** widgets = s->widgets;
int i, count = 0;
for (i = 0; i < s->numWidgets; i++)
{
if (!widgets[i]) continue;
count += widgets[i]->VTABLE->GetMaxVertices(widgets[i]);
}
return count;
}
void Screen_BuildMesh(void* screen) { void Screen_BuildMesh(void* screen) {
struct Screen* s = (struct Screen*)screen; struct Screen* s = (struct Screen*)screen;
struct Widget** widgets = s->widgets; struct Widget** widgets = s->widgets;

View File

@ -112,6 +112,7 @@ void Screen_UpdateVb(void* screen);
struct VertexTextured* Screen_LockVb(void* screen); struct VertexTextured* Screen_LockVb(void* screen);
int Screen_DoPointerDown(void* screen, int id, int x, int y); int Screen_DoPointerDown(void* screen, int id, int x, int y);
int Screen_Index(void* screen, void* w); int Screen_Index(void* screen, void* w);
int Screen_CalcDefaultMaxVertices(void* screen);
/* Default mesh building implementation for a screen */ /* Default mesh building implementation for a screen */
/* (Locks vb, calls Widget_BuildMesh on each widget, then unlocks vb) */ /* (Locks vb, calls Widget_BuildMesh on each widget, then unlocks vb) */
@ -156,7 +157,10 @@ struct WidgetVTABLE {
void (*BuildMesh)(void* elem, struct VertexTextured** vertices); void (*BuildMesh)(void* elem, struct VertexTextured** vertices);
/* Draws this widget on-screen. */ /* Draws this widget on-screen. */
int (*Render2)(void* elem, int offset); int (*Render2)(void* elem, int offset);
/* Returns the maximum number of vertices this widget may use */
int (*GetMaxVertices)(void* elem);
}; };
#define Widget_Body const struct WidgetVTABLE* VTABLE; \ #define Widget_Body const struct WidgetVTABLE* VTABLE; \
int x, y, width, height; /* Top left corner, and dimensions, of this widget */ \ int x, y, width, height; /* Top left corner, and dimensions, of this widget */ \
cc_bool active; /* Whether this widget is currently being moused over */ \ cc_bool active; /* Whether this widget is currently being moused over */ \

View File

@ -258,7 +258,6 @@ static struct Widget* list_widgets[] = {
(struct Widget*)&ListScreen.right, (struct Widget*)&ListScreen.title, (struct Widget*)&ListScreen.right, (struct Widget*)&ListScreen.title,
(struct Widget*)&ListScreen.done, NULL (struct Widget*)&ListScreen.done, NULL
}; };
#define LIST_MAX_VERTICES (9 * BUTTONWIDGET_MAX + TEXTWIDGET_MAX)
#define LISTSCREEN_EMPTY "-" #define LISTSCREEN_EMPTY "-"
static void ListScreen_Layout(void* screen) { static void ListScreen_Layout(void* screen) {
@ -400,7 +399,6 @@ static void ListScreen_Init(void* screen) {
s->numWidgets = Array_Elems(list_widgets); s->numWidgets = Array_Elems(list_widgets);
s->wheelAcc = 0.0f; s->wheelAcc = 0.0f;
s->currentIndex = 0; s->currentIndex = 0;
s->maxVertices = LIST_MAX_VERTICES;
for (i = 0; i < LIST_SCREEN_ITEMS; i++) { for (i = 0; i < LIST_SCREEN_ITEMS; i++) {
ButtonWidget_Init(&s->btns[i], 300, s->EntryClick); ButtonWidget_Init(&s->btns[i], 300, s->EntryClick);
@ -419,6 +417,8 @@ static void ListScreen_Init(void* screen) {
ButtonWidget_Init(&s->left, 40, ListScreen_MoveBackwards); ButtonWidget_Init(&s->left, 40, ListScreen_MoveBackwards);
ButtonWidget_Init(&s->right, 40, ListScreen_MoveForwards); ButtonWidget_Init(&s->right, 40, ListScreen_MoveForwards);
TextWidget_Init(&s->title); TextWidget_Init(&s->title);
s->maxVertices = Screen_CalcDefaultMaxVertices(screen);
s->LoadEntries(s); s->LoadEntries(s);
} }
@ -499,7 +499,6 @@ static struct PauseScreen {
struct ButtonWidget btns[PAUSE_MAX_BTNS], quit, back; struct ButtonWidget btns[PAUSE_MAX_BTNS], quit, back;
struct TextWidget title; struct TextWidget title;
} PauseScreen; } PauseScreen;
#define PAUSE_MAX_VERTICES (TEXTWIDGET_MAX + (PAUSE_MAX_BTNS + 2) * BUTTONWIDGET_MAX)
static void PauseScreenBase_Quit(void* a, void* b) { Window_Close(); } static void PauseScreenBase_Quit(void* a, void* b) { Window_Close(); }
static void PauseScreenBase_Game(void* a, void* b) { Gui_Remove((struct Screen*)&PauseScreen); } static void PauseScreenBase_Game(void* a, void* b) { Gui_Remove((struct Screen*)&PauseScreen); }
@ -513,10 +512,11 @@ static void PauseScreenBase_ContextRecreated(struct PauseScreen* s, struct FontD
} }
static void PauseScreenBase_Init(struct PauseScreen* s, int width) { static void PauseScreenBase_Init(struct PauseScreen* s, int width) {
s->maxVertices = PAUSE_MAX_VERTICES;
Menu_InitButtons(s->btns, width, s->descs, s->descsCount); Menu_InitButtons(s->btns, width, s->descs, s->descsCount);
ButtonWidget_Init(&s->back, 400, PauseScreenBase_Game); ButtonWidget_Init(&s->back, 400, PauseScreenBase_Game);
TextWidget_Init(&s->title); TextWidget_Init(&s->title);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
@ -683,7 +683,6 @@ static struct Widget* optGroups_widgets[] = {
(struct Widget*)&OptionsGroupScreen.btns[6], (struct Widget*)&OptionsGroupScreen.btns[7], (struct Widget*)&OptionsGroupScreen.btns[6], (struct Widget*)&OptionsGroupScreen.btns[7],
(struct Widget*)&OptionsGroupScreen.desc, (struct Widget*)&OptionsGroupScreen.done (struct Widget*)&OptionsGroupScreen.desc, (struct Widget*)&OptionsGroupScreen.done
}; };
#define OPTGROUPS_MAX_VERTICES (8 * BUTTONWIDGET_MAX + TEXTWIDGET_MAX + BUTTONWIDGET_MAX)
static const char* const optsGroup_descs[8] = { static const char* const optsGroup_descs[8] = {
"&eMusic/Sound, view bobbing, and more", "&eMusic/Sound, view bobbing, and more",
@ -753,11 +752,12 @@ static void OptionsGroupScreen_Init(void* screen) {
s->widgets = optGroups_widgets; s->widgets = optGroups_widgets;
s->numWidgets = Array_Elems(optGroups_widgets); s->numWidgets = Array_Elems(optGroups_widgets);
s->selectedI = -1; s->selectedI = -1;
s->maxVertices = OPTGROUPS_MAX_VERTICES;
Menu_InitButtons(s->btns, 300, optsGroup_btns, 8); Menu_InitButtons(s->btns, 300, optsGroup_btns, 8);
TextWidget_Init(&s->desc); TextWidget_Init(&s->desc);
ButtonWidget_Init(&s->done, 400, Menu_SwitchPause); ButtonWidget_Init(&s->done, 400, Menu_SwitchPause);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static void OptionsGroupScreen_Free(void* screen) { static void OptionsGroupScreen_Free(void* screen) {
@ -805,13 +805,12 @@ static struct EditHotkeyScreen {
struct ButtonWidget btns[5], cancel; struct ButtonWidget btns[5], cancel;
} EditHotkeyScreen; } EditHotkeyScreen;
static struct Widget* edithotkey_widgets[7] = { static struct Widget* edithotkey_widgets[] = {
(struct Widget*)&EditHotkeyScreen.btns[0], (struct Widget*)&EditHotkeyScreen.btns[1], (struct Widget*)&EditHotkeyScreen.btns[0], (struct Widget*)&EditHotkeyScreen.btns[1],
(struct Widget*)&EditHotkeyScreen.btns[2], (struct Widget*)&EditHotkeyScreen.btns[3], (struct Widget*)&EditHotkeyScreen.btns[2], (struct Widget*)&EditHotkeyScreen.btns[3],
(struct Widget*)&EditHotkeyScreen.btns[4], (struct Widget*)&EditHotkeyScreen.input, (struct Widget*)&EditHotkeyScreen.btns[4], (struct Widget*)&EditHotkeyScreen.input,
(struct Widget*)&EditHotkeyScreen.cancel (struct Widget*)&EditHotkeyScreen.cancel
}; };
#define EDITHOTKEY_MAX_VERTICES (MENUINPUTWIDGET_MAX + 6 * BUTTONWIDGET_MAX)
static void HotkeyListScreen_MakeFlags(int flags, cc_string* str); static void HotkeyListScreen_MakeFlags(int flags, cc_string* str);
static void EditHotkeyScreen_MakeFlags(int flags, cc_string* str) { static void EditHotkeyScreen_MakeFlags(int flags, cc_string* str) {
@ -1020,7 +1019,6 @@ static void EditHotkeyScreen_Init(void* screen) {
s->widgets = edithotkey_widgets; s->widgets = edithotkey_widgets;
s->numWidgets = Array_Elems(edithotkey_widgets); s->numWidgets = Array_Elems(edithotkey_widgets);
s->selectedI = -1; s->selectedI = -1;
s->maxVertices = EDITHOTKEY_MAX_VERTICES;
MenuInput_String(desc); MenuInput_String(desc);
ButtonWidget_Init(&s->btns[0], 300, EditHotkeyScreen_BaseKey); ButtonWidget_Init(&s->btns[0], 300, EditHotkeyScreen_BaseKey);
@ -1036,6 +1034,8 @@ static void EditHotkeyScreen_Init(void* screen) {
TextInputWidget_Create(&s->input, 500, &text, &desc); TextInputWidget_Create(&s->input, 500, &text, &desc);
ButtonWidget_Init(&s->cancel, 400, Menu_SwitchHotkeys); ButtonWidget_Init(&s->cancel, 400, Menu_SwitchHotkeys);
s->input.onscreenPlaceholder = "Hotkey text"; s->input.onscreenPlaceholder = "Hotkey text";
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static const struct ScreenVTABLE EditHotkeyScreen_VTABLE = { static const struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
@ -1068,7 +1068,7 @@ static struct GenLevelScreen {
} GenLevelScreen; } GenLevelScreen;
#define GENLEVEL_NUM_INPUTS 4 #define GENLEVEL_NUM_INPUTS 4
static struct Widget* gen_widgets[12] = { static struct Widget* gen_widgets[] = {
(struct Widget*)&GenLevelScreen.inputs[0], (struct Widget*)&GenLevelScreen.inputs[1], (struct Widget*)&GenLevelScreen.inputs[0], (struct Widget*)&GenLevelScreen.inputs[1],
(struct Widget*)&GenLevelScreen.inputs[2], (struct Widget*)&GenLevelScreen.inputs[3], (struct Widget*)&GenLevelScreen.inputs[2], (struct Widget*)&GenLevelScreen.inputs[3],
(struct Widget*)&GenLevelScreen.labels[0], (struct Widget*)&GenLevelScreen.labels[1], (struct Widget*)&GenLevelScreen.labels[0], (struct Widget*)&GenLevelScreen.labels[1],
@ -1076,7 +1076,6 @@ static struct Widget* gen_widgets[12] = {
(struct Widget*)&GenLevelScreen.title, (struct Widget*)&GenLevelScreen.flatgrass, (struct Widget*)&GenLevelScreen.title, (struct Widget*)&GenLevelScreen.flatgrass,
(struct Widget*)&GenLevelScreen.vanilla, (struct Widget*)&GenLevelScreen.cancel (struct Widget*)&GenLevelScreen.vanilla, (struct Widget*)&GenLevelScreen.cancel
}; };
#define GEN_MAX_VERTICES (3 * BUTTONWIDGET_MAX + 4 * MENUINPUTWIDGET_MAX + 5 * TEXTWIDGET_MAX)
CC_NOINLINE static int GenLevelScreen_GetInt(struct GenLevelScreen* s, int index) { CC_NOINLINE static int GenLevelScreen_GetInt(struct GenLevelScreen* s, int index) {
struct TextInputWidget* input = &s->inputs[index]; struct TextInputWidget* input = &s->inputs[index];
@ -1252,7 +1251,6 @@ static void GenLevelScreen_Init(void* screen) {
s->widgets = gen_widgets; s->widgets = gen_widgets;
s->numWidgets = Array_Elems(gen_widgets); s->numWidgets = Array_Elems(gen_widgets);
s->selectedI = -1; s->selectedI = -1;
s->maxVertices = GEN_MAX_VERTICES;
GenLevelScreen_Make(s, 0, World.Width); GenLevelScreen_Make(s, 0, World.Width);
GenLevelScreen_Make(s, 1, World.Height); GenLevelScreen_Make(s, 1, World.Height);
@ -1263,6 +1261,8 @@ static void GenLevelScreen_Init(void* screen) {
ButtonWidget_Init(&s->flatgrass, 200, GenLevelScreen_Flatgrass); ButtonWidget_Init(&s->flatgrass, 200, GenLevelScreen_Flatgrass);
ButtonWidget_Init(&s->vanilla, 200, GenLevelScreen_Notchy); ButtonWidget_Init(&s->vanilla, 200, GenLevelScreen_Notchy);
ButtonWidget_Init(&s->cancel, 400, Menu_SwitchPause); ButtonWidget_Init(&s->cancel, 400, Menu_SwitchPause);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static const struct ScreenVTABLE GenLevelScreen_VTABLE = { static const struct ScreenVTABLE GenLevelScreen_VTABLE = {
@ -1295,7 +1295,6 @@ static struct Widget* classicgen_widgets[] = {
(struct Widget*)&ClassicGenScreen.btns[0], (struct Widget*)&ClassicGenScreen.btns[1], (struct Widget*)&ClassicGenScreen.btns[0], (struct Widget*)&ClassicGenScreen.btns[1],
(struct Widget*)&ClassicGenScreen.btns[2], (struct Widget*)&ClassicGenScreen.cancel (struct Widget*)&ClassicGenScreen.btns[2], (struct Widget*)&ClassicGenScreen.cancel
}; };
#define CLASSICGEN_MAX_VERTICES (TEXTWIDGET_MAX + 4 * BUTTONWIDGET_MAX)
static void ClassicGenScreen_Gen(int size) { static void ClassicGenScreen_Gen(int size) {
RNGState rnd; Random_SeedFromCurrentTime(&rnd); RNGState rnd; Random_SeedFromCurrentTime(&rnd);
@ -1338,13 +1337,14 @@ static void ClassicGenScreen_Init(void* screen) {
struct ClassicGenScreen* s = (struct ClassicGenScreen*)screen; struct ClassicGenScreen* s = (struct ClassicGenScreen*)screen;
s->widgets = classicgen_widgets; s->widgets = classicgen_widgets;
s->numWidgets = Array_Elems(classicgen_widgets); s->numWidgets = Array_Elems(classicgen_widgets);
s->maxVertices = CLASSICGEN_MAX_VERTICES;
TextWidget_Init(&s->title); TextWidget_Init(&s->title);
ButtonWidget_Init(&s->btns[0], 400, ClassicGenScreen_Small); ButtonWidget_Init(&s->btns[0], 400, ClassicGenScreen_Small);
ButtonWidget_Init(&s->btns[1], 400, ClassicGenScreen_Medium); ButtonWidget_Init(&s->btns[1], 400, ClassicGenScreen_Medium);
ButtonWidget_Init(&s->btns[2], 400, ClassicGenScreen_Huge); ButtonWidget_Init(&s->btns[2], 400, ClassicGenScreen_Huge);
ButtonWidget_Init(&s->cancel, 400, Menu_SwitchPause); ButtonWidget_Init(&s->cancel, 400, Menu_SwitchPause);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static const struct ScreenVTABLE ClassicGenScreen_VTABLE = { static const struct ScreenVTABLE ClassicGenScreen_VTABLE = {
@ -1379,7 +1379,6 @@ static struct Widget* save_widgets[] = {
(struct Widget*)&SaveLevelScreen.cancel, (struct Widget*)&SaveLevelScreen.cancel,
(struct Widget*)&SaveLevelScreen.input, (struct Widget*)&SaveLevelScreen.desc, (struct Widget*)&SaveLevelScreen.input, (struct Widget*)&SaveLevelScreen.desc,
}; };
#define SAVE_MAX_VERTICES (3 * BUTTONWIDGET_MAX + MENUINPUTWIDGET_MAX + TEXTWIDGET_MAX)
static void SaveLevelScreen_UpdateSave(struct SaveLevelScreen* s) { static void SaveLevelScreen_UpdateSave(struct SaveLevelScreen* s) {
ButtonWidget_SetConst(&s->save, ButtonWidget_SetConst(&s->save,
@ -1554,7 +1553,6 @@ static void SaveLevelScreen_Init(void* screen) {
s->widgets = save_widgets; s->widgets = save_widgets;
s->numWidgets = Array_Elems(save_widgets); s->numWidgets = Array_Elems(save_widgets);
s->maxVertices = SAVE_MAX_VERTICES;
MenuInput_Path(desc); MenuInput_Path(desc);
ButtonWidget_Init(&s->save, 400, SaveLevelScreen_Save); ButtonWidget_Init(&s->save, 400, SaveLevelScreen_Save);
@ -1564,6 +1562,8 @@ static void SaveLevelScreen_Init(void* screen) {
TextInputWidget_Create(&s->input, 400, &World.Name, &desc); TextInputWidget_Create(&s->input, 400, &World.Name, &desc);
TextWidget_Init(&s->desc); TextWidget_Init(&s->desc);
s->input.onscreenPlaceholder = "Map name"; s->input.onscreenPlaceholder = "Map name";
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static const struct ScreenVTABLE SaveLevelScreen_VTABLE = { static const struct ScreenVTABLE SaveLevelScreen_VTABLE = {
@ -1853,7 +1853,6 @@ static struct Widget* bindsSource_widgets[] = {
(struct Widget*)&BindsSourceScreen.btns[0], (struct Widget*)&BindsSourceScreen.btns[1], (struct Widget*)&BindsSourceScreen.btns[0], (struct Widget*)&BindsSourceScreen.btns[1],
(struct Widget*)&BindsSourceScreen.cancel (struct Widget*)&BindsSourceScreen.cancel
}; };
#define BINDSSOURCE_MAX_VERTICES (BUTTONWIDGET_MAX * 3)
static void BindsSourceScreen_ModeNormal(void* screen, void* b) { static void BindsSourceScreen_ModeNormal(void* screen, void* b) {
binds_gamepad = false; binds_gamepad = false;
@ -1890,11 +1889,12 @@ static void BindsSourceScreen_Init(void* screen) {
s->widgets = bindsSource_widgets; s->widgets = bindsSource_widgets;
s->numWidgets = Array_Elems(bindsSource_widgets); s->numWidgets = Array_Elems(bindsSource_widgets);
s->selectedI = -1; s->selectedI = -1;
s->maxVertices = BINDSSOURCE_MAX_VERTICES;
ButtonWidget_Init(&s->btns[0], 300, BindsSourceScreen_ModeNormal); ButtonWidget_Init(&s->btns[0], 300, BindsSourceScreen_ModeNormal);
ButtonWidget_Init(&s->btns[1], 300, BindsSourceScreen_ModeGamepad); ButtonWidget_Init(&s->btns[1], 300, BindsSourceScreen_ModeGamepad);
ButtonWidget_Init(&s->cancel, 400, Menu_SwitchPause); ButtonWidget_Init(&s->cancel, 400, Menu_SwitchPause);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static const struct ScreenVTABLE BindsSourceScreen_VTABLE = { static const struct ScreenVTABLE BindsSourceScreen_VTABLE = {
@ -1947,7 +1947,6 @@ static struct KeyBindsScreen {
struct ButtonWidget back, left, right; struct ButtonWidget back, left, right;
struct ButtonWidget buttons[KEYBINDS_MAX_BTNS]; struct ButtonWidget buttons[KEYBINDS_MAX_BTNS];
} KeyBindsScreen; } KeyBindsScreen;
#define KEYBINDS_MAX_VERTICES ((KEYBINDS_MAX_BTNS + 3) * BUTTONWIDGET_MAX + 2 * TEXTWIDGET_MAX)
static struct Widget* key_widgets[KEYBINDS_MAX_BTNS + 5] = { static struct Widget* key_widgets[KEYBINDS_MAX_BTNS + 5] = {
NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,
@ -2057,7 +2056,6 @@ static void KeyBindsScreen_Init(void* screen) {
s->widgets = key_widgets; s->widgets = key_widgets;
s->numWidgets = KEYBINDS_MAX_BTNS + 3; s->numWidgets = KEYBINDS_MAX_BTNS + 3;
s->curI = -1; s->curI = -1;
s->maxVertices = KEYBINDS_MAX_VERTICES;
for (i = 0; i < s->bindsCount; i++) { for (i = 0; i < s->bindsCount; i++) {
ButtonWidget_Init(&s->buttons[i], s->btnWidth, KeyBindsScreen_OnBindingClick); ButtonWidget_Init(&s->buttons[i], s->btnWidth, KeyBindsScreen_OnBindingClick);
@ -2074,8 +2072,10 @@ static void KeyBindsScreen_Init(void* screen) {
Widget_SetDisabled(&s->left, !s->leftPage); Widget_SetDisabled(&s->left, !s->leftPage);
Widget_SetDisabled(&s->right, !s->rightPage); Widget_SetDisabled(&s->right, !s->rightPage);
if (!s->leftPage && !s->rightPage) return; if (s->leftPage || s->rightPage)
s->numWidgets += 2; s->numWidgets += 2;
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static const struct ScreenVTABLE KeyBindsScreen_VTABLE = { static const struct ScreenVTABLE KeyBindsScreen_VTABLE = {
@ -2229,11 +2229,10 @@ static struct MenuInputOverlay {
cc_string value; char valueBuffer[STRING_SIZE]; cc_string value; char valueBuffer[STRING_SIZE];
} MenuInputOverlay; } MenuInputOverlay;
static struct Widget* menuInput_widgets[3] = { static struct Widget* menuInput_widgets[] = {
(struct Widget*)&MenuInputOverlay.ok, (struct Widget*)&MenuInputOverlay.Default, (struct Widget*)&MenuInputOverlay.ok, (struct Widget*)&MenuInputOverlay.Default,
(struct Widget*)&MenuInputOverlay.input (struct Widget*)&MenuInputOverlay.input
}; };
#define MENUINPUT_MAX_VERTICES (2 * BUTTONWIDGET_MAX + MENUINPUTWIDGET_MAX)
static void MenuInputOverlay_Close(struct MenuInputOverlay* s, cc_bool valid) { static void MenuInputOverlay_Close(struct MenuInputOverlay* s, cc_bool valid) {
Gui_Remove((struct Screen*)&MenuInputOverlay); Gui_Remove((struct Screen*)&MenuInputOverlay);
@ -2295,7 +2294,6 @@ static void MenuInputOverlay_Init(void* screen) {
struct MenuInputOverlay* s = (struct MenuInputOverlay*)screen; struct MenuInputOverlay* s = (struct MenuInputOverlay*)screen;
s->widgets = menuInput_widgets; s->widgets = menuInput_widgets;
s->numWidgets = Array_Elems(menuInput_widgets); s->numWidgets = Array_Elems(menuInput_widgets);
s->maxVertices = MENUINPUT_MAX_VERTICES;
TextInputWidget_Create(&s->input, 400, &s->value, s->desc); TextInputWidget_Create(&s->input, 400, &s->value, s->desc);
ButtonWidget_Init(&s->Default, 200, MenuInputOverlay_Default); ButtonWidget_Init(&s->Default, 200, MenuInputOverlay_Default);
@ -2306,6 +2304,8 @@ static void MenuInputOverlay_Init(void* screen) {
} else if (s->desc->VTABLE == &FloatInput_VTABLE) { } else if (s->desc->VTABLE == &FloatInput_VTABLE) {
s->input.onscreenType = KEYBOARD_TYPE_NUMBER; s->input.onscreenType = KEYBOARD_TYPE_NUMBER;
} }
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static void MenuInputOverlay_Update(void* screen, double delta) { static void MenuInputOverlay_Update(void* screen, double delta) {
@ -3314,7 +3314,6 @@ static struct Widget* nostalgiaMenu_widgets[] = {
(struct Widget*)&NostalgiaMenuScreen.btnA, (struct Widget*)&NostalgiaMenuScreen.btnF, (struct Widget*)&NostalgiaMenuScreen.btnA, (struct Widget*)&NostalgiaMenuScreen.btnF,
(struct Widget*)&NostalgiaMenuScreen.done, (struct Widget*)&NostalgiaMenuScreen.title (struct Widget*)&NostalgiaMenuScreen.done, (struct Widget*)&NostalgiaMenuScreen.title
}; };
#define NOSTALGIA_MENU_MAX_VERTICES (3 * BUTTONWIDGET_MAX + TEXTWIDGET_MAX)
static void NostalgiaMenuScreen_Appearance(void* a, void* b) { NostalgiaAppearanceScreen_Show(); } static void NostalgiaMenuScreen_Appearance(void* a, void* b) { NostalgiaAppearanceScreen_Show(); }
static void NostalgiaMenuScreen_Functionality(void* a, void* b) { NostalgiaFunctionalityScreen_Show(); } static void NostalgiaMenuScreen_Functionality(void* a, void* b) { NostalgiaFunctionalityScreen_Show(); }
@ -3350,12 +3349,13 @@ static void NostalgiaMenuScreen_Init(void* screen) {
s->widgets = nostalgiaMenu_widgets; s->widgets = nostalgiaMenu_widgets;
s->numWidgets = Array_Elems(nostalgiaMenu_widgets); s->numWidgets = Array_Elems(nostalgiaMenu_widgets);
s->maxVertices = NOSTALGIA_MENU_MAX_VERTICES;
TextWidget_Init(&s->title); TextWidget_Init(&s->title);
ButtonWidget_Init(&s->btnA, 400, NostalgiaMenuScreen_Appearance); ButtonWidget_Init(&s->btnA, 400, NostalgiaMenuScreen_Appearance);
ButtonWidget_Init(&s->btnF, 400, NostalgiaMenuScreen_Functionality); ButtonWidget_Init(&s->btnF, 400, NostalgiaMenuScreen_Functionality);
ButtonWidget_Init(&s->done, 400, NostalgiaMenuScreen_SwitchBack); ButtonWidget_Init(&s->done, 400, NostalgiaMenuScreen_SwitchBack);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static const struct ScreenVTABLE NostalgiaMenuScreen_VTABLE = { static const struct ScreenVTABLE NostalgiaMenuScreen_VTABLE = {
@ -3734,12 +3734,11 @@ static struct UrlWarningOverlay {
char _urlBuffer[STRING_SIZE * 4]; char _urlBuffer[STRING_SIZE * 4];
} UrlWarningOverlay; } UrlWarningOverlay;
static struct Widget* urlwarning_widgets[6] = { static struct Widget* urlwarning_widgets[] = {
(struct Widget*)&UrlWarningOverlay.lbls[0], (struct Widget*)&UrlWarningOverlay.lbls[1], (struct Widget*)&UrlWarningOverlay.lbls[0], (struct Widget*)&UrlWarningOverlay.lbls[1],
(struct Widget*)&UrlWarningOverlay.lbls[2], (struct Widget*)&UrlWarningOverlay.lbls[3], (struct Widget*)&UrlWarningOverlay.lbls[2], (struct Widget*)&UrlWarningOverlay.lbls[3],
(struct Widget*)&UrlWarningOverlay.btns[0], (struct Widget*)&UrlWarningOverlay.btns[1] (struct Widget*)&UrlWarningOverlay.btns[0], (struct Widget*)&UrlWarningOverlay.btns[1]
}; };
#define URLWARNING_MAX_VERTICES (4 * TEXTWIDGET_MAX + 2 * BUTTONWIDGET_MAX)
static void UrlWarningOverlay_OpenUrl(void* screen, void* b) { static void UrlWarningOverlay_OpenUrl(void* screen, void* b) {
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen; struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
@ -3783,11 +3782,12 @@ static void UrlWarningOverlay_Init(void* screen) {
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen; struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
s->widgets = urlwarning_widgets; s->widgets = urlwarning_widgets;
s->numWidgets = Array_Elems(urlwarning_widgets); s->numWidgets = Array_Elems(urlwarning_widgets);
s->maxVertices = URLWARNING_MAX_VERTICES;
Overlay_InitLabels(s->lbls); Overlay_InitLabels(s->lbls);
ButtonWidget_Init(&s->btns[0], 160, UrlWarningOverlay_OpenUrl); ButtonWidget_Init(&s->btns[0], 160, UrlWarningOverlay_OpenUrl);
ButtonWidget_Init(&s->btns[1], 160, UrlWarningOverlay_AppendUrl); ButtonWidget_Init(&s->btns[1], 160, UrlWarningOverlay_AppendUrl);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static const struct ScreenVTABLE UrlWarningOverlay_VTABLE = { static const struct ScreenVTABLE UrlWarningOverlay_VTABLE = {
@ -3830,7 +3830,6 @@ static struct Widget* texpack_widgets[] = {
(struct Widget*)&TexPackOverlay.btns[0], (struct Widget*)&TexPackOverlay.btns[1], (struct Widget*)&TexPackOverlay.btns[0], (struct Widget*)&TexPackOverlay.btns[1],
(struct Widget*)&TexPackOverlay.btns[2], (struct Widget*)&TexPackOverlay.btns[3] (struct Widget*)&TexPackOverlay.btns[2], (struct Widget*)&TexPackOverlay.btns[3]
}; };
#define TEXPACK_MAX_VERTICES (4 * TEXTWIDGET_MAX + 4 * BUTTONWIDGET_MAX)
static cc_bool TexPackOverlay_IsAlways(void* screen, void* w) { return Screen_Index(screen, w) >= 6; } static cc_bool TexPackOverlay_IsAlways(void* screen, void* w) { return Screen_Index(screen, w) >= 6; }
@ -3957,7 +3956,6 @@ static void TexPackOverlay_Init(void* screen) {
struct TexPackOverlay* s = (struct TexPackOverlay*)screen; struct TexPackOverlay* s = (struct TexPackOverlay*)screen;
s->widgets = texpack_widgets; s->widgets = texpack_widgets;
s->numWidgets = Array_Elems(texpack_widgets); s->numWidgets = Array_Elems(texpack_widgets);
s->maxVertices = TEXPACK_MAX_VERTICES;
s->contentLength = 0; s->contentLength = 0;
s->gotContent = false; s->gotContent = false;
@ -3968,6 +3966,8 @@ static void TexPackOverlay_Init(void* screen) {
ButtonWidget_Init(&s->btns[1], 160, NULL); ButtonWidget_Init(&s->btns[1], 160, NULL);
ButtonWidget_Init(&s->btns[2], 160, NULL); ButtonWidget_Init(&s->btns[2], 160, NULL);
ButtonWidget_Init(&s->btns[3], 160, NULL); ButtonWidget_Init(&s->btns[3], 160, NULL);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static const struct ScreenVTABLE TexPackOverlay_VTABLE = { static const struct ScreenVTABLE TexPackOverlay_VTABLE = {

View File

@ -1502,7 +1502,11 @@ static struct InventoryScreen {
struct TableWidget table; struct TableWidget table;
struct TextWidget title; struct TextWidget title;
cc_bool releasedInv, deferredSelect; cc_bool releasedInv, deferredSelect;
} InventoryScreen_Instance; } InventoryScreen;
static struct Widget* inventory_widgets[] = {
(struct Widget*)&InventoryScreen.title, (struct Widget*)&InventoryScreen.table
};
static void InventoryScreen_GetTitleText(cc_string* desc, BlockID block) { static void InventoryScreen_GetTitleText(cc_string* desc, BlockID block) {
@ -1531,7 +1535,7 @@ static void InventoryScreen_UpdateTitle(struct InventoryScreen* s, BlockID block
} }
static void InventoryScreen_OnUpdateTitle(BlockID block) { static void InventoryScreen_OnUpdateTitle(BlockID block) {
InventoryScreen_UpdateTitle(&InventoryScreen_Instance, block); InventoryScreen_UpdateTitle(&InventoryScreen, block);
} }
@ -1547,12 +1551,9 @@ static void InventoryScreen_NeedRedrawing(void* screen) {
static void InventoryScreen_ContextLost(void* screen) { static void InventoryScreen_ContextLost(void* screen) {
struct InventoryScreen* s = (struct InventoryScreen*)screen; struct InventoryScreen* s = (struct InventoryScreen*)screen;
Gfx_DeleteDynamicVb(&s->vb);
s->table.vb = 0;
Font_Free(&s->font); Font_Free(&s->font);
Elem_Free(&s->table); Screen_ContextLost(s);
Elem_Free(&s->title); s->table.vb = 0;
} }
static void InventoryScreen_ContextRecreated(void* screen) { static void InventoryScreen_ContextRecreated(void* screen) {
@ -1564,19 +1565,6 @@ static void InventoryScreen_ContextRecreated(void* screen) {
TableWidget_Recreate(&s->table); TableWidget_Recreate(&s->table);
} }
static void InventoryScreen_BuildMesh(void* screen) {
struct InventoryScreen* s = (struct InventoryScreen*)screen;
struct VertexTextured* data;
struct VertexTextured** ptr;
data = Screen_LockVb(s);
ptr = &data;
Widget_BuildMesh(&s->title, ptr);
Widget_BuildMesh(&s->table, ptr);
Gfx_UnlockDynamicVb(s->vb);
}
static void InventoryScreen_MoveToSelected(struct InventoryScreen* s) { static void InventoryScreen_MoveToSelected(struct InventoryScreen* s) {
struct TableWidget* table = &s->table; struct TableWidget* table = &s->table;
TableWidget_SetBlockTo(table, Inventory_SelectedBlock); TableWidget_SetBlockTo(table, Inventory_SelectedBlock);
@ -1591,7 +1579,8 @@ static void InventoryScreen_MoveToSelected(struct InventoryScreen* s) {
static void InventoryScreen_Init(void* screen) { static void InventoryScreen_Init(void* screen) {
struct InventoryScreen* s = (struct InventoryScreen*)screen; struct InventoryScreen* s = (struct InventoryScreen*)screen;
s->maxVertices = TEXTWIDGET_MAX + TABLE_MAX_VERTICES; s->widgets = inventory_widgets;
s->numWidgets = Array_Elems(inventory_widgets);
TextWidget_Init(&s->title); TextWidget_Init(&s->title);
TableWidget_Create(&s->table, 22 * Options_GetFloat(OPT_INV_SCROLLBAR_SCALE, 0, 10, 1)); TableWidget_Create(&s->table, 22 * Options_GetFloat(OPT_INV_SCROLLBAR_SCALE, 0, 10, 1));
@ -1607,6 +1596,8 @@ static void InventoryScreen_Init(void* screen) {
Event_Register_(&TextureEvents.AtlasChanged, s, InventoryScreen_NeedRedrawing); Event_Register_(&TextureEvents.AtlasChanged, s, InventoryScreen_NeedRedrawing);
Event_Register_(&BlockEvents.PermissionsChanged, s, InventoryScreen_OnBlockChanged); Event_Register_(&BlockEvents.PermissionsChanged, s, InventoryScreen_OnBlockChanged);
Event_Register_(&BlockEvents.BlockDefChanged, s, InventoryScreen_OnBlockChanged); Event_Register_(&BlockEvents.BlockDefChanged, s, InventoryScreen_OnBlockChanged);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static void InventoryScreen_Free(void* screen) { static void InventoryScreen_Free(void* screen) {
@ -1658,7 +1649,7 @@ static int InventoryScreen_KeyDown(void* screen, int key) {
static cc_bool InventoryScreen_IsHotbarActive(void) { static cc_bool InventoryScreen_IsHotbarActive(void) {
struct Screen* grabbed = Gui.InputGrab; struct Screen* grabbed = Gui.InputGrab;
/* Only toggle hotbar when inventory or no grab screen is open */ /* Only toggle hotbar when inventory or no grab screen is open */
return !grabbed || grabbed == (struct Screen*)&InventoryScreen_Instance; return !grabbed || grabbed == (struct Screen*)&InventoryScreen;
} }
static void InventoryScreen_KeyUp(void* screen, int key) { static void InventoryScreen_KeyUp(void* screen, int key) {
@ -1702,13 +1693,13 @@ static int InventoryScreen_MouseScroll(void* screen, float delta) {
static const struct ScreenVTABLE InventoryScreen_VTABLE = { static const struct ScreenVTABLE InventoryScreen_VTABLE = {
InventoryScreen_Init, InventoryScreen_Update, InventoryScreen_Free, InventoryScreen_Init, InventoryScreen_Update, InventoryScreen_Free,
InventoryScreen_Render, InventoryScreen_BuildMesh, InventoryScreen_Render, Screen_BuildMesh,
InventoryScreen_KeyDown, InventoryScreen_KeyUp, Screen_TKeyPress, Screen_TText, InventoryScreen_KeyDown, InventoryScreen_KeyUp, Screen_TKeyPress, Screen_TText,
InventoryScreen_PointerDown, InventoryScreen_PointerUp, InventoryScreen_PointerMove, InventoryScreen_MouseScroll, InventoryScreen_PointerDown, InventoryScreen_PointerUp, InventoryScreen_PointerMove, InventoryScreen_MouseScroll,
InventoryScreen_Layout, InventoryScreen_ContextLost, InventoryScreen_ContextRecreated InventoryScreen_Layout, InventoryScreen_ContextLost, InventoryScreen_ContextRecreated
}; };
void InventoryScreen_Show(void) { void InventoryScreen_Show(void) {
struct InventoryScreen* s = &InventoryScreen_Instance; struct InventoryScreen* s = &InventoryScreen;
s->grabsInput = true; s->grabsInput = true;
s->closable = true; s->closable = true;
@ -1734,10 +1725,9 @@ static struct LoadingScreen {
char _titleBuffer[STRING_SIZE]; char _titleBuffer[STRING_SIZE];
char _messageBuffer[STRING_SIZE]; char _messageBuffer[STRING_SIZE];
} LoadingScreen; } LoadingScreen;
#define LOADING_MAX_VERTICES (2 * TEXTWIDGET_MAX)
#define LOADING_TILE_SIZE 64 #define LOADING_TILE_SIZE 64
static struct Widget* loading_widgets[2] = { static struct Widget* loading_widgets[] = {
(struct Widget*)&LoadingScreen.title, (struct Widget*)&LoadingScreen.message (struct Widget*)&LoadingScreen.title, (struct Widget*)&LoadingScreen.message
}; };
@ -1752,7 +1742,7 @@ static void LoadingScreen_SetMessage(struct LoadingScreen* s) {
static void LoadingScreen_CalcMaxVertices(struct LoadingScreen* s) { static void LoadingScreen_CalcMaxVertices(struct LoadingScreen* s) {
s->rows = Math_CeilDiv(WindowInfo.Height, LOADING_TILE_SIZE); s->rows = Math_CeilDiv(WindowInfo.Height, LOADING_TILE_SIZE);
s->maxVertices = LOADING_MAX_VERTICES + s->rows * 4; s->maxVertices = Screen_CalcDefaultMaxVertices(s) + s->rows * 4;
} }
static void LoadingScreen_Layout(void* screen) { static void LoadingScreen_Layout(void* screen) {
@ -1980,7 +1970,6 @@ static struct Widget* disconnect_widgets[] = {
(struct Widget*)&DisconnectScreen.reconnect, (struct Widget*)&DisconnectScreen.reconnect,
(struct Widget*)&DisconnectScreen.quit (struct Widget*)&DisconnectScreen.quit
}; };
#define DISCONNECT_MAX_VERTICES (2 * TEXTWIDGET_MAX + 2 * BUTTONWIDGET_MAX)
#define DISCONNECT_DELAY_SECS 5 #define DISCONNECT_DELAY_SECS 5
static void DisconnectScreen_Layout(void* screen) { static void DisconnectScreen_Layout(void* screen) {
@ -2039,8 +2028,6 @@ static void DisconnectScreen_OnQuit(void* s, void* w) { Window_Close(); }
static void DisconnectScreen_Init(void* screen) { static void DisconnectScreen_Init(void* screen) {
struct DisconnectScreen* s = (struct DisconnectScreen*)screen; struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
s->maxVertices = DISCONNECT_MAX_VERTICES;
TextWidget_Init(&s->title); TextWidget_Init(&s->title);
TextWidget_Init(&s->message); TextWidget_Init(&s->message);
@ -2055,6 +2042,7 @@ static void DisconnectScreen_Init(void* screen) {
s->lastSecsLeft = DISCONNECT_DELAY_SECS; s->lastSecsLeft = DISCONNECT_DELAY_SECS;
s->widgets = disconnect_widgets; s->widgets = disconnect_widgets;
s->numWidgets = Array_Elems(disconnect_widgets); s->numWidgets = Array_Elems(disconnect_widgets);
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
} }
static void DisconnectScreen_Update(void* screen, double delta) { static void DisconnectScreen_Update(void* screen, double delta) {

View File

@ -59,11 +59,13 @@ static int TextWidget_Render2(void* widget, int offset) {
return offset + 4; return offset + 4;
} }
static int TextWidget_MaxVertices(void* widget) { return TEXTWIDGET_MAX; }
static const struct WidgetVTABLE TextWidget_VTABLE = { static const struct WidgetVTABLE TextWidget_VTABLE = {
TextWidget_Render, TextWidget_Free, TextWidget_Reposition, TextWidget_Render, TextWidget_Free, TextWidget_Reposition,
Widget_InputDown, Widget_InputUp, Widget_MouseScroll, Widget_InputDown, Widget_InputUp, Widget_MouseScroll,
Widget_Pointer, Widget_PointerUp, Widget_PointerMove, Widget_Pointer, Widget_PointerUp, Widget_PointerMove,
TextWidget_BuildMesh, TextWidget_Render2 TextWidget_BuildMesh, TextWidget_Render2, TextWidget_MaxVertices
}; };
void TextWidget_Init(struct TextWidget* w) { void TextWidget_Init(struct TextWidget* w) {
Widget_Reset(w); Widget_Reset(w);
@ -209,11 +211,13 @@ static int ButtonWidget_Render2(void* widget, int offset) {
return offset + 12; return offset + 12;
} }
static int ButtonWidget_MaxVertices(void* widget) { return BUTTONWIDGET_MAX; }
static const struct WidgetVTABLE ButtonWidget_VTABLE = { static const struct WidgetVTABLE ButtonWidget_VTABLE = {
ButtonWidget_Render, ButtonWidget_Free, ButtonWidget_Reposition, ButtonWidget_Render, ButtonWidget_Free, ButtonWidget_Reposition,
Widget_InputDown, Widget_InputUp, Widget_MouseScroll, Widget_InputDown, Widget_InputUp, Widget_MouseScroll,
Widget_Pointer, Widget_PointerUp, Widget_PointerMove, Widget_Pointer, Widget_PointerUp, Widget_PointerMove,
ButtonWidget_BuildMesh, ButtonWidget_Render2 ButtonWidget_BuildMesh, ButtonWidget_Render2, ButtonWidget_MaxVertices
}; };
void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick, cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset) { void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick, cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset) {
ButtonWidget_Init(w, minWidth, onClick); ButtonWidget_Init(w, minWidth, onClick);
@ -456,6 +460,8 @@ static int HotbarWidget_Render2(void* widget, int offset) {
return HOTBAR_MAX_VERTICES; return HOTBAR_MAX_VERTICES;
} }
static int HotbarWidget_MaxVertices(void* w) { return HOTBAR_MAX_VERTICES; }
void HotbarWidget_Update(struct HotbarWidget* w, double delta) { void HotbarWidget_Update(struct HotbarWidget* w, double delta) {
#ifdef CC_BUILD_TOUCH #ifdef CC_BUILD_TOUCH
int i; int i;
@ -653,7 +659,7 @@ static const struct WidgetVTABLE HotbarWidget_VTABLE = {
NULL, HotbarWidget_Free, HotbarWidget_Reposition, NULL, HotbarWidget_Free, HotbarWidget_Reposition,
HotbarWidget_KeyDown, HotbarWidget_InputUp, HotbarWidget_MouseScroll, HotbarWidget_KeyDown, HotbarWidget_InputUp, HotbarWidget_MouseScroll,
HotbarWidget_PointerDown, HotbarWidget_PointerUp, HotbarWidget_PointerMove, HotbarWidget_PointerDown, HotbarWidget_PointerUp, HotbarWidget_PointerMove,
HotbarWidget_BuildMesh, HotbarWidget_Render2, HotbarWidget_BuildMesh, HotbarWidget_Render2, HotbarWidget_MaxVertices
}; };
void HotbarWidget_Create(struct HotbarWidget* w) { void HotbarWidget_Create(struct HotbarWidget* w) {
Widget_Reset(w); Widget_Reset(w);
@ -823,6 +829,8 @@ static int TableWidget_Render2(void* widget, int offset) {
return offset + TABLE_MAX_VERTICES; return offset + TABLE_MAX_VERTICES;
} }
static int TableWidget_MaxVertices(void* w) { return TABLE_MAX_VERTICES; }
static void TableWidget_Free(void* widget) { } static void TableWidget_Free(void* widget) { }
void TableWidget_Recreate(struct TableWidget* w) { void TableWidget_Recreate(struct TableWidget* w) {
@ -970,7 +978,7 @@ static const struct WidgetVTABLE TableWidget_VTABLE = {
NULL, TableWidget_Free, TableWidget_Reposition, NULL, TableWidget_Free, TableWidget_Reposition,
TableWidget_KeyDown, Widget_InputUp, TableWidget_MouseScroll, TableWidget_KeyDown, Widget_InputUp, TableWidget_MouseScroll,
TableWidget_PointerDown, TableWidget_PointerUp, TableWidget_PointerMove, TableWidget_PointerDown, TableWidget_PointerUp, TableWidget_PointerMove,
TableWidget_BuildMesh, TableWidget_Render2 TableWidget_BuildMesh, TableWidget_Render2, TableWidget_MaxVertices
}; };
void TableWidget_Create(struct TableWidget* w, int sbWidth) { void TableWidget_Create(struct TableWidget* w, int sbWidth) {
cc_bool classic; cc_bool classic;
@ -1569,6 +1577,8 @@ static int TextInputWidget_Render2(void* widget, int offset) {
return offset + 4; return offset + 4;
} }
static int TextInputWidget_MaxVertices(void* widget) { return MENUINPUTWIDGET_MAX; }
static void TextInputWidget_RemakeTexture(void* widget) { static void TextInputWidget_RemakeTexture(void* widget) {
cc_string range; char rangeBuffer[STRING_SIZE]; cc_string range; char rangeBuffer[STRING_SIZE];
struct TextInputWidget* w = (struct TextInputWidget*)widget; struct TextInputWidget* w = (struct TextInputWidget*)widget;
@ -1655,7 +1665,7 @@ static const struct WidgetVTABLE TextInputWidget_VTABLE = {
TextInputWidget_Render, InputWidget_Free, InputWidget_Reposition, TextInputWidget_Render, InputWidget_Free, InputWidget_Reposition,
InputWidget_KeyDown, Widget_InputUp, Widget_MouseScroll, InputWidget_KeyDown, Widget_InputUp, Widget_MouseScroll,
TextInputWidget_PointerDown, Widget_PointerUp, Widget_PointerMove, TextInputWidget_PointerDown, Widget_PointerUp, Widget_PointerMove,
TextInputWidget_BuildMesh, TextInputWidget_Render2 TextInputWidget_BuildMesh, TextInputWidget_Render2, TextInputWidget_MaxVertices
}; };
void TextInputWidget_Create(struct TextInputWidget* w, int width, const cc_string* text, struct MenuInputDesc* desc) { void TextInputWidget_Create(struct TextInputWidget* w, int width, const cc_string* text, struct MenuInputDesc* desc) {
InputWidget_Reset(&w->base); InputWidget_Reset(&w->base);