From 22f205a961060213fd3cfb492085ed609e9c80e1 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 1 Dec 2019 10:38:55 +1100 Subject: [PATCH] make field names of structs in LWidgets camel case --- src/Input.h | 2 +- src/LScreens.c | 126 ++++++------ src/LWidgets.c | 548 ++++++++++++++++++++++++------------------------- src/LWidgets.h | 78 +++---- 4 files changed, 377 insertions(+), 377 deletions(-) diff --git a/src/Input.h b/src/Input.h index fbbfe2de4..c8c6b7748 100644 --- a/src/Input.h +++ b/src/Input.h @@ -54,7 +54,7 @@ extern const char* const Input_Names[INPUT_COUNT]; #define Key_IsShiftPressed() (Input_Pressed[KEY_LSHIFT] || Input_Pressed[KEY_RSHIFT]) #ifdef CC_BUILD_OSX -/* osx uses CMD instead of CTRL for clipboard and stuff */ +/* macOS uses CMD instead of CTRL for clipboard and stuff */ #define Key_IsActionPressed() Key_IsWinPressed() #else #define Key_IsActionPressed() Key_IsControlPressed() diff --git a/src/LScreens.c b/src/LScreens.c index 4ee6ef9ec..fcffa48e2 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -33,9 +33,9 @@ CC_NOINLINE static struct LWidget* LScreen_WidgetAt(struct LScreen* s, int x, in for (i = 0; i < s->numWidgets; i++) { w = s->widgets[i]; - if (w->Hidden) continue; + if (w->hidden) continue; - if (Gui_Contains(w->X, w->Y, w->Width, w->Height, x, y)) return w; + if (Gui_Contains(w->x, w->y, w->width, w->height, x, y)) return w; } return NULL; } @@ -58,14 +58,14 @@ static void LScreen_UnhoverWidget(struct LScreen* s, struct LWidget* w) { } CC_NOINLINE static void LScreen_SelectWidget(struct LScreen* s, struct LWidget* w, cc_bool was) { if (!w) return; - w->Selected = true; + w->selected = true; s->selectedWidget = w; if (w->VTABLE->OnSelect) w->VTABLE->OnSelect(w, was); } CC_NOINLINE static void LScreen_UnselectWidget(struct LScreen* s, struct LWidget* w) { if (!w) return; - w->Selected = false; + w->selected = false; s->selectedWidget = NULL; if (w->VTABLE->OnUnselect) w->VTABLE->OnUnselect(w); } @@ -84,7 +84,7 @@ static void LScreen_HandleTab(struct LScreen* s) { if (i < 0) i += s->numWidgets; w = s->widgets[i]; - if (w->Hidden || !w->TabSelectable) continue; + if (w->hidden || !w->tabSelectable) continue; LScreen_UnselectWidget(s, s->selectedWidget); LScreen_SelectWidget(s, w, false); @@ -144,7 +144,7 @@ static void LScreen_MouseMove(struct LScreen* s, int deltaX, int deltaY) { cc_bool overSame = prev == over; if (prev && !overSame) { - prev->Hovered = false; + prev->hovered = false; s->hoveredWidget = NULL; s->UnhoverWidget(s, prev); @@ -152,7 +152,7 @@ static void LScreen_MouseMove(struct LScreen* s, int deltaX, int deltaY) { } if (over) { - over->Hovered = true; + over->hovered = true; s->hoveredWidget = over; s->HoverWidget(s, over); @@ -181,8 +181,8 @@ CC_NOINLINE static void LScreen_Reset(struct LScreen* s) { /* reset all widgets mouse state */ for (i = 0; i < s->numWidgets; i++) { - s->widgets[i]->Hovered = false; - s->widgets[i]->Selected = false; + s->widgets[i]->hovered = false; + s->widgets[i]->selected = false; } s->onEnterWidget = NULL; @@ -247,10 +247,10 @@ static void UseModeClassic(void* w, int x, int y) { ChooseMode_Click(true, f static void ChooseModeScreen_Init(struct LScreen* s_) { struct ChooseModeScreen* s = (struct ChooseModeScreen*)s_; - s->lblHelp.Hidden = !s->firstTime; - s->btnBack.Hidden = s->firstTime; - s->seps[0].Col = Launcher_ButtonBorderCol; - s->seps[1].Col = Launcher_ButtonBorderCol; + s->lblHelp.hidden = !s->firstTime; + s->btnBack.hidden = s->firstTime; + s->seps[0].col = Launcher_ButtonBorderCol; + s->seps[1].col = Launcher_ButtonBorderCol; if (s->numWidgets) return; s->widgets = s->_widgets; @@ -278,7 +278,7 @@ static void ChooseModeScreen_Init(struct LScreen* s_) { s->btnClassic.OnClick = UseModeClassic; s->btnBack.OnClick = SwitchToSettings; - s->lblTitle.Font = &Launcher_TitleFont; + s->lblTitle.font = &Launcher_TitleFont; LLabel_SetConst(&s->lblTitle, "Choose game mode"); } @@ -365,9 +365,9 @@ static void ColoursScreen_TextChanged(struct LInput* w) { /* if index of G input, changes to index of R input */ index = (index / 3) * 3; - if (!Convert_ParseUInt8(&s->iptColours[index + 0].Text, &r)) return; - if (!Convert_ParseUInt8(&s->iptColours[index + 1].Text, &g)) return; - if (!Convert_ParseUInt8(&s->iptColours[index + 2].Text, &b)) return; + if (!Convert_ParseUInt8(&s->iptColours[index + 0].text, &r)) return; + if (!Convert_ParseUInt8(&s->iptColours[index + 1].text, &g)) return; + if (!Convert_ParseUInt8(&s->iptColours[index + 2].text, &b)) return; *col = BitmapCol_Make(r, g, b, 255); Launcher_SaveSkin(); @@ -384,14 +384,14 @@ static void ColoursScreen_AdjustSelected(struct LScreen* s, int delta) { if (index >= 15) return; w = (struct LInput*)s->selectedWidget; - if (!Convert_ParseUInt8(&w->Text, &col)) return; + if (!Convert_ParseUInt8(&w->text, &col)) return; newCol = col + delta; Math_Clamp(newCol, 0, 255); - w->Text.length = 0; - String_AppendInt(&w->Text, newCol); + w->text.length = 0; + String_AppendInt(&w->text, newCol); - if (w->CaretPos >= w->Text.length) w->CaretPos = -1; + if (w->caretPos >= w->text.length) w->caretPos = -1; ColoursScreen_TextChanged(w); } @@ -544,9 +544,9 @@ static void DirectConnectScreen_Save(const String* user, const String* mppass, c static void DirectConnectScreen_StartClient(void* w, int x, int y) { static const String loopbackIp = String_FromConst("127.0.0.1"); static const String defMppass = String_FromConst("(none)"); - const String* user = &DirectConnectScreen_Instance.iptUsername.Text; - const String* addr = &DirectConnectScreen_Instance.iptAddress.Text; - const String* mppass = &DirectConnectScreen_Instance.iptMppass.Text; + const String* user = &DirectConnectScreen_Instance.iptUsername.text; + const String* addr = &DirectConnectScreen_Instance.iptAddress.text; + const String* mppass = &DirectConnectScreen_Instance.iptMppass.text; String ip, port; cc_uint8 raw_ip[4]; @@ -669,8 +669,8 @@ CC_NOINLINE static void MainScreen_Error(struct LWebTask* task, const char* acti static void MainScreen_Login(void* w, int x, int y) { struct MainScreen* s = &MainScreen_Instance; - String* user = &s->iptUsername.Text; - String* pass = &s->iptPassword.Text; + String* user = &s->iptUsername.text; + String* pass = &s->iptPassword.text; if (!user->length) { LLabel_SetConst(&s->lblStatus, "&eUsername required"); @@ -706,7 +706,7 @@ static void MainScreen_Resume(void* w, int x, int y) { static void MainScreen_Singleplayer(void* w, int x, int y) { static const String defUser = String_FromConst("Singleplayer"); - const String* user = &MainScreen_Instance.iptUsername.Text; + const String* user = &MainScreen_Instance.iptUsername.text; if (!user->length) user = &defUser; Launcher_StartGame(user, &String_Empty, &String_Empty, &String_Empty, &String_Empty); @@ -719,7 +719,7 @@ static void MainScreen_Init(struct LScreen* s_) { struct MainScreen* s = (struct MainScreen*)s_; /* status should reset after user has gone to another menu */ - s->lblStatus.Text.length = 0; + s->lblStatus.text.length = 0; if (s->numWidgets) return; s->widgets = s->_widgets; @@ -745,9 +745,9 @@ static void MainScreen_Init(struct LScreen* s_) { s->btnRegister.OnClick = MainScreen_Register; /* need to set text here for right size */ - s->lblUpdate.Font = &Launcher_HintFont; + s->lblUpdate.font = &Launcher_HintFont; LLabel_SetConst(&s->lblUpdate, "&eChecking.."); - s->iptPassword.Password = true; + s->iptPassword.password = true; s->iptPassword.TextFilter = MainScreen_PasswordFilter; String_InitArray(pass, passBuffer); @@ -785,7 +785,7 @@ static void MainScreen_HoverWidget(struct LScreen* s_, struct LWidget* w) { if (!info.user.length) return; String_InitArray(str, strBuffer); - if (info.server.length && String_Equals(&info.user, &s->iptUsername.Text)) { + if (info.server.length && String_Equals(&info.user, &s->iptUsername.text)) { String_Format1(&str, "&eResume to %s", &info.server); } else if (info.server.length) { String_Format2(&str, "&eResume as %s to %s", &info.user, &info.server); @@ -842,7 +842,7 @@ static void MainScreen_TickGetToken(struct MainScreen* s) { if (!GetTokenTask.Base.Completed) return; if (GetTokenTask.Base.Success) { - SignInTask_Run(&s->iptUsername.Text, &s->iptPassword.Text); + SignInTask_Run(&s->iptUsername.text, &s->iptPassword.text); } else { MainScreen_Error(&GetTokenTask.Base, "signing in"); } @@ -858,7 +858,7 @@ static void MainScreen_TickSignIn(struct MainScreen* s) { LWidget_Redraw(&s->lblStatus); } else if (SignInTask.Base.Success) { /* website returns case correct username */ - if (!String_Equals(&s->iptUsername.Text, &SignInTask.Username)) { + if (!String_Equals(&s->iptUsername.text, &SignInTask.Username)) { LInput_SetText(&s->iptUsername, &SignInTask.Username); LWidget_Redraw(&s->iptUsername); } @@ -931,12 +931,12 @@ static void ResourcesScreen_Download(void* w, int x, int y) { Fetcher_Run(); s->selectedWidget = NULL; - s->btnYes.Hidden = true; - s->btnNo.Hidden = true; - s->lblLine1.Hidden = true; - s->lblLine2.Hidden = true; - s->btnCancel.Hidden = false; - s->sdrProgress.Hidden = false; + s->btnYes.hidden = true; + s->btnNo.hidden = true; + s->lblLine1.hidden = true; + s->lblLine2.hidden = true; + s->btnCancel.hidden = false; + s->sdrProgress.hidden = false; s->Draw((struct LScreen*)s); } @@ -971,14 +971,14 @@ static void ResourcesScreen_Init(struct LScreen* s_) { LButton_Init(s_, &s->btnCancel, 120, 35, "Cancel"); LSlider_Init(s_, &s->sdrProgress, 200, 12, progressCol); - s->btnCancel.Hidden = true; - s->sdrProgress.Hidden = true; + s->btnCancel.hidden = true; + s->sdrProgress.hidden = true; /* TODO: Size 13 italic font?? does it matter?? */ String_InitArray(str, buffer); size = Resources_Size / 1024.0f; - s->lblStatus.Font = &Launcher_HintFont; + s->lblStatus.font = &Launcher_HintFont; String_Format1(&str, "&eDownload size: %f2 megabytes", &size); LLabel_SetText(&s->lblStatus, &str); @@ -1025,12 +1025,12 @@ static void ResourcesScreen_Draw(struct LScreen* s) { static void ResourcesScreen_SetStatus(const String* str) { struct LLabel* w = &ResourcesScreen_Instance.lblStatus; - ResourcesScreen_ResetArea(w->Last.X, w->Last.Y, - w->Last.Width, w->Last.Height); + ResourcesScreen_ResetArea(w->last.X, w->last.Y, + w->last.Width, w->last.Height); LLabel_SetText(w, str); - w->YOffset = -10; - ResourcesScreen_Instance.statusYOffset = w->YOffset; + w->yOffset = -10; + ResourcesScreen_Instance.statusYOffset = w->yOffset; LWidget_CalcPosition(w); LWidget_Draw(w); } @@ -1046,7 +1046,7 @@ static void ResourcesScreen_UpdateStatus(struct HttpRequest* req) { count = Fetcher_Downloaded + 1; String_Format3(&str, "&eFetching %s.. (%i/%i)", &id, &count, &Resources_Count); - if (String_Equals(&str, &w->Text)) return; + if (String_Equals(&str, &w->text)) return; ResourcesScreen_SetStatus(&str); } @@ -1059,8 +1059,8 @@ static void ResourcesScreen_UpdateProgress(struct ResourcesScreen* s) { /* making request still, haven't started download yet */ if (progress < 0 || progress > 100) return; - if (progress == s->sdrProgress.Value) return; - s->sdrProgress.Value = progress; + if (progress == s->sdrProgress.value) return; + s->sdrProgress.value = progress; LWidget_Draw(&s->sdrProgress); } @@ -1113,10 +1113,10 @@ static struct ServersScreen { static void ServersScreen_Connect(void* w, int x, int y) { struct LTable* table = &ServersScreen_Instance.table; - String* hash = &ServersScreen_Instance.iptHash.Text; + String* hash = &ServersScreen_Instance.iptHash.text; - if (!hash->length && table->RowsCount) { - hash = <able_Get(table->TopRow)->hash; + if (!hash->length && table->rowsCount) { + hash = <able_Get(table->topRow)->hash; } Launcher_ConnectToServer(hash); } @@ -1192,8 +1192,8 @@ static void ServersScreen_InitWidgets(struct LScreen* s_) { s->iptHash.ClipboardFilter = ServersScreen_HashFilter; LTable_Init(&s->table, &s->rowFont); - s->table.Filter = &s->iptSearch.Text; - s->table.SelectedHash = &s->iptHash.Text; + s->table.filter = &s->iptSearch.text; + s->table.selectedHash = &s->iptHash.text; s->table.OnSelectedChanged = ServersScreen_OnSelectedChanged; s->widgets[s->numWidgets++] = (struct LWidget*)&s->table; @@ -1204,7 +1204,7 @@ static void ServersScreen_Init(struct LScreen* s_) { Drawer2D_MakeFont(&s->rowFont, 11, FONT_STYLE_NORMAL); if (!s->numWidgets) ServersScreen_InitWidgets(s_); - s->table.RowFont = &s->rowFont; + s->table.rowFont = &s->rowFont; /* also resets hash and filter */ LTable_Reset(&s->table); @@ -1254,9 +1254,9 @@ static void ServersScreen_Layout(struct LScreen* s_) { LWidget_SetLocation(&s->btnRefresh, ANCHOR_MAX, ANCHOR_MIN, 135, 10); LWidget_SetLocation(&s->table, ANCHOR_MIN, ANCHOR_MIN, 10, 50); - s->table.Width = Window_Width - s->table.X; - s->table.Height = Window_Height - s->table.Y * 2; - s->table.Height = max(1, s->table.Height); + s->table.width = Window_Width - s->table.x; + s->table.height = Window_Height - s->table.y * 2; + s->table.height = max(1, s->table.height); LTable_Reposition(&s->table); } @@ -1312,8 +1312,8 @@ static struct SettingsScreen { static void SettingsScreen_Init(struct LScreen* s_) { struct SettingsScreen* s = (struct SettingsScreen*)s_; - s->btnColours.Hidden = Launcher_ClassicBackground; - s->lblColours.Hidden = Launcher_ClassicBackground; + s->btnColours.hidden = Launcher_ClassicBackground; + s->lblColours.hidden = Launcher_ClassicBackground; if (s->numWidgets) return; s->widgets = s->_widgets; @@ -1505,8 +1505,8 @@ static void UpdatesScreen_Update(struct UpdatesScreen* s) { static void UpdatesScreen_Init(struct LScreen* s_) { struct UpdatesScreen* s = (struct UpdatesScreen*)s_; - s->seps[0].Col = Launcher_ButtonBorderCol; - s->seps[1].Col = Launcher_ButtonBorderCol; + s->seps[0].col = Launcher_ButtonBorderCol; + s->seps[1].col = Launcher_ButtonBorderCol; if (s->numWidgets) { UpdatesScreen_Update(s); return; } s->widgets = s->_widgets; @@ -1568,7 +1568,7 @@ static void UpdatesScreen_Free(struct LScreen* s_) { s->buildProgress = -1; FetchUpdateTask.Base.Working = false; - s->lblStatus.Text.length = 0; + s->lblStatus.text.length = 0; } struct LScreen* UpdatesScreen_MakeInstance(void) { diff --git a/src/LWidgets.c b/src/LWidgets.c index cdf8cef2b..c16385b19 100644 --- a/src/LWidgets.c +++ b/src/LWidgets.c @@ -18,30 +18,30 @@ void LWidget_SetLocation(void* widget, cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset) { struct LWidget* w = (struct LWidget*)widget; - w->HorAnchor = horAnchor; w->VerAnchor = verAnchor; - w->XOffset = xOffset; w->YOffset = yOffset; + w->horAnchor = horAnchor; w->verAnchor = verAnchor; + w->xOffset = xOffset; w->yOffset = yOffset; LWidget_CalcPosition(widget); } void LWidget_CalcPosition(void* widget) { struct LWidget* w = (struct LWidget*)widget; - w->X = Gui_CalcPos(w->HorAnchor, Display_ScaleX(w->XOffset), w->Width, Window_Width); - w->Y = Gui_CalcPos(w->VerAnchor, Display_ScaleY(w->YOffset), w->Height, Window_Height); + w->x = Gui_CalcPos(w->horAnchor, Display_ScaleX(w->xOffset), w->width, Window_Width); + w->y = Gui_CalcPos(w->verAnchor, Display_ScaleY(w->yOffset), w->height, Window_Height); } void LWidget_Draw(void* widget) { struct LWidget* w = (struct LWidget*)widget; - w->Last.X = w->X; w->Last.Width = w->Width; - w->Last.Y = w->Y; w->Last.Height = w->Height; + w->last.X = w->x; w->last.Width = w->width; + w->last.Y = w->y; w->last.Height = w->height; - if (w->Hidden) return; + if (w->hidden) return; w->VTABLE->Draw(w); - Launcher_MarkDirty(w->X, w->Y, w->Width, w->Height); + Launcher_MarkDirty(w->x, w->y, w->width, w->height); } void LWidget_Redraw(void* widget) { struct LWidget* w = (struct LWidget*)widget; - Launcher_ResetArea(w->Last.X, w->Last.Y, w->Last.Width, w->Last.Height); + Launcher_ResetArea(w->last.X, w->last.Y, w->last.Width, w->last.Height); LWidget_Draw(w); } @@ -63,15 +63,15 @@ static void LButton_DrawBackground(struct LButton* w) { BitmapCol col; if (Launcher_ClassicBackground) { - col = w->Hovered ? activeCol : inactiveCol; + col = w->hovered ? activeCol : inactiveCol; Gradient_Noise(&Launcher_Framebuffer, col, 8, - w->X + BORDER, w->Y + BORDER, - w->Width - BORDER2, w->Height - BORDER2); + w->x + BORDER, w->y + BORDER, + w->width - BORDER2, w->height - BORDER2); } else { - col = w->Hovered ? Launcher_ButtonForeActiveCol : Launcher_ButtonForeCol; + col = w->hovered ? Launcher_ButtonForeActiveCol : Launcher_ButtonForeCol; Gradient_Vertical(&Launcher_Framebuffer, LButton_Expand(col, 8), LButton_Expand(col, -8), - w->X + BORDER, w->Y + BORDER, - w->Width - BORDER2, w->Height - BORDER2); + w->x + BORDER, w->y + BORDER, + w->width - BORDER2, w->height - BORDER2); } } @@ -80,17 +80,17 @@ static void LButton_DrawBorder(struct LButton* w) { BitmapCol backCol = Launcher_ClassicBackground ? black : Launcher_ButtonBorderCol; Drawer2D_Clear(&Launcher_Framebuffer, backCol, - w->X + BORDER, w->Y, - w->Width - BORDER2, BORDER); + w->x + BORDER, w->y, + w->width - BORDER2, BORDER); Drawer2D_Clear(&Launcher_Framebuffer, backCol, - w->X + BORDER, w->Y + w->Height - BORDER, - w->Width - BORDER2, BORDER); + w->x + BORDER, w->y + w->height - BORDER, + w->width - BORDER2, BORDER); Drawer2D_Clear(&Launcher_Framebuffer, backCol, - w->X, w->Y + BORDER, - BORDER, w->Height - BORDER2); + w->x, w->y + BORDER, + BORDER, w->height - BORDER2); Drawer2D_Clear(&Launcher_Framebuffer, backCol, - w->X + w->Width - BORDER, w->Y + BORDER, - BORDER, w->Height - BORDER2); + w->x + w->width - BORDER, w->y + BORDER, + BORDER, w->height - BORDER2); } static void LButton_DrawHighlight(struct LButton* w) { @@ -99,17 +99,17 @@ static void LButton_DrawHighlight(struct LButton* w) { BitmapCol highlightCol; if (Launcher_ClassicBackground) { - highlightCol = w->Hovered ? activeCol : inactiveCol; + highlightCol = w->hovered ? activeCol : inactiveCol; Drawer2D_Clear(&Launcher_Framebuffer, highlightCol, - w->X + BORDER2, w->Y + BORDER, - w->Width - BORDER4, BORDER); + w->x + BORDER2, w->y + BORDER, + w->width - BORDER4, BORDER); Drawer2D_Clear(&Launcher_Framebuffer, highlightCol, - w->X + BORDER, w->Y + BORDER2, - BORDER, w->Height - BORDER4); - } else if (!w->Hovered) { + w->x + BORDER, w->y + BORDER2, + BORDER, w->height - BORDER4); + } else if (!w->hovered) { Drawer2D_Clear(&Launcher_Framebuffer, Launcher_ButtonHighlightCol, - w->X + BORDER2, w->Y + BORDER, - w->Width - BORDER4, BORDER); + w->x + BORDER2, w->y + BORDER, + w->width - BORDER4, BORDER); } } @@ -117,22 +117,22 @@ static void LButton_Draw(void* widget) { struct LButton* w = (struct LButton*)widget; struct DrawTextArgs args; int xOffset, yOffset; - if (w->Hidden) return; + if (w->hidden) return; - xOffset = w->Width - w->_TextSize.Width; - yOffset = w->Height - w->_TextSize.Height; - DrawTextArgs_Make(&args, &w->Text, &Launcher_TitleFont, true); + xOffset = w->width - w->_textSize.Width; + yOffset = w->height - w->_textSize.Height; + DrawTextArgs_Make(&args, &w->text, &Launcher_TitleFont, true); LButton_DrawBackground(w); LButton_DrawBorder(w); LButton_DrawHighlight(w); - if (!w->Hovered) Drawer2D_Cols['f'] = Drawer2D_Cols['7']; + if (!w->hovered) Drawer2D_Cols['f'] = Drawer2D_Cols['7']; Drawer2D_DrawText(&Launcher_Framebuffer, &args, - w->X + xOffset / 2, w->Y + yOffset / 2); + w->x + xOffset / 2, w->y + yOffset / 2); - if (!w->Hovered) Drawer2D_Cols['f'] = Drawer2D_Cols['F']; - Launcher_MarkDirty(w->X, w->Y, w->Width, w->Height); + if (!w->hovered) Drawer2D_Cols['f'] = Drawer2D_Cols['F']; + Launcher_MarkDirty(w->x, w->y, w->width, w->height); } static void LButton_Hover(void* w, int x, int y, cc_bool wasOver) { @@ -148,9 +148,9 @@ static struct LWidgetVTABLE lbutton_VTABLE = { }; void LButton_Init(struct LScreen* s, struct LButton* w, int width, int height, const char* text) { w->VTABLE = &lbutton_VTABLE; - w->TabSelectable = true; - w->Width = Display_ScaleX(width); - w->Height = Display_ScaleY(height); + w->tabSelectable = true; + w->width = Display_ScaleX(width); + w->height = Display_ScaleY(height); LButton_SetConst(w, text); s->widgets[s->numWidgets++] = (struct LWidget*)w; @@ -158,9 +158,9 @@ void LButton_Init(struct LScreen* s, struct LButton* w, int width, int height, c void LButton_SetConst(struct LButton* w, const char* text) { struct DrawTextArgs args; - w->Text = String_FromReadonly(text); - DrawTextArgs_Make(&args, &w->Text, &Launcher_TitleFont, true); - w->_TextSize = Drawer2D_MeasureText(&args); + w->text = String_FromReadonly(text); + DrawTextArgs_Make(&args, &w->text, &Launcher_TitleFont, true); + w->_textSize = Drawer2D_MeasureText(&args); } @@ -169,9 +169,9 @@ void LButton_SetConst(struct LButton* w, const char* text) { *#########################################################################################################################*/ CC_NOINLINE static void LInput_GetText(struct LInput* w, String* text) { int i; - if (!w->Password) { *text = w->Text; return; } + if (!w->password) { *text = w->text; return; } - for (i = 0; i < w->Text.length; i++) { + for (i = 0; i < w->text.length; i++) { String_Append(text, '*'); } } @@ -179,28 +179,28 @@ CC_NOINLINE static void LInput_GetText(struct LInput* w, String* text) { static void LInput_DrawOuterBorder(struct LInput* w) { BitmapCol col = BitmapCol_Make(97, 81, 110, 255); - if (w->Selected) { + if (w->selected) { Drawer2D_Clear(&Launcher_Framebuffer, col, - w->X, w->Y, - w->Width, BORDER); + w->x, w->y, + w->width, BORDER); Drawer2D_Clear(&Launcher_Framebuffer, col, - w->X, w->Y + w->Height - BORDER, - w->Width, BORDER); + w->x, w->y + w->height - BORDER, + w->width, BORDER); Drawer2D_Clear(&Launcher_Framebuffer, col, - w->X, w->Y, - BORDER, w->Height); + w->x, w->y, + BORDER, w->height); Drawer2D_Clear(&Launcher_Framebuffer, col, - w->X + w->Width - BORDER, w->Y, - BORDER, w->Height); + w->x + w->width - BORDER, w->y, + BORDER, w->height); } else { - Launcher_ResetArea(w->X, w->Y, - w->Width, BORDER); - Launcher_ResetArea(w->X, w->Y + w->Height - BORDER, - w->Width, BORDER); - Launcher_ResetArea(w->X, w->Y, - BORDER, w->Height); - Launcher_ResetArea(w->X + w->Width - BORDER, w->Y, - BORDER, w->Height); + Launcher_ResetArea(w->x, w->y, + w->width, BORDER); + Launcher_ResetArea(w->x, w->y + w->height - BORDER, + w->width, BORDER); + Launcher_ResetArea(w->x, w->y, + BORDER, w->height); + Launcher_ResetArea(w->x + w->width - BORDER, w->y, + BORDER, w->height); } } @@ -208,46 +208,46 @@ static void LInput_DrawInnerBorder(struct LInput* w) { BitmapCol col = BitmapCol_Make(165, 142, 168, 255); Drawer2D_Clear(&Launcher_Framebuffer, col, - w->X + BORDER, w->Y + BORDER, - w->Width - BORDER2, BORDER); + w->x + BORDER, w->y + BORDER, + w->width - BORDER2, BORDER); Drawer2D_Clear(&Launcher_Framebuffer, col, - w->X + BORDER, w->Y + w->Height - BORDER2, - w->Width - BORDER2, BORDER); + w->x + BORDER, w->y + w->height - BORDER2, + w->width - BORDER2, BORDER); Drawer2D_Clear(&Launcher_Framebuffer, col, - w->X + BORDER, w->Y + BORDER, - BORDER, w->Height - BORDER2); + w->x + BORDER, w->y + BORDER, + BORDER, w->height - BORDER2); Drawer2D_Clear(&Launcher_Framebuffer, col, - w->X + w->Width - BORDER2, w->Y + BORDER, - BORDER, w->Height - BORDER2); + w->x + w->width - BORDER2, w->y + BORDER, + BORDER, w->height - BORDER2); } static void LInput_BlendBoxTop(struct LInput* w) { BitmapCol col = BitmapCol_Make(0, 0, 0, 255); Gradient_Blend(&Launcher_Framebuffer, col, 75, - w->X + BORDER, w->Y + BORDER, - w->Width - BORDER2, BORDER); + w->x + BORDER, w->y + BORDER, + w->width - BORDER2, BORDER); Gradient_Blend(&Launcher_Framebuffer, col, 50, - w->X + BORDER, w->Y + BORDER2, - w->Width - BORDER2, BORDER); + w->x + BORDER, w->y + BORDER2, + w->width - BORDER2, BORDER); Gradient_Blend(&Launcher_Framebuffer, col, 25, - w->X + BORDER, w->Y + BORDER3, - w->Width - BORDER2, BORDER); + w->x + BORDER, w->y + BORDER3, + w->width - BORDER2, BORDER); } static void LInput_DrawText(struct LInput* w, struct DrawTextArgs* args) { int y, hintHeight; - if (w->Text.length || !w->HintText) { - y = w->Y + (w->Height - w->_TextHeight) / 2; - Drawer2D_DrawText(&Launcher_Framebuffer, args, w->X + 5, y + 2); + if (w->text.length || !w->hintText) { + y = w->y + (w->height - w->_textHeight) / 2; + Drawer2D_DrawText(&Launcher_Framebuffer, args, w->x + 5, y + 2); } else { - args->text = String_FromReadonly(w->HintText); + args->text = String_FromReadonly(w->hintText); args->font = &Launcher_HintFont; hintHeight = Drawer2D_TextHeight(args); - y = w->Y + (w->Height - hintHeight) / 2; - Drawer2D_DrawText(&Launcher_Framebuffer, args, w->X + 5, y); + y = w->y + (w->height - hintHeight) / 2; + Drawer2D_DrawText(&Launcher_Framebuffer, args, w->x + 5, y); } } @@ -262,14 +262,14 @@ static void LInput_Draw(void* widget) { DrawTextArgs_Make(&args, &text, &Launcher_TextFont, false); size = Drawer2D_MeasureText(&args); - w->Width = max(w->MinWidth, size.Width + 20); - w->_TextHeight = size.Height; + w->width = max(w->minWidth, size.Width + 20); + w->_textHeight = size.Height; LInput_DrawOuterBorder(w); LInput_DrawInnerBorder(w); Drawer2D_Clear(&Launcher_Framebuffer, BITMAPCOL_WHITE, - w->X + BORDER2, w->Y + BORDER2, - w->Width - BORDER4, w->Height - BORDER4); + w->x + BORDER2, w->y + BORDER2, + w->width - BORDER4, w->height - BORDER4); LInput_BlendBoxTop(w); Drawer2D_Cols['f'] = Drawer2D_Cols['0']; @@ -286,17 +286,17 @@ static Rect2D LInput_MeasureCaret(struct LInput* w) { LInput_GetText(w, &text); DrawTextArgs_Make(&args, &text, &Launcher_TextFont, true); - r.X = w->X + 5; - r.Y = w->Y + w->Height - 5; r.Height = 2; + r.X = w->x + 5; + r.Y = w->y + w->height - 5; r.Height = 2; - if (w->CaretPos == -1) { + if (w->caretPos == -1) { r.X += Drawer2D_TextWidth(&args); r.Width = 10; } else { - args.text = String_UNSAFE_Substring(&text, 0, w->CaretPos); + args.text = String_UNSAFE_Substring(&text, 0, w->caretPos); r.X += Drawer2D_TextWidth(&args); - args.text = String_UNSAFE_Substring(&text, w->CaretPos, 1); + args.text = String_UNSAFE_Substring(&text, w->caretPos, 1); r.Width = Drawer2D_TextWidth(&args); } return r; @@ -332,19 +332,19 @@ static void LInput_TickCaret(void* widget) { /* Fast path, caret is blinking in same spot */ Launcher_MarkDirty(r.X, r.Y, r.Width, r.Height); } else { - Launcher_MarkDirty(w->X, w->Y, w->Width, w->Height); + Launcher_MarkDirty(w->x, w->y, w->width, w->height); } lastCaretRec = r; } static void LInput_AdvanceCaretPos(struct LInput* w, cc_bool forwards) { - if (forwards && w->CaretPos == -1) return; - if (!forwards && w->CaretPos == 0) return; - if (w->CaretPos == -1 && !forwards) /* caret after text */ - w->CaretPos = w->Text.length; + if (forwards && w->caretPos == -1) return; + if (!forwards && w->caretPos == 0) return; + if (w->caretPos == -1 && !forwards) /* caret after text */ + w->caretPos = w->text.length; - w->CaretPos += (forwards ? 1 : -1); - if (w->CaretPos < 0 || w->CaretPos >= w->Text.length) w->CaretPos = -1; + w->caretPos += (forwards ? 1 : -1); + if (w->caretPos < 0 || w->caretPos >= w->text.length) w->caretPos = -1; LWidget_Redraw(w); } @@ -356,16 +356,16 @@ static void LInput_MoveCaretToCursor(struct LInput* w) { /* Input widget may have been selected by pressing tab */ /* In which case cursor is completely outside, so ignore */ - if (!Gui_Contains(w->X, w->Y, w->Width, w->Height, x, y)) return; + if (!Gui_Contains(w->x, w->y, w->width, w->height, x, y)) return; lastCaretShow = false; String_InitArray(text, textBuffer); LInput_GetText(w, &text); - x -= w->X; y -= w->Y; + x -= w->x; y -= w->y; DrawTextArgs_Make(&args, &text, &Launcher_TextFont, true); if (x >= Drawer2D_TextWidth(&args)) { - w->CaretPos = -1; return; + w->caretPos = -1; return; } for (i = 0; i < text.length; i++) { @@ -375,7 +375,7 @@ static void LInput_MoveCaretToCursor(struct LInput* w) { args.text = String_UNSAFE_Substring(&text, i, 1); charWidth = Drawer2D_TextWidth(&args); if (x >= charX && x < charX + charWidth) { - w->CaretPos = i; return; + w->caretPos = i; return; } } } @@ -412,7 +412,7 @@ static void LInput_KeyDown(void* widget, int key, cc_bool was) { } else if (key == KEY_DELETE) { LInput_Delete(w); } else if (key == 'C' && Key_IsActionPressed()) { - if (w->Text.length) Clipboard_SetText(&w->Text); + if (w->text.length) Clipboard_SetText(&w->text); } else if (key == 'V' && Key_IsActionPressed()) { Clipboard_RequestText(LInput_CopyFromClipboard, w); } else if (key == KEY_ESCAPE) { @@ -442,17 +442,17 @@ static struct LWidgetVTABLE linput_VTABLE = { }; void LInput_Init(struct LScreen* s, struct LInput* w, int width, const char* hintText) { w->VTABLE = &linput_VTABLE; - w->TabSelectable = true; + w->tabSelectable = true; w->TextFilter = LInput_DefaultInputFilter; - String_InitArray(w->Text, w->_TextBuffer); + String_InitArray(w->text, w->_textBuffer); - w->Width = Display_ScaleX(width); - w->Height = Display_ScaleY(30); - w->MinWidth = w->Width; + w->width = Display_ScaleX(width); + w->height = Display_ScaleY(30); + w->minWidth = w->width; LWidget_CalcPosition(w); - w->HintText = hintText; - w->CaretPos = -1; + w->hintText = hintText; + w->caretPos = -1; s->widgets[s->numWidgets++] = (struct LWidget*)w; } @@ -461,23 +461,23 @@ void LInput_SetText(struct LInput* w, const String* text_) { struct DrawTextArgs args; Size2D size; - String_Copy(&w->Text, text_); + String_Copy(&w->text, text_); String_InitArray(text, textBuffer); LInput_GetText(w, &text); DrawTextArgs_Make(&args, &text, &Launcher_TextFont, true); size = Drawer2D_MeasureText(&args); - w->Width = max(w->MinWidth, size.Width + 20); - w->_TextHeight = size.Height; + w->width = max(w->minWidth, size.Width + 20); + w->_textHeight = size.Height; } static CC_NOINLINE cc_bool LInput_AppendRaw(struct LInput* w, char c) { - if (w->TextFilter(c) && w->Text.length < w->Text.capacity) { - if (w->CaretPos == -1) { - String_Append(&w->Text, c); + if (w->TextFilter(c) && w->text.length < w->text.capacity) { + if (w->caretPos == -1) { + String_Append(&w->text, c); } else { - String_InsertAt(&w->Text, w->CaretPos, c); - w->CaretPos++; + String_InsertAt(&w->text, w->caretPos, c); + w->caretPos++; } return true; } @@ -501,38 +501,38 @@ void LInput_AppendString(struct LInput* w, const String* str) { } void LInput_Backspace(struct LInput* w) { - if (!w->Text.length || w->CaretPos == 0) return; + if (!w->text.length || w->caretPos == 0) return; - if (w->CaretPos == -1) { - String_DeleteAt(&w->Text, w->Text.length - 1); + if (w->caretPos == -1) { + String_DeleteAt(&w->text, w->text.length - 1); } else { - String_DeleteAt(&w->Text, w->CaretPos - 1); - w->CaretPos--; - if (w->CaretPos == -1) w->CaretPos = 0; + String_DeleteAt(&w->text, w->caretPos - 1); + w->caretPos--; + if (w->caretPos == -1) w->caretPos = 0; } if (w->TextChanged) w->TextChanged(w); - if (w->CaretPos >= w->Text.length) w->CaretPos = -1; + if (w->caretPos >= w->text.length) w->caretPos = -1; LWidget_Redraw(w); } void LInput_Delete(struct LInput* w) { - if (!w->Text.length || w->CaretPos == -1) return; + if (!w->text.length || w->caretPos == -1) return; - String_DeleteAt(&w->Text, w->CaretPos); - if (w->CaretPos == -1) w->CaretPos = 0; + String_DeleteAt(&w->text, w->caretPos); + if (w->caretPos == -1) w->caretPos = 0; if (w->TextChanged) w->TextChanged(w); - if (w->CaretPos >= w->Text.length) w->CaretPos = -1; + if (w->caretPos >= w->text.length) w->caretPos = -1; LWidget_Redraw(w); } void LInput_Clear(struct LInput* w) { - if (!w->Text.length) return; - w->Text.length = 0; + if (!w->text.length) return; + w->text.length = 0; if (w->TextChanged) w->TextChanged(w); - w->CaretPos = -1; + w->caretPos = -1; LWidget_Redraw(w); } @@ -544,8 +544,8 @@ static void LLabel_Draw(void* widget) { struct LLabel* w = (struct LLabel*)widget; struct DrawTextArgs args; - DrawTextArgs_Make(&args, &w->Text, w->Font, true); - Drawer2D_DrawText(&Launcher_Framebuffer, &args, w->X, w->Y); + DrawTextArgs_Make(&args, &w->text, w->font, true); + Drawer2D_DrawText(&Launcher_Framebuffer, &args, w->x, w->y); } static struct LWidgetVTABLE llabel_VTABLE = { @@ -556,9 +556,9 @@ static struct LWidgetVTABLE llabel_VTABLE = { }; void LLabel_Init(struct LScreen* s, struct LLabel* w, const char* text) { w->VTABLE = &llabel_VTABLE; - w->Font = &Launcher_TextFont; + w->font = &Launcher_TextFont; - String_InitArray(w->Text, w->_TextBuffer); + String_InitArray(w->text, w->_textBuffer); LLabel_SetConst(w, text); s->widgets[s->numWidgets++] = (struct LWidget*)w; } @@ -566,11 +566,11 @@ void LLabel_Init(struct LScreen* s, struct LLabel* w, const char* text) { void LLabel_SetText(struct LLabel* w, const String* text) { struct DrawTextArgs args; Size2D size; - String_Copy(&w->Text, text); + String_Copy(&w->text, text); - DrawTextArgs_Make(&args, &w->Text, w->Font, true); + DrawTextArgs_Make(&args, &w->text, w->font, true); size = Drawer2D_MeasureText(&args); - w->Width = size.Width; w->Height = size.Height; + w->width = size.Width; w->height = size.Height; LWidget_CalcPosition(w); } @@ -585,7 +585,7 @@ void LLabel_SetConst(struct LLabel* w, const char* text) { *#########################################################################################################################*/ static void LLine_Draw(void* widget) { struct LLine* w = (struct LLine*)widget; - Gradient_Blend(&Launcher_Framebuffer, w->Col, 128, w->X, w->Y, w->Width, w->Height); + Gradient_Blend(&Launcher_Framebuffer, w->col, 128, w->x, w->y, w->width, w->height); } static struct LWidgetVTABLE lline_VTABLE = { @@ -596,8 +596,8 @@ static struct LWidgetVTABLE lline_VTABLE = { }; void LLine_Init(struct LScreen* s, struct LLine* w, int width) { w->VTABLE = &lline_VTABLE; - w->Width = Display_ScaleX(width); - w->Height = Display_ScaleY(2); + w->width = Display_ScaleX(width); + w->height = Display_ScaleY(2); s->widgets[s->numWidgets++] = (struct LWidget*)w; } @@ -611,31 +611,31 @@ static void LSlider_DrawBoxBounds(struct LSlider* w) { /* TODO: Check these are actually right */ Drawer2D_Clear(&Launcher_Framebuffer, boundsTop, - w->X, w->Y, - w->Width, BORDER); + w->x, w->y, + w->width, BORDER); Drawer2D_Clear(&Launcher_Framebuffer, boundsBottom, - w->X, w->Y + w->Height - BORDER, - w->Width, BORDER); + w->x, w->y + w->height - BORDER, + w->width, BORDER); Gradient_Vertical(&Launcher_Framebuffer, boundsTop, boundsBottom, - w->X, w->Y, - BORDER, w->Height); + w->x, w->y, + BORDER, w->height); Gradient_Vertical(&Launcher_Framebuffer, boundsTop, boundsBottom, - w->X + w->Width - BORDER, w->Y, - BORDER, w->Height); + w->x + w->width - BORDER, w->y, + BORDER, w->height); } static void LSlider_DrawBox(struct LSlider* w) { BitmapCol progTop = BitmapCol_Make(220, 204, 233, 255); BitmapCol progBottom = BitmapCol_Make(207, 181, 216, 255); - int halfHeight = (w->Height - BORDER2) / 2; + int halfHeight = (w->height - BORDER2) / 2; Gradient_Vertical(&Launcher_Framebuffer, progTop, progBottom, - w->X + BORDER, w->Y + BORDER, - w->Width - BORDER2, halfHeight); + w->x + BORDER, w->y + BORDER, + w->width - BORDER2, halfHeight); Gradient_Vertical(&Launcher_Framebuffer, progBottom, progTop, - w->X + BORDER, w->Y + BORDER + halfHeight, - w->Width - BORDER2, halfHeight); + w->x + BORDER, w->y + BORDER + halfHeight, + w->width - BORDER2, halfHeight); } static void LSlider_Draw(void* widget) { @@ -645,10 +645,10 @@ static void LSlider_Draw(void* widget) { LSlider_DrawBoxBounds(w); LSlider_DrawBox(w); - curWidth = (int)((w->Width - BORDER2) * w->Value / w->MaxValue); - Drawer2D_Clear(&Launcher_Framebuffer, w->Col, - w->X + BORDER, w->Y + BORDER, - curWidth, w->Height - BORDER2); + curWidth = (int)((w->width - BORDER2) * w->value / w->maxValue); + Drawer2D_Clear(&Launcher_Framebuffer, w->col, + w->x + BORDER, w->y + BORDER, + curWidth, w->height - BORDER2); } static struct LWidgetVTABLE lslider_VTABLE = { @@ -659,10 +659,10 @@ static struct LWidgetVTABLE lslider_VTABLE = { }; void LSlider_Init(struct LScreen* s, struct LSlider* w, int width, int height, BitmapCol col) { w->VTABLE = &lslider_VTABLE; - w->Width = Display_ScaleX(width); - w->Height = Display_ScaleY(height); - w->MaxValue = 100; - w->Col = col; + w->width = Display_ScaleX(width); + w->height = Display_ScaleY(height); + w->maxValue = 100; + w->col = col; s->widgets[s->numWidgets++] = (struct LWidget*)w; } @@ -726,20 +726,20 @@ static int sortingCol = -1; /* Works out top and height of the scrollbar */ static void LTable_GetScrollbarCoords(struct LTable* w, int* y, int* height) { float scale; - if (!w->RowsCount) { *y = 0; *height = 0; return; } + if (!w->rowsCount) { *y = 0; *height = 0; return; } - scale = w->Height / (float)w->RowsCount; - *y = Math_Ceil(w->TopRow * scale); - *height = Math_Ceil(w->VisibleRows * scale); - *height = min(*y + *height, w->Height) - *y; + scale = w->height / (float)w->rowsCount; + *y = Math_Ceil(w->topRow * scale); + *height = Math_Ceil(w->visibleRows * scale); + *height = min(*y + *height, w->height) - *y; } /* Ensures top/first visible row index lies within table */ static void LTable_ClampTopRow(struct LTable* w) { - if (w->TopRow > w->RowsCount - w->VisibleRows) { - w->TopRow = w->RowsCount - w->VisibleRows; + if (w->topRow > w->rowsCount - w->visibleRows) { + w->topRow = w->rowsCount - w->visibleRows; } - if (w->TopRow < 0) w->TopRow = 0; + if (w->topRow < 0) w->topRow = 0; } /* Returns index of selected row in currently visible rows */ @@ -747,20 +747,20 @@ static int LTable_GetSelectedIndex(struct LTable* w) { struct ServerInfo* entry; int row; - for (row = 0; row < w->RowsCount; row++) { + for (row = 0; row < w->rowsCount; row++) { entry = LTable_Get(row); - if (String_CaselessEquals(w->SelectedHash, &entry->hash)) return row; + if (String_CaselessEquals(w->selectedHash, &entry->hash)) return row; } return -1; } /* Sets selected row to given row, scrolling table if needed */ static void LTable_SetSelectedTo(struct LTable* w, int index) { - if (!w->RowsCount) return; - if (index >= w->RowsCount) index = w->RowsCount - 1; + if (!w->rowsCount) return; + if (index >= w->rowsCount) index = w->rowsCount - 1; if (index < 0) index = 0; - String_Copy(w->SelectedHash, <able_Get(index)->hash); + String_Copy(w->selectedHash, <able_Get(index)->hash); LTable_ShowSelected(w); w->OnSelectedChanged(); } @@ -778,9 +778,9 @@ static void LTable_DrawHeaderBackground(struct LTable* w) { if (!Launcher_ClassicBackground) { Drawer2D_Clear(&Launcher_Framebuffer, gridCol, - w->X, w->Y, w->Width, w->HdrHeight); + w->x, w->y, w->width, w->hdrHeight); } else { - Launcher_ResetArea(w->X, w->Y, w->Width, w->HdrHeight); + Launcher_ResetArea(w->x, w->y, w->width, w->hdrHeight); } } @@ -793,7 +793,7 @@ static BitmapCol LTable_RowCol(struct LTable* w, struct ServerInfo* row) { cc_bool selected; if (row) { - selected = String_Equals(&row->hash, w->SelectedHash); + selected = String_Equals(&row->hash, w->selectedHash); if (row->featured) { return selected ? featSelCol : featuredCol; } else if (selected) { @@ -809,21 +809,21 @@ static void LTable_DrawRowsBackground(struct LTable* w) { BitmapCol col; int y, height, row; - y = w->RowsBegY; - for (row = w->TopRow; ; row++, y += w->RowHeight) { - entry = row < w->RowsCount ? LTable_Get(row) : NULL; + y = w->rowsBegY; + for (row = w->topRow; ; row++, y += w->rowHeight) { + entry = row < w->rowsCount ? LTable_Get(row) : NULL; col = LTable_RowCol(w, entry); /* last row may get chopped off */ - height = min(y + w->RowHeight, w->RowsEndY) - y; + height = min(y + w->rowHeight, w->rowsEndY) - y; /* hit the end of the table */ if (height < 0) break; if (col) { Drawer2D_Clear(&Launcher_Framebuffer, col, - w->X, y, w->Width, height); + w->x, y, w->width, height); } else { - Launcher_ResetArea(w->X, y, w->Width, height); + Launcher_ResetArea(w->x, y, w->width, height); } } } @@ -833,17 +833,17 @@ static void LTable_DrawGridlines(struct LTable* w) { int i, x; if (Launcher_ClassicBackground) return; - x = w->X; + x = w->x; Drawer2D_Clear(&Launcher_Framebuffer, Launcher_BackgroundCol, - x, w->Y + w->HdrHeight, w->Width, w->GridlineHeight); + x, w->y + w->hdrHeight, w->width, w->gridlineHeight); - for (i = 0; i < w->NumColumns; i++) { - x += w->Columns[i].width; - if (!w->Columns[i].columnGridline) continue; + for (i = 0; i < w->numColumns; i++) { + x += w->columns[i].width; + if (!w->columns[i].columnGridline) continue; Drawer2D_Clear(&Launcher_Framebuffer, Launcher_BackgroundCol, - x, w->Y, w->GridlineWidth, w->Height); - x += w->GridlineWidth; + x, w->y, w->gridlineWidth, w->height); + x += w->gridlineWidth; } } @@ -860,16 +860,16 @@ static void LTable_DrawHeaders(struct LTable* w) { int i, x, y; DrawTextArgs_MakeEmpty(&args, &Launcher_TextFont, true); - x = w->X; y = w->Y; + x = w->x; y = w->y; - for (i = 0; i < w->NumColumns; i++) { - args.text = String_FromReadonly(w->Columns[i].name); + for (i = 0; i < w->numColumns; i++) { + args.text = String_FromReadonly(w->columns[i].name); Drawer2D_DrawClippedText(&Launcher_Framebuffer, &args, x + CELL_XOFFSET, y + HDR_YOFFSET, - w->Columns[i].width - CELL_XPADDING); + w->columns[i].width - CELL_XPADDING); - x += w->Columns[i].width; - if (w->Columns[i].columnGridline) x += w->GridlineWidth; + x += w->columns[i].width; + if (w->columns[i].columnGridline) x += w->gridlineWidth; } } @@ -881,29 +881,29 @@ static void LTable_DrawRows(struct LTable* w) { int i, x, y, row, end; String_InitArray(str, strBuffer); - DrawTextArgs_Make(&args, &str, w->RowFont, true); - y = w->RowsBegY; - end = w->TopRow + w->VisibleRows; + DrawTextArgs_Make(&args, &str, w->rowFont, true); + y = w->rowsBegY; + end = w->topRow + w->visibleRows; - for (row = w->TopRow; row < end; row++, y += w->RowHeight) { - x = w->X; + for (row = w->topRow; row < end; row++, y += w->rowHeight) { + x = w->x; - if (row >= w->RowsCount) break; - if (y + w->RowHeight > w->RowsEndY) break; + if (row >= w->rowsCount) break; + if (y + w->rowHeight > w->rowsEndY) break; entry = LTable_Get(row); - for (i = 0; i < w->NumColumns; i++) { + for (i = 0; i < w->numColumns; i++) { args.text = str; - w->Columns[i].DrawRow(entry, &args, x, y); + w->columns[i].DrawRow(entry, &args, x, y); if (args.text.length) { Drawer2D_DrawClippedText(&Launcher_Framebuffer, &args, x + CELL_XOFFSET, y + ROW_YOFFSET, - w->Columns[i].width - CELL_XPADDING); + w->columns[i].width - CELL_XPADDING); } - x += w->Columns[i].width; - if (w->Columns[i].columnGridline) x += w->GridlineWidth; + x += w->columns[i].width; + if (w->columns[i].columnGridline) x += w->gridlineWidth; } } } @@ -916,13 +916,13 @@ static void LTable_DrawScrollbar(struct LTable* w) { BitmapCol scrollCol = Launcher_ClassicBackground ? classicScroll : Launcher_ButtonForeActiveCol; int x, y, height; - x = w->X + w->Width - w->ScrollbarWidth; + x = w->x + w->width - w->scrollbarWidth; LTable_GetScrollbarCoords(w, &y, &height); Drawer2D_Clear(&Launcher_Framebuffer, backCol, - x, w->Y, w->ScrollbarWidth, w->Height); + x, w->y, w->scrollbarWidth, w->height); Drawer2D_Clear(&Launcher_Framebuffer, scrollCol, - x, w->Y + y, w->ScrollbarWidth, height); + x, w->y + y, w->scrollbarWidth, height); } cc_bool LTable_HandlesKey(int key) { @@ -938,9 +938,9 @@ static void LTable_KeyDown(void* widget, int key, cc_bool was) { } else if (key == KEY_DOWN) { index++; } else if (key == KEY_PAGEUP) { - index -= w->VisibleRows; + index -= w->visibleRows; } else if (key == KEY_PAGEDOWN) { - index += w->VisibleRows; + index += w->visibleRows; } else { return; } w->_lastRow = -1; @@ -949,30 +949,30 @@ static void LTable_KeyDown(void* widget, int key, cc_bool was) { static void LTable_MouseMove(void* widget, int deltaX, int deltaY, cc_bool wasOver) { struct LTable* w = (struct LTable*)widget; - int x = Mouse_X - w->X, y = Mouse_Y - w->Y, col; + int x = Mouse_X - w->x, y = Mouse_Y - w->y, col; - if (w->DraggingScrollbar) { - float scale = w->Height / (float)w->RowsCount; - int row = (int)((y - w->MouseOffset) / scale); + if (w->draggingScrollbar) { + float scale = w->height / (float)w->rowsCount; + int row = (int)((y - w->mouseOffset) / scale); /* avoid expensive redraw when possible */ - if (w->TopRow == row) return; + if (w->topRow == row) return; - w->TopRow = row; + w->topRow = row; LTable_ClampTopRow(w); LWidget_Draw(w); - } else if (w->DraggingColumn >= 0) { - if (!deltaX || x >= w->X + w->Width - 20) return; - col = w->DraggingColumn; + } else if (w->draggingColumn >= 0) { + if (!deltaX || x >= w->x + w->width - 20) return; + col = w->draggingColumn; - w->Columns[col].width += deltaX; - Math_Clamp(w->Columns[col].width, 20, w->Width - 20); + w->columns[col].width += deltaX; + Math_Clamp(w->columns[col].width, 20, w->width - 20); LWidget_Draw(w); } } static void LTable_RowsClick(struct LTable* w) { - int mouseY = Mouse_Y - w->RowsBegY; - int row = w->TopRow + mouseY / w->RowHeight; + int mouseY = Mouse_Y - w->rowsBegY; + int row = w->topRow + mouseY / w->rowHeight; TimeMS now; LTable_SetSelectedTo(w, row); @@ -991,54 +991,54 @@ static void LTable_RowsClick(struct LTable* w) { static void LTable_HeadersClick(struct LTable* w) { int x, i, mouseX = Mouse_X; - for (i = 0, x = w->X; i < w->NumColumns; i++) { + for (i = 0, x = w->x; i < w->numColumns; i++) { /* clicked on gridline, begin dragging */ - if (mouseX >= (x - 8) && mouseX < (x + 8) && w->Columns[i].interactable) { - w->DraggingColumn = i - 1; + if (mouseX >= (x - 8) && mouseX < (x + 8) && w->columns[i].interactable) { + w->draggingColumn = i - 1; return; } - x += w->Columns[i].width; - if (w->Columns[i].columnGridline) x += w->GridlineWidth; + x += w->columns[i].width; + if (w->columns[i].columnGridline) x += w->gridlineWidth; } - for (i = 0, x = w->X; i < w->NumColumns; i++) { - if (mouseX >= x && mouseX < (x + w->Columns[i].width) && w->Columns[i].interactable) { + for (i = 0, x = w->x; i < w->numColumns; i++) { + if (mouseX >= x && mouseX < (x + w->columns[i].width) && w->columns[i].interactable) { sortingCol = i; - w->Columns[i].invertSort = !w->Columns[i].invertSort; + w->columns[i].invertSort = !w->columns[i].invertSort; LTable_Sort(w); return; } - x += w->Columns[i].width; - if (w->Columns[i].columnGridline) x += w->GridlineWidth; + x += w->columns[i].width; + if (w->columns[i].columnGridline) x += w->gridlineWidth; } } /* Handles clicking on the scrollbar on right edge of table */ static void LTable_ScrollbarClick(struct LTable* w) { - int y, height, mouseY = Mouse_Y - w->Y; + int y, height, mouseY = Mouse_Y - w->y; LTable_GetScrollbarCoords(w, &y, &height); if (mouseY < y) { - w->TopRow -= w->VisibleRows; + w->topRow -= w->visibleRows; } else if (mouseY >= y + height) { - w->TopRow += w->VisibleRows; + w->topRow += w->visibleRows; } else { - w->MouseOffset = mouseY - y; + w->mouseOffset = mouseY - y; } - w->DraggingScrollbar = true; + w->draggingScrollbar = true; LTable_ClampTopRow(w); } static void LTable_MouseDown(void* widget, cc_bool wasSelected) { struct LTable* w = (struct LTable*)widget; - if (Mouse_X >= Window_Width - w->ScrollbarWidth) { + if (Mouse_X >= Window_Width - w->scrollbarWidth) { LTable_ScrollbarClick(w); w->_lastRow = -1; - } else if (Mouse_Y < w->RowsBegY) { + } else if (Mouse_Y < w->rowsBegY) { LTable_HeadersClick(w); w->_lastRow = -1; } else { @@ -1049,7 +1049,7 @@ static void LTable_MouseDown(void* widget, cc_bool wasSelected) { static void LTable_MouseWheel(void* widget, float delta) { struct LTable* w = (struct LTable*)widget; - w->TopRow -= Utils_AccumulateWheelDelta(&w->_wheelAcc, delta); + w->topRow -= Utils_AccumulateWheelDelta(&w->_wheelAcc, delta); LTable_ClampTopRow(w); LWidget_Draw(w); w->_lastRow = -1; @@ -1058,21 +1058,21 @@ static void LTable_MouseWheel(void* widget, float delta) { /* Stops an in-progress dragging of resizing column. */ static void LTable_StopDragging(void* widget) { struct LTable* w = (struct LTable*)widget; - w->DraggingColumn = -1; - w->DraggingScrollbar = false; - w->MouseOffset = 0; + w->draggingColumn = -1; + w->draggingScrollbar = false; + w->mouseOffset = 0; } void LTable_Reposition(struct LTable* w) { int rowsHeight; - w->HdrHeight = Drawer2D_FontHeight(&Launcher_TextFont, true) + HDR_YPADDING; - w->RowHeight = Drawer2D_FontHeight(w->RowFont, true) + ROW_YPADDING; + w->hdrHeight = Drawer2D_FontHeight(&Launcher_TextFont, true) + HDR_YPADDING; + w->rowHeight = Drawer2D_FontHeight(w->rowFont, true) + ROW_YPADDING; - w->RowsBegY = w->Y + w->HdrHeight + w->GridlineHeight; - w->RowsEndY = w->Y + w->Height; - rowsHeight = w->Height - (w->RowsBegY - w->Y); + w->rowsBegY = w->y + w->hdrHeight + w->gridlineHeight; + w->rowsEndY = w->y + w->height; + rowsHeight = w->height - (w->rowsBegY - w->y); - w->VisibleRows = rowsHeight / w->RowHeight; + w->visibleRows = rowsHeight / w->rowHeight; LTable_ClampTopRow(w); } @@ -1095,16 +1095,16 @@ static struct LWidgetVTABLE ltable_VTABLE = { void LTable_Init(struct LTable* w, struct FontDesc* rowFont) { int i; w->VTABLE = <able_VTABLE; - w->Columns = tableColumns; - w->NumColumns = Array_Elems(tableColumns); - w->RowFont = rowFont; + w->columns = tableColumns; + w->numColumns = Array_Elems(tableColumns); + w->rowFont = rowFont; - w->ScrollbarWidth = Display_ScaleX(10); - w->GridlineWidth = Display_ScaleX(2); - w->GridlineHeight = Display_ScaleY(2); + w->scrollbarWidth = Display_ScaleX(10); + w->gridlineWidth = Display_ScaleX(2); + w->gridlineHeight = Display_ScaleY(2); - for (i = 0; i < w->NumColumns; i++) { - w->Columns[i].width = Display_ScaleX(w->Columns[i].width); + for (i = 0; i < w->numColumns; i++) { + w->columns[i].width = Display_ScaleX(w->columns[i].width); } } @@ -1112,13 +1112,13 @@ void LTable_Reset(struct LTable* w) { LTable_StopDragging(w); LTable_Reposition(w); - w->TopRow = 0; - w->RowsCount = 0; + w->topRow = 0; + w->rowsCount = 0; sortingCol = -1; w->_wheelAcc = 0.0f; - w->SelectedHash->length = 0; - w->Filter->length = 0; + w->selectedHash->length = 0; + w->filter->length = 0; } void LTable_ApplyFilter(struct LTable* w) { @@ -1126,12 +1126,12 @@ void LTable_ApplyFilter(struct LTable* w) { count = FetchServersTask.NumServers; for (i = 0, j = 0; i < count; i++) { - if (String_CaselessContains(&Servers_Get(i)->name, w->Filter)) { + if (String_CaselessContains(&Servers_Get(i)->name, w->filter)) { FetchServersTask.Servers[j++]._order = FetchServersTask.Orders[i]; } } - w->RowsCount = j; + w->rowsCount = j; for (; j < count; j++) { FetchServersTask.Servers[j]._order = -100000; } @@ -1183,10 +1183,10 @@ void LTable_ShowSelected(struct LTable* w) { int i = LTable_GetSelectedIndex(w); if (i == -1) return; - if (i >= w->TopRow + w->VisibleRows) { - w->TopRow = i - (w->VisibleRows - 1); + if (i >= w->topRow + w->visibleRows) { + w->topRow = i - (w->visibleRows - 1); } - if (i < w->TopRow) w->TopRow = i; + if (i < w->topRow) w->topRow = i; LTable_ClampTopRow(w); } #endif diff --git a/src/LWidgets.h b/src/LWidgets.h index 19d33187b..f35b1fb5f 100644 --- a/src/LWidgets.h +++ b/src/LWidgets.h @@ -34,15 +34,15 @@ struct LWidgetVTABLE { #define LWidget_Layout \ struct LWidgetVTABLE* VTABLE; /* General widget functions */ \ - int X, Y, Width, Height; /* Top left corner, and dimensions, of this widget */ \ - cc_bool Hovered; /* Whether this widget is currently being moused over */ \ - cc_bool Selected; /* Whether this widget is last widget to be clicked on */ \ - cc_bool Hidden; /* Whether this widget is hidden from view */ \ - cc_bool TabSelectable; /* Whether this widget gets selected when pressing tab */ \ - cc_uint8 HorAnchor, VerAnchor; /* Specifies the reference point for when this widget is resized */ \ - int XOffset, YOffset; /* Offset from the reference point */ \ + int x, y, width, height; /* Top left corner, and dimensions, of this widget */ \ + cc_bool hovered; /* Whether this widget is currently being moused over */ \ + cc_bool selected; /* Whether this widget is last widget to be clicked on */ \ + cc_bool hidden; /* Whether this widget is hidden from view */ \ + cc_bool tabSelectable; /* Whether this widget gets selected when pressing tab */ \ + cc_uint8 horAnchor, verAnchor; /* Specifies the reference point for when this widget is resized */ \ + int xOffset, yOffset; /* Offset from the reference point */ \ void (*OnClick)(void* widget, int x, int y); /* Called when widget is clicked */ \ - Rect2D Last; /* Widget's last drawn area */ + Rect2D last; /* Widget's last drawn area */ /* Represents an individual 2D gui component in the launcher. */ struct LWidget { LWidget_Layout }; @@ -53,8 +53,8 @@ void LWidget_Redraw(void* widget); struct LButton { LWidget_Layout - String Text; - Size2D _TextSize; + String text; + Size2D _textSize; }; CC_NOINLINE void LButton_Init(struct LScreen* s, struct LButton* w, int width, int height, const char* text); CC_NOINLINE void LButton_SetConst(struct LButton* w, const char* text); @@ -62,11 +62,11 @@ CC_NOINLINE void LButton_SetConst(struct LButton* w, const char* text); struct LInput; struct LInput { LWidget_Layout - int MinWidth; + int minWidth; /* Text displayed when the user has not entered anything in the text field. */ - const char* HintText; + const char* hintText; /* Whether all characters should be rendered as *. */ - cc_bool Password; + cc_bool password; /* Filter applied to text received from the clipboard. Can be NULL. */ void (*ClipboardFilter)(String* str); /* Callback invoked when the text is changed. Can be NULL. */ @@ -75,10 +75,10 @@ struct LInput { cc_bool (*TextFilter)(char c); /* Specifies the position that characters are inserted/deleted from. */ /* NOTE: -1 to insert/delete characters at end of the text. */ - int CaretPos; - String Text; - int _TextHeight; - char _TextBuffer[STRING_SIZE]; + int caretPos; + String text; + int _textHeight; + char _textBuffer[STRING_SIZE]; }; CC_NOINLINE void LInput_Init(struct LScreen* s, struct LInput* w, int width, const char* hintText); CC_NOINLINE void LInput_SetText(struct LInput* w, const String* text); @@ -97,10 +97,10 @@ CC_NOINLINE void LInput_Clear(struct LInput* w); /* Represents non-interactable text. */ struct LLabel { LWidget_Layout - struct FontDesc* Font; - String Text; - Size2D _TextSize; - char _TextBuffer[STRING_SIZE]; + struct FontDesc* font; + String text; + Size2D _textSize; + char _textBuffer[STRING_SIZE]; }; CC_NOINLINE void LLabel_Init(struct LScreen* s, struct LLabel* w, const char* text); CC_NOINLINE void LLabel_SetText(struct LLabel* w, const String* text); @@ -109,15 +109,15 @@ CC_NOINLINE void LLabel_SetConst(struct LLabel* w, const char* text); /* Represents a coloured translucent line separator. */ struct LLine { LWidget_Layout - BitmapCol Col; + BitmapCol col; }; CC_NOINLINE void LLine_Init(struct LScreen* s, struct LLine* w, int width); /* Represents a slider bar that may or may not be modifiable by the user. */ struct LSlider { LWidget_Layout - int Value, MaxValue; - BitmapCol Col; + int value, maxValue; + BitmapCol col; }; CC_NOINLINE void LSlider_Init(struct LScreen* s, struct LSlider* w, int width, int height, BitmapCol col); @@ -148,36 +148,36 @@ struct LTableColumn { struct LTable { LWidget_Layout /* Columns of the table. */ - struct LTableColumn* Columns; + struct LTableColumn* columns; /* Number of columns in the table. */ - int NumColumns; + int numColumns; /* Fonts for text in rows. */ - struct FontDesc* RowFont; + struct FontDesc* rowFont; /* Y start and end of rows and height of each row. */ - int RowsBegY, RowsEndY, RowHeight; + int rowsBegY, rowsEndY, rowHeight; /* Y height of headers. */ - int HdrHeight; + int hdrHeight; /* Maximum number of rows visible. */ - int VisibleRows; + int visibleRows; /* Total number of rows in the table (after filter is applied). */ - int RowsCount; + int rowsCount; /* Index of top row currently visible. */ - int TopRow; + int topRow; /* Hash of the currently selected server. */ - String* SelectedHash; + String* selectedHash; /* Filter for which server names to show. */ - String* Filter; + String* filter; /* Callback when selected has has changed. */ void (*OnSelectedChanged)(void); /* Index of table column currently being dragged. */ - int DraggingColumn; - int GridlineWidth, GridlineHeight; + int draggingColumn; + int gridlineWidth, gridlineHeight; - cc_bool DraggingScrollbar; /* Is scrollbar is currently being dragged */ - int MouseOffset; /* Offset of mouse for scrollbar dragging */ - int ScrollbarWidth; /* How wide scrollbar is in pixels */ + cc_bool draggingScrollbar; /* Is scrollbar is currently being dragged */ + int mouseOffset; /* Offset of mouse for scrollbar dragging */ + int scrollbarWidth; /* How wide scrollbar is in pixels */ float _wheelAcc; /* mouse wheel accumulator */ int _lastRow; /* last clicked row (for doubleclick join) */