Launcher: Fix clicking on checkboxes over and over not properly resetting previously drawn text, which resulted in some ugly artifacts

This commit is contained in:
UnknownShadow200 2022-03-12 20:50:38 +11:00
parent b54222a2c1
commit cd5f316383
5 changed files with 102 additions and 134 deletions

View File

@ -98,7 +98,6 @@ add_library(classicube SHARED
../../src/EnvRenderer.c ../../src/EnvRenderer.c
../../src/Animations.c ../../src/Animations.c
../../src/LBackend.c ../../src/LBackend.c
../../src/TouchUI.c
) )
# add lib dependencies # add lib dependencies

View File

@ -365,7 +365,7 @@ void LBackend_DrawSlider(struct LSlider* w) {
LSlider_DrawBox(w); LSlider_DrawBox(w);
curWidth = (int)((w->width - xBorder2) * w->value / w->maxValue); curWidth = (int)((w->width - xBorder2) * w->value / w->maxValue);
Drawer2D_Clear(&Launcher_Framebuffer, w->col, Drawer2D_Clear(&Launcher_Framebuffer, w->color,
w->x + xBorder, w->y + yBorder, w->x + xBorder, w->y + yBorder,
curWidth, w->height - yBorder2); curWidth, w->height - yBorder2);
} }

View File

