diff --git a/src/Drawer2D.c b/src/Drawer2D.c index 802e4f326..6ca99371c 100644 --- a/src/Drawer2D.c +++ b/src/Drawer2D.c @@ -257,6 +257,18 @@ void Drawer2D_BmpCopy(Bitmap* dst, int x, int y, int width, int height, Bitmap* } } +void Drawer2D_Rect(Bitmap* bmp, BitmapCol col, int x, int y, int width, int height) { + /* Box contents are (x+1,y+1,width-1,height-1) */ + /* Then the box is surrounded by blended borders */ + /* TODO: The pixels of corners is wrong.. */ + Drawer2D_Clear(bmp, col, x + 1, y + 1, width - 1, height - 1); + + Gradient_Blend(bmp, col, 128, x, y, width + 1, 1); + Gradient_Blend(bmp, col, 128, x, y + height, width + 1, 1); + Gradient_Blend(bmp, col, 128, x, y, 1, height + 1); + Gradient_Blend(bmp, col, 128, x + width, y, 1, height + 1); +} + void Drawer2D_Clear(Bitmap* bmp, BitmapCol col, int x, int y, int width, int height) { BitmapCol* row; int xx, yy; diff --git a/src/LScreens.c b/src/LScreens.c index d31449e03..0758847ca 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -3,6 +3,7 @@ #include "Launcher.h" #include "Gui.h" #include "Game.h" +#include "Drawer2D.h" /*########################################################################################################################* *---------------------------------------------------------Screen base-----------------------------------------------------* @@ -163,44 +164,32 @@ CC_NOINLINE static void LScreen_Reset(struct LScreen* s) { /*########################################################################################################################* *--------------------------------------------------------Widget helpers---------------------------------------------------* *#########################################################################################################################*/ -CC_NOINLINE static void LScreen_Button(struct LScreen* s, struct LButton* w, int width, int height, const char* text, - uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) { +CC_NOINLINE static void LScreen_Button(struct LScreen* s, struct LButton* w, int width, int height, const char* text) { String str = String_FromReadonly(text); LButton_Init(w, width, height); LButton_SetText(w, &str, &Launcher_TitleFont); - s->Widgets[s->NumWidgets++] = (struct LWidget*)w; - LWidget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset); } -CC_NOINLINE static void LScreen_Label(struct LScreen* s, struct LLabel* w, const char* text, - uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) { +CC_NOINLINE static void LScreen_Label(struct LScreen* s, struct LLabel* w, const char* text) { String str = String_FromReadonly(text); LLabel_Init(w); LLabel_SetText(w, &str, &Launcher_TextFont); - s->Widgets[s->NumWidgets++] = (struct LWidget*)w; - LWidget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset); } -CC_NOINLINE static void LScreen_Input(struct LScreen* s, struct LInput* w, int width, bool password, const char* hintText, - uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) { +CC_NOINLINE static void LScreen_Input(struct LScreen* s, struct LInput* w, int width, bool password, const char* hintText) { LInput_Init(w, width, 30, hintText, &Launcher_HintFont); w->Password = password; - s->Widgets[s->NumWidgets++] = (struct LWidget*)w; - LWidget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset); } CC_NOINLINE static void LScreen_Slider(struct LScreen* s, struct LSlider* w, int width, int height, - int initValue, int maxValue, BitmapCol progressCol, - uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) { + int initValue, int maxValue, BitmapCol progressCol) { LSlider_Init(w, width, height); w->Value = initValue; w->MaxValue = maxValue; w->ProgressCol = progressCol; - s->Widgets[s->NumWidgets++] = (struct LWidget*)w; - LWidget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset); } static void SwitchToChooseMode(void* w, int x, int y) { @@ -253,43 +242,53 @@ static void UseModeClassicHax(void* w, int x, int y) { ChooseMode_Click(true, t static void UseModeClassic(void* w, int x, int y) { ChooseMode_Click(true, false); } static void ChooseModeScreen_InitWidgets(struct ChooseModeScreen* s) { + static String titleText = String_FromConst("Choose game mode"); struct LScreen* s_ = (struct LScreen*)s; - int middle = Game_Width / 2; s->Widgets = s->_widgets; + LScreen_Label(s_, &s->LblTitle, ""); - LScreen_Label(s_, &s->LblTitle, "&eGet the latest stuff", - ANCHOR_CENTRE, ANCHOR_CENTRE, 10, -135); + LScreen_Button(s_, &s->BtnEnhanced, 145, 35, "Enhanced"); + LScreen_Label(s_, &s->LblEnhanced[0], "&eEnables custom blocks, changing env"); + LScreen_Label(s_, &s->LblEnhanced[1], "&esettings, longer messages, and more"); - LScreen_Button(s_, &s->BtnEnhanced, 145, 35, "Enhanced", - ANCHOR_MIN, ANCHOR_CENTRE, middle - 250, -72); - LScreen_Label(s_, &s->LblEnhanced[0], "&eEnables custom blocks, changing env", - ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, -72 - 12); - LScreen_Label(s_, &s->LblEnhanced[1], "&esettings, longer messages, and more", - ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, -72 + 12); + LScreen_Button(s_, &s->BtnClassicHax, 145, 35, "Classic +hax"); + LScreen_Label(s_, &s->LblClassicHax[0], "&eSame as Classic mode, except that"); + LScreen_Label(s_, &s->LblClassicHax[1], "&ehacks (noclip/fly/speed) are enabled"); - LScreen_Button(s_, &s->BtnClassicHax, 145, 35, "Classic +hax", - ANCHOR_MIN, ANCHOR_CENTRE, middle - 250, 0); - LScreen_Label(s_, &s->LblClassicHax[0], "&eSame as Classic mode, except that", - ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, 0 - 12); - LScreen_Label(s_, &s->LblClassicHax[1], "&ehacks (noclip/fly/speed) are enabled", - ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, 0 + 12); + LScreen_Button(s_, &s->BtnClassic, 145, 35, "Classic"); + LScreen_Label(s_, &s->LblClassic[0], "&eOnly uses blocks and features from"); + LScreen_Label(s_, &s->LblClassic[1], "ðe original minecraft classic"); - LScreen_Button(s_, &s->BtnClassic, 145, 35, "Classic", - ANCHOR_MIN, ANCHOR_CENTRE, middle - 250, 72); - LScreen_Label(s_, &s->LblClassic[0], "&eOnly uses blocks and features from", - ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, 72 - 12); - LScreen_Label(s_, &s->LblClassic[1], "ðe original minecraft classic", - ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, 72 + 12); - - LScreen_Label(s_, &s->LblHelp, "&eClick &fEnhanced &eif you'e not sure which mode to choose.", - ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 160); - LScreen_Button(s_, &s->BtnBack, 80, 35, "Back", - ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 170); + LScreen_Label(s_, &s->LblHelp, "&eClick &fEnhanced &eif you'e not sure which mode to choose."); + LScreen_Button(s_, &s->BtnBack, 80, 35, "Back"); s->BtnEnhanced.OnClick = UseModeEnhanced; s->BtnClassicHax.OnClick = UseModeClassicHax; s->BtnClassic.OnClick = UseModeClassic; s->BtnBack.OnClick = SwitchToSettings; + + LLabel_SetText(&s->LblTitle, &titleText, &Launcher_TitleFont); +} + +static void ChooseModeScreen_Reposition(struct LScreen* s_) { + struct ChooseModeScreen* s = (struct ChooseModeScreen*)s_; + int middle = Game_Width / 2; + LWidget_SetLocation(&s->LblTitle, ANCHOR_CENTRE, ANCHOR_CENTRE, 10, -135); + + LWidget_SetLocation(&s->BtnEnhanced, ANCHOR_MIN, ANCHOR_CENTRE, middle - 250, -72); + LWidget_SetLocation(&s->LblEnhanced[0], ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, -72 - 12); + LWidget_SetLocation(&s->LblEnhanced[1], ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, -72 + 12); + + LWidget_SetLocation(&s->BtnClassicHax, ANCHOR_MIN, ANCHOR_CENTRE, middle - 250, 0); + LWidget_SetLocation(&s->LblClassicHax[0], ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, 0 - 12); + LWidget_SetLocation(&s->LblClassicHax[1], ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, 0 + 12); + + LWidget_SetLocation(&s->BtnClassic, ANCHOR_MIN, ANCHOR_CENTRE, middle - 250, 72); + LWidget_SetLocation(&s->LblClassic[0], ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, 72 - 12); + LWidget_SetLocation(&s->LblClassic[1], ANCHOR_MIN, ANCHOR_CENTRE, middle - 85, 72 + 12); + + LWidget_SetLocation(&s->LblHelp, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 160); + LWidget_SetLocation(&s->BtnBack, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 170); } static void ChooseModeScreen_Init(struct LScreen* s_) { @@ -298,18 +297,190 @@ static void ChooseModeScreen_Init(struct LScreen* s_) { s->LblHelp.Hidden = !s->FirstTime; s->BtnBack.Hidden = s->FirstTime; - s->DrawAll(s_); +} + +static void ChooseModeScreen_DrawAll(struct LScreen* s_) { + int midX = Game_Width / 2, midY = Game_Height / 2; + LScreen_DrawAll(s_); + + Drawer2D_Rect(&Launcher_Framebuffer, Launcher_ButtonBorderCol, + midX - 250, midY - 35, 490, 1); + Drawer2D_Rect(&Launcher_Framebuffer, Launcher_ButtonBorderCol, + midX - 250, midY + 35, 490, 1); } struct LScreen* ChooseModeScreen_MakeInstance(bool firstTime) { struct ChooseModeScreen* s = &ChooseModeScreen_Instance; LScreen_Reset((struct LScreen*)s); - s->Init = ChooseModeScreen_Init; - s->FirstTime = firstTime; + s->Init = ChooseModeScreen_Init; + s->Reposition = ChooseModeScreen_Reposition; + s->DrawAll = ChooseModeScreen_DrawAll; + s->FirstTime = firstTime; return (struct LScreen*)s; } +/*########################################################################################################################* +*---------------------------------------------------------ColoursScreen---------------------------------------------------* +*#########################################################################################################################*/ +/*struct ColoursScreen { + LScreen_Layout + struct LButton BtnDefault, BtnBack; + struct LLabel LblNames[5], LblRGB[3]; + struct LInput IptColours[5 * 3]; + struct LWidget* _widgets[25]; +}; + +static void MakeWidgets(struct ColoursScreen* s) { + struct LScreen* s_ = (struct LScreen*)s; + int i; + for (i = 0; i < 5 * 3; i++) { + LScreen_Input(s_, &s->IptColours[i], 55, false, NULL, ) + } + MakeAllRGBTriplets(false); + + LScreen_Label(s_, &s->LblNames[0], "Background", + ANCHOR_CENTRE, ANCHOR_CENTRE, -60, -100); + LScreen_Label(s_, &s->LblNames[1], "Button border", + ANCHOR_CENTRE, ANCHOR_CENTRE, -70, -60); + LScreen_Label(s_, &s->LblNames[2], "Button highlight", + ANCHOR_CENTRE, ANCHOR_CENTRE, -80, -20); + LScreen_Label(s_, &s->LblNames[3], "Button", + ANCHOR_CENTRE, ANCHOR_CENTRE, -40, 20); + LScreen_Label(s_, &s->LblNames[4], "Active button", + ANCHOR_CENTRE, ANCHOR_CENTRE, -70, 60); + + LScreen_Label(s_, &s->LblRGB[0], "Red", + ANCHOR_CENTRE, ANCHOR_CENTRE, 30, -130); + LScreen_Label(s_, &s->LblRGB[1], "Green", + ANCHOR_CENTRE, ANCHOR_CENTRE, 95, -130); + LScreen_Label(s_, &s->LblRGB[2], "Blue", + ANCHOR_CENTRE, ANCHOR_CENTRE, 160, -130); + + LScreen_Button(s_, &s->BtnDefault, 160, 35, "Default colours", + ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 120); + LScreen_Button(s_, &s->BtnBack, 80, 35, "Back", + ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 170); +} + +void MakeAllRGBTriplets(bool force) { + widgetIndex = 0; + MakeRGBTriplet(LauncherSkin.BackgroundCol, force, -100); + MakeRGBTriplet(LauncherSkin.ButtonBorderCol, force, 60); + MakeRGBTriplet(LauncherSkin.ButtonHighlightCol, force, -20); + MakeRGBTriplet(LauncherSkin.ButtonForeCol, force, 20); + MakeRGBTriplet(LauncherSkin.ButtonForeActiveCol, force, 60); +} + +void MakeRGBTriplet(PackedCol defCol, bool force, int y) { + MakeInput(GetCol(defCol.R, force), 55, false, 3, null) + .SetLocation(ANCHOR_CENTRE, ANCHOR_CENTRE, 30, y); + MakeInput(GetCol(defCol.G, force), 55, false, 3, null) + .SetLocation(ANCHOR_CENTRE, ANCHOR_CENTRE, 95, y); + MakeInput(GetCol(defCol.B, force), 55, false, 3, null) + .SetLocation(ANCHOR_CENTRE, ANCHOR_CENTRE, 160, y); +} + +string GetCol(byte col, bool force) { + if (force) return col.ToString(); + Widget widget = widgets[widgetIndex]; + return widget == null ? col.ToString() : widget.Text; +} + +void Init() { + base.Init(); + view.Init(); + + widgets[view.defIndex].OnClick = ResetColours; + widgets[view.defIndex + 1].OnClick = SwitchToSettings; + SetupInputHandlers(); + for (int i = 0; i < widgets.Length; i++) { + InputWidget input = widgets[i] as InputWidget; + if (input == null) continue; + input.Chars.TextChanged = TextChanged; + } + Resize(); +} + +void ResetColours(int x, int y) { + LauncherSkin.ResetToDefault(); + view.MakeAllRGBTriplets(true); + game.RedrawBackground(); + Resize(); +} + +void Resize() { + view.DrawAll(); + game.Dirty = true; +} + +void Dispose() { + view.Dispose(); + base.Dispose(); +} + + +float colourAcc; +void MouseWheelChanged(float delta) { + int steps = Utils.AccumulateWheelDelta(ref colourAcc, delta); + AdjustSelectedColour(steps); +} + +void KeyDown(Key key) { + if (key == KEY_LEFT) { + AdjustSelectedColour(-1); + } else if (key == KEY_RIGHT) { + AdjustSelectedColour(+1); + } else if (key == KEY_UP) { + AdjustSelectedColour(+10); + } else if (key == KEY_DOWN) { + AdjustSelectedColour(-10); + } else { + base.KeyDown(key); + } +} + +void AdjustSelectedColour(int delta) { + if (curInput == null) return; + int index = IndexOfWidget(curInput); + if (index >= 15) return; + + byte col; + if (!Byte.TryParse(curInput.Text, out col)) return; + int newCol = col + delta; + + Utils.Clamp(ref newCol, 0, 255); + curInput.Text = newCol.ToString(); + if (curInput.Chars.CaretPos >= curInput.Text.Length) + curInput.Chars.CaretPos = -1; + TextChanged(curInput); +} + +void TextChanged(InputWidget widget) { + bool changed = false; + int index = IndexOfWidget(widget); + if (index < 3) changed |= Parse(0, ref LauncherSkin.BackgroundCol); + else if (index < 6) changed |= Parse(3, ref LauncherSkin.ButtonBorderCol); + else if (index < 9) changed |= Parse(6, ref LauncherSkin.ButtonHighlightCol); + else if (index < 12) changed |= Parse(9, ref LauncherSkin.ButtonForeCol); + else if (index < 15) changed |= Parse(12, ref LauncherSkin.ButtonForeActiveCol); + + if (!changed) return; + game.RedrawBackground(); + Resize(); +} + +bool Parse(int index, ref PackedCol dst) { + byte r, g, b; + if (!Byte.TryParse(widgets[index + 0].Text, out r) + || !Byte.TryParse(widgets[index + 1].Text, out g) + || !Byte.TryParse(widgets[index + 2].Text, out b)) + return false; + dst.R = r; dst.G = g; dst.B = b; + return true; +}*/ + + /*########################################################################################################################* *------------------------------------------------------DirectConnectScreen------------------------------------------------* *#########################################################################################################################*/ @@ -402,19 +573,13 @@ static void DirectConnectScreen_InitWidgets(struct DirectConnectScreen* s) { struct LScreen* s_ = (struct LScreen*)s; s->Widgets = s->_widgets; - LScreen_Input(s_, &s->IptUsername, 330, false, "&gUsername..", - ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -120); - LScreen_Input(s_, &s->IptAddress, 330, false, "&gIP address:Port number..", - ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -75); - LScreen_Input(s_, &s->IptMppass, 330, false, "&gMppass..", - ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -30); + LScreen_Input(s_, &s->IptUsername, 330, false, "&gUsername.."); + LScreen_Input(s_, &s->IptAddress, 330, false, "&gIP address:Port number.."); + LScreen_Input(s_, &s->IptMppass, 330, false, "&gMppass.."); - LScreen_Button(s_, &s->BtnConnect, 110, 35, "Connect", - ANCHOR_CENTRE, ANCHOR_CENTRE, -110, 20); - LScreen_Button(s_, &s->BtnBack, 80, 35, "Back", - ANCHOR_CENTRE, ANCHOR_CENTRE, 125, 20); - LScreen_Label(s_, &s->LblStatus, "", - ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 70); + LScreen_Button(s_, &s->BtnConnect, 110, 35, "Connect"); + LScreen_Button(s_, &s->BtnBack, 80, 35, "Back"); + LScreen_Label(s_, &s->LblStatus, ""); s->BtnConnect.OnClick = StartClient; s->BtnBack.OnClick = SwitchToMain; @@ -423,17 +588,27 @@ static void DirectConnectScreen_InitWidgets(struct DirectConnectScreen* s) { DirectConnectScreen_Load(s); } +static void DirectConnectScreen_Reposition(struct LScreen* s_) { + struct DirectConnectScreen* s = (struct DirectConnectScreen*)s_; + LWidget_SetLocation(&s->IptUsername, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -120); + LWidget_SetLocation(&s->IptAddress, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -75); + LWidget_SetLocation(&s->IptMppass, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -30); + + LWidget_SetLocation(&s->BtnConnect, ANCHOR_CENTRE, ANCHOR_CENTRE, -110, 20); + LWidget_SetLocation(&s->BtnBack, ANCHOR_CENTRE, ANCHOR_CENTRE, 125, 20); + LWidget_SetLocation(&s->LblStatus, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 70); +} + static void DirectConnectScreen_Init(struct LScreen* s_) { struct DirectConnectScreen* s = (struct DirectConnectScreen*)s_; if (!s->NumWidgets) DirectConnectScreen_InitWidgets(s); - - s->DrawAll(s_); } struct LScreen* DirectConnectScreen_MakeInstance(void) { struct DirectConnectScreen* s = &DirectConnectScreen_Instance; LScreen_Reset((struct LScreen*)s); s->Init = DirectConnectScreen_Init; + s->Reposition = DirectConnectScreen_Reposition; s->OnEnterWidget = (struct LWidget*)&s->BtnConnect; return (struct LScreen*)s; } @@ -453,23 +628,16 @@ static void SettingsScreen_InitWidgets(struct SettingsScreen* s) { struct LScreen* s_ = (struct LScreen*)s; s->Widgets = s->_widgets; - LScreen_Button(s_, &s->BtnUpdates, 110, 35, "Updates", - ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -120); - LScreen_Label(s_, &s->LblUpdates, "&eGet the latest stuff", - ANCHOR_CENTRE, ANCHOR_CENTRE, 10, -120); + LScreen_Button(s_, &s->BtnUpdates, 110, 35, "Updates"); + LScreen_Label(s_, &s->LblUpdates, "&eGet the latest stuff"); - LScreen_Button(s_, &s->BtnMode, 110, 35, "Mode", - ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -70); - LScreen_Label(s_, &s->LblMode, "&eChange the enabled features", - ANCHOR_CENTRE, ANCHOR_CENTRE, 55, -70); + LScreen_Button(s_, &s->BtnMode, 110, 35, "Mode"); + LScreen_Label(s_, &s->LblMode, "&eChange the enabled features"); - LScreen_Button(s_, &s->BtnColours, 110, 35, "Colours", - ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -20); - LScreen_Label(s_, &s->LblColours, "&eChange how the launcher looks", - ANCHOR_CENTRE, ANCHOR_CENTRE, 65, -20); + LScreen_Button(s_, &s->BtnColours, 110, 35, "Colours"); + LScreen_Label(s_, &s->LblColours, "&eChange how the launcher looks"); - LScreen_Button(s_, &s->BtnBack, 80, 35, "Back", - ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 170); + LScreen_Button(s_, &s->BtnBack, 80, 35, "Back"); s->BtnMode.OnClick = SwitchToChooseMode; s->BtnUpdates.OnClick = SwitchToUpdates; @@ -477,18 +645,32 @@ static void SettingsScreen_InitWidgets(struct SettingsScreen* s) { s->BtnBack.OnClick = SwitchToMain; } +static void SettingsScreen_Reposition(struct LScreen* s_) { + struct SettingsScreen* s = (struct SettingsScreen*)s_; + LWidget_SetLocation(&s->BtnUpdates, ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -120); + LWidget_SetLocation(&s->LblUpdates, ANCHOR_CENTRE, ANCHOR_CENTRE, 10, -120); + + LWidget_SetLocation(&s->BtnMode, ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -70); + LWidget_SetLocation(&s->LblMode, ANCHOR_CENTRE, ANCHOR_CENTRE, 55, -70); + + LWidget_SetLocation(&s->BtnColours, ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -20); + LWidget_SetLocation(&s->LblColours, ANCHOR_CENTRE, ANCHOR_CENTRE, 65, -20); + + LWidget_SetLocation(&s->BtnBack, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 170); +} + static void SettingsScreen_Init(struct LScreen* s_) { struct SettingsScreen* s = (struct SettingsScreen*)s_; if (!s->NumWidgets) SettingsScreen_InitWidgets(s); s->BtnColours.Hidden = Launcher_ClassicBackground; s->LblColours.Hidden = Launcher_ClassicBackground; - s->DrawAll(s_); } struct LScreen* SettingsScreen_MakeInstance(void) { struct SettingsScreen* s = &SettingsScreen_Instance; LScreen_Reset((struct LScreen*)s); - s->Init = SettingsScreen_Init; + s->Init = SettingsScreen_Init; + s->Reposition = SettingsScreen_Reposition; return (struct LScreen*)s; } diff --git a/src/LScreens.h b/src/LScreens.h index b4aa4ee6e..50622050d 100644 --- a/src/LScreens.h +++ b/src/LScreens.h @@ -15,6 +15,7 @@ typedef void(*LWidget_Func)(struct LScreen* s, struct LWidget* w); #define LScreen_Layout \ LScreen_Func Init; /* Initialises widgets and other data. */ \ LScreen_Func Free; /* Cleans up all native resources. */ \ + LScreen_Func Reposition; /* Repositions the widgets in the screen. */ \ LScreen_Func DrawAll; /* Redraws all widgets. */ \ LScreen_Func Tick; /* Repeatedly called multiple times every second. */ \ LScreen_Func OnDisplay; /* Called when framebuffer is about to be displayed. */ \ diff --git a/src/LWidgets.c b/src/LWidgets.c index 8678b2b43..f3204ef70 100644 --- a/src/LWidgets.c +++ b/src/LWidgets.c @@ -276,6 +276,7 @@ static struct LWidgetVTABLE linput_VTABLE = { void LInput_Init(struct LInput* w, int width, int height, const char* hintText, const FontDesc* hintFont) { Widget_Reset(w); w->VTABLE = &linput_VTABLE; + w->TabSelectable = true; String_InitArray(w->Text, w->_TextBuffer); w->BaseWidth = width; diff --git a/src/Launcher.c b/src/Launcher.c index e00806640..68a93c0bf 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -53,6 +53,8 @@ void Launcher_SetScreen(struct LScreen* screen) { Launcher_Screen = screen; screen->Init(screen); + screen->Reposition(screen); + screen->DrawAll(screen); /* for hovering over active button etc */ screen->MouseMove(screen, 0, 0); } @@ -80,6 +82,7 @@ static void Launcher_OnResize(void* obj) { Launcher_Framebuffer.Height = Game_Height; Window_InitRaw(&Launcher_Framebuffer); + if (Launcher_Screen) Launcher_Screen->Reposition(Launcher_Screen); Launcher_RedrawAll(NULL); } @@ -213,7 +216,7 @@ void Launcher_Run(void) { } else { Launcher_SetScreen(MainScreen_MakeInstance()); }*/ - Launcher_SetScreen(DirectConnectScreen_MakeInstance()); + Launcher_SetScreen(SettingsScreen_MakeInstance()); for (;;) { Window_ProcessEvents(); @@ -555,4 +558,4 @@ static void Launcher_ApplyUpdate(void) { /* TODO: chmod +x on non-windows */ res = Platform_StartProcess(&scriptName, &scriptArgs); if (res) { Launcher_ShowError(res, "starting update script"); return; } -} \ No newline at end of file +}