diff --git a/src/Drawer2D.c b/src/Drawer2D.c index aa7d017c9..c0bdda8fb 100644 --- a/src/Drawer2D.c +++ b/src/Drawer2D.c @@ -832,13 +832,11 @@ static void SysFonts_Update(void) { } static void SysFonts_Load(void) { - static const cc_string cachePath = String_FromConst(FONT_CACHE_FILE); - if (!File_Exists(&cachePath)) { - Window_ShowDialog("One time load", "Initialising font cache, this can take several seconds."); - } - EntryList_UNSAFE_Load(&font_list, FONT_CACHE_FILE); - if (!font_list.count) SysFonts_Update(); + if (font_list.count) return; + + Window_ShowDialog("One time load", "Initialising font cache, this can take several seconds."); + SysFonts_Update(); } /* Some language-specific fonts don't support English letters */ diff --git a/src/Program.c b/src/Program.c index 17979869c..95d2b9ee6 100644 --- a/src/Program.c +++ b/src/Program.c @@ -148,13 +148,13 @@ static int Program_Run(int argc, char** argv) { return 0; } -/* NOTE: This is used when compiling with MingW without linking to startup files. */ -/* The final code produced for "main" is our "main" combined with crt's main. (mingw-w64-crt/crt/gccmain.c) */ -/* This immediately crashes the game on startup. */ +/* NOTE: main_real is used for when compiling with MingW without linking to startup files. */ +/* Normally, the final code produced for "main" is our "main" combined with crt's main */ +/* (mingw-w64-crt/crt/gccmain.c)) - alas this immediately crashes the game on startup. */ /* Using main_real instead and setting main_real as the entrypoint fixes the crash. */ #ifdef CC_NOMAIN int main_real(int argc, char** argv) { -#else +#else int main(int argc, char** argv) { #endif static char ipBuffer[STRING_SIZE]; @@ -178,10 +178,10 @@ int main(int argc, char** argv) { } /* ClassiCube is just a native library on android, */ -/* unlike other platforms where it is the executable. */ +/* unlike other platforms where it is the executable. */ /* As such, we have to hook into the java-side activity, */ -/* which in its onCreate() calls runGameAsync to */ -/* actually run the game on a separate thread. */ +/* which in its onCreate() calls runGameAsync to */ +/* actually run the game on a separate thread. */ #ifdef CC_BUILD_ANDROID static void android_main(void) { Platform_LogConst("Main loop started!"); diff --git a/src/Screens.c b/src/Screens.c index c1e10538e..e332b3fef 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -205,6 +205,13 @@ static void HUDScreen_ContextRecreated(void* screen) { static void HUDScreen_BuildMesh(void* screen) { } +static int HUDScreen_LayoutHotbar(void) { + struct HUDScreen* s = &HUDScreen_Instance; + s->hotbar.scale = Gui_GetHotbarScale(); + Widget_Layout(&s->hotbar); + return s->hotbar.height; +} + static void HUDScreen_Layout(void* screen) { struct HUDScreen* s = (struct HUDScreen*)screen; struct TextWidget* line1 = &s->line1; @@ -226,8 +233,7 @@ static void HUDScreen_Layout(void* screen) { line2->yOffset = posY + s->posAtlas.tex.Height; } - s->hotbar.scale = Gui_GetHotbarScale(); - Widget_Layout(&s->hotbar); + HUDScreen_LayoutHotbar(); Widget_Layout(line2); } @@ -753,11 +759,8 @@ static struct ChatScreen { static void ChatScreen_UpdateChatYOffsets(struct ChatScreen* s) { int pad, y; - /* Determining chat Y requires us to know hotbar's position */ - /* But HUD is lower priority, so it gets laid out AFTER chat */ - /* Hence use this hack to resize HUD first */ - HUDScreen_Layout(Gui_HUD); + HUDScreen_LayoutHotbar(); y = min(s->input.base.y, Gui_HUD->hotbar.y); y -= s->input.base.yOffset; /* add some padding */ @@ -1043,8 +1046,6 @@ static void ChatScreen_BuildMesh(void* screen) { } static void ChatScreen_Layout(void* screen) { struct ChatScreen* s = (struct ChatScreen*)screen; - /* See comment in ChatScreen_UpdateChatYOffsets */ - HUDScreen_Layout(Gui_HUD); if (ChatScreen_ChatUpdateFont(s)) ChatScreen_Redraw(s); s->paddingX = Display_ScaleX(5); @@ -1059,7 +1060,7 @@ static void ChatScreen_Layout(void* screen) { ChatScreen_UpdateChatYOffsets(s); /* Can't use Widget_SetLocation because it DPI scales input */ - s->bottomRight.yOffset = Gui_HUD->hotbar.height + Display_ScaleY(15); + s->bottomRight.yOffset = HUDScreen_LayoutHotbar() + Display_ScaleY(15); Widget_Layout(&s->bottomRight); Widget_SetLocation(&s->announcement, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 0); @@ -2127,10 +2128,8 @@ static void TouchScreen_Layout(void* screen) { Widget_SetLocation(&s->onscreen[i], ANCHOR_MAX, ANCHOR_MIN, 10, 10 + i * 40); } Widget_SetLocation(&s->more, ANCHOR_CENTRE, ANCHOR_MIN, 0, 10); - /* Need to align these relative to the hotbar */ - HUDScreen_Layout(Gui_HUD); - height = Gui_HUD->hotbar.height; + height = HUDScreen_LayoutHotbar(); for (i = 0; i < s->numBtns; i++) { desc = &s->descs[i];