From fa355250c13315713b826d30e0676ca5d6f5e4df Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 19 Sep 2020 13:42:48 +1000 Subject: [PATCH] For mobile, clicking last slot in inventory hotbar instead opens the inventory. Also replace 'inventory' with 'screenshot' in more menu. --- src/Inventory.h | 1 + src/LWeb.h | 5 ++--- src/Menus.c | 6 +++--- src/Widgets.c | 14 +++++++++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Inventory.h b/src/Inventory.h index 8facc746f..8ef3907cf 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -13,6 +13,7 @@ extern struct IGameComponent Inventory_Component; #define INVENTORY_BLOCKS_PER_HOTBAR 9 /* Number of hotbars that can be selected between */ #define INVENTORY_HOTBARS 9 +#define HOTBAR_MAX_INDEX (INVENTORY_BLOCKS_PER_HOTBAR - 1) CC_VAR extern struct _InventoryData { /* Stores the currently bound blocks for all hotbars. */ diff --git a/src/LWeb.h b/src/LWeb.h index 9afd70e96..f1f6dacb4 100644 --- a/src/LWeb.h +++ b/src/LWeb.h @@ -47,8 +47,7 @@ struct LWebTask { cc_result res; /* Error returned (e.g. for DNS failure) */ int status; /* HTTP return code for the request */ - int reqID; /* Unique identifier for this web task. */ - String url; /* URL this task is downloading from/uploading to. */ + int reqID; /* Unique request identifier for this web task. */ /* Called when task successfully downloaded/uploaded data. */ void (*Handle)(cc_uint8* data, cc_uint32 len); }; @@ -65,7 +64,7 @@ void GetTokenTask_Run(void); extern struct SignInTaskData { struct LWebTask Base; String username; /* Username to sign in as. Changed to case correct username. */ - const char* error; /* If sign in fails, the reason as to why. */ + const char* error; /* If sign in fails, the reason why. */ cc_bool needMFA; /* need login code for multifactor authentication */ } SignInTask; void SignInTask_Run(const String* user, const String* pass, const String* mfaCode); diff --git a/src/Menus.c b/src/Menus.c index ca84ec228..4b6b1e1e3 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -3568,9 +3568,9 @@ static void TouchMore_Chat(void* s, void* w) { Gui_Remove((struct Screen*)&TouchMoreScreen); ChatScreen_OpenInput(&String_Empty); } -static void TouchMore_Inv(void* s, void* w) { +static void TouchMore_Take(void* s, void* w) { Gui_Remove((struct Screen*)&TouchMoreScreen); - InventoryScreen_Show(); + Game_ScreenshotRequested = true; } static void TouchMore_Menu(void* s, void* w) { Gui_Remove((struct Screen*)&TouchMoreScreen); @@ -3587,7 +3587,7 @@ static const struct SimpleButtonDesc touchMore_btns[8] = { { -160, 0, "Speed", TouchMore_Speed }, { -160, 50, "Fly", TouchMore_Fly }, { -160, 100, "Menu", TouchMore_Menu }, - { 160, -50, "Inventory", TouchMore_Inv }, + { 160, -50, "Screenshot", TouchMore_Take }, { 160, 0, "Fullscreen", TouchMore_Screen }, { 160, 50, "Noclip", TouchMore_Noclip }, { 160, 100, "Fog", TouchMore_Fog } diff --git a/src/Widgets.c b/src/Widgets.c index 484e8dbfc..8baad2d70 100644 --- a/src/Widgets.c +++ b/src/Widgets.c @@ -416,6 +416,10 @@ static void HotbarWidget_RenderHotbarBlocks(struct HotbarWidget* w) { for (i = 0; i < INVENTORY_BLOCKS_PER_HOTBAR; i++) { x = (int)(w->x + w->slotXOffset + width * i); y = w->y + (w->height / 2); + +#ifdef CC_BUILD_TOUCH + if (i == HOTBAR_MAX_INDEX && Input_TouchMode) continue; +#endif IsometricDrawer_DrawBatch(Inventory_Get(i), scale, x, y); } IsometricDrawer_EndBatch(); @@ -510,11 +514,15 @@ static int HotbarWidget_PointerDown(void* widget, int id, int x, int y) { for (i = 0; i < INVENTORY_BLOCKS_PER_HOTBAR; i++) { cellX = (int)(w->x + width * i); cellY = w->y; + if (!Gui_Contains(cellX, cellY, width, height, x, y)) continue; - if (Gui_Contains(cellX, cellY, width, height, x, y)) { - Inventory_SetSelectedIndex(i); - return true; +#ifdef CC_BUILD_TOUCH + if (i == HOTBAR_MAX_INDEX && Input_TouchMode) { + InventoryScreen_Show(); return true; } +#endif + Inventory_SetSelectedIndex(i); + return true; } return false; }