diff --git a/src/LWidgets.c b/src/LWidgets.c index 4521a1d1c..e5eeef18b 100644 --- a/src/LWidgets.c +++ b/src/LWidgets.c @@ -13,11 +13,12 @@ #ifndef CC_BUILD_WEB static int xBorder, xBorder2, xBorder3, xBorder4; static int yBorder, yBorder2, yBorder3, yBorder4; -static int xInputOffset, yInputOffset; +static int xInputOffset, yInputOffset, inputExpand; static int caretOffset, caretWidth, caretHeight; static int scrollbarWidth, dragPad, gridlineWidth, gridlineHeight; static int hdrYOffset, hdrYPadding, rowYOffset, rowYPadding; static int cellXOffset, cellXPadding, cellMinWidth; +static int flagXOffset, flagYOffset; void LWidget_CalcOffsets(void) { xBorder = Display_ScaleX(1); xBorder2 = xBorder * 2; xBorder3 = xBorder * 3; xBorder4 = xBorder * 4; @@ -25,6 +26,8 @@ void LWidget_CalcOffsets(void) { xInputOffset = Display_ScaleX(5); yInputOffset = Display_ScaleY(2); + inputExpand = Display_ScaleX(20); + caretOffset = Display_ScaleY(5); caretWidth = Display_ScaleX(10); caretHeight = Display_ScaleY(2); @@ -42,6 +45,8 @@ void LWidget_CalcOffsets(void) { cellXOffset = Display_ScaleX(6); cellXPadding = Display_ScaleX(5); cellMinWidth = Display_ScaleX(20); + flagXOffset = Display_ScaleX(2); + flagYOffset = Display_ScaleY(6); } void LWidget_SetLocation(void* widget, cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset) { @@ -293,7 +298,7 @@ static void LInput_Draw(void* widget) { DrawTextArgs_Make(&args, &text, &Launcher_TextFont, false); textWidth = Drawer2D_TextWidth(&args); - w->width = max(w->minWidth, textWidth + 20); + w->width = max(w->minWidth, textWidth + inputExpand); w->_textHeight = Drawer2D_TextHeight(&args); LInput_DrawOuterBorder(w); @@ -498,7 +503,7 @@ void LInput_SetText(struct LInput* w, const String* text_) { DrawTextArgs_Make(&args, &text, &Launcher_TextFont, true); textWidth = Drawer2D_TextWidth(&args); - w->width = max(w->minWidth, textWidth + 20); + w->width = max(w->minWidth, textWidth + inputExpand); w->_textHeight = Drawer2D_TextHeight(&args); } @@ -702,7 +707,8 @@ void LSlider_Init(struct LScreen* s, struct LSlider* w, int width, int height, B *#########################################################################################################################*/ static void FlagColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, int x, int y) { Bitmap* bmp = Flags_Get(row); - if (bmp) Drawer2D_BmpCopy(&Launcher_Framebuffer, x + 2, y + 6, bmp); + if (!bmp) return; + Drawer2D_BmpCopy(&Launcher_Framebuffer, x + flagXOffset, y + flagYOffset, bmp); } static void NameColumn_Draw(struct ServerInfo* row, struct DrawTextArgs* args, int x, int y) { diff --git a/src/Launcher.c b/src/Launcher.c index 1d808f332..7712c22e9 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -465,12 +465,13 @@ static cc_result Launcher_ProcessZipEntry(const String* path, struct Stream* dat return 0; } -static void Launcher_ExtractTexturePack(const String* path) { +static void ExtractTexturePack(const String* path) { struct ZipState state; struct Stream stream; cc_result res; res = Stream_OpenFile(&stream, path); + if (res == ReturnCode_FileNotFound) return; if (res) { Logger_Warn(res, "opening texture pack"); return; } Zip_Init(&state, &stream); @@ -493,17 +494,15 @@ void Launcher_TryLoadTexturePack(void) { Launcher_ClassicBackground = Options_GetBool(OPT_CLASSIC_MODE, false); } - Options_UNSAFE_Get(OPT_DEFAULT_TEX_PACK, &texPack); - String_InitArray(path, pathBuffer); - String_Format1(&path, "texpacks/%s", &texPack); + if (Options_UNSAFE_Get(OPT_DEFAULT_TEX_PACK, &texPack)) { + String_InitArray(path, pathBuffer); + String_Format1(&path, "texpacks/%s", &texPack); + ExtractTexturePack(&path); + } - if (!texPack.length || !File_Exists(&path)) path = defZipPath; - if (!File_Exists(&path)) return; - - Launcher_ExtractTexturePack(&path); /* user selected texture pack is missing some required .png files */ if (!fontBmp.scan0 || !dirtBmp.scan0) { - Launcher_ExtractTexturePack(&defZipPath); + ExtractTexturePack(&defZipPath); } }