@ -274,23 +274,23 @@ static void ChooseModeScreen_Init(struct LScreen* s_) {
s->widgets = chooseMode_widgets; s->widgets = chooseMode_widgets;
s->numWidgets = Array_Elems(chooseMode_widgets); s->numWidgets = Array_Elems(chooseMode_widgets);
LLine_Init2( &s->seps[0], 490); LLine_Init( &s->seps[0], 490);
LLine_Init2( &s->seps[1], 490); LLine_Init( &s->seps[1], 490);
LButton_Init2(&s->btnEnhanced, 145, 35, "Enhanced"); LButton_Init(&s->btnEnhanced, 145, 35, "Enhanced");
LLabel_Init2( &s->lblEnhanced[0], "&eEnables custom blocks, changing env"); LLabel_Init( &s->lblEnhanced[0], "&eEnables custom blocks, changing env");
LLabel_Init2( &s->lblEnhanced[1], "&esettings, longer messages, and more"); LLabel_Init( &s->lblEnhanced[1], "&esettings, longer messages, and more");
LButton_Init2(&s->btnClassicHax, 145, 35, "Classic +hax"); LButton_Init(&s->btnClassicHax, 145, 35, "Classic +hax");
LLabel_Init2( &s->lblClassicHax[0], "&eSame as Classic mode, except that"); LLabel_Init( &s->lblClassicHax[0], "&eSame as Classic mode, except that");
LLabel_Init2( &s->lblClassicHax[1], "&ehacks (noclip/fly/speed) are enabled"); LLabel_Init( &s->lblClassicHax[1], "&ehacks (noclip/fly/speed) are enabled");
LButton_Init2(&s->btnClassic, 145, 35, "Classic"); LButton_Init(&s->btnClassic, 145, 35, "Classic");
LLabel_Init2( &s->lblClassic[0], "&eOnly uses blocks and features from"); LLabel_Init( &s->lblClassic[0], "&eOnly uses blocks and features from");
LLabel_Init2( &s->lblClassic[1], "&ethe original minecraft classic"); LLabel_Init( &s->lblClassic[1], "&ethe original minecraft classic");
LLabel_Init2( &s->lblHelp, "&eClick &fEnhanced &eif you're not sure which mode to choose."); LLabel_Init( &s->lblHelp, "&eClick &fEnhanced &eif you're not sure which mode to choose.");
LButton_Init2(&s->btnBack, 80, 35, "Back"); LButton_Init(&s->btnBack, 80, 35, "Back");
s->btnEnhanced.OnClick = UseModeEnhanced; s->btnEnhanced.OnClick = UseModeEnhanced;
s->btnClassicHax.OnClick = UseModeClassicHax; s->btnClassicHax.OnClick = UseModeClassicHax;
@ -475,24 +475,24 @@ static void ColoursScreen_Init(struct LScreen* s_) {
s->numWidgets = Array_Elems(colours_widgets); s->numWidgets = Array_Elems(colours_widgets);
for (i = 0; i < 5 * 3; i++) { for (i = 0; i < 5 * 3; i++) {
LInput_Init2(&s->iptColours[i], 55, NULL); LInput_Init(&s->iptColours[i], 55, NULL);
s->iptColours[i].type = KEYBOARD_TYPE_INTEGER; s->iptColours[i].type = KEYBOARD_TYPE_INTEGER;
s->iptColours[i].TextFilter = ColoursScreen_InputFilter; s->iptColours[i].TextFilter = ColoursScreen_InputFilter;
s->iptColours[i].TextChanged = ColoursScreen_TextChanged; s->iptColours[i].TextChanged = ColoursScreen_TextChanged;
} }
LLabel_Init2( &s->lblNames[0], "Background"); LLabel_Init( &s->lblNames[0], "Background");
LLabel_Init2( &s->lblNames[1], "Button border"); LLabel_Init( &s->lblNames[1], "Button border");
LLabel_Init2( &s->lblNames[2], "Button highlight"); LLabel_Init( &s->lblNames[2], "Button highlight");
LLabel_Init2( &s->lblNames[3], "Button"); LLabel_Init( &s->lblNames[3], "Button");
LLabel_Init2( &s->lblNames[4], "Active button"); LLabel_Init( &s->lblNames[4], "Active button");
LLabel_Init2( &s->lblRGB[0], "Red"); LLabel_Init( &s->lblRGB[0], "Red");
LLabel_Init2( &s->lblRGB[1], "Green"); LLabel_Init( &s->lblRGB[1], "Green");
LLabel_Init2( &s->lblRGB[2], "Blue"); LLabel_Init( &s->lblRGB[2], "Blue");
LButton_Init2(&s->btnBack, 80, 35, "Back"); LButton_Init(&s->btnBack, 80, 35, "Back");
LCheckbox_Init2(&s->cbClassic, "Classic style"); LCheckbox_Init(&s->cbClassic, "Classic style");
s->cbClassic.OnClick = ColoursScreen_ToggleBG; s->cbClassic.OnClick = ColoursScreen_ToggleBG;
s->btnBack.OnClick = SwitchToThemes; s->btnBack.OnClick = SwitchToThemes;
} }
@ -650,13 +650,13 @@ static void DirectConnectScreen_Init(struct LScreen* s_) {
s->widgets = directConnect_widgets; s->widgets = directConnect_widgets;
s->numWidgets = Array_Elems(directConnect_widgets); s->numWidgets = Array_Elems(directConnect_widgets);
LInput_Init2(&s->iptUsername, 330, "&gUsername.."); LInput_Init(&s->iptUsername, 330, "&gUsername..");
LInput_Init2(&s->iptAddress, 330, "&gIP address:Port number.."); LInput_Init(&s->iptAddress, 330, "&gIP address:Port number..");
LInput_Init2(&s->iptMppass, 330, "&gMppass.."); LInput_Init(&s->iptMppass, 330, "&gMppass..");
LButton_Init2(&s->btnConnect, 110, 35, "Connect"); LButton_Init(&s->btnConnect, 110, 35, "Connect");
LButton_Init2(&s->btnBack, 80, 35, "Back"); LButton_Init(&s->btnBack, 80, 35, "Back");
LLabel_Init2( &s->lblStatus, ""); LLabel_Init( &s->lblStatus, "");
s->iptUsername.ClipboardFilter = DirectConnectScreen_UrlFilter; s->iptUsername.ClipboardFilter = DirectConnectScreen_UrlFilter;
s->iptAddress.ClipboardFilter = DirectConnectScreen_UrlFilter; s->iptAddress.ClipboardFilter = DirectConnectScreen_UrlFilter;
@ -722,10 +722,10 @@ static void MFAScreen_Init(struct LScreen* s_) {
s->widgets = mfa_widgets; s->widgets = mfa_widgets;
s->numWidgets = Array_Elems(mfa_widgets); s->numWidgets = Array_Elems(mfa_widgets);
LLabel_Init2( &s->lblTitle, ""); LLabel_Init( &s->lblTitle, "");
LInput_Init2( &s->iptCode, 280, "&gLogin code.."); LInput_Init( &s->iptCode, 280, "&gLogin code..");
LButton_Init2(&s->btnSignIn, 100, 35, "Sign in"); LButton_Init(&s->btnSignIn, 100, 35, "Sign in");
LButton_Init2(&s->btnCancel, 100, 35, "Cancel"); LButton_Init(&s->btnCancel, 100, 35, "Cancel");
s->btnSignIn.OnClick = MFAScreen_SignIn; s->btnSignIn.OnClick = MFAScreen_SignIn;
s->btnCancel.OnClick = MFAScreen_Cancel; s->btnCancel.OnClick = MFAScreen_Cancel;
@ -873,18 +873,18 @@ static void MainScreen_Init(struct LScreen* s_) {
s->widgets = main_widgets; s->widgets = main_widgets;
s->numWidgets = Array_Elems(main_widgets); s->numWidgets = Array_Elems(main_widgets);
LInput_Init2( &s->iptUsername, 280, "&gUsername.."); LInput_Init( &s->iptUsername, 280, "&gUsername..");
LInput_Init2( &s->iptPassword, 280, "&gPassword.."); LInput_Init( &s->iptPassword, 280, "&gPassword..");
LButton_Init2(&s->btnLogin, 100, 35, "Sign in"); LButton_Init(&s->btnLogin, 100, 35, "Sign in");
LButton_Init2(&s->btnResume, 100, 35, "Resume"); LButton_Init(&s->btnResume, 100, 35, "Resume");
LLabel_Init2( &s->lblStatus, ""); LLabel_Init( &s->lblStatus, "");
LButton_Init2(&s->btnDirect, 200, 35, "Direct connect"); LButton_Init(&s->btnDirect, 200, 35, "Direct connect");
LButton_Init2(&s->btnSPlayer, 200, 35, "Singleplayer"); LButton_Init(&s->btnSPlayer, 200, 35, "Singleplayer");
LLabel_Init2( &s->lblUpdate, ""); LLabel_Init( &s->lblUpdate, "");
LButton_Init2(&s->btnRegister, 100, 35, "Register"); LButton_Init(&s->btnRegister, 100, 35, "Register");
LButton_Init2(&s->btnOptions, 100, 35, "Options"); LButton_Init(&s->btnOptions, 100, 35, "Options");
s->btnLogin.OnClick = MainScreen_Login; s->btnLogin.OnClick = MainScreen_Login;
s->btnResume.OnClick = MainScreen_Resume; s->btnResume.OnClick = MainScreen_Resume;
@ -1121,12 +1121,12 @@ static void CheckResourcesScreen_Init(struct LScreen* s_) {
s->widgets = checkResources_widgets; s->widgets = checkResources_widgets;
s->numWidgets = Array_Elems(checkResources_widgets); s->numWidgets = Array_Elems(checkResources_widgets);
LLabel_Init2( &s->lblLine1, "Some required resources weren't found"); LLabel_Init( &s->lblLine1, "Some required resources weren't found");
LLabel_Init2( &s->lblLine2, "Okay to download?"); LLabel_Init( &s->lblLine2, "Okay to download?");
LLabel_Init2( &s->lblStatus, ""); LLabel_Init( &s->lblStatus, "");
LButton_Init2(&s->btnYes, 70, 35, "Yes"); LButton_Init(&s->btnYes, 70, 35, "Yes");
LButton_Init2(&s->btnNo, 70, 35, "No"); LButton_Init(&s->btnNo, 70, 35, "No");
s->btnYes.OnClick = CheckResourcesScreen_Yes; s->btnYes.OnClick = CheckResourcesScreen_Yes;
s->btnNo.OnClick = CheckResourcesScreen_Next; s->btnNo.OnClick = CheckResourcesScreen_Next;
} }
@ -1204,9 +1204,9 @@ static void FetchResourcesScreen_Init(struct LScreen* s_) {
s->widgets = fetchResources_widgets; s->widgets = fetchResources_widgets;
s->numWidgets = Array_Elems(fetchResources_widgets); s->numWidgets = Array_Elems(fetchResources_widgets);
LLabel_Init2( &s->lblStatus, ""); LLabel_Init( &s->lblStatus, "");
LButton_Init2(&s->btnCancel, 120, 35, "Cancel"); LButton_Init(&s->btnCancel, 120, 35, "Cancel");
LSlider_Init2(&s->sdrProgress, 200, 12, BitmapCol_Make(0, 220, 0, 255)); LSlider_Init(&s->sdrProgress, 200, 12, BitmapCol_Make(0, 220, 0, 255));
s->lblStatus.font = &Launcher_HintFont; s->lblStatus.font = &Launcher_HintFont;
s->btnCancel.OnClick = CheckResourcesScreen_Next; s->btnCancel.OnClick = CheckResourcesScreen_Next;
@ -1375,12 +1375,12 @@ static void ServersScreen_Init(struct LScreen* s_) {
s->widgets = servers_widgets; s->widgets = servers_widgets;
s->numWidgets = Array_Elems(servers_widgets); s->numWidgets = Array_Elems(servers_widgets);
LInput_Init2( &s->iptSearch, 370, "&gSearch servers.."); LInput_Init( &s->iptSearch, 370, "&gSearch servers..");
LInput_Init2( &s->iptHash, 475, "&gclassicube.net/server/play/..."); LInput_Init( &s->iptHash, 475, "&gclassicube.net/server/play/...");
LButton_Init2(&s->btnBack, 110, 30, "Back"); LButton_Init(&s->btnBack, 110, 30, "Back");
LButton_Init2(&s->btnConnect, 130, 30, "Connect"); LButton_Init(&s->btnConnect, 130, 30, "Connect");
LButton_Init2(&s->btnRefresh, 110, 30, "Refresh"); LButton_Init(&s->btnRefresh, 110, 30, "Refresh");
s->btnBack.OnClick = SwitchToMain; s->btnBack.OnClick = SwitchToMain;
s->btnConnect.OnClick = ServersScreen_Connect; s->btnConnect.OnClick = ServersScreen_Connect;
@ -1536,7 +1536,7 @@ static void SettingsScreen_AutoClose(void* w, int idx) {
struct LCheckbox* cb = (struct LCheckbox*)w; struct LCheckbox* cb = (struct LCheckbox*)w;
cb->value = !cb->value; cb->value = !cb->value;
Options_SetBool(LOPT_AUTO_CLOSE, cb->value); Options_SetBool(LOPT_AUTO_CLOSE, cb->value);
LWidget_Draw(cb); LWidget_Redraw(cb);
} }
#endif #endif
static void SettingsScreen_ShowEmpty(void* w, int idx) { static void SettingsScreen_ShowEmpty(void* w, int idx) {
@ -1545,33 +1545,33 @@ static void SettingsScreen_ShowEmpty(void* w, int idx) {
Launcher_ShowEmptyServers = cb->value; Launcher_ShowEmptyServers = cb->value;
Options_SetBool(LOPT_SHOW_EMPTY, cb->value); Options_SetBool(LOPT_SHOW_EMPTY, cb->value);
LWidget_Draw(cb); LWidget_Redraw(cb);
} }
static void SettingsScreen_Init(struct LScreen* s_) { static void SettingsScreen_Init(struct LScreen* s_) {
struct SettingsScreen* s = (struct SettingsScreen*)s_; struct SettingsScreen* s = (struct SettingsScreen*)s_;
LLine_Init2( &s->sep, 380); LLine_Init( &s->sep, 380);
LButton_Init2(&s->btnUpdates, 110, 35, "Updates"); LButton_Init(&s->btnUpdates, 110, 35, "Updates");
LLabel_Init2( &s->lblUpdates, "&eGet the latest stuff"); LLabel_Init( &s->lblUpdates, "&eGet the latest stuff");
LButton_Init2(&s->btnMode, 110, 35, "Mode"); LButton_Init(&s->btnMode, 110, 35, "Mode");
LLabel_Init2( &s->lblMode, "&eChange the enabled features"); LLabel_Init( &s->lblMode, "&eChange the enabled features");
LButton_Init2(&s->btnColours, 110, 35, "Theme"); LButton_Init(&s->btnColours, 110, 35, "Theme");
LLabel_Init2( &s->lblColours, "&eChange how the launcher looks"); LLabel_Init( &s->lblColours, "&eChange how the launcher looks");
#if defined CC_BUILD_MOBILE #if defined CC_BUILD_MOBILE
LCheckbox_Init2(&s->cbExtra, "Force landscape"); LCheckbox_Init(&s->cbExtra, "Force landscape");
s->cbExtra.OnClick = SettingsScreen_LockOrientation; s->cbExtra.OnClick = SettingsScreen_LockOrientation;
#else #else
LCheckbox_Init2(&s->cbExtra, "Close this after game starts"); LCheckbox_Init(&s->cbExtra, "Close this after game starts");
s->cbExtra.OnClick = SettingsScreen_AutoClose; s->cbExtra.OnClick = SettingsScreen_AutoClose;
#endif #endif
LCheckbox_Init2(&s->cbEmpty, "Show empty servers in list"); LCheckbox_Init(&s->cbEmpty, "Show empty servers in list");
s->cbEmpty.OnClick = SettingsScreen_ShowEmpty; s->cbEmpty.OnClick = SettingsScreen_ShowEmpty;
LButton_Init2( &s->btnBack, 80, 35, "Back"); LButton_Init( &s->btnBack, 80, 35, "Back");
s->btnMode.OnClick = SwitchToChooseMode; s->btnMode.OnClick = SwitchToChooseMode;
s->btnUpdates.OnClick = SwitchToUpdates; s->btnUpdates.OnClick = SwitchToUpdates;
@ -1669,11 +1669,11 @@ static void ThemesScreen_Init(struct LScreen* s_) {
s->widgets = themes_widgets; s->widgets = themes_widgets;
s->numWidgets = Array_Elems(themes_widgets); s->numWidgets = Array_Elems(themes_widgets);
LButton_Init2(&s->btnModern, 200, 35, "Modern"); LButton_Init(&s->btnModern, 200, 35, "Modern");
LButton_Init2(&s->btnClassic, 200, 35, "Classic"); LButton_Init(&s->btnClassic, 200, 35, "Classic");
LButton_Init2(&s->btnNordic, 200, 35, "Nordic"); LButton_Init(&s->btnNordic, 200, 35, "Nordic");
LButton_Init2(&s->btnCustom, 200, 35, "Custom"); LButton_Init(&s->btnCustom, 200, 35, "Custom");
LButton_Init2(&s->btnBack, 80, 35, "Back"); LButton_Init(&s->btnBack, 80, 35, "Back");
s->btnModern.OnClick = ThemesScreen_Modern; s->btnModern.OnClick = ThemesScreen_Modern;
s->btnClassic.OnClick = ThemesScreen_Classic; s->btnClassic.OnClick = ThemesScreen_Classic;
@ -1868,24 +1868,24 @@ static void UpdatesScreen_Init(struct LScreen* s_) {
if (Updater_Info.numBuilds < 2) s->numWidgets -= 2; if (Updater_Info.numBuilds < 2) s->numWidgets -= 2;
if (Updater_Info.numBuilds < 1) s->numWidgets -= 2; if (Updater_Info.numBuilds < 1) s->numWidgets -= 2;
LLabel_Init2(&s->lblYour, "Your build: (unknown)"); LLabel_Init(&s->lblYour, "Your build: (unknown)");
LLine_Init2( &s->seps[0], 320); LLine_Init( &s->seps[0], 320);
LLine_Init2( &s->seps[1], 320); LLine_Init( &s->seps[1], 320);
LLabel_Init2( &s->lblRel, "Latest release: Checking.."); LLabel_Init( &s->lblRel, "Latest release: Checking..");
LLabel_Init2( &s->lblDev, "Latest dev build: Checking.."); LLabel_Init( &s->lblDev, "Latest dev build: Checking..");
LLabel_Init2( &s->lblStatus, ""); LLabel_Init( &s->lblStatus, "");
LButton_Init2(&s->btnBack, 80, 35, "Back"); LButton_Init(&s->btnBack, 80, 35, "Back");
if (Updater_Info.numBuilds >= 1) { if (Updater_Info.numBuilds >= 1) {
LButton_Init2(&s->btnRel[0], 130, 35, Updater_Info.builds[0].name); LButton_Init(&s->btnRel[0], 130, 35, Updater_Info.builds[0].name);
LButton_Init2(&s->btnDev[0], 130, 35, Updater_Info.builds[0].name); LButton_Init(&s->btnDev[0], 130, 35, Updater_Info.builds[0].name);
} }
if (Updater_Info.numBuilds >= 2) { if (Updater_Info.numBuilds >= 2) {
LButton_Init2(&s->btnRel[1], 130, 35, Updater_Info.builds[1].name); LButton_Init(&s->btnRel[1], 130, 35, Updater_Info.builds[1].name);
LButton_Init2(&s->btnDev[1], 130, 35, Updater_Info.builds[1].name); LButton_Init(&s->btnDev[1], 130, 35, Updater_Info.builds[1].name);
} }
LLabel_Init2(&s->lblInfo, Updater_Info.info); LLabel_Init(&s->lblInfo, Updater_Info.info);
s->btnRel[0].OnClick = UpdatesScreen_Rel_0; s->btnRel[0].OnClick = UpdatesScreen_Rel_0;
s->btnRel[1].OnClick = UpdatesScreen_Rel_1; s->btnRel[1].OnClick = UpdatesScreen_Rel_1;

View File

@ -95,11 +95,7 @@ static const struct LWidgetVTABLE lbutton_VTABLE = {
LButton_Hover, LWidget_Draw, /* Hover */ LButton_Hover, LWidget_Draw, /* Hover */
NULL, NULL /* Select */ NULL, NULL /* Select */
}; };
void LButton_Init(struct LScreen* s, struct LButton* w, int width, int height, const char* text) { void LButton_Init(struct LButton* w, int width, int height, const char* text) {
LButton_Init2(w, width, height, text);
s->widgets[s->numWidgets++] = (struct LWidget*)w;
}
void LButton_Init2(struct LButton* w, int width, int height, const char* text) {
w->VTABLE = &lbutton_VTABLE; w->VTABLE = &lbutton_VTABLE;
w->tabSelectable = true; w->tabSelectable = true;
w->width = Display_ScaleX(width); w->width = Display_ScaleX(width);
@ -132,11 +128,7 @@ static const struct LWidgetVTABLE lcheckbox_VTABLE = {
NULL, NULL, /* Hover */ NULL, NULL, /* Hover */
NULL, NULL /* Select */ NULL, NULL /* Select */
}; };
void LCheckbox_Init(struct LScreen* s, struct LCheckbox* w, const char* text) { void LCheckbox_Init(struct LCheckbox* w, const char* text) {
LCheckbox_Init2(w, text);
s->widgets[s->numWidgets++] = (struct LWidget*)w;
}
void LCheckbox_Init2(struct LCheckbox* w, const char* text) {
struct DrawTextArgs args; struct DrawTextArgs args;
w->VTABLE = &lcheckbox_VTABLE; w->VTABLE = &lcheckbox_VTABLE;
w->font = &Launcher_TextFont; w->font = &Launcher_TextFont;
@ -411,11 +403,7 @@ static const struct LWidgetVTABLE linput_VTABLE = {
LInput_Select, LInput_Unselect, /* Select */ LInput_Select, LInput_Unselect, /* Select */
NULL, LInput_TextChanged /* TextChanged */ NULL, LInput_TextChanged /* TextChanged */
}; };
void LInput_Init(struct LScreen* s, struct LInput* w, int width, const char* hintText) { void LInput_Init(struct LInput* w, int width, const char* hintText) {
LInput_Init2(w, width, hintText);
s->widgets[s->numWidgets++] = (struct LWidget*)w;
}
void LInput_Init2(struct LInput* w, int width, const char* hintText) {
w->VTABLE = &linput_VTABLE; w->VTABLE = &linput_VTABLE;
w->tabSelectable = true; w->tabSelectable = true;
w->TextFilter = LInput_DefaultInputFilter; w->TextFilter = LInput_DefaultInputFilter;
@ -484,11 +472,7 @@ static const struct LWidgetVTABLE llabel_VTABLE = {
NULL, NULL, /* Hover */ NULL, NULL, /* Hover */
NULL, NULL /* Select */ NULL, NULL /* Select */
}; };
void LLabel_Init(struct LScreen* s, struct LLabel* w, const char* text) { void LLabel_Init(struct LLabel* w, const char* text) {
LLabel_Init2(w, text);
s->widgets[s->numWidgets++] = (struct LWidget*)w;
}
void LLabel_Init2(struct LLabel* w, const char* text) {
w->VTABLE = &llabel_VTABLE; w->VTABLE = &llabel_VTABLE;
w->font = &Launcher_TextFont; w->font = &Launcher_TextFont;
@ -526,11 +510,7 @@ static const struct LWidgetVTABLE lline_VTABLE = {
NULL, NULL, /* Hover */ NULL, NULL, /* Hover */
NULL, NULL /* Select */ NULL, NULL /* Select */
}; };
void LLine_Init(struct LScreen* s, struct LLine* w, int width) { void LLine_Init(struct LLine* w, int width) {
LLine_Init2(w, width);
s->widgets[s->numWidgets++] = (struct LWidget*)w;
}
void LLine_Init2(struct LLine* w, int width) {
w->VTABLE = &lline_VTABLE; w->VTABLE = &lline_VTABLE;
w->width = Display_ScaleX(width); w->width = Display_ScaleX(width);
w->height = Display_ScaleY(2); w->height = Display_ScaleY(2);
@ -551,16 +531,12 @@ static const struct LWidgetVTABLE lslider_VTABLE = {
NULL, NULL, /* Hover */ NULL, NULL, /* Hover */
NULL, NULL /* Select */ NULL, NULL /* Select */
}; };
void LSlider_Init(struct LScreen* s, struct LSlider* w, int width, int height, BitmapCol col) { void LSlider_Init(struct LSlider* w, int width, int height, BitmapCol color) {
LSlider_Init2(w, width, height, col);
s->widgets[s->numWidgets++] = (struct LWidget*)w;
}
void LSlider_Init2(struct LSlider* w, int width, int height, BitmapCol col) {
w->VTABLE = &lslider_VTABLE; w->VTABLE = &lslider_VTABLE;
w->width = Display_ScaleX(width); w->width = Display_ScaleX(width);
w->height = Display_ScaleY(height); w->height = Display_ScaleY(height);
w->maxValue = 100; w->maxValue = 100;
w->col = col; w->color = color;
} }

View File

@ -5,7 +5,6 @@
/* Describes and manages individual 2D GUI elements in the launcher. /* Describes and manages individual 2D GUI elements in the launcher.
Copyright 2014-2021 ClassiCube | Licensed under BSD-3 Copyright 2014-2021 ClassiCube | Licensed under BSD-3
*/ */
struct LScreen;
struct FontDesc; struct FontDesc;
struct LWidgetVTABLE { struct LWidgetVTABLE {
@ -57,8 +56,7 @@ struct LButton {
cc_string text; cc_string text;
int _textWidth, _textHeight; int _textWidth, _textHeight;
}; };
CC_NOINLINE void LButton_Init(struct LScreen* s, struct LButton* w, int width, int height, const char* text); CC_NOINLINE void LButton_Init(struct LButton* w, int width, int height, const char* text);
CC_NOINLINE void LButton_Init2(struct LButton* w, int width, int height, const char* text);
CC_NOINLINE void LButton_SetConst(struct LButton* w, const char* text); CC_NOINLINE void LButton_SetConst(struct LButton* w, const char* text);
struct LCheckbox { struct LCheckbox {
@ -68,8 +66,7 @@ struct LCheckbox {
cc_string text; cc_string text;
char _textBuffer[STRING_SIZE]; char _textBuffer[STRING_SIZE];
}; };
CC_NOINLINE void LCheckbox_Init(struct LScreen* s, struct LCheckbox* w, const char* text); CC_NOINLINE void LCheckbox_Init(struct LCheckbox* w, const char* text);
CC_NOINLINE void LCheckbox_Init2(struct LCheckbox* w, const char* text);
struct LInput; struct LInput;
struct LInput { struct LInput {
@ -93,8 +90,7 @@ struct LInput {
int _textHeight; int _textHeight;
char _textBuffer[STRING_SIZE]; char _textBuffer[STRING_SIZE];
}; };
CC_NOINLINE void LInput_Init(struct LScreen* s, struct LInput* w, int width, const char* hintText); CC_NOINLINE void LInput_Init(struct LInput* w, int width, const char* hintText);
CC_NOINLINE void LInput_Init2(struct LInput* w, int width, const char* hintText);
CC_NOINLINE void LInput_SetText(struct LInput* w, const cc_string* text); CC_NOINLINE void LInput_SetText(struct LInput* w, const cc_string* text);
CC_NOINLINE void LInput_ClearText(struct LInput* w); CC_NOINLINE void LInput_ClearText(struct LInput* w);
@ -112,8 +108,7 @@ struct LLabel {
cc_string text; cc_string text;
char _textBuffer[STRING_SIZE]; char _textBuffer[STRING_SIZE];
}; };
CC_NOINLINE void LLabel_Init(struct LScreen* s, struct LLabel* w, const char* text); CC_NOINLINE void LLabel_Init(struct LLabel* w, const char* text);
CC_NOINLINE void LLabel_Init2(struct LLabel* w, const char* text);
CC_NOINLINE void LLabel_SetText(struct LLabel* w, const cc_string* text); CC_NOINLINE void LLabel_SetText(struct LLabel* w, const cc_string* text);
CC_NOINLINE void LLabel_SetConst(struct LLabel* w, const char* text); CC_NOINLINE void LLabel_SetConst(struct LLabel* w, const char* text);
@ -121,17 +116,15 @@ CC_NOINLINE void LLabel_SetConst(struct LLabel* w, const char* text);
struct LLine { struct LLine {
LWidget_Layout LWidget_Layout
}; };
CC_NOINLINE void LLine_Init(struct LScreen* s, struct LLine* w, int width); CC_NOINLINE void LLine_Init(struct LLine* w, int width);
CC_NOINLINE void LLine_Init2(struct LLine* w, int width);
/* Represents a slider bar that may or may not be modifiable by the user. */ /* Represents a slider bar that may or may not be modifiable by the user. */
struct LSlider { struct LSlider {
LWidget_Layout LWidget_Layout
int value, maxValue; int value, maxValue;
BitmapCol col; BitmapCol color;
}; };
CC_NOINLINE void LSlider_Init(struct LScreen* s, struct LSlider* w, int width, int height, BitmapCol col); CC_NOINLINE void LSlider_Init(struct LSlider* w, int width, int height, BitmapCol color);
CC_NOINLINE void LSlider_Init2(struct LSlider* w, int width, int height, BitmapCol col);
struct ServerInfo; struct ServerInfo;
struct DrawTextArgs; struct DrawTextArgs;