diff --git a/Minecraft.Client/BannerRenderer.cpp b/Minecraft.Client/BannerRenderer.cpp index 22af2479..89003fe5 100644 --- a/Minecraft.Client/BannerRenderer.cpp +++ b/Minecraft.Client/BannerRenderer.cpp @@ -4,6 +4,8 @@ #include "ModelPart.h" #include "TileEntityRenderDispatcher.h" #include "Textures.h" +#include "BufferedImage.h" +#include #include "../Minecraft.World/net.minecraft.world.level.tile.entity.h" #include "../Minecraft.World/net.minecraft.world.level.tile.h" #include "../Minecraft.World/net.minecraft.world.level.h" @@ -34,11 +36,28 @@ void BannerRenderer::init(TileEntityRenderDispatcher *dispatcher) instance = this; } +static const int BANNER_COLOR_RGB[16] = +{ + 0x1D1D21, 0xB02E26, 0x5E7C16, 0x835432, 0x3C44AA, 0x8932B8, 0x169C9C, 0x9D9D97, + 0x474F52, 0xF38BAA, 0x80C71F, 0xFED83D, 0x3AB3DA, 0xC74EBD, 0xF9801D, 0xF9FFFE +}; + +static int getBannerColorRGB(int baseColor) +{ + ColourTable *table = Minecraft::GetInstance()->getColourTable(); + if (table != nullptr) + { + unsigned int rgb = table->getColour(static_cast(eMinecraftColour_Banner_White + (15 - baseColor))); + if (rgb != 0) return static_cast(rgb & 0xFFFFFF); + } + return BANNER_COLOR_RGB[baseColor]; +} + static void applyBannerColor(int baseColor, float alpha, float brightness = 1.0f) { if (baseColor >= 0 && baseColor < 16) { - int rgb = DyePowderItem::COLOR_RGB[baseColor]; + int rgb = getBannerColorRGB(baseColor); float r = ((rgb >> 16) & 0xFF) / 255.0f * brightness; float g = ((rgb >> 8) & 0xFF) / 255.0f * brightness; float b = ( rgb & 0xFF) / 255.0f * brightness; @@ -145,16 +164,112 @@ void BannerRenderer::renderPatterns(const std::vector &patterns, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } +static BufferedImage *getBannerMaskImage(Textures *textures, const wchar_t *name) +{ + static std::unordered_map s_images; + auto it = s_images.find(name); + if (it != s_images.end()) return it->second; + BufferedImage *img = textures->readImage(TN_COUNT, std::wstring(L"mob/banner/") + name + L".png"); + if (img != nullptr && (img->getWidth() != 64 || img->getHeight() != 64)) img = nullptr; + s_images[name] = img; + return img; +} + +static int getCompositeBannerTexture(Textures *textures, int baseColor, const std::vector &patterns, const wchar_t *(*nameFor)(const std::wstring &)) +{ + if (textures == nullptr || baseColor < 0 || baseColor > 15) return -1; + + std::wstring key = std::to_wstring(baseColor); + for (const BannerPattern &bp : patterns) key += L";" + bp.pattern + L":" + std::to_wstring(bp.color); + + static std::unordered_map s_cache; + auto cached = s_cache.find(key); + if (cached != s_cache.end()) return cached->second; + + BufferedImage *baseImage = getBannerMaskImage(textures, L"banner_base"); + BufferedImage *baseMask = getBannerMaskImage(textures, L"base"); + if (baseImage == nullptr || baseMask == nullptr) + { + s_cache[key] = -1; + return -1; + } + + BufferedImage *out = new BufferedImage(64, 64, BufferedImage::TYPE_INT_ARGB); + int *dst = out->getData(); + int *src = baseImage->getData(); + const int pixels = 64 * 64; + float r[64 * 64], g[64 * 64], b[64 * 64]; + for (int i = 0; i < pixels; i++) + { + r[i] = g[i] = b[i] = 0.0f; + } + + std::vector > layers; + layers.push_back(std::make_pair(baseMask, baseColor)); + for (const BannerPattern &bp : patterns) + { + const wchar_t *tex = nameFor(bp.pattern); + if (tex == nullptr) continue; + BufferedImage *mask = getBannerMaskImage(textures, tex); + if (mask != nullptr) layers.push_back(std::make_pair(mask, bp.color & 15)); + } + + for (const auto &layer : layers) + { + int rgb = getBannerColorRGB(layer.second); + float cr = ((rgb >> 16) & 0xFF) / 255.0f; + float cg = ((rgb >> 8) & 0xFF) / 255.0f; + float cb = (rgb & 0xFF) / 255.0f; + int *mask = layer.first->getData(); + for (int i = 0; i < pixels; i++) + { + int m = mask[i]; + float a = (((m >> 24) & 0xFF) / 255.0f) * ((m & 0xFF) / 255.0f); + if (a <= 0.0f) continue; + int s = src[i]; + float lr = ((s >> 16) & 0xFF) / 255.0f * cr; + float lg = ((s >> 8) & 0xFF) / 255.0f * cg; + float lb = (s & 0xFF) / 255.0f * cb; + r[i] += (lr - r[i]) * a; + g[i] += (lg - g[i]) * a; + b[i] += (lb - b[i]) * a; + } + } + + for (int i = 0; i < pixels; i++) + { + int a = (src[i] >> 24) & 0xFF; + int ir = static_cast(r[i] * 255.0f + 0.5f); + int ig = static_cast(g[i] * 255.0f + 0.5f); + int ib = static_cast(b[i] * 255.0f + 0.5f); + dst[i] = (a << 24) | (ir << 16) | (ig << 8) | ib; + } + + int id = textures->getTexture(out, C4JRender::TEXTURE_FORMAT_RxGyBzAw, false); + s_cache[key] = id; + return id; +} + void BannerRenderer::renderModelColoured(int baseColor, const std::vector &patterns, float alpha, bool useCompiled, float lightU, float lightV) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - bindTexture(&BANNER_LOCATION); - applyBannerColor(baseColor, alpha); - bannerModel->bannerSlate->render(1.0f / 16.0f, false); - - renderPatterns(patterns, alpha, lightU, lightV); + Textures *textures = tileEntityRenderDispatcher ? tileEntityRenderDispatcher->textures : nullptr; + int composite = getCompositeBannerTexture(textures, baseColor, patterns, &BannerRenderer::patternTextureName); + if (composite >= 0) + { + textures->bind(composite); + glColor4f(1.0f, 1.0f, 1.0f, alpha); + bannerModel->bannerSlate->render(1.0f / 16.0f, false); + } + else + { + bindTexture(&BANNER_LOCATION); + applyBannerColor(baseColor, alpha); + bannerModel->bannerSlate->render(1.0f / 16.0f, false); + renderPatterns(patterns, alpha, lightU, lightV); + } bindTexture(&BANNER_LOCATION); glColor4f(1.0f, 1.0f, 1.0f, alpha); @@ -223,25 +338,22 @@ void BannerRenderer::renderBannerForGui(float x, float y, float scaleX, float sc glPushMatrix(); - glTranslatef(x, y, 0.0f); - glScalef(16.0f * scaleX, 16.0f * scaleY, 1.0f); + glTranslatef(x + 8.0f * scaleX, y + 8.0f * scaleY, 0.0f); + glScalef(16.0f * scaleX, -16.0f * scaleY, 1.0f); - glTranslatef(0.5f, 0.72f, 0.0f); + glTranslatef(0.0f, -3.25f / 16.0f, 0.0f); + glRotatef(30.0f, 1.0f, 0.0f, 0.0f); + glRotatef(20.0f, 0.0f, 1.0f, 0.0f); + glScalef(0.5325f, 0.5325f, 0.5325f); - glRotatef(-25.0f, 1.0f, 0.0f, 0.0f); - glRotatef(199.0f, 0.0f, 1.0f, 0.0f); - glScalef(-1.0f, 1.0f, 1.0f); - - const float s = 0.33f; - glScalef(s, s, s); + const float f = 0.6666667f; + glScalef(f, -f, -f); bannerModel->bannerSlate->y = -32.0f; - bannerModel->bannerSlate->xRot = 0.0f; + bannerModel->bannerSlate->xRot = (-0.0125f + 0.01f) * 3.14159265f; bannerModel->bannerStand->visible = true; - glDisable(GL_LIGHTING); renderModelColoured(baseColor, patterns, alpha, false); - glEnable(GL_LIGHTING); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glPopMatrix(); diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index bef94dae..7e33035b 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -879,7 +879,16 @@ void ClientConnection::handleSetEntityData(shared_ptr packe shared_ptr e = getEntity(packet->id); if (e != nullptr && packet->getUnpackedData() != nullptr) { + shared_ptr localGlider = nullptr; + for (int i = 0; i < XUSER_MAX_COUNT; ++i) + { + if (minecraft->localplayers[i] != nullptr && minecraft->localplayers[i] == e) + localGlider = minecraft->localplayers[i]; + } + bool wasGliding = localGlider != nullptr && localGlider->isElytraFlying(); e->getEntityData()->assignValues(packet->getUnpackedData()); + if (localGlider != nullptr && localGlider->isElytraFlying() != wasGliding) + localGlider->setElytraFlag(wasGliding); } } @@ -3186,6 +3195,20 @@ void ClientConnection::handleContainerOpen(shared_ptr packe } } break; + case ContainerOpenPacket::SHULKER_BOX: + { + shared_ptr box = std::make_shared(); + if (packet->customName) box->setCustomName(packet->title); + if (player->openContainer(box)) + { + player->containerMenu->containerId = packet->containerId; + } + else + { + failed = true; + } + } + break; case ContainerOpenPacket::HOPPER: { shared_ptr hopper = std::make_shared(); @@ -3598,6 +3621,11 @@ void ClientConnection::handleGameEvent(shared_ptr gameEventPack level->getLevelData()->setRaining(false); level->setRainLevel(0); } + else if (event == GameEventPacket::THUNDER_LEVEL_CHANGE) + { + level->getLevelData()->setThundering(param != 0); + level->setThunderLevel(param != 0 ? 1.0f : 0.0f); + } else if (event == GameEventPacket::CHANGE_GAME_MODE) { minecraft->localgameModes[m_userIndex]->setLocalMode(GameType::byId(param)); diff --git a/Minecraft.Client/Common/App_Defines.h b/Minecraft.Client/Common/App_Defines.h index 48c4ab79..b769540b 100644 --- a/Minecraft.Client/Common/App_Defines.h +++ b/Minecraft.Client/Common/App_Defines.h @@ -46,6 +46,7 @@ #define GAME_HOST_OPTION_BITMASK_NATURALREGEN 0x10000000 #define GAME_HOST_OPTION_BITMASK_DODAYLIGHTCYCLE 0x20000000 #define GAME_HOST_OPTION_BITMASK_HARDCORE 0x40000000 // 4J Added - for hardcore mode +#define GAME_HOST_OPTION_BITMASK_DOWEATHERCYCLE 0x80000000 #define GAME_HOST_OPTION_BITMASK_ALL 0xFFFFFFFF #define GAME_HOST_OPTION_BITMASK_WORLDSIZE_BITSHIFT 20 diff --git a/Minecraft.Client/Common/App_enums.h b/Minecraft.Client/Common/App_enums.h index a60e5358..7d9e0518 100644 --- a/Minecraft.Client/Common/App_enums.h +++ b/Minecraft.Client/Common/App_enums.h @@ -357,6 +357,43 @@ enum eMinecraftColour eMinecraftColour_Material_Water, eMinecraftColour_Material_Wood, eMinecraftColour_Material_Emerald, + eMinecraftColour_Material_Quartz, + eMinecraftColour_Material_Color_Orange, + eMinecraftColour_Material_Color_Magenta, + eMinecraftColour_Material_Color_Light_Blue, + eMinecraftColour_Material_Color_Yellow, + eMinecraftColour_Material_Color_Light_Green, + eMinecraftColour_Material_Color_Pink, + eMinecraftColour_Material_Color_Grey, + eMinecraftColour_Material_Color_Silver, + eMinecraftColour_Material_Color_Cyan, + eMinecraftColour_Material_Color_Purple, + eMinecraftColour_Material_Color_Blue, + eMinecraftColour_Material_Color_Brown, + eMinecraftColour_Material_Color_Green, + eMinecraftColour_Material_Color_Red, + eMinecraftColour_Material_Color_Black, + eMinecraftColour_Material_Gold, + eMinecraftColour_Material_Diamond, + eMinecraftColour_Material_Lapis, + eMinecraftColour_Material_Podzol, + eMinecraftColour_Material_Nether, + eMinecraftColour_Material_Terracotta_White, + eMinecraftColour_Material_Terracotta_Orange, + eMinecraftColour_Material_Terracotta_Magenta, + eMinecraftColour_Material_Terracotta_Light_Blue, + eMinecraftColour_Material_Terracotta_Yellow, + eMinecraftColour_Material_Terracotta_Light_Green, + eMinecraftColour_Material_Terracotta_Pink, + eMinecraftColour_Material_Terracotta_Grey, + eMinecraftColour_Material_Terracotta_Silver, + eMinecraftColour_Material_Terracotta_Cyan, + eMinecraftColour_Material_Terracotta_Purple, + eMinecraftColour_Material_Terracotta_Blue, + eMinecraftColour_Material_Terracotta_Brown, + eMinecraftColour_Material_Terracotta_Green, + eMinecraftColour_Material_Terracotta_Red, + eMinecraftColour_Material_Terracotta_Black, eMinecraftColour_Particle_Note_00, eMinecraftColour_Particle_Note_01, @@ -595,6 +632,38 @@ enum eMinecraftColour eMinecraftColour_Mob_Shulker_Colour1, eMinecraftColour_Mob_Shulker_Colour2, eMinecraftColour_Mob_Shulker_Shell, + eMinecraftColour_Banner_White, + eMinecraftColour_Banner_Orange, + eMinecraftColour_Banner_Magenta, + eMinecraftColour_Banner_Light_Blue, + eMinecraftColour_Banner_Yellow, + eMinecraftColour_Banner_Lime, + eMinecraftColour_Banner_Pink, + eMinecraftColour_Banner_Gray, + eMinecraftColour_Banner_Silver, + eMinecraftColour_Banner_Cyan, + eMinecraftColour_Banner_Purple, + eMinecraftColour_Banner_Blue, + eMinecraftColour_Banner_Brown, + eMinecraftColour_Banner_Green, + eMinecraftColour_Banner_Red, + eMinecraftColour_Banner_Black, + eMinecraftColour_Shulker_Box_White, + eMinecraftColour_Shulker_Box_Orange, + eMinecraftColour_Shulker_Box_Magenta, + eMinecraftColour_Shulker_Box_Light_Blue, + eMinecraftColour_Shulker_Box_Yellow, + eMinecraftColour_Shulker_Box_Light_Green, + eMinecraftColour_Shulker_Box_Pink, + eMinecraftColour_Shulker_Box_Grey, + eMinecraftColour_Shulker_Box_Silver, + eMinecraftColour_Shulker_Box_Cyan, + eMinecraftColour_Shulker_Box_Purple, + eMinecraftColour_Shulker_Box_Blue, + eMinecraftColour_Shulker_Box_Brown, + eMinecraftColour_Shulker_Box_Green, + eMinecraftColour_Shulker_Box_Red, + eMinecraftColour_Shulker_Box_Black, eMinecraftColour_COUNT, }; @@ -709,6 +778,7 @@ enum eGameHostOption eGameHostOption_NaturalRegeneration, eGameHostOption_DoDaylightCycle, eGameHostOption_Hardcore, // 4J Added - for hardcore mode + eGameHostOption_DoWeatherCycle, }; // 4J-PB - If any new DLC items are added to the TMSFiles, this array needs updated @@ -931,6 +1001,8 @@ enum EControllerActions MINECRAFT_ACTION_DPAD_RIGHT, MINECRAFT_ACTION_DPAD_UP, MINECRAFT_ACTION_DPAD_DOWN, + MINECRAFT_ACTION_SPRINT, + MINECRAFT_ACTION_PICK_BLOCK, MINECRAFT_ACTION_MAX, diff --git a/Minecraft.Client/Common/Audio/SoundNames.cpp b/Minecraft.Client/Common/Audio/SoundNames.cpp index b25112e6..cfecb84e 100644 --- a/Minecraft.Client/Common/Audio/SoundNames.cpp +++ b/Minecraft.Client/Common/Audio/SoundNames.cpp @@ -377,6 +377,8 @@ const WCHAR *ConsoleSoundEngine::wchSoundNames[eSoundType_MAX]= L"item.hoe.till", L"entity.boat.paddle_water", L"entity.boat.paddle_land", + L"block.shulker_box.open", + L"block.shulker_box.close", }; diff --git a/Minecraft.Client/Common/Colours/ColourTable.cpp b/Minecraft.Client/Common/Colours/ColourTable.cpp index e6a99889..d726555d 100644 --- a/Minecraft.Client/Common/Colours/ColourTable.cpp +++ b/Minecraft.Client/Common/Colours/ColourTable.cpp @@ -144,6 +144,43 @@ const wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] = L"Material_Water", L"Material_Wood", L"Material_Emerald", + L"Material_Quartz", + L"Material_Color_Orange", + L"Material_Color_Magenta", + L"Material_Color_Light_Blue", + L"Material_Color_Yellow", + L"Material_Color_Light_Green", + L"Material_Color_Pink", + L"Material_Color_Grey", + L"Material_Color_Silver", + L"Material_Color_Cyan", + L"Material_Color_Purple", + L"Material_Color_Blue", + L"Material_Color_Brown", + L"Material_Color_Green", + L"Material_Color_Red", + L"Material_Color_Black", + L"Material_Gold", + L"Material_Diamond", + L"Material_Lapis", + L"Material_Podzol", + L"Material_Nether", + L"Material_Terracotta_White", + L"Material_Terracotta_Orange", + L"Material_Terracotta_Magenta", + L"Material_Terracotta_Light_Blue", + L"Material_Terracotta_Yellow", + L"Material_Terracotta_Light_Green", + L"Material_Terracotta_Pink", + L"Material_Terracotta_Grey", + L"Material_Terracotta_Silver", + L"Material_Terracotta_Cyan", + L"Material_Terracotta_Purple", + L"Material_Terracotta_Blue", + L"Material_Terracotta_Brown", + L"Material_Terracotta_Green", + L"Material_Terracotta_Red", + L"Material_Terracotta_Black", L"Particle_Note_00", L"Particle_Note_01", @@ -359,6 +396,38 @@ const wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] = L"Mob_Shulker_Colour1", L"Mob_Shulker_Colour2", L"Mob_Shulker_Shell", + L"Banner_White", + L"Banner_Orange", + L"Banner_Magenta", + L"Banner_Light_Blue", + L"Banner_Yellow", + L"Banner_Lime", + L"Banner_Pink", + L"Banner_Gray", + L"Banner_Silver", + L"Banner_Cyan", + L"Banner_Purple", + L"Banner_Blue", + L"Banner_Brown", + L"Banner_Green", + L"Banner_Red", + L"Banner_Black", + L"Shulker_Box_White", + L"Shulker_Box_Orange", + L"Shulker_Box_Magenta", + L"Shulker_Box_Light_Blue", + L"Shulker_Box_Yellow", + L"Shulker_Box_Light_Green", + L"Shulker_Box_Pink", + L"Shulker_Box_Grey", + L"Shulker_Box_Silver", + L"Shulker_Box_Cyan", + L"Shulker_Box_Purple", + L"Shulker_Box_Blue", + L"Shulker_Box_Brown", + L"Shulker_Box_Green", + L"Shulker_Box_Red", + L"Shulker_Box_Black", }; void ColourTable::staticCtor() diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 0859af98..a0fdfb1d 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -27,6 +27,7 @@ #include "../GameMode.h" #include "../Xbox/Social/SocialManager.h" #include "Tutorial/TutorialMode.h" +#include "UI/UICustomStrings.h" #ifdef _WINDOWS64 #include "../Windows64/Network/WinsockNetLayer.h" // HUCKLE - added for quit on disconnect #endif @@ -445,6 +446,12 @@ const wchar_t *ResolveStringKeyFromId(int iID) LPCWSTR CMinecraftApp::GetString(int iID) { + if(iID >= UICustomStrings::BASE_ID) + { + const wchar_t *custom = UICustomStrings::Lookup(iID); + return custom != nullptr ? custom : L""; + } + if(app.m_stringTable == nullptr) { const wchar_t *key = ResolveStringKeyFromId(iID); @@ -1132,6 +1139,7 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con app.SetGameHostOption(eGameHostOption_DoTileDrops, 1 ); app.SetGameHostOption(eGameHostOption_NaturalRegeneration, 1 ); app.SetGameHostOption(eGameHostOption_DoDaylightCycle, 1 ); + app.SetGameHostOption(eGameHostOption_DoWeatherCycle, 1 ); //TU25 SetGameSettings(iPad, eGameSetting_ClassicCrafting, 0); @@ -8921,6 +8929,16 @@ void CMinecraftApp::SetGameHostOption(unsigned int &uiHostSettings, eGameHostOpt uiHostSettings &= ~GAME_HOST_OPTION_BITMASK_DODAYLIGHTCYCLE; } break; + case eGameHostOption_DoWeatherCycle: + if(uiVal!=1) + { + uiHostSettings |= GAME_HOST_OPTION_BITMASK_DOWEATHERCYCLE; + } + else + { + uiHostSettings &= ~GAME_HOST_OPTION_BITMASK_DOWEATHERCYCLE; + } + break; case eGameHostOption_WorldSize: // clear the difficulty first uiHostSettings&=~GAME_HOST_OPTION_BITMASK_WORLDSIZE; @@ -9037,6 +9055,8 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame case eGameHostOption_DoDaylightCycle: return !(uiHostSettings&GAME_HOST_OPTION_BITMASK_DODAYLIGHTCYCLE); break; + case eGameHostOption_DoWeatherCycle: + return !(uiHostSettings&GAME_HOST_OPTION_BITMASK_DOWEATHERCYCLE); case eGameHostOption_Hardcore: // 4J Added - for hardcore mode return (uiHostSettings&GAME_HOST_OPTION_BITMASK_HARDCORE) ? 1 : 0; break; diff --git a/Minecraft.Client/Common/Media/MediaWindows64/EditServerMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/EditServerMenu1080.swf new file mode 100644 index 00000000..01fd59fd Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/EditServerMenu1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/ControlType/HD/xboxOneHD.swf b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/ControlType/HD/xboxOneHD.swf index 464cb346..36b56483 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/ControlType/HD/xboxOneHD.swf and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/ControlType/HD/xboxOneHD.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_0.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_0.png new file mode 100644 index 00000000..3cf4e03d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_0.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_1.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_1.png new file mode 100644 index 00000000..592f64d2 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_1.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_2.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_2.png new file mode 100644 index 00000000..0f7ebe81 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_2.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_3.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_3.png new file mode 100644 index 00000000..1be52c93 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_3.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_4.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_4.png new file mode 100644 index 00000000..f8bdf1eb Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_4.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_5.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_5.png new file mode 100644 index 00000000..0942557f Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_5.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_6.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_6.png new file mode 100644 index 00000000..dd03ed75 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_6.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_7.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_7.png new file mode 100644 index 00000000..5d5dab42 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_7.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_8.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_8.png new file mode 100644 index 00000000..7b5aac49 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_8.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_9.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_9.png new file mode 100644 index 00000000..df4e38de Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_9.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_A.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_A.png new file mode 100644 index 00000000..0b66d226 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_A.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Apostrophe.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Apostrophe.png new file mode 100644 index 00000000..11c9c3ff Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Apostrophe.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_B.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_B.png new file mode 100644 index 00000000..529e81c2 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_B.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Backslash.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Backslash.png new file mode 100644 index 00000000..7de023f3 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Backslash.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Backspace.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Backspace.png new file mode 100644 index 00000000..9bb8ad96 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Backspace.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_C.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_C.png new file mode 100644 index 00000000..18f9ee40 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_C.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Comma.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Comma.png new file mode 100644 index 00000000..3a762ba5 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Comma.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Ctrl.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Ctrl.png new file mode 100644 index 00000000..60be125d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Ctrl.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_D.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_D.png new file mode 100644 index 00000000..3ac604b9 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_D.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_DOWN.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_DOWN.png new file mode 100644 index 00000000..0bd262a0 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_DOWN.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_E.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_E.png new file mode 100644 index 00000000..036e86e4 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_E.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Enter.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Enter.png new file mode 100644 index 00000000..fc6a0903 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Enter.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Equals.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Equals.png new file mode 100644 index 00000000..d2963210 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Equals.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Esc.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Esc.png new file mode 100644 index 00000000..eea41e84 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Esc.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F.png new file mode 100644 index 00000000..014e3b66 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F1.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F1.png new file mode 100644 index 00000000..44be4a61 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F1.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F10.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F10.png new file mode 100644 index 00000000..60b0c9c6 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F10.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F11.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F11.png new file mode 100644 index 00000000..5c5509d4 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F11.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F12.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F12.png new file mode 100644 index 00000000..85394a6c Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F12.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F2.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F2.png new file mode 100644 index 00000000..09d3b3b9 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F2.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F3.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F3.png new file mode 100644 index 00000000..6991fded Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F3.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F4.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F4.png new file mode 100644 index 00000000..45d6e181 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F4.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F5.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F5.png new file mode 100644 index 00000000..e7db4a46 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F5.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F6.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F6.png new file mode 100644 index 00000000..094ee463 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F6.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F7.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F7.png new file mode 100644 index 00000000..189c939c Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F7.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F8.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F8.png new file mode 100644 index 00000000..d7589c61 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F8.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F9.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F9.png new file mode 100644 index 00000000..d58941de Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_F9.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_G.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_G.png new file mode 100644 index 00000000..2d14975d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_G.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Grave.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Grave.png new file mode 100644 index 00000000..edb33eab Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Grave.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_H.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_H.png new file mode 100644 index 00000000..d60995c9 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_H.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_I.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_I.png new file mode 100644 index 00000000..9afb21cd Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_I.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_J.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_J.png new file mode 100644 index 00000000..b6240d52 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_J.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_K.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_K.png new file mode 100644 index 00000000..a8b00f65 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_K.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_L.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_L.png new file mode 100644 index 00000000..8a512478 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_L.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_LBracket.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_LBracket.png new file mode 100644 index 00000000..df02a53b Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_LBracket.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_LEFT.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_LEFT.png new file mode 100644 index 00000000..c3eeec56 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_LEFT.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_M.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_M.png new file mode 100644 index 00000000..42500804 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_M.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Minus.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Minus.png new file mode 100644 index 00000000..b828522a Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Minus.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Mouse1.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Mouse1.png new file mode 100644 index 00000000..412fb5de Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Mouse1.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Mouse2.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Mouse2.png new file mode 100644 index 00000000..965a88af Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Mouse2.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_N.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_N.png new file mode 100644 index 00000000..0fb036c3 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_N.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_O.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_O.png new file mode 100644 index 00000000..75420672 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_O.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_P.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_P.png new file mode 100644 index 00000000..0e8fe96b Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_P.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Period.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Period.png new file mode 100644 index 00000000..9dce9629 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Period.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Q.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Q.png new file mode 100644 index 00000000..f68ca50e Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Q.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_R.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_R.png new file mode 100644 index 00000000..b8fc04db Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_R.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_RBracket.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_RBracket.png new file mode 100644 index 00000000..3e46b359 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_RBracket.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_RIGHT.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_RIGHT.png new file mode 100644 index 00000000..922396c8 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_RIGHT.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_S.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_S.png new file mode 100644 index 00000000..cd1ba570 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_S.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Semicolon.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Semicolon.png new file mode 100644 index 00000000..4af86ea2 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Semicolon.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Shift.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Shift.png new file mode 100644 index 00000000..a23159fa Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Shift.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Space.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Space.png new file mode 100644 index 00000000..b2357f05 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Space.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_T.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_T.png new file mode 100644 index 00000000..dc422367 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_T.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Tab.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Tab.png new file mode 100644 index 00000000..9227c71f Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Tab.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_U.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_U.png new file mode 100644 index 00000000..703d430b Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_U.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_UP.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_UP.png new file mode 100644 index 00000000..91895a76 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_UP.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_V.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_V.png new file mode 100644 index 00000000..e3a1772e Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_V.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_W.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_W.png new file mode 100644 index 00000000..6bcee31d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_W.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_X.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_X.png new file mode 100644 index 00000000..b9071957 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_X.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Y.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Y.png new file mode 100644 index 00000000..88f81cb8 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Y.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Z.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Z.png new file mode 100644 index 00000000..c1502af0 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/KeyIcons/Key_Z.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonA.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonA.png new file mode 100644 index 00000000..df639232 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonA.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonB.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonB.png new file mode 100644 index 00000000..36a747a8 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonB.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonBack.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonBack.png new file mode 100644 index 00000000..24dfade5 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonBack.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadD.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadD.png new file mode 100644 index 00000000..6b1e3b6d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadD.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadL.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadL.png new file mode 100644 index 00000000..95ab268c Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadL.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadR.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadR.png new file mode 100644 index 00000000..46aeb00b Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadR.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadU.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadU.png new file mode 100644 index 00000000..dac9c01c Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonDpadU.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLS.png new file mode 100644 index 00000000..34f1a69c Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLeftBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLeftBumper.png new file mode 100644 index 00000000..ab73b144 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLeftBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLeftStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLeftStick.png new file mode 100644 index 00000000..c803b415 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLeftStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLeftTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLeftTrigger.png new file mode 100644 index 00000000..acbae8ca Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonLeftTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRS.png new file mode 100644 index 00000000..d4924474 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRightBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRightBumper.png new file mode 100644 index 00000000..c2b5186f Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRightBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRightStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRightStick.png new file mode 100644 index 00000000..1fe428bc Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRightStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRightTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRightTrigger.png new file mode 100644 index 00000000..a24c046d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonRightTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonStart.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonStart.png new file mode 100644 index 00000000..7d12d705 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonStart.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonX.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonX.png new file mode 100644 index 00000000..54a1c7b5 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonX.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonY.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonY.png new file mode 100644 index 00000000..9e3b289e Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS3/ButtonY.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonA.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonA.png new file mode 100644 index 00000000..3390fca8 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonA.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonB.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonB.png new file mode 100644 index 00000000..d97e767f Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonB.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonBack.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonBack.png new file mode 100644 index 00000000..d3858c62 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonBack.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadD.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadD.png new file mode 100644 index 00000000..942209ae Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadD.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadL.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadL.png new file mode 100644 index 00000000..e7510dcd Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadL.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadR.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadR.png new file mode 100644 index 00000000..bac687ee Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadR.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadU.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadU.png new file mode 100644 index 00000000..5a062d13 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonDpadU.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLS.png new file mode 100644 index 00000000..1c3f7d36 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLeftBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLeftBumper.png new file mode 100644 index 00000000..e95015fd Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLeftBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLeftStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLeftStick.png new file mode 100644 index 00000000..65070f4c Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLeftStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLeftTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLeftTrigger.png new file mode 100644 index 00000000..cc31f25f Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonLeftTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRS.png new file mode 100644 index 00000000..d93a174d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRightBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRightBumper.png new file mode 100644 index 00000000..382ef1dd Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRightBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRightStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRightStick.png new file mode 100644 index 00000000..1a7cce30 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRightStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRightTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRightTrigger.png new file mode 100644 index 00000000..9309da76 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonRightTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonStart.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonStart.png new file mode 100644 index 00000000..e44749ad Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonStart.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonX.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonX.png new file mode 100644 index 00000000..853b5225 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonX.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonY.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonY.png new file mode 100644 index 00000000..50e4b0fa Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/PS4/ButtonY.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonA.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonA.png new file mode 100644 index 00000000..6cc5bccb Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonA.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonB.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonB.png new file mode 100644 index 00000000..b70a09e7 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonB.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonBack.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonBack.png new file mode 100644 index 00000000..878246b5 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonBack.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadD.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadD.png new file mode 100644 index 00000000..098cc7ec Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadD.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadL.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadL.png new file mode 100644 index 00000000..cca845c1 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadL.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadR.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadR.png new file mode 100644 index 00000000..0185afb8 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadR.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadU.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadU.png new file mode 100644 index 00000000..b23e79a5 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonDpadU.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLS.png new file mode 100644 index 00000000..cff219f9 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLeftBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLeftBumper.png new file mode 100644 index 00000000..bbe95298 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLeftBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLeftStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLeftStick.png new file mode 100644 index 00000000..e2eb17f9 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLeftStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLeftTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLeftTrigger.png new file mode 100644 index 00000000..414e443a Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonLeftTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRS.png new file mode 100644 index 00000000..39a14ff2 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRightBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRightBumper.png new file mode 100644 index 00000000..065e7e1d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRightBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRightStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRightStick.png new file mode 100644 index 00000000..547ee80a Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRightStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRightTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRightTrigger.png new file mode 100644 index 00000000..f6372376 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonRightTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonStart.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonStart.png new file mode 100644 index 00000000..ad09fa0f Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonStart.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonX.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonX.png new file mode 100644 index 00000000..8d57858b Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonX.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonY.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonY.png new file mode 100644 index 00000000..7c9e8bc1 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/WiiU/ButtonY.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonA.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonA.png new file mode 100644 index 00000000..b16d565c Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonA.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonB.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonB.png new file mode 100644 index 00000000..14d25c32 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonB.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonBack.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonBack.png new file mode 100644 index 00000000..d7f9880d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonBack.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadD.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadD.png new file mode 100644 index 00000000..95dad1b6 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadD.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadL.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadL.png new file mode 100644 index 00000000..b40d04c8 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadL.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadR.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadR.png new file mode 100644 index 00000000..c6bf1820 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadR.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadU.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadU.png new file mode 100644 index 00000000..5d9be3f2 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonDpadU.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLS.png new file mode 100644 index 00000000..51ac0fea Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLeftBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLeftBumper.png new file mode 100644 index 00000000..1fe80340 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLeftBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLeftStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLeftStick.png new file mode 100644 index 00000000..9d0ceede Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLeftStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLeftTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLeftTrigger.png new file mode 100644 index 00000000..3183d414 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonLeftTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRS.png new file mode 100644 index 00000000..6e81e502 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRightBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRightBumper.png new file mode 100644 index 00000000..8e41b2f2 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRightBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRightStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRightStick.png new file mode 100644 index 00000000..ff77e93b Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRightStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRightTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRightTrigger.png new file mode 100644 index 00000000..58b03fa6 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonRightTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonStart.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonStart.png new file mode 100644 index 00000000..fa427269 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonStart.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonX.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonX.png new file mode 100644 index 00000000..123ca559 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonX.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonY.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonY.png new file mode 100644 index 00000000..c7c05242 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xbox360/ButtonY.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonA.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonA.png new file mode 100644 index 00000000..18071209 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonA.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonB.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonB.png new file mode 100644 index 00000000..8e4372a8 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonB.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonBack.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonBack.png new file mode 100644 index 00000000..e8b779ea Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonBack.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadD.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadD.png new file mode 100644 index 00000000..21be412b Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadD.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadL.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadL.png new file mode 100644 index 00000000..a297a341 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadL.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadR.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadR.png new file mode 100644 index 00000000..9b96132f Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadR.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadU.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadU.png new file mode 100644 index 00000000..8200b308 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonDpadU.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLS.png new file mode 100644 index 00000000..918bbe9f Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLeftBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLeftBumper.png new file mode 100644 index 00000000..87947a37 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLeftBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLeftStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLeftStick.png new file mode 100644 index 00000000..71badeed Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLeftStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLeftTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLeftTrigger.png new file mode 100644 index 00000000..b1c90416 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonLeftTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRS.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRS.png new file mode 100644 index 00000000..5e4e4367 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRS.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRightBumper.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRightBumper.png new file mode 100644 index 00000000..09ab93b1 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRightBumper.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRightStick.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRightStick.png new file mode 100644 index 00000000..0bfb7e7d Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRightStick.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRightTrigger.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRightTrigger.png new file mode 100644 index 00000000..fa1fdf93 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonRightTrigger.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonStart.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonStart.png new file mode 100644 index 00000000..fa3c439f Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonStart.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonX.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonX.png new file mode 100644 index 00000000..3ca757c3 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonX.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonY.png b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonY.png new file mode 100644 index 00000000..07cfb052 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/Graphics/PadIcons/xboxOne/ButtonY.png differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu1080.swf index 35f624b7..5f0eed1f 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu1080.swf and b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu480.swf b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu480.swf index 226ac721..72644b9c 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu480.swf and b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu480.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu720.swf b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu720.swf index 75c22f50..e2047cd1 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu720.swf and b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenu720.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuSplit1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuSplit1080.swf index efe2d484..81d27618 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuSplit1080.swf and b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuSplit1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuSplit720.swf b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuSplit720.swf index a9d13a05..d02236f1 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuSplit720.swf and b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuSplit720.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuVita.swf b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuVita.swf index 1eae726a..70c29404 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuVita.swf and b/Minecraft.Client/Common/Media/MediaWindows64/InventoryMenuVita.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu1080.swf index aab3a49d..79e9304a 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu1080.swf and b/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu480.swf b/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu480.swf index 6cc68b1a..1c31dd4e 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu480.swf and b/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu480.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu720.swf b/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu720.swf index 5862b2a1..e9490794 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu720.swf and b/Minecraft.Client/Common/Media/MediaWindows64/LaunchMoreOptionsMenu720.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenu1080.swf index 1c8adadc..936c7993 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenu1080.swf and b/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenu1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenu720.swf b/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenu720.swf index df0f958c..f6386cee 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenu720.swf and b/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenu720.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenuSplit1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenuSplit1080.swf index 1c4b279e..64019d38 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenuSplit1080.swf and b/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenuSplit1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenuSplit720.swf b/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenuSplit720.swf index 748facf3..ed5c1ecf 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenuSplit720.swf and b/Minecraft.Client/Common/Media/MediaWindows64/MultilistMenuSplit720.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/chests/spawn_bonus_chest.xml b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/chests/spawn_bonus_chest.xml index 38b528fa..8f537ec7 100644 --- a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/chests/spawn_bonus_chest.xml +++ b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/chests/spawn_bonus_chest.xml @@ -157,5 +157,187 @@ + + + 2 + 4 + + + + item + minecraft:sapling + 2 + + + set_data + 0 + + + set_count + + 4 + 4 + + + + + + item + minecraft:sapling + 2 + + + set_data + 1 + + + set_count + + 4 + 4 + + + + + + item + minecraft:sapling + 2 + + + set_data + 2 + + + set_count + + 4 + 4 + + + + + + item + minecraft:sapling + 4 + + + set_data + 3 + + + set_count + + 4 + 4 + + + + + + item + minecraft:melon_seeds + 3 + + + set_count + + 1 + 2 + + + + + + item + minecraft:pumpkin_seeds + 3 + + + set_count + + 1 + 2 + + + + + + item + minecraft:cactus + 3 + + + set_count + + 1 + 2 + + + + + + item + minecraft:dye + 2 + + + set_data + 3 + + + set_count + + 1 + 2 + + + + + + item + minecraft:potato + 3 + + + set_count + + 1 + 2 + + + + + + item + minecraft:carrot + 3 + + + set_count + + 1 + 2 + + + + + + item + minecraft:mushroom_brown + 2 + + + set_count + + 1 + 2 + + + + + + diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/elderguardian.xml b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/elderguardian.xml index ddafed7d..c3373f0a 100644 --- a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/elderguardian.xml +++ b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/elderguardian.xml @@ -35,6 +35,18 @@ minecraft:fish 3 + + furnace_smelt + + + entity_properties + this + + True + + + + looting_enchant diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/guardian.xml b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/guardian.xml index f3b848f4..08b2f8c0 100644 --- a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/guardian.xml +++ b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/guardian.xml @@ -35,6 +35,18 @@ minecraft:fish 2 + + furnace_smelt + + + entity_properties + this + + True + + + + looting_enchant diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/polarbear.xml b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/polarbear.xml index f9325c3f..093e3f50 100644 --- a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/polarbear.xml +++ b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/polarbear.xml @@ -9,6 +9,18 @@ minecraft:fish 3 + + furnace_smelt + + + entity_properties + this + + True + + + + set_count @@ -34,6 +46,18 @@ minecraft:fish 1 + + furnace_smelt + + + entity_properties + this + + True + + + + set_count diff --git a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/shulker.xml b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/shulker.xml index f209a425..709da701 100644 --- a/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/shulker.xml +++ b/Minecraft.Client/Common/Media/MediaWindows64/Structures/loot_tables/entities/shulker.xml @@ -1,2 +1,22 @@ - + + + + + + random_chance_with_looting + 0.5 + 0.0625 + + + 1 + + + item + minecraft:shulker_shell + 1 + + + + + diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SuperflatEditLayerMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SuperflatEditLayerMenu1080.swf new file mode 100644 index 00000000..0625888c Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/SuperflatEditLayerMenu1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SuperflatMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SuperflatMenu1080.swf new file mode 100644 index 00000000..c3677013 Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/SuperflatMenu1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SuperflatPresetsMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SuperflatPresetsMenu1080.swf new file mode 100644 index 00000000..2539b41c Binary files /dev/null and b/Minecraft.Client/Common/Media/MediaWindows64/SuperflatPresetsMenu1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/ToolTips1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/ToolTips1080.swf index 2251f80e..7904918e 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/ToolTips1080.swf and b/Minecraft.Client/Common/Media/MediaWindows64/ToolTips1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/ToolTips480.swf b/Minecraft.Client/Common/Media/MediaWindows64/ToolTips480.swf index 3ebebb9b..d3033132 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/ToolTips480.swf and b/Minecraft.Client/Common/Media/MediaWindows64/ToolTips480.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/ToolTips720.swf b/Minecraft.Client/Common/Media/MediaWindows64/ToolTips720.swf index 7c5a5ba4..8479b7bf 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/ToolTips720.swf and b/Minecraft.Client/Common/Media/MediaWindows64/ToolTips720.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsSplit1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsSplit1080.swf index 820fdda1..f2899b76 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsSplit1080.swf and b/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsSplit1080.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsSplit720.swf b/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsSplit720.swf index 7c5ae7ea..3fd3d958 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsSplit720.swf and b/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsSplit720.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsVita.swf b/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsVita.swf index c2b9dfe8..4746f9bf 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsVita.swf and b/Minecraft.Client/Common/Media/MediaWindows64/ToolTipsVita.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/skinHDHud.swf b/Minecraft.Client/Common/Media/MediaWindows64/skinHDHud.swf index fd4c4c19..f68f9620 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/skinHDHud.swf and b/Minecraft.Client/Common/Media/MediaWindows64/skinHDHud.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/skinHud.swf b/Minecraft.Client/Common/Media/MediaWindows64/skinHud.swf index bcac5d51..2c79f104 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/skinHud.swf and b/Minecraft.Client/Common/Media/MediaWindows64/skinHud.swf differ diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.h b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.h index 1d34dad9..75c5d568 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.h +++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.h @@ -43,6 +43,7 @@ protected: eSectionInventoryUsing, eSectionInventoryInventory, eSectionInventoryArmor, + eSectionInventoryOffhand, eSectionInventoryCraftingGrid, eSectionInventoryCraftingResult, eSectionInventoryMax, diff --git a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp index 83960302..38c7b3de 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.cpp @@ -29,26 +29,15 @@ Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping9GridA[IUIScene_Cra Recipy::eGroupType_Decoration, }; -Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeBannerMapping9GridA[m_iMaxBannerGroupH3x3] = -{ - Recipy::eGroupType_Banner_CustomLogic, - Recipy::eGroupType_Banner_Stripes, - Recipy::eGroupType_Banner_Halves, - Recipy::eGroupType_Banner_Shapes, - Recipy::eGroupType_Banner_BBG, //borders backgrounds and gradients - Recipy::eGroupType_Banner_Symbols, -}; - - LPCWSTR IUIScene_CraftingMenu::m_GroupIconNameA[m_iMaxGroupH3x3]= { - L"Structures",//Recipy::eGroupType_Structure, - L"Tools",//Recipy::eGroupType_Tool, - L"Food",//Recipy::eGroupType_Food, - L"Armour",//Recipy::eGroupType_Armour, - L"Mechanisms",//Recipy::eGroupType_Mechanism, - L"Transport",//Recipy::eGroupType_Transport, - L"Decoration",//Recipy::eGroupType_Decoration, + L"Structures", + L"Tools", + L"Food", + L"Armour", + L"Mechanisms", + L"Transport", + L"Decoration", }; IUIScene_CraftingMenu::_eGroupTab IUIScene_CraftingMenu::m_GroupTabBkgMapping2x2A[m_iMaxGroupH2x2]= @@ -72,124 +61,46 @@ IUIScene_CraftingMenu::_eGroupTab IUIScene_CraftingMenu::m_GroupTabBkgMapping3x3 eGroupTab_Right, }; - -// mapping array to map the base objects to their description string -// This should map the enums -// enum -// { -// eBaseItemType_undefined=0, -// eBaseItemType_sword, -// eBaseItemType_shovel, -// eBaseItemType_pickaxe, -// eBaseItemType_hatchet, -// eBaseItemType_hoe, -// eBaseItemType_door, -// eBaseItemType_helmet, -// eBaseItemType_chestplate, -// eBaseItemType_leggings, -// eBaseItemType_boots, -// eBaseItemType_ingot, -// eBaseItemType_rail, -// eBaseItemType_block, -// eBaseItemType_pressureplate, -// eBaseItemType_stairs, -// eBaseItemType_cloth, -// eBaseItemType_dyepowder, -// eBaseItemType_structplanks -// eBaseItemType_structblock, -// eBaseItemType_slab, -// eBaseItemType_halfslab, -// eBaseItemType_torch, -// eBaseItemType_bow, -// eBaseItemType_pockettool, -// eBaseItemType_utensil, -// -// } -// eBaseItemType; - IUIScene_CraftingMenu::IUIScene_CraftingMenu() { m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1; - for(int i=0;i= BannerPatternRecipe::PATTERN_COUNT) return 16; - return BannerPatternRecipe::PATTERNS[patternId].specialItemId != 0 ? 17 : 16; -} - -static void resetBannerPatternColorOptions(int* options, int patternId) -{ - if (patternId >= 0 && patternId < BannerPatternRecipe::PATTERN_COUNT && - BannerPatternRecipe::PATTERNS[patternId].specialItemId != 0) - { - options[0] = 15; - options[1] = -1; - options[2] = 0; - } - else - { - options[0] = 15; - options[1] = 0; - options[2] = 1; - } -} - -static int stepBannerPatternColorOption(int patternId, int colorIndex, int direction) -{ - bool specialPattern = patternId >= 0 && patternId < BannerPatternRecipe::PATTERN_COUNT && - BannerPatternRecipe::PATTERNS[patternId].specialItemId != 0; - int optionCount = bannerPatternColorOptionCount(patternId); - int optionIndex = specialPattern ? colorIndex + 1 : colorIndex; - if (optionIndex < 0 || optionIndex >= optionCount) optionIndex = 0; - optionIndex = (optionIndex + optionCount + direction) % optionCount; - return specialPattern ? optionIndex - 1 : optionIndex; + return app.DebugSettingsOn() && (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)); } bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) @@ -262,7 +133,6 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) if(m_bIgnoreKeyPresses) return bHandled; - // ignore key repeats of the X key - because it's X to open this menu, it can come through as a repeat on opening if(bRepeat &&(iAction==ACTION_MENU_X)) { return S_OK; @@ -283,45 +153,55 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) } } + if (iAction == ACTION_MENU_PAGEUP || iAction == ACTION_MENU_PAGEDOWN) + { + if (iAction == ACTION_MENU_PAGEUP) + { + m_iGroupVIndex = (m_iGroupVIndex == 0) ? getMaxVGroups() - 1 : m_iGroupVIndex - 1; + } + else + { + m_iGroupVIndex++; + if (m_iGroupVIndex >= getMaxVGroups()) m_iGroupVIndex = 0; + } + + m_iGroupHIndex = 0; + m_iCurrentSlotHIndex = 0; + m_iCurrentSlotVIndex = 1; + ui.PlayUISFX(eSFX_Focus); + + if (isSpecialTab()) + { + Special_EnterTab(); + } + else + { + m_iDisplayDescription = DISPLAY_INVENTORY; + setVGroupHighlight(m_iGroupVIndex); + UpdateCraftingPanels(); + CheckRecipesAvailable(); + iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = 1; + UpdateVerticalSlots(); + UpdateHighlight(); + setGroupText(GetGroupNameText(m_pGroupA[m_iGroupHIndex])); + UpdateTooltips(); + } + return true; + } + + if (isSpecialTab()) + { + return Special_HandleKeyDown(iPad, iAction, bRepeat); + } switch(iAction) { - case ACTION_MENU_Y: - if (m_selectedBannerEdit != nullptr && (BannerPatternRecipe::getBannerPatternCount(m_selectedBannerEdit) + m_bannerPreviewData.size()) < 6) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - if (patternId != -1) { - PreviewBannerData data(patternId, iVSlotIndexA[m_iCurrentSlotVIndex]); - vector previewData = m_bannerPreviewData; - previewData.emplace_back(data); - if (hasResourcesForBannerPatterns(previewData)) { - m_bannerPreviewData.emplace_back(data); - rebuildPreviewItem(); - DisplayIngredients(); - ui.PlayUISFX(eSFX_Focus); - } else { - ui.PlayUISFX(eSFX_CraftFail); - } - } - } - UpdateTooltips(); - break; case ACTION_MENU_X: - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - if (m_bannerPreviewData.size() > 0) { - m_bannerPreviewData.pop_back(); - rebuildPreviewItem(); - DisplayIngredients(); - } else { - setSelectedBannerEdit(nullptr); - } - } else { - if (m_iDisplayDescription != DISPLAY_PREVIEW) { - m_iDisplayDescription++; - if (m_iDisplayDescription == DISPLAY_PREVIEW) m_iDisplayDescription++; - } - - if(m_iDisplayDescription==DISPLAY_MAX) m_iDisplayDescription=DISPLAY_INVENTORY; - } + m_iDisplayDescription++; + if (m_iDisplayDescription == DISPLAY_PREVIEW) m_iDisplayDescription++; + if(m_iDisplayDescription>=DISPLAY_MAX) m_iDisplayDescription=DISPLAY_INVENTORY; ui.PlayUISFX(eSFX_Focus); UpdateMultiPanel(); UpdateTooltips(); @@ -332,444 +212,152 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) ui.ShowTooltip( iPad, eToolTipButtonB, false ); ui.ShowTooltip( iPad, eToolTipButtonA, false ); ui.ShowTooltip( iPad, eToolTipButtonRB, false ); - // kill the crafting xui - //ui.PlayUISFX(eSFX_Back); ui.CloseUIScenes(iPad); - bHandled = true; break; case ACTION_MENU_A: #ifdef __ORBIS__ case ACTION_MENU_TOUCHPAD_PRESS: #endif - // Do some crafting! if(m_pPlayer && m_pPlayer->inventory) { - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { - if (CurrentInventoryBanners.size() > 0) { - setSelectedBannerEdit(CurrentInventoryBanners[m_iCurrentSlotVIndex-1]); - } - } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - if (app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)) { - if (m_bannerPreviewData.size() > 0) { - shared_ptr pTempItemInst = ItemInstance::clone(m_selectedBannerEdit); - for (PreviewBannerData& data : m_bannerPreviewData) { - BannerPatternRecipe::addBannerPattern(pTempItemInst, BannerPatternRecipe::PATTERNS[data.id].id, data.color); - } - - if (pMinecraft->localgameModes[iPad] != nullptr) { - Tutorial* tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); - if (tutorial != nullptr) { - tutorial->onCrafted(pTempItemInst); - } - } - - pMinecraft->localgameModes[iPad]->handleCraftBanner(m_selectedBannerEdit, m_bannerPreviewData, m_pPlayer); - m_pPlayer->inventory->removeResources(m_selectedBannerEdit); - - if (m_pPlayer->inventory->add(pTempItemInst) == false) - { - // no room in inventory, so throw it down - m_pPlayer->drop(pTempItemInst); - } - ui.PlayUISFX(eSFX_Craft); - } - } else if (m_bannerPreviewData.size() > 0) { - bool canCraft = true; - int requiredDyes[16] = {}; - std::vector> requiredSpecialItems; - - for (const PreviewBannerData& data : m_bannerPreviewData) { - const BannerPatternRecipe::PatternInfo& pattern = BannerPatternRecipe::PATTERNS[data.id]; - - if (pattern.specialItemId != 0) { - bool found = false; - - for (auto& ingredient : requiredSpecialItems) { - if (ingredient.first == pattern.specialItemId && ingredient.second == pattern.specialItemAux) { - found = true; - break; - } - } - - if (!found) requiredSpecialItems.emplace_back(pattern.specialItemId, pattern.specialItemAux); - if (data.color >= 0) ++requiredDyes[data.color & 15]; - } else { - if (pattern.rows == nullptr) continue; - - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - if (pattern.rows[row][col] != ' ') - ++requiredDyes[data.color & 15]; - } - } - } - } - - for (const PreviewBannerData& data : m_bannerPreviewData) { - const BannerPatternRecipe::PatternInfo& pattern = BannerPatternRecipe::PATTERNS[data.id]; - - if (pattern.specialItemId == 0) continue; - int requiredCount = 0; - - for (const PreviewBannerData& other : m_bannerPreviewData) { - const BannerPatternRecipe::PatternInfo& otherPattern = - BannerPatternRecipe::PATTERNS[other.id]; - - if (otherPattern.specialItemId == pattern.specialItemId && otherPattern.specialItemAux == pattern.specialItemAux) { - ++requiredCount; - } - } - - if (!hasItem(pattern.specialItemId, requiredCount, pattern.specialItemAux)) { - canCraft = false; - break; - } - } - - if (canCraft) { - for (int color = 0; color < 16; ++color) { - if (requiredDyes[color] > 0 && - !hasItem(Item::dye_Id, requiredDyes[color], color)) { - canCraft = false; - break; - } - } - } - - if (canCraft) { - shared_ptr pTempItemInst = ItemInstance::clone(m_selectedBannerEdit); - - for (const PreviewBannerData& data : m_bannerPreviewData) { - const BannerPatternRecipe::PatternInfo& pattern = BannerPatternRecipe::PATTERNS[data.id]; - BannerPatternRecipe::addBannerPattern(pTempItemInst, pattern.id, data.color); - } - - if (pMinecraft->localgameModes[iPad] != nullptr) { - Tutorial* tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); - - if (tutorial != nullptr) tutorial->onCrafted(pTempItemInst); - } - - for (int color = 0; color < 16; ++color) { - for (int i = 0; i < requiredDyes[color]; ++i) { - m_pPlayer->inventory->removeResource(Item::dye_Id, color); - } - } - - for (const PreviewBannerData& data : m_bannerPreviewData) { - const BannerPatternRecipe::PatternInfo& pattern = BannerPatternRecipe::PATTERNS[data.id]; - - if (pattern.specialItemId != 0) { - m_pPlayer->inventory->removeResource(pattern.specialItemId, pattern.specialItemAux); - } - } - - pMinecraft->localgameModes[iPad]->handleCraftBanner(m_selectedBannerEdit, m_bannerPreviewData, m_pPlayer); - m_pPlayer->inventory->removeResources(m_selectedBannerEdit); - - if (!m_pPlayer->inventory->add(pTempItemInst)) m_pPlayer->drop(pTempItemInst); - - ui.PlayUISFX(eSFX_Craft); - - m_bannerPreviewData.clear(); - setSelectedBannerEdit(nullptr); - - CheckRecipesAvailable(); - UpdateVerticalSlots(); - UpdateHighlight(); - DisplayIngredients(); - } else { - ui.PlayUISFX(eSFX_CraftFail); - } - } - } else { - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); - Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); - // Force a make if the debug is on - if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<getRecipeIngredientsArray(); + if(isCraftAnything()) + { + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) - { - int iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; - - int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; - shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); - //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); - - if( pMinecraft->localgameModes[iPad] != nullptr) - { - Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); - if(tutorial != nullptr) - { - tutorial->onCrafted(pTempItemInst); - } - } - - pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); - - if(m_pPlayer->inventory->add(pTempItemInst)==false) - { - // no room in inventory, so throw it down - m_pPlayer->drop(pTempItemInst); - } - // play a sound - //pMinecraft->soundEngine->playUI( L"random.pop", 1.0f, 1.0f); - ui.PlayUISFX(eSFX_Craft); - } - } - else if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) - { - int iSlot; - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) - { - iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; - } - else - { - iSlot=0; - } + int iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); - //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); - if( pMinecraft->localgameModes[iPad] != nullptr ) + if( pMinecraft->localgameModes[iPad] != nullptr) { Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); if(tutorial != nullptr) { - tutorial->createItemSelected(pTempItemInst, pRecipeIngredientsRequired[iRecipe].bCanMake[iPad]); + tutorial->onCrafted(pTempItemInst); } } - if(pRecipeIngredientsRequired[iRecipe].bCanMake[iPad]) + pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); + + if(m_pPlayer->inventory->add(pTempItemInst)==false) { - pTempItemInst->onCraftedBy(m_pPlayer->level, dynamic_pointer_cast( m_pPlayer->shared_from_this() ), pTempItemInst->count ); - // TODO 4J Stu - handleCraftItem should do a lot more than what it does, loads of the "can we craft" code should also probably be - // shifted to the GameMode - pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); + m_pPlayer->drop(pTempItemInst); + } + ui.PlayUISFX(eSFX_Craft); + } + } + else if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) + { + int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; + int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; + shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); - // play a sound - //pMinecraft->soundEngine->playUI( L"random.pop", 1.0f, 1.0f); - ui.PlayUISFX(eSFX_Craft); + if( pMinecraft->localgameModes[iPad] != nullptr ) + { + Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); + if(tutorial != nullptr) + { + tutorial->createItemSelected(pTempItemInst, pRecipeIngredientsRequired[iRecipe].bCanMake[iPad]); + } + } - if(pTempItemInst->id != Item::firework_charge_Id && pTempItemInst->id != Item::fireworks_Id) + if(pRecipeIngredientsRequired[iRecipe].bCanMake[iPad]) + { + pTempItemInst->onCraftedBy(m_pPlayer->level, dynamic_pointer_cast( m_pPlayer->shared_from_this() ), pTempItemInst->count ); + pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer); + ui.PlayUISFX(eSFX_Craft); + + for(int i=0;i ingItemInst = nullptr; + if(pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]!=Recipes::ANY_AUX_VALUE) { - for(int j=0;jinventory->getResourceItem( pRecipeIngredientsRequired[iRecipe].iIngIDA[i],pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i] ); + m_pPlayer->inventory->removeResource(pRecipeIngredientsRequired[iRecipe].iIngIDA[i],pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]); + } + else + { + ingItemInst = m_pPlayer->inventory->getResourceItem( pRecipeIngredientsRequired[iRecipe].iIngIDA[i] ); + m_pPlayer->inventory->removeResource(pRecipeIngredientsRequired[iRecipe].iIngIDA[i]); + } + + if (ingItemInst != nullptr) + { + if (ingItemInst->getItem()->hasCraftingRemainingItem()) { - shared_ptr ingItemInst = nullptr; - // do we need to remove a specific aux value? - if(pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]!=Recipes::ANY_AUX_VALUE) - { - ingItemInst = m_pPlayer->inventory->getResourceItem( pRecipeIngredientsRequired[iRecipe].iIngIDA[i],pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i] ); - m_pPlayer->inventory->removeResource(pRecipeIngredientsRequired[iRecipe].iIngIDA[i],pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]); - } - else - { - ingItemInst = m_pPlayer->inventory->getResourceItem( pRecipeIngredientsRequired[iRecipe].iIngIDA[i] ); - m_pPlayer->inventory->removeResource(pRecipeIngredientsRequired[iRecipe].iIngIDA[i]); - } - - // 4J Stu - Fix for #13097 - Bug: Milk Buckets are removed when crafting Cake - if (ingItemInst != nullptr) - { - if (ingItemInst->getItem()->hasCraftingRemainingItem()) - { - // replace item with remaining result - m_pPlayer->inventory->add(std::make_shared(ingItemInst->getItem()->getCraftingRemainingItem())); - } - - } + m_pPlayer->inventory->add(std::make_shared(ingItemInst->getItem()->getCraftingRemainingItem())); } } - - // 4J Stu - Fix for #13119 - We should add the item after we remove the ingredients - if(m_pPlayer->inventory->add(pTempItemInst)==false ) - { - // no room in inventory, so throw it down - m_pPlayer->drop(pTempItemInst); - } - - //4J Gordon: Achievements - switch(pTempItemInst->id ) - { - case Tile::crafting_table_Id: m_pPlayer->awardStat(GenericStats::buildWorkbench(), GenericStats::param_buildWorkbench()); break; - case Item::wooden_pickaxe_Id: m_pPlayer->awardStat(GenericStats::buildPickaxe(), GenericStats::param_buildPickaxe()); break; - case Tile::furnace_Id: m_pPlayer->awardStat(GenericStats::buildFurnace(), GenericStats::param_buildFurnace()); break; - //case Item::wooden_hoe_Id: m_pPlayer->awardStat(GenericStats::buildHoe(), GenericStats::param_buildHoe()); break; - case Item::bread_Id: m_pPlayer->awardStat(GenericStats::makeBread(), GenericStats::param_makeBread()); break; - case Item::cake_Id: m_pPlayer->awardStat(GenericStats::bakeCake(), GenericStats::param_bakeCake()); break; - case Item::stone_pickaxe_Id: m_pPlayer->awardStat(GenericStats::buildBetterPickaxe(), GenericStats::param_buildBetterPickaxe()); break; - //case Item::wooden_sword_Id: m_pPlayer->awardStat(GenericStats::buildSword(), GenericStats::param_buildSword()); break; - case Tile::dispenser_Id: m_pPlayer->awardStat(GenericStats::dispenseWithThis(), GenericStats::param_dispenseWithThis()); break; - case Tile::enchanting_table_Id: m_pPlayer->awardStat(GenericStats::enchantments(), GenericStats::param_enchantments()); break; - case Tile::bookshelf_Id: m_pPlayer->awardStat(GenericStats::bookcase(), GenericStats::param_bookcase()); break; - } - switch (pTempItemInst->getItem()->getBaseItemType()) { - case Item::eBaseItemType_hoe: m_pPlayer->awardStat(GenericStats::buildHoe(), GenericStats::param_buildHoe()); break; - case Item::eBaseItemType_sword: m_pPlayer->awardStat(GenericStats::buildSword(), GenericStats::param_buildSword()); break; - } - - // We've used some ingredients from our inventory, so update the recipes we can make - CheckRecipesAvailable(); - // don't reset the vertical slots - we want to stay where we are - UpdateVerticalSlots(); - UpdateHighlight(); } } - else + + if(m_pPlayer->inventory->add(pTempItemInst)==false ) { - //pMinecraft->soundEngine->playUI( L"btn.back", 1.0f, 1.0f); - ui.PlayUISFX(eSFX_CraftFail); + m_pPlayer->drop(pTempItemInst); } + + switch(pTempItemInst->id ) + { + case Tile::crafting_table_Id: m_pPlayer->awardStat(GenericStats::buildWorkbench(), GenericStats::param_buildWorkbench()); break; + case Item::wooden_pickaxe_Id: m_pPlayer->awardStat(GenericStats::buildPickaxe(), GenericStats::param_buildPickaxe()); break; + case Tile::furnace_Id: m_pPlayer->awardStat(GenericStats::buildFurnace(), GenericStats::param_buildFurnace()); break; + case Item::bread_Id: m_pPlayer->awardStat(GenericStats::makeBread(), GenericStats::param_makeBread()); break; + case Item::cake_Id: m_pPlayer->awardStat(GenericStats::bakeCake(), GenericStats::param_bakeCake()); break; + case Item::stone_pickaxe_Id: m_pPlayer->awardStat(GenericStats::buildBetterPickaxe(), GenericStats::param_buildBetterPickaxe()); break; + case Tile::dispenser_Id: m_pPlayer->awardStat(GenericStats::dispenseWithThis(), GenericStats::param_dispenseWithThis()); break; + case Tile::enchanting_table_Id: m_pPlayer->awardStat(GenericStats::enchantments(), GenericStats::param_enchantments()); break; + case Tile::bookshelf_Id: m_pPlayer->awardStat(GenericStats::bookcase(), GenericStats::param_bookcase()); break; + } + switch (pTempItemInst->getItem()->getBaseItemType()) { + case Item::eBaseItemType_hoe: m_pPlayer->awardStat(GenericStats::buildHoe(), GenericStats::param_buildHoe()); break; + case Item::eBaseItemType_sword: m_pPlayer->awardStat(GenericStats::buildSword(), GenericStats::param_buildSword()); break; + } + + CheckRecipesAvailable(); + UpdateVerticalSlots(); + UpdateHighlight(); + } + else + { + ui.PlayUISFX(eSFX_CraftFail); } } } break; - case ACTION_MENU_PAGEUP: - if (m_iGroupVIndex == 0) { - m_iGroupVIndex = (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupV3x3 - 1 : m_iMaxGroupV2x2); - } else { - m_iGroupHIndex--; - } - - setVGroupHighlight(m_iGroupVIndex); - - m_iCurrentSlotHIndex = 0; - m_iCurrentSlotVIndex = 1; - UpdateCraftingPanels(); - CheckRecipesAvailable(); - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - bool specialPattern = patternId >= 0 && patternId < BannerPatternRecipe::PATTERN_COUNT && - BannerPatternRecipe::PATTERNS[patternId].specialItemId != 0; - iVSlotIndexA[0] = 15; - iVSlotIndexA[1] = specialPattern ? -1 : 0; - iVSlotIndexA[2] = specialPattern ? 0 : 1; - } - else { - iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; - iVSlotIndexA[1] = 0; - iVSlotIndexA[2] = 1; - } - ui.PlayUISFX(eSFX_Focus); - UpdateVerticalSlots(); - UpdateHighlight(); - setGroupText(GetGroupNameText(m_pGroupA[m_iGroupVIndex][m_iGroupHIndex])); - UpdateTooltips(); - break; - case ACTION_MENU_PAGEDOWN: - m_iGroupVIndex++; - if (m_iGroupVIndex >= (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupV3x3 : m_iMaxGroupV2x2)) { - m_iGroupVIndex = 0; - } - - setVGroupHighlight(m_iGroupVIndex); - - m_iCurrentSlotHIndex = 0; - m_iCurrentSlotVIndex = 1; - UpdateCraftingPanels(); - CheckRecipesAvailable(); - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - bool specialPattern = patternId >= 0 && patternId < BannerPatternRecipe::PATTERN_COUNT && - BannerPatternRecipe::PATTERNS[patternId].specialItemId != 0; - iVSlotIndexA[0] = 15; - iVSlotIndexA[1] = specialPattern ? -1 : 0; - iVSlotIndexA[2] = specialPattern ? 0 : 1; - } - else { - iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; - iVSlotIndexA[1] = 0; - iVSlotIndexA[2] = 1; - } - ui.PlayUISFX(eSFX_Focus); - UpdateVerticalSlots(); - UpdateHighlight(); - setGroupText(GetGroupNameText(m_pGroupA[m_iGroupVIndex][m_iGroupHIndex])); - UpdateTooltips(); - break; case ACTION_MENU_LEFT_SCROLL: - if (m_iGroupVIndex == eGroupVType_Workbench) { - if (m_iGroupHIndex == 0) { - m_iGroupHIndex = ((m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2) - 1); - } else { - m_iGroupHIndex--; - } - } else if (m_iGroupVIndex == eGroupVType_Banner) { - if (m_selectedBannerEdit != nullptr) { - if (m_iGroupHIndex == 1) { - m_iGroupHIndex = m_iMaxBannerGroupH3x3 - 1; - } else { - m_iGroupHIndex--; - } - } - } - - // turn on the new group - setHGroupHighlight(m_iGroupHIndex); - - m_iCurrentSlotHIndex=0; - m_iCurrentSlotVIndex=1; - UpdateCraftingPanels(); - CheckRecipesAvailable(); - // reset the vertical slots - if (m_iGroupVIndex == eGroupVType_Workbench) { - iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; - iVSlotIndexA[1] = 0; - iVSlotIndexA[2] = 1; - } else if (m_iGroupVIndex == eGroupVType_Banner) { - int patternId = m_iGroupHIndex > 0 ? m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex] : -1; - resetBannerPatternColorOptions(iVSlotIndexA, patternId); - } - ui.PlayUISFX(eSFX_Focus); - UpdateVerticalSlots(); - UpdateHighlight(); - setGroupText(GetGroupNameText(m_pGroupA[m_iGroupVIndex][m_iGroupHIndex])); - - break; case ACTION_MENU_RIGHT_SCROLL: - m_iGroupHIndex++; - if (m_iGroupVIndex == eGroupVType_Workbench) { - if (m_iGroupHIndex >= (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2)) { - m_iGroupHIndex = 0; + { + int groupCount = (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2); + if (iAction == ACTION_MENU_LEFT_SCROLL) + { + m_iGroupHIndex = (m_iGroupHIndex == 0) ? groupCount - 1 : m_iGroupHIndex - 1; } - } else if (m_iGroupVIndex == eGroupVType_Banner) { - if (m_selectedBannerEdit != nullptr) { - if (m_iGroupHIndex >= m_iMaxBannerGroupH3x3) { - m_iGroupHIndex = 1; - } - } else { - m_iGroupHIndex = 0; + else + { + m_iGroupHIndex++; + if (m_iGroupHIndex >= groupCount) m_iGroupHIndex = 0; } - } - // turn on the new group - setHGroupHighlight(m_iGroupHIndex); + setHGroupHighlight(m_iGroupHIndex); - - m_iCurrentSlotHIndex=0; - m_iCurrentSlotVIndex=1; - CheckRecipesAvailable(); - // reset the vertical slots - if (m_iGroupVIndex == eGroupVType_Workbench) { + m_iCurrentSlotHIndex=0; + m_iCurrentSlotVIndex=1; + UpdateCraftingPanels(); + CheckRecipesAvailable(); iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; iVSlotIndexA[1] = 0; iVSlotIndexA[2] = 1; - } else if (m_iGroupVIndex == eGroupVType_Banner) { - int patternId = m_iGroupHIndex > 0 ? m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex] : -1; - resetBannerPatternColorOptions(iVSlotIndexA, patternId); + ui.PlayUISFX(eSFX_Focus); + UpdateVerticalSlots(); + UpdateHighlight(); + setGroupText(GetGroupNameText(m_pGroupA[m_iGroupHIndex])); } - ui.PlayUISFX(eSFX_Focus); - UpdateVerticalSlots(); - UpdateHighlight(); - setGroupText(GetGroupNameText(m_pGroupA[m_iGroupVIndex][m_iGroupHIndex])); break; } - // 4J-Tomk - check if we've only got one vertical scroll slot (480, splits & Vita) bool bNoScrollSlots = false; if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) { @@ -779,7 +367,6 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) bNoScrollSlots = true; #endif - // 4J Stu - We did used to swap the thumsticks based on Southpaw in this scene, but ONLY in this scene switch(iAction) { case ACTION_MENU_OTHER_STICK_UP: @@ -795,23 +382,13 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) m_iCurrentSlotHIndex++; if(m_iCurrentSlotHIndex>=m_iCraftablesMaxHSlotC) m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1; - // clear the indices - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - resetBannerPatternColorOptions(iVSlotIndexA, patternId); - } else { - iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; - iVSlotIndexA[1] = 0; - iVSlotIndexA[2] = 1; - } + iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = 1; UpdateVerticalSlots(); UpdateHighlight(); - // re-enable the old hslot - //if(CanBeMadeA[iOldHSlot].iCount>0) - //{ - setShowCraftHSlot(iOldHSlot,true); - //} + setShowCraftHSlot(iOldHSlot,true); ui.PlayUISFX(eSFX_Focus); bHandled = true; } @@ -824,23 +401,13 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) if(m_iCurrentSlotHIndex==0) m_iCurrentSlotHIndex=m_iCraftablesMaxHSlotC-1; else m_iCurrentSlotHIndex--; m_iCurrentSlotVIndex=1; - // clear the indices - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - resetBannerPatternColorOptions(iVSlotIndexA, patternId); - } else { - iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; - iVSlotIndexA[1] = 0; - iVSlotIndexA[2] = 1; - } + iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = 1; UpdateVerticalSlots(); UpdateHighlight(); - // re-enable the old hslot - //if(CanBeMadeA[iOldHSlot].iCount>0) - //{ - setShowCraftHSlot(iOldHSlot,true); - //} + setShowCraftHSlot(iOldHSlot,true); ui.PlayUISFX(eSFX_Focus); } bHandled = true; @@ -848,183 +415,109 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) break; case ACTION_MENU_UP: { - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { - if (CurrentInventoryBanners.size() > 1) { - const int bannerCount = static_cast(CurrentInventoryBanners.size()); - - if (bNoScrollSlots) { - iVSlotIndexA[1] = (iVSlotIndexA[1] + bannerCount - 1) % bannerCount; - ui.PlayUISFX(eSFX_Focus); - } else { - if (bannerCount > 2) { - if (m_iCurrentSlotVIndex > 1) { - m_iCurrentSlotVIndex--; - } else { - iVSlotIndexA[2] = iVSlotIndexA[1]; - iVSlotIndexA[1] = iVSlotIndexA[0]; - iVSlotIndexA[0] = (iVSlotIndexA[0] + bannerCount - 1) % bannerCount; - - m_iCurrentSlotVIndex = bannerCount; - } - - ui.PlayUISFX(eSFX_Focus); - } else { - m_iCurrentSlotVIndex = (m_iCurrentSlotVIndex == 1) ? 2 : 1; + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) + { + if(bNoScrollSlots) + { + if(iVSlotIndexA[1]==0) + { + iVSlotIndexA[1]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; + } + else + { + iVSlotIndexA[1]--; + } + ui.PlayUISFX(eSFX_Focus); + } + else + { + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2) + { + if(m_iCurrentSlotVIndex!=0) + { + m_iCurrentSlotVIndex--; + ui.PlayUISFX(eSFX_Focus); + } + else + { + iVSlotIndexA[2]=iVSlotIndexA[1]; + iVSlotIndexA[1]=iVSlotIndexA[0]; + if(iVSlotIndexA[0]==0) + { + iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; + } + else + { + iVSlotIndexA[0]--; + } ui.PlayUISFX(eSFX_Focus); } - - UpdateVerticalSlots(); - UpdateHighlight(); } - } - } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - if (bNoScrollSlots) { - iVSlotIndexA[1] = stepBannerPatternColorOption(patternId, iVSlotIndexA[1], -1); - ui.PlayUISFX(eSFX_Focus); - } else { - if (m_iCurrentSlotVIndex > 1) { - m_iCurrentSlotVIndex--; + else + { + if(m_iCurrentSlotVIndex!=1) + { + m_iCurrentSlotVIndex--; + ui.PlayUISFX(eSFX_Focus); + } } - else { - iVSlotIndexA[1] = stepBannerPatternColorOption(patternId, iVSlotIndexA[1], -1); - iVSlotIndexA[0] = stepBannerPatternColorOption(patternId, iVSlotIndexA[1], -1); - iVSlotIndexA[2] = stepBannerPatternColorOption(patternId, iVSlotIndexA[1], 1); - } - - ui.PlayUISFX(eSFX_Focus); - UpdateVerticalSlots(); UpdateHighlight(); } - } else { - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { - if(bNoScrollSlots) { - if(iVSlotIndexA[1]==0) { - iVSlotIndexA[1]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; - } else { - iVSlotIndexA[1]--; - } - ui.PlayUISFX(eSFX_Focus); - } else { - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2) { - { - if(m_iCurrentSlotVIndex!=0) { - // just move the highlight - m_iCurrentSlotVIndex--; - ui.PlayUISFX(eSFX_Focus); - } else { - //move the slots - iVSlotIndexA[2]=iVSlotIndexA[1]; - iVSlotIndexA[1]=iVSlotIndexA[0]; - // on 0 and went up, so cycle the values - if(iVSlotIndexA[0]==0) { - iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; - } else { - iVSlotIndexA[0]--; - } - ui.PlayUISFX(eSFX_Focus); - } - } - } else { - if(m_iCurrentSlotVIndex!=1) { - // just move the highlight - m_iCurrentSlotVIndex--; - ui.PlayUISFX(eSFX_Focus); - } - } - UpdateVerticalSlots(); - UpdateHighlight(); - } - } } } break; case ACTION_MENU_DOWN: { - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { - if(CurrentInventoryBanners.size()>1) { - if (bNoScrollSlots) { - iVSlotIndexA[1] = (iVSlotIndexA[1] + 1) % CurrentInventoryBanners.size(); - ui.PlayUISFX(eSFX_Focus); - } else { - const int bannerCount = static_cast(CurrentInventoryBanners.size()); - - if (bannerCount > 2) { - if (m_iCurrentSlotVIndex < 2) { - m_iCurrentSlotVIndex++; - } else { - iVSlotIndexA[0] = iVSlotIndexA[1]; - iVSlotIndexA[1] = iVSlotIndexA[2]; - iVSlotIndexA[2] = (iVSlotIndexA[2] + 1) % bannerCount; - - m_iCurrentSlotVIndex = 1; - } - - ui.PlayUISFX(eSFX_Focus); - } else { - m_iCurrentSlotVIndex = (m_iCurrentSlotVIndex == 1) ? 2 : 1; + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) + { + if(bNoScrollSlots) + { + if(iVSlotIndexA[1]==(CanBeMadeA[m_iCurrentSlotHIndex].iCount-1)) + { + iVSlotIndexA[1]=0; + } + else + { + iVSlotIndexA[1]++; + } + ui.PlayUISFX(eSFX_Focus); + } + else + { + if (CanBeMadeA[m_iCurrentSlotHIndex].iCount > 2) + { + if (m_iCurrentSlotVIndex != 2) + { + m_iCurrentSlotVIndex++; + ui.PlayUISFX(eSFX_Focus); + } + else + { + iVSlotIndexA[0] = iVSlotIndexA[1]; + iVSlotIndexA[1] = iVSlotIndexA[2]; + if (iVSlotIndexA[m_iCurrentSlotVIndex] == (CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1)) + { + iVSlotIndexA[2] = 0; + } + else + { + iVSlotIndexA[2]++; + } ui.PlayUISFX(eSFX_Focus); } - - UpdateVerticalSlots(); - UpdateHighlight(); } - } - } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - if (bNoScrollSlots) { - iVSlotIndexA[1] = stepBannerPatternColorOption(patternId, iVSlotIndexA[1], 1); - ui.PlayUISFX(eSFX_Focus); - } else { - if (m_iCurrentSlotVIndex < 1) { - m_iCurrentSlotVIndex++; + else + { + if (m_iCurrentSlotVIndex != (CanBeMadeA[m_iCurrentSlotHIndex].iCount)) + { + m_iCurrentSlotVIndex++; + ui.PlayUISFX(eSFX_Focus); + } } - else { - iVSlotIndexA[1] = stepBannerPatternColorOption(patternId, iVSlotIndexA[1], 1); - iVSlotIndexA[0] = stepBannerPatternColorOption(patternId, iVSlotIndexA[1], -1); - iVSlotIndexA[2] = stepBannerPatternColorOption(patternId, iVSlotIndexA[1], 1); - } - - ui.PlayUISFX(eSFX_Focus); - UpdateVerticalSlots(); UpdateHighlight(); } - } else { - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { - if(bNoScrollSlots) { - if(iVSlotIndexA[1]==(CanBeMadeA[m_iCurrentSlotHIndex].iCount-1)) { - iVSlotIndexA[1]=0; - } else { - iVSlotIndexA[1]++; - } - ui.PlayUISFX(eSFX_Focus); - } else { - if (CanBeMadeA[m_iCurrentSlotHIndex].iCount > 2) { - if (m_iCurrentSlotVIndex != 2) { - m_iCurrentSlotVIndex++; - ui.PlayUISFX(eSFX_Focus); - } else { - iVSlotIndexA[0] = iVSlotIndexA[1]; - iVSlotIndexA[1] = iVSlotIndexA[2]; - if (iVSlotIndexA[m_iCurrentSlotVIndex] == (CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1)) { - iVSlotIndexA[2] = 0; - } else { - iVSlotIndexA[2]++; - } - ui.PlayUISFX(eSFX_Focus); - } - } else { - if (m_iCurrentSlotVIndex != (CanBeMadeA[m_iCurrentSlotHIndex].iCount)) { - m_iCurrentSlotVIndex++; - ui.PlayUISFX(eSFX_Focus); - } - } - UpdateVerticalSlots(); - UpdateHighlight(); - } - } } } break; @@ -1033,277 +526,65 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) return bHandled; } -bool IUIScene_CraftingMenu::hasItem(int id, int requiredCount, int aux) -{ - if (!m_pPlayer || !m_pPlayer->inventory) return false; - - int count = 0; - - for (unsigned int i = 0; i < m_pPlayer->inventory->items.length; ++i) { - const auto& item = m_pPlayer->inventory->items[i]; - - if (item == nullptr || item->id != id) continue; - - if (aux != -1 && item->getAuxValue() != aux) continue; - - count += item->count; - - if (count >= requiredCount) return true; - } - - return false; -} - -void IUIScene_CraftingMenu::rebuildPreviewItem() { - m_bannerPreviewHolder = ItemInstance::clone(m_selectedBannerEdit); - - for (PreviewBannerData& data : m_bannerPreviewData) { - BannerPatternRecipe::addBannerPattern(m_bannerPreviewHolder, BannerPatternRecipe::PATTERNS[data.id].id, data.color); - } -} - -int IUIScene_CraftingMenu::hasItemCounts(int id, int requiredCount, int aux) -{ - if (!m_pPlayer || !m_pPlayer->inventory) return 0; - - int count = 0; - - for (unsigned int i = 0; i < m_pPlayer->inventory->items.length; ++i) { - const auto& item = m_pPlayer->inventory->items[i]; - - if (item == nullptr || item->id != id) continue; - - if (aux != -1 && item->getAuxValue() != aux) continue; - - count += item->count; - - if (requiredCount != -1 && count >= requiredCount) return count; - } - - return count; -} - -bool IUIScene_CraftingMenu::canCraftPattern(const BannerPatternRecipe::PatternInfo& pattern, char color) { - - if (pattern.specialItemId != 0) { - return hasItem(pattern.specialItemId, 1, pattern.specialItemAux) && (color < 0 || hasItem(Item::dye_Id, 1, color)); - } else { - int requiredDye = 0; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - if (pattern.rows[row][col] != ' ') ++requiredDye; - } - } - - if (hasItem(Item::dye_Id, requiredDye, color)) return true; - } - - return false; -} - -bool IUIScene_CraftingMenu::hasResourcesForBannerPatterns(const vector& patterns) -{ - if (m_selectedBannerEdit == nullptr || !hasItem(Tile::standing_banner_Id)) return false; - - struct RequiredSpecialItem - { - int itemId; - int aux; - int count; - }; - - int requiredDyes[16] = {}; - vector requiredSpecialItems; - for (const PreviewBannerData& data : patterns) - { - if (data.id < 0 || data.id >= BannerPatternRecipe::PATTERN_COUNT) return false; - - const BannerPatternRecipe::PatternInfo& pattern = BannerPatternRecipe::PATTERNS[data.id]; - if (pattern.specialItemId != 0) - { - bool found = false; - for (RequiredSpecialItem& required : requiredSpecialItems) - { - if (required.itemId == pattern.specialItemId && required.aux == pattern.specialItemAux) - { - ++required.count; - found = true; - break; - } - } - if (!found) requiredSpecialItems.push_back({ pattern.specialItemId, pattern.specialItemAux, 1 }); - - if (data.color >= 0) - { - if (data.color >= 16) return false; - ++requiredDyes[data.color]; - } - } - else - { - if (data.color < 0 || data.color >= 16 || pattern.rows[0] == nullptr) return false; - for (int row = 0; row < 3; ++row) - { - for (int col = 0; col < 3; ++col) - { - if (pattern.rows[row][col] != ' ') ++requiredDyes[data.color]; - } - } - } - } - - for (const RequiredSpecialItem& required : requiredSpecialItems) - { - if (!hasItem(required.itemId, required.count, required.aux)) return false; - } - for (int color = 0; color < 16; ++color) - { - if (requiredDyes[color] > 0 && !hasItem(Item::dye_Id, requiredDyes[color], color)) return false; - } - - return true; -} - -static inline bool DoesPatternHaveVertical(int id) { - return true; -} - -////////////////////////////////////////////////////////////////////////// -// -// CheckRecipesAvailable -// -////////////////////////////////////////////////////////////////////////// void IUIScene_CraftingMenu::CheckRecipesAvailable() { + if (isSpecialTab()) + { + Special_CheckRecipesAvailable(); + return; + } + int iHSlotBrushControl=0; - // clear the current list memset(CanBeMadeA,0,sizeof(CANBEMADE)*m_iCraftablesMaxHSlotC); - CurrentInventoryBanners.clear(); hideAllHSlots(); if(m_pPlayer && m_pPlayer->inventory) { - for (unsigned int k = 0; k < m_pPlayer->inventory->items.length; k++) { - if (m_pPlayer->inventory->items[k] != nullptr) { - if (m_pPlayer->inventory->items[k]->id == Tile::standing_banner_Id) { - if (BannerPatternRecipe::getBannerPatternCount(m_pPlayer->inventory->items[k]) >= 6) continue; - - CurrentInventoryBanners.push_back(m_pPlayer->inventory->items[k]); - } - } - } - - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - for (int i = 0; i < 12; i++) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex-1][i]; - if (patternId == -1) continue; - - BannerPatternRecipe::PatternInfo pattern = BannerPatternRecipe::PATTERNS[patternId]; - int colorIndex = pattern.specialItemId != 0 ? -1 : DyePowderItem::BLACK; - bool canCraft = canCraftPattern(pattern, colorIndex) || (app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)); - setCraftHSlotItem(getPad(), i, BannerPatternRecipe::createBannerWithPattern(pattern.id, colorIndex), canCraft ? 31 : 16); - } - return; - } - - // dump out the inventory - /* for (unsigned int k = 0; k < m_pPlayer->inventory->items.length; k++) - { - if (m_pPlayer->inventory->items[k] != nullptr) - { - wstring itemstring=m_pPlayer->inventory->items[k]->toString(); - - //printf("--- Player has "); - OutputDebugStringW(itemstring.c_str()); - //printf(" with Aux val = %d, base type = %d, Material = %d\n",m_pPlayer->inventory->items[k]->getAuxValue(),m_pPlayer->inventory->items[k]->getItem()->getBaseItemType(),m_pPlayer->inventory->items[k]->getItem()->getMaterial()); - } - } - */ RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); int iRecipeC=static_cast(recipes->size()); - auto itRecipe = recipes->begin(); - - // dump out the recipe products - - // for (int i = 0; i < iRecipeC; i++) - // { - // shared_ptr pTempItemInst=pRecipeIngredientsRequired[i].pRecipy->assemble(nullptr); - // if (pTempItemInst != nullptr) - // { - // wstring itemstring=pTempItemInst->toString(); - // - // printf("Recipe [%d] = ",i); - // OutputDebugStringW(itemstring.c_str()); - // if(pTempItemInst->id!=0) - // { - // if(pTempItemInst->id<256) - // { - // Tile *pTile=Tile::tiles[pTempItemInst->id]; - // printf("[TILE] ID\t%d\tAux val\t%d\tBase type\t%d\tMaterial\t%d\t Count=%d\n",pTempItemInst->id, pTempItemInst->getAuxValue(),pTile->getBaseItemType(),pTile->getMaterial(),pTempItemInst->GetCount()); - // } - // else - // { - // printf("ID\t%d\tAux val\t%d\tBase type\t%d\tMaterial\t%d Count=%d\n",pTempItemInst->id, pTempItemInst->getAuxValue(),pTempItemInst->getItem()->getBaseItemType(),pTempItemInst->getItem()->getMaterial(),pTempItemInst->GetCount()); - // } - // - // } - // } - // } + auto itRecipe = recipes->begin(); for(int i=0;igetGroup()!=m_pGroupA[m_iGroupVIndex][m_iGroupHIndex]) + if(r->getGroup()!=m_pGroupA[m_iGroupHIndex]) { itRecipe++; pRecipeIngredientsRequired[i].bCanMake[getPad()]=false; continue; } - // if we are in the inventory menu, then we have 2x2 crafting available only if((m_iContainerType==RECIPE_TYPE_2x2) && (pRecipeIngredientsRequired[i].iType==RECIPE_TYPE_3x3)) { - // need a crafting table for this recipe itRecipe++; pRecipeIngredientsRequired[i].bCanMake[getPad()]=false; continue; } - // clear the mask showing which ingredients are missing pRecipeIngredientsRequired[i].usBitmaskMissingGridIngredients[getPad()]=0; - //bool bCanMakeRecipe=true; bool *bFoundA= new bool [pRecipeIngredientsRequired[i].iIngC]; for(int j=0;jinventory->items.length; k++) { if (m_pPlayer->inventory->items[k] != nullptr) { - // do they have the ingredient, and the aux value matches, and enough off it? if((m_pPlayer->inventory->items[k]->id == pRecipeIngredientsRequired[i].iIngIDA[j]) && - // check if the ingredient required doesn't care about the aux value, or if it does, does the inventory item aux match it ((pRecipeIngredientsRequired[i].iIngAuxValA[j]==Recipes::ANY_AUX_VALUE) || (pRecipeIngredientsRequired[i].iIngAuxValA[j]==m_pPlayer->inventory->items[k]->getAuxValue())) ) { - // do they have enough? We need to check the whole inventory, since they may have enough in different slots (milk isn't milkx3, but milk,milk,milk) if(m_pPlayer->inventory->items[k]->GetCount()>=pRecipeIngredientsRequired[i].iIngValA[j]) { - // they have enough with one slot bFoundA[j]=true; } else { - // look at the combined value from the whole inventory - for(unsigned int l=0;linventory->items.length;l++) { if (m_pPlayer->inventory->items[l] != nullptr) @@ -1323,25 +604,19 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() bFoundA[j]=true; } } - - // 4J Stu - TU-1 hotfix - // Fix for #13143 - Players are able to craft items they do not have enough ingredients for if they store the ingredients in multiple, smaller stacks break; } } } - // if bFoundA[j] is false, then we didn't have enough of the ingredient required by the recipe, so mark the grid items we're short of if(bFoundA[j]==false) { int iMissing = pRecipeIngredientsRequired[i].iIngValA[j]-iTotalCount; int iGridIndex=0; while(iMissing!=0 && iGridIndex<9) { - // need to check if there is an aux val and match that if(((pRecipeIngredientsRequired[i].uiGridA[iGridIndex]&0x00FFFFFF)==pRecipeIngredientsRequired[i].iIngIDA[j]) && ((pRecipeIngredientsRequired[i].iIngAuxValA[j]==Recipes::ANY_AUX_VALUE) ||((pRecipeIngredientsRequired[i].iIngAuxValA[j]&0xFF)== ((pRecipeIngredientsRequired[i].uiGridA[iGridIndex]&0xFF000000)>>24))) ) { - // this grid entry is the ingredient we don't have enough of pRecipeIngredientsRequired[i].usBitmaskMissingGridIngredients[getPad()]|=1< pTempItemInst=pRecipeIngredientsRequired[i].pRecipy->assemble(nullptr); - //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); int iID=pTempItemInst->getItem()->id; int iBaseType; - if(iID<256) // is it a tile? + if(iID<256) { iBaseType=Tile::tiles[iID]->getBaseItemType(); } @@ -1381,24 +653,17 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() iBaseType=pTempItemInst->getItem()->getBaseItemType(); } - // ignore for the misc base type - these have not been placed in a base type group if(iBaseType!=Item::eBaseItemType_undefined) { for(int k=0;kgetDescriptionId())); -#endif - app.DebugPrintf("\n"); - - } } } - else - { - app.DebugPrintf("Need more HSlots\n"); - } delete [] bFoundA; itRecipe++; } } - // run through the canbemade list and update the icons displayed int iIndex=0; - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); while((iIndex pTempItemInst=pRecipeIngredientsRequired[CanBeMadeA[iIndex].iRecipeA[0]].pRecipy->assemble(nullptr); - assert(pTempItemInst->id!=0); unsigned int uiAlpha; - if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<id == Item::clock_Id || pTempItemInst->id == Item::compass_Id ) { pTempItemInst->setAuxValue( 255 ); @@ -1471,104 +710,57 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() iIndex++; } +} - // 4J-PB - Removed - UpdateTooltips will do this - // Update tooltips - /*if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) +void IUIScene_CraftingMenu::UpdateHighlight() +{ + if (isSpecialTab()) { - ui.ShowTooltip( getPad(), eToolTipButtonA, true ); - // 4J-PB - not implemented ! - //ui.EnableTooltip( getPad(), eToolTipButtonA, true ); + Special_UpdateHighlight(); + return; + } + + updateHighlightAndScrollPositions(); + + bool bCanBeMade = CanBeMadeA[m_iCurrentSlotHIndex].iCount != 0; + if (bCanBeMade) + { + Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); + int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount > 1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; + shared_ptr pTempItemInstAdditional = pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].pRecipy->assemble(nullptr); + + int id = pTempItemInstAdditional->getDescriptionId(); + wstring itemstring; + + switch (id) + { + case IDS_TILE_TORCH: + if (pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].iIngAuxValA[0] == 1) + itemstring = app.GetString(IDS_TILE_TORCHCHARCOAL); + else + itemstring = app.GetString(IDS_TILE_TORCHCOAL); + break; + case IDS_ITEM_FIREBALL: + if (pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].iIngAuxValA[2] == 1) + itemstring = app.GetString(IDS_ITEM_FIREBALLCHARCOAL); + else + itemstring = app.GetString(IDS_ITEM_FIREBALLCOAL); + break; + default: + if (pTempItemInstAdditional->hasCustomHoverName()) + itemstring = pTempItemInstAdditional->getHoverName(); + else + itemstring = app.GetString(id); + break; + } + + setItemText(itemstring.c_str()); } else { - ui.ShowTooltip( getPad(), eToolTipButtonA, false ); - }*/ -} - -////////////////////////////////////////////////////////////////////////// -// -// UpdateHighlight -// -////////////////////////////////////////////////////////////////////////// -void IUIScene_CraftingMenu::UpdateHighlight() -{ - updateHighlightAndScrollPositions(); - - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { - if (CurrentInventoryBanners.size() > 0) { - wstring selectedBannerName = CurrentInventoryBanners[m_iCurrentSlotVIndex - 1]->getHoverName(); - setItemText(selectedBannerName.c_str()); - setDescriptionText(selectedBannerName.c_str()); - } - } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { setItemText(L""); - setDescriptionText(L""); - }else { - bool bCanBeMade = CanBeMadeA[m_iCurrentSlotHIndex].iCount != 0; - if (bCanBeMade) - { - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); - Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); - int iSlot; - if (CanBeMadeA[m_iCurrentSlotHIndex].iCount > 1) - { - iSlot = iVSlotIndexA[m_iCurrentSlotVIndex]; - } - else - { - iSlot = 0; - } - shared_ptr pTempItemInstAdditional = pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].pRecipy->assemble(nullptr); - - // special case for the torch coal/charcoal - int id = pTempItemInstAdditional->getDescriptionId(); - wstring itemstring; - - switch (id) - { - case IDS_TILE_TORCH: - { - if (pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].iIngAuxValA[0] == 1) - { - itemstring = app.GetString(IDS_TILE_TORCHCHARCOAL); - } - else - { - itemstring = app.GetString(IDS_TILE_TORCHCOAL); - } - } - break; - case IDS_ITEM_FIREBALL: - { - if (pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].iIngAuxValA[2] == 1) - { - itemstring = app.GetString(IDS_ITEM_FIREBALLCHARCOAL); - } - else - { - itemstring = app.GetString(IDS_ITEM_FIREBALLCOAL); - } - } - break; - default: - if (pTempItemInstAdditional->hasCustomHoverName()) { - itemstring = pTempItemInstAdditional->getHoverName(); - } - else { - itemstring = app.GetString(id); - } - break; - } - - setItemText(itemstring.c_str()); - } - else - { - setItemText(L""); - } - UpdateDescriptionText(bCanBeMade); } + UpdateDescriptionText(bCanBeMade); DisplayIngredients(); UpdateMultiPanel(); @@ -1576,508 +768,238 @@ void IUIScene_CraftingMenu::UpdateHighlight() UpdateTooltips(); } -////////////////////////////////////////////////////////////////////////// -// -// UpdateVerticalSlots -// -////////////////////////////////////////////////////////////////////////// void IUIScene_CraftingMenu::UpdateVerticalSlots() { - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + if (isSpecialTab()) + { + Special_UpdateVerticalSlots(); + return; + } + Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); - // update the vertical items for the current horizontal slot hideAllVSlots(); - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - if (patternId != -1 && DoesPatternHaveVertical(patternId)) { - setShowCraftHSlot(m_iCurrentSlotHIndex, false); - const BannerPatternRecipe::PatternInfo& pattern = BannerPatternRecipe::PATTERNS[patternId]; + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) + { + setShowCraftHSlot(m_iCurrentSlotHIndex,false); + int iSlots=(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2)?3:2; - bool bNoScrollSlots = false; - if (m_bSplitscreen || (!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) - { - bNoScrollSlots = true; - } - - for (int i = 0; i < 3; i++) { - if (bNoScrollSlots) { - if (i != 1) continue; - } - - int colorIndex = iVSlotIndexA[i]; - - bool canCraft = canCraftPattern(pattern, colorIndex) || (app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)); - setCraftVSlotItem(getPad(), i, BannerPatternRecipe::createBannerWithPattern(pattern.id, colorIndex), canCraft ? 31 : 16); - updateVSlotPositions(3, i); - } - } - } else { - - // could have either 1 or 2 vertical slots, above and below the horizontal slot - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) + bool bNoScrollSlots = false; + if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) { - // turn off the horizontal one since we could be cycling through others - setShowCraftHSlot(m_iCurrentSlotHIndex,false); - int iSlots=(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2)?3:2; - - // 4J-Tomk - check if we've only got one vertical scroll slot (480, splits & Vita) - bool bNoScrollSlots = false; - if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) - { - bNoScrollSlots = true; - } - #ifdef __PSVITA__ bNoScrollSlots = true; - #endif + } +#ifdef __PSVITA__ + bNoScrollSlots = true; +#endif - for(int i=0;i pTempItemInstAdditional=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iVSlotIndexA[i]]].pRecipy->assemble(nullptr); + + unsigned int uiAlpha; + if(isCraftAnything()) { - // 4J this check determines if the crafting scene has only one vertical scroll slot - if(bNoScrollSlots) - { - if(i!=1) continue; - } - shared_ptr pTempItemInstAdditional=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iVSlotIndexA[i]]].pRecipy->assemble(nullptr); - - assert(pTempItemInstAdditional->id!=0); - unsigned int uiAlpha; - - if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<id == Item::clock_Id || pTempItemInstAdditional->id == Item::compass_Id ) - { - pTempItemInstAdditional->setAuxValue( 255 ); - } - - setCraftVSlotItem(getPad(),i,pTempItemInstAdditional,uiAlpha); - - updateVSlotPositions(iSlots, i); + uiAlpha = 31; } + else + { + uiAlpha = pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iVSlotIndexA[i]]].bCanMake[getPad()] ? 31 : 16; + } + + if( pTempItemInstAdditional->id == Item::clock_Id || pTempItemInstAdditional->id == Item::compass_Id ) + { + pTempItemInstAdditional->setAuxValue( 255 ); + } + + setCraftVSlotItem(getPad(),i,pTempItemInstAdditional,uiAlpha); + updateVSlotPositions(iSlots, i); } } } -////////////////////////////////////////////////////////////////////////// -// -// DisplayIngredients -// -////////////////////////////////////////////////////////////////////////// void IUIScene_CraftingMenu::DisplayIngredients() { + if (isSpecialTab()) + { + Special_DisplayIngredients(); + return; + } - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { - hideAllIngredientsSlots(); + Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); - if (CurrentInventoryBanners.size() >= 1) { - auto selectedBanner = CurrentInventoryBanners[m_iCurrentSlotVIndex - 1]; + hideAllIngredientsSlots(); - setCraftingOutputSlotItem(getPad(), selectedBanner); - setCraftingOutputSlotRedBox(false); + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) + { + int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; + int iRecipy = CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; - // if it's a 2x2 , only clear the 4 m_pCraftingIngredientA slots - int iIngredientsSlots = (m_iContainerType == RECIPE_TYPE_2x2) ? 4 : m_iIngredients3x3SlotC; - for (int i = 0; i < iIngredientsSlots; i++) { - setIngredientSlotRedBox(i, false); - setIngredientSlotItem(getPad(), i, nullptr); - } + int iBoxWidth=(m_iContainerType==RECIPE_TYPE_2x2)?2:3; + int iRecipe=iRecipy; + bool bCanMakeRecipe = pRecipeIngredientsRequired[iRecipe].bCanMake[getPad()]; + shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); - int centerSlot = (m_iContainerType == RECIPE_TYPE_2x2) ? 4 : 5; - setIngredientSlotItem(getPad(), centerSlot-1, selectedBanner); - } - } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - hideAllIngredientsSlots(); + m_iIngredientsC=pRecipeIngredientsRequired[iRecipe].iIngC; - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - if (patternId != -1) { - const BannerPatternRecipe::PatternInfo& pattern = BannerPatternRecipe::PATTERNS[patternId]; - - auto whiteBanner = std::make_shared(Tile::standing_banner_Id, 1, 0); - - if (pattern.specialItemId != 0) { - const int bannerSlot = 0; - const int specialItemSlot = 1; - const int dyeSlot = 2; - const int specialAux = pattern.specialItemAux == -1 ? 0 : pattern.specialItemAux; - const int colorIndex = iVSlotIndexA[m_iCurrentSlotVIndex]; - auto specialItem = std::make_shared(pattern.specialItemId, 1, specialAux); - - for (int slot = 0; slot < 9; ++slot) { - setIngredientSlotItem(getPad(), slot, nullptr); - setIngredientSlotRedBox(slot, false); - } - setIngredientSlotItem(getPad(), bannerSlot, whiteBanner); - setIngredientSlotItem(getPad(), specialItemSlot, specialItem); - setIngredientSlotRedBox(bannerSlot, !hasItem(Tile::standing_banner_Id)); - setIngredientSlotRedBox(specialItemSlot, !hasItem(pattern.specialItemId, 1, pattern.specialItemAux)); - - if (colorIndex >= 0) { - auto dyeItem = std::make_shared(Item::dye_Id, 1, colorIndex); - setIngredientSlotItem(getPad(), dyeSlot, dyeItem); - - int dyeAlreadyConsumed = 0; - for (const PreviewBannerData& data : m_bannerPreviewData) { - if (data.color != colorIndex) continue; - const BannerPatternRecipe::PatternInfo& pendingPattern = BannerPatternRecipe::PATTERNS[data.id]; - if (pendingPattern.specialItemId != 0) { - ++dyeAlreadyConsumed; - } else if (pendingPattern.rows[0] != nullptr) { - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - if (pendingPattern.rows[row][col] != ' ') ++dyeAlreadyConsumed; - } - } - } - } - - bool hasDye = hasItemCounts(Item::dye_Id, -1, colorIndex) > dyeAlreadyConsumed; - setIngredientSlotRedBox(dyeSlot, !hasDye && !(app.DebugSettingsOn() && (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)))); - } - - setCraftingOutputSlotItem(getPad(), BannerPatternRecipe::createBannerWithPattern(pattern.id, colorIndex)); - setCraftingOutputSlotRedBox(!((canCraftPattern(pattern, colorIndex)) || (app.DebugSettingsOn() && (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything))))); - } else { - int colorIndex = iVSlotIndexA[m_iCurrentSlotVIndex]; - if (colorIndex == -1) colorIndex = DyePowderItem::BLACK; - - auto dyeItem = std::make_shared(Item::dye_Id, 1, colorIndex); - const int bannerPositions[] = { 4, 1, 7, 8, 6, 5, 3, 2, 0 }; - int bannerSlot = -1; - - for (int position : bannerPositions) { - int row = position / 3; - int col = position % 3; - if (pattern.rows[row][col] == ' ') { - bannerSlot = position; - break; - } - } - - int dyeCount = hasItemCounts(dyeItem->id, -1, dyeItem->getAuxValue()); - int dyeAlreadyConsumed = 0; - for (PreviewBannerData& data : m_bannerPreviewData) { - if (data.color != colorIndex) continue; - const BannerPatternRecipe::PatternInfo& pendingPattern = BannerPatternRecipe::PATTERNS[data.id]; - if (pendingPattern.rows[0] == nullptr) continue; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - if (pendingPattern.rows[row][col] != ' ') ++dyeAlreadyConsumed; - } - } - } - dyeCount -= dyeAlreadyConsumed; - - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - int slot = row * 3 + col; - bool enableRedSlot = false; - if (slot == bannerSlot) { - setIngredientSlotItem(getPad(), slot, whiteBanner); - } else if (pattern.rows[row][col] != ' ') { - setIngredientSlotItem(getPad(), slot, dyeItem); - if (dyeCount <= 0 && !(app.DebugSettingsOn() && (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything)))) enableRedSlot = true; - else dyeCount--; - } else { - setIngredientSlotItem(getPad(), slot, nullptr); - } - setIngredientSlotRedBox(slot, enableRedSlot); - } - } - - setCraftingOutputSlotItem(getPad(), BannerPatternRecipe::createBannerWithPattern(pattern.id, colorIndex)); - setCraftingOutputSlotRedBox(!((canCraftPattern(pattern, colorIndex)) || (app.DebugSettingsOn() && (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & (1L << eDebugSetting_CraftAnything))))); - } - } else { - setCraftingOutputSlotItem(getPad(), nullptr); - setCraftingOutputSlotRedBox(false); - } - } else { - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); - Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); - - // hide the previous ingredients - hideAllIngredientsSlots(); - - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) + for(int i=0;i1) + int id=pRecipeIngredientsRequired[iRecipe].iIngIDA[i]; + int iAuxVal=pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]; + Item *item = Item::items[id]; + + shared_ptr itemInst= std::make_shared(item, pRecipeIngredientsRequired[iRecipe].iIngValA[i], iAuxVal); + + int idescID; + + if( ((pTempItemInst->id==Item::bed_Id) &&(id==Tile::wool_Id)) || + ((pTempItemInst->id==Item::painting_Id) &&(id==Tile::wool_Id)) ) { - iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; - iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; + idescID=IDS_ANY_WOOL; + } + else if((pTempItemInst->id==Item::firework_charge_Id) && (id==Item::dye_Id)) + { + idescID=IDS_ITEM_DYE_POWDER; + iAuxVal = 1; } else { - iSlot=0; - iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[0]; + idescID=itemInst->getDescriptionId(); } + setIngredientDescriptionText(i,app.GetString(idescID)); - // show the 2x2 or 3x3 to make the current item - int iBoxWidth=(m_iContainerType==RECIPE_TYPE_2x2)?2:3; - int iRecipe=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; - bool bCanMakeRecipe = pRecipeIngredientsRequired[iRecipe].bCanMake[getPad()]; - shared_ptr pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); + if( (iAuxVal & 0xFF) == 0xFF) + iAuxVal = 0; - m_iIngredientsC=pRecipeIngredientsRequired[iRecipe].iIngC; - - // update the ingredients required - these will all be hidden until cycled by the user - for(int i=0;i itemInst= std::make_shared(item, pRecipeIngredientsRequired[iRecipe].iIngValA[i], iAuxVal); - - // 4J-PB - a very special case - the bed can use any kind of wool, so we can't use the item description - // and the same goes for the painting - int idescID; - - if( ((pTempItemInst->id==Item::bed_Id) &&(id==Tile::wool_Id)) || - ((pTempItemInst->id==Item::painting_Id) &&(id==Tile::wool_Id)) ) - { - idescID=IDS_ANY_WOOL; - } - else if((pTempItemInst->id==Item::firework_charge_Id) && (id==Item::dye_Id)) - { - idescID=IDS_ITEM_DYE_POWDER; - iAuxVal = 1; - } - else - { - idescID=itemInst->getDescriptionId(); - } - setIngredientDescriptionText(i,app.GetString(idescID)); - - - if( (iAuxVal & 0xFF) == 0xFF) // 4J Stu - If the aux value is set to match any - iAuxVal = 0; - - // 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture - // rather than the dynamic one for the player - if( id == Item::clock_Id || id == Item::compass_Id ) - { - iAuxVal = 0xFF; - } - itemInst->setAuxValue(iAuxVal); - - setIngredientDescriptionItem(getPad(),i,itemInst); - setIngredientDescriptionRedBox(i,false); + iAuxVal = 0xFF; } + itemInst->setAuxValue(iAuxVal); - // 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture - // rather than the dynamic one for the player - if( pTempItemInst->id == Item::clock_Id || pTempItemInst->id == Item::compass_Id ) - { - pTempItemInst->setAuxValue( 255 ); - } + setIngredientDescriptionItem(getPad(),i,itemInst); + setIngredientDescriptionRedBox(i,false); + } - // don't grey out the output icon - setCraftingOutputSlotItem(getPad(), pTempItemInst); + if( pTempItemInst->id == Item::clock_Id || pTempItemInst->id == Item::compass_Id ) + { + pTempItemInst->setAuxValue( 255 ); + } - if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<>24; + for (int k = 0; k < pRecipeIngredientsRequired[iRecipy].iIngC; k++) { - int id=pRecipeIngredientsRequired[iRecipy].uiGridA[x+y*3]&0x00FFFFFF; - assert(id!=0); - int iAuxVal=(pRecipeIngredientsRequired[iRecipy].uiGridA[x+y*3]&0xFF000000)>>24; - for (int k = 0; k < pRecipeIngredientsRequired[iRecipy].iIngC; k++) + int fullAux = pRecipeIngredientsRequired[iRecipy].iIngAuxValA[k]; + if (pRecipeIngredientsRequired[iRecipy].iIngIDA[k] == id && fullAux != Recipes::ANY_AUX_VALUE && (fullAux & 0xFF) == iAuxVal) { - int fullAux = pRecipeIngredientsRequired[iRecipy].iIngAuxValA[k]; - if (pRecipeIngredientsRequired[iRecipy].iIngIDA[k] == id && fullAux != Recipes::ANY_AUX_VALUE && (fullAux & 0xFF) == iAuxVal) - { - iAuxVal = fullAux; - break; - } + iAuxVal = fullAux; + break; } + } - // 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture - // rather than the dynamic one for the player - if( id == Item::clock_Id || id == Item::compass_Id ) - { - iAuxVal = 0xFF; - } - else if( pTempItemInst->id==Item::firework_charge_Id && id == Item::dye_Id) - { - iAuxVal = 1; - } - shared_ptr itemInst= std::make_shared(id, 1, iAuxVal); - setIngredientSlotItem(getPad(),index,itemInst); - // show the ingredients we don't have if we can't make the recipe - if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<id==Item::firework_charge_Id && id == Item::dye_Id) + { + iAuxVal = 1; + } + shared_ptr itemInst= std::make_shared(id, 1, iAuxVal); + setIngredientSlotItem(getPad(),index,itemInst); + if(isCraftAnything()) + { + setIngredientSlotRedBox(index, false); } else { - setIngredientSlotRedBox(index, false); - setIngredientSlotItem(getPad(),index,nullptr); + setIngredientSlotRedBox(index, (pRecipeIngredientsRequired[iRecipy].usBitmaskMissingGridIngredients[getPad()]&(1<<(x+y*3)))!=0); } } + else + { + setIngredientSlotRedBox(index, false); + setIngredientSlotItem(getPad(),index,nullptr); + } } } - else - { - setCraftingOutputSlotItem(getPad(), nullptr); - setCraftingOutputSlotRedBox(false); - m_iIngredientsC=0; - int iIngredientsSlots; - // if it's a 2x2 , only clear the 4 m_pCraftingIngredientA slots - if(m_iContainerType==RECIPE_TYPE_2x2) - { - iIngredientsSlots=4; - } - else - { - iIngredientsSlots=m_iIngredients3x3SlotC; - } + } + else + { + setCraftingOutputSlotItem(getPad(), nullptr); + setCraftingOutputSlotRedBox(false); + m_iIngredientsC=0; + int iIngredientsSlots = (m_iContainerType==RECIPE_TYPE_2x2) ? 4 : m_iIngredients3x3SlotC; - for(int i=0;igetRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); if(bCanBeMade) { - int iSlot;//,iRecipy; - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) - { - iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; - //iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; - } - else - { - iSlot=0; - //iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[0]; - } + int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; shared_ptr pTempItemInst=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].pRecipy->assemble(nullptr); int iID=pTempItemInst->getItem()->id; int iAuxVal=pTempItemInst->getAuxValue(); int iBaseType; - if(iID<256) // is it a tile? + if(iID<256) { iBaseType=Tile::tiles[iID]->getBaseItemType(); - iIDSString = Tile::tiles[iID]->getUseDescriptionId(); } else { iBaseType=pTempItemInst->getItem()->getBaseItemType(); - iIDSString = pTempItemInst->getUseDescriptionId(); } - // A few special cases where the description required is specific to crafting, rather than the normal description - if(iBaseType!=Item::eBaseItemType_undefined) + if(iBaseType==Item::eBaseItemType_cloth && iAuxVal==0) { - switch(iBaseType) - { - case Item::eBaseItemType_cloth: - switch(iAuxVal) - { - case 0: - iIDSString=IDS_DESC_WOOLSTRING; - break; - } - break; - } + iIDSString=IDS_DESC_WOOLSTRING; } - // set the string mapped to by the base object mapping array - if(iIDSString>=0) { - // this is an html control now, so set the font size and colour - //wstring wsText=app.GetString(iIDSString); wstring wsText=app.FormatHTMLString(getPad(),app.GetString(iIDSString)); - - // 12 for splitscreen, 14 for normal - EHTMLFontSize size = eHTMLSize_Normal; - if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) - { - size = eHTMLSize_Splitscreen; - } wchar_t startTags[64]; swprintf(startTags,64,L"

",app.GetHTMLColour(eHTMLColor_Black)); wsText= startTags + wsText + L"

"; - setDescriptionText(wsText.c_str()); } else { - /// Missing string! -#ifdef _DEBUG - setDescriptionText(L"This is some placeholder description text about the craftable item."); -#else setDescriptionText(L""); -#endif } } else @@ -2086,118 +1008,37 @@ void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) } } -////////////////////////////////////////////////////////////////////////// -// -// UpdateTooltips -// -////////////////////////////////////////////////////////////////////////// void IUIScene_CraftingMenu::UpdateTooltips() { - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { - ui.SetTooltips(getPad(), -1, IDS_TOOLTIPS_EXIT, -1, IDS_TOOLTIPS_SELECT, -1, -1, -1, -1); - } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - int tooltipA = -1; - int tooltipX = -1; - int tooltipY = -1; - - if (m_selectedBannerEdit != nullptr && !m_bannerPreviewData.empty()) - { - tooltipA = IDS_TOOLTIPS_CREATE; - } - if (m_selectedBannerEdit != nullptr) tooltipX = IDS_TOOLTIPS_REMOVE; - - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - if (m_selectedBannerEdit != nullptr && patternId != -1 && - (BannerPatternRecipe::getBannerPatternCount(m_selectedBannerEdit) + m_bannerPreviewData.size()) < 6) - { - PreviewBannerData data(patternId, iVSlotIndexA[m_iCurrentSlotVIndex]); - vector previewData = m_bannerPreviewData; - previewData.emplace_back(data); - if (hasResourcesForBannerPatterns(previewData)) tooltipY = IDS_TOOLTIPS_ADD; - } - - ui.SetTooltips(getPad(), tooltipA, IDS_TOOLTIPS_EXIT, tooltipX, tooltipY, -2, IDS_TOOLTIPS_CHANGE_TYPE, -2, IDS_TOOLTIPS_CHANGE_GROUP); - } else { - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); - Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); - // Update tooltips - - bool bDisplayCreate; - - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) - { - int iSlot; - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) - { - iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; - } - else - { - iSlot=0; - } - - if(pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].bCanMake[getPad()]) - { - bDisplayCreate=true; - } - else - { - bDisplayCreate=false; - } - } - else - { - bDisplayCreate=false; - } - - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 0) { - ui.SetTooltips(getPad(), bDisplayCreate ? IDS_TOOLTIPS_CREATE : -1, IDS_TOOLTIPS_EXIT, -1, -1, (m_iContainerType == RECIPE_TYPE_3x3) ? -2 : -1, (m_iContainerType == RECIPE_TYPE_3x3) ? IDS_TOOLTIPS_CHANGE_TYPE : -1, -1, -1); - } else { - switch(m_iDisplayDescription) - { - case DISPLAY_INVENTORY: - ui.SetTooltips( getPad(), bDisplayCreate?IDS_TOOLTIPS_CREATE:-1,IDS_TOOLTIPS_EXIT, IDS_TOOLTIPS_SHOW_DESCRIPTION,-1, (m_iContainerType==RECIPE_TYPE_3x3)?-2:-1,(m_iContainerType==RECIPE_TYPE_3x3)?IDS_TOOLTIPS_CHANGE_TYPE:-1,-2, IDS_TOOLTIPS_CHANGE_GROUP); - break; - case DISPLAY_DESCRIPTION: - ui.SetTooltips( getPad(), bDisplayCreate?IDS_TOOLTIPS_CREATE:-1,IDS_TOOLTIPS_EXIT, IDS_TOOLTIPS_SHOW_INGREDIENTS,-1,(m_iContainerType==RECIPE_TYPE_3x3)?-2:-1,(m_iContainerType==RECIPE_TYPE_3x3)?IDS_TOOLTIPS_CHANGE_TYPE:-1,-2, IDS_TOOLTIPS_CHANGE_GROUP); - break; - case DISPLAY_INGREDIENTS: - ui.SetTooltips( getPad(), bDisplayCreate?IDS_TOOLTIPS_CREATE:-1,IDS_TOOLTIPS_EXIT, IDS_TOOLTIPS_SHOW_INVENTORY,-1,(m_iContainerType==RECIPE_TYPE_3x3)?-2:-1,(m_iContainerType==RECIPE_TYPE_3x3)?IDS_TOOLTIPS_CHANGE_TYPE:-1,-2, IDS_TOOLTIPS_CHANGE_GROUP); - break; - } - } - - /*if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) - { - int iSlot; - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) - { - iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; - } - else - { - iSlot=0; - } - - if(pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].bCanMake[getPad()]) - { - ui.EnableTooltip( getPad(), eToolTipButtonA, true ); - } - else - { - ui.EnableTooltip( getPad(), eToolTipButtonA, false ); - } - } - else - { - ui.ShowTooltip( getPad(), eToolTipButtonA, false ); - }*/ + if (isSpecialTab()) + { + Special_UpdateTooltips(); + return; } + + Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); + + bool bDisplayCreate = false; + + if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) + { + int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; + bDisplayCreate = pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].bCanMake[getPad()]; + } + + int showNext = IDS_TOOLTIPS_SHOW_DESCRIPTION; + if (m_iDisplayDescription == DISPLAY_DESCRIPTION) showNext = IDS_TOOLTIPS_SHOW_INGREDIENTS; + else if (m_iDisplayDescription == DISPLAY_INGREDIENTS) showNext = IDS_TOOLTIPS_SHOW_INVENTORY; + + ui.SetTooltips( getPad(), bDisplayCreate?IDS_TOOLTIPS_CREATE:-1,IDS_TOOLTIPS_EXIT, showNext,-1, -2, IDS_TOOLTIPS_CHANGE_TYPE, -2, IDS_TOOLTIPS_CHANGE_GROUP); } void IUIScene_CraftingMenu::HandleInventoryUpdated() { - // Check which recipes are available with the resources we have + if (isSpecialTab()) + { + Special_RefreshBaseItemSlots(nullptr); + } CheckRecipesAvailable(); UpdateVerticalSlots(); UpdateHighlight(); @@ -2206,23 +1047,22 @@ void IUIScene_CraftingMenu::HandleInventoryUpdated() bool IUIScene_CraftingMenu::isItemSelected(int itemId) { + if (isSpecialTab()) + { + int recipe = Special_GetSelectedRecipe(); + if (recipe < 0) return false; + shared_ptr result = m_specialRecipes[recipe].result; + return result != nullptr && result->id == itemId; + } + bool isSelected = false; if(m_pPlayer && m_pPlayer->inventory) { - //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { - int iSlot; - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) - { - iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; - } - else - { - iSlot=0; - } + int iSlot = (CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; ItemInstance *pTempItemInst = (ItemInstance *)pRecipeIngredientsRequired[iRecipe].pRecipy->getResultItem(); diff --git a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.h b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.h index ea06ff0c..ee08c587 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.h +++ b/Minecraft.Client/Common/UI/IUIScene_CraftingMenu.h @@ -4,8 +4,8 @@ #include "../../../Minecraft.World/BannerPatternRecipe.h" class LocalPlayer; +class CraftingContainer; -// 4J Stu - Crafting menu code that's shared across Iggy and XUI class IUIScene_CraftingMenu { public: @@ -28,12 +28,11 @@ protected: eGroupVType_Workbench = 0, eGroupVType_Banner = 1, eGroupVType_Firework = 2, - eGroupVType_Dye = 3, }; static const int m_iMaxHSlotC = 40; static const int m_iMaxHCraftingSlotC = 40; - static const int m_iMaxVSlotC = 99; + static const int m_iMaxVSlotC = 99; static const int m_iMaxDisplayedVSlotC = 3; static const int m_iIngredients3x3SlotC = 9; static const int m_iIngredients2x2SlotC = 4; @@ -43,52 +42,67 @@ protected: static const int m_iMaxGroupH3x3 = 7; static const int m_iMaxGroupH2x2 = 6; - static const int m_iMaxGroupV2x2 = 0; - static const int m_iMaxGroupV3x3 = 2; + static const int m_iMaxGroupV = 3; - static const int m_iMaxBannerGroupH3x3 = 6; + static const int m_iMaxSpecialRecipeIngredients = 9; + static const int m_iMaxSpecialColumnRecipes = 32; + static const int m_iMaxBannerPatterns = 6; static int m_iBaseTypeMapA[Item::eBaseItemType_MAXTYPES]; - typedef struct + typedef struct { int iCount; int iItemBaseType; - int iRecipeA[m_iMaxVSlotC]; // tiers of item that can be made + int iRecipeA[m_iMaxVSlotC]; } CANBEMADE; CANBEMADE CanBeMadeA[m_iMaxHSlotC]; - std::vector> CurrentInventoryBanners; - shared_ptr m_selectedBannerEdit; - - vector m_bannerPreviewData; - shared_ptr m_bannerPreviewHolder; - + struct SpecialRecipe + { + int group; + int key; + int patternIndex; + int dye; + int recipeIndex; + bool needs3x3; + unsigned int grid[9]; + int ingC; + int ingId[m_iMaxSpecialRecipeIngredients]; + int ingAux[m_iMaxSpecialRecipeIngredients]; + int ingCount[m_iMaxSpecialRecipeIngredients]; + bool available; + unsigned short missingMask; + shared_ptr result; + }; + struct SpecialColumn + { + int key; + int count; + int recipes[m_iMaxSpecialColumnRecipes]; + }; int m_iCurrentSlotHIndex; int m_iCurrentSlotVIndex; int m_iRecipeC; - int m_iContainerType; // 2x2 or 3x3 + int m_iContainerType; shared_ptr m_pPlayer; - char m_aBannerCraftPatterns[5][12]; - int m_iGroupHIndex; int m_iGroupVIndex; - int iVSlotIndexA[3]; // index of the v slots currently displayed + int iVSlotIndexA[3]; int iHSlotState[7]; static LPCWSTR m_GroupIconNameA[m_iMaxGroupH3x3]; static Recipy::_eGroupType m_GroupTypeMapping4GridA[m_iMaxGroupH2x2]; static Recipy::_eGroupType m_GroupTypeMapping9GridA[m_iMaxGroupH3x3]; - static Recipy::_eGroupType m_GroupTypeBannerMapping9GridA[m_iMaxBannerGroupH3x3]; - Recipy::_eGroupType** m_pGroupA; + Recipy::_eGroupType* m_pGroupA; - static LPCWSTR m_GroupTabNameA[3]; + static LPCWSTR m_GroupTabNameA[3]; static _eGroupTab m_GroupTabBkgMapping2x2A[m_iMaxGroupH2x2]; static _eGroupTab m_GroupTabBkgMapping3x3A[m_iMaxGroupH3x3]; _eGroupTab *m_pGroupTabA; @@ -101,22 +115,40 @@ protected: eTutorial_State m_previousTutorialState; + vector m_specialRecipes; + SpecialColumn m_specialColumns[m_iMaxHSlot]; + int m_iSpecialColumnC; + int m_iSpecialHSlotC; + int m_iSpecialGroupC; + + vector m_baseItemSlots; + vector > m_duplicateItemSlots; + shared_ptr m_baseRecipeItem; + shared_ptr m_accumulatedItem; + vector m_stackedRecipes; + int m_iBaseCreateRecipe; + int m_iBaseCopySlot; + bool m_bBaseFromInventory; + + vector, bool> > m_customRecipes[3]; + vector > m_recipeIngredients; + shared_ptr m_customGridItems[9]; + vector m_customIngredientSlots; + int m_customRecipeSlots[3]; + bool m_customRecipeValid; + bool m_hasGunpowder; + int m_iSpecialIngredientCount; + shared_ptr m_craftingContainer; + bool handleKeyDown(int iPad, int iAction, bool bRepeat); public: IUIScene_CraftingMenu(); - ~IUIScene_CraftingMenu() { - delete[] m_pGroupA; - } + ~IUIScene_CraftingMenu() {} protected: LPCWSTR GetGroupNameText(int iGroupType); - bool hasItem(int id, int requiredCount = 1, int aux = -1); - int hasItemCounts(int id, int requiredCount = -1, int aux = -1); - bool canCraftPattern(const BannerPatternRecipe::PatternInfo& pattern, char color); - bool hasResourcesForBannerPatterns(const vector& patterns); - void CheckRecipesAvailable(); void UpdateHighlight(); void UpdateVerticalSlots(); @@ -125,8 +157,66 @@ protected: void UpdateDescriptionText(bool); void HandleInventoryUpdated(); + bool isSpecialTab() const { return m_iGroupVIndex != eGroupVType_Workbench; } + bool isSpinnerGroup() const; + bool isInventoryItem() const; + bool isDuplicateItem() const; + bool isCustomRecipe() const { return m_iGroupVIndex == eGroupVType_Firework; } + bool isCraftAnything() const; + int getMaxVGroups() const { return m_iMaxGroupV; } + int getNumSpinnerSlots() const; + int getSpecialGroupCount() const; + int getSpecialVSlotCount() const; + int getSpecialSelection() const; + const wchar_t* getSpecialGroupName(int group) const; + const wchar_t* getSpinnerTitle() const; + + void Special_EnterTab(); + void Special_EnterGroup(); + void Special_BuildRecipes(); + void Special_BuildBannerRecipes(); + void Special_BuildFireworkRecipes(); + void Special_RefreshBaseItemSlots(shared_ptr keepSelected); + void Special_CheckRecipesAvailable(); + void Special_UpdateHorizontalSlots(); + void Special_UpdateVerticalSlots(); + void Special_UpdateHighlight(); + void Special_DisplayIngredients(); + void Special_DisplayCustomRecipeIngredients(); + void Special_UpdateTooltips(); + void Special_UpdateDescriptionText(); + bool Special_HandleKeyDown(int iPad, int iAction, bool bRepeat); + void Special_ResetVerticalSlots(); + void Special_ChangeGroup(int direction); + void Special_ScrollHorizontal(int direction); + void Special_ScrollVertical(int direction); + void Special_Craft(); + bool Special_AddStackedRecipe(); + void Special_RemoveStackedRecipe(); + void Special_ClearBase(); + void Special_UpdateAccumulatedItem(); + bool Special_CanAddMoreStacks() const; + int Special_GetBannerPatternCount(shared_ptr banner) const; + int Special_GetSelectedRecipe() const; + int Special_GetUsedCount(int id, int aux) const; + int Special_GetInventoryCount(int id, int aux) const; + void Special_ComputeAvailability(SpecialRecipe& recipe) const; + shared_ptr Special_GetSpinnerItem(int spinner, int slot, bool& enabled) const; + shared_ptr Special_GetBaseItemSlot(int column, int slot, bool& enabled) const; + bool Special_IsValidCustomIngredient(int index, shared_ptr item) const; + bool Special_CanAddCustomIngredient(shared_ptr item) const; + void Special_AddCustomIngredient(shared_ptr item); + void Special_RemoveLastCustomIngredient(); + void Special_ClearCustomIngredients(); + int Special_GetCustomIngredientCount(shared_ptr item) const; + shared_ptr Special_GetFireworkResult(); + void Special_UpdateTabs(); + void Special_RemoveFromLocalInventory(int id, int aux, int count); + bool Special_RemoveMatchingFromLocalInventory(shared_ptr item); + void Special_GiveLocalItem(shared_ptr item); + public: - Recipy::_eGroupType getCurrentGroup() { return m_pGroupA[m_iGroupVIndex][m_iGroupHIndex]; } + Recipy::_eGroupType getCurrentGroup() { return isSpecialTab() ? Recipy::eGroupType_Max : m_pGroupA[m_iGroupHIndex]; } bool isItemSelected(int itemId); protected: @@ -155,9 +245,15 @@ protected: virtual void updateHighlightAndScrollPositions() = 0; virtual void updateVSlotPositions(int iSlots, int i) = 0; virtual void UpdateCraftingPanels() = 0; - void rebuildPreviewItem(); - - virtual void setSelectedBannerEdit(shared_ptr banner) = 0; - virtual void UpdateMultiPanel() = 0; -}; \ No newline at end of file + + virtual void setSpecialSlotItem(int iIndex, shared_ptr item, unsigned int uiAlpha) = 0; + virtual void clearSpecialSlots() = 0; + virtual void setPreviewSlotItem(shared_ptr item) = 0; + virtual void setSpinnerTitle(LPCWSTR text) = 0; + virtual void setHTabItem(int iIndex, shared_ptr item) = 0; + virtual void EnableTab(int iIndex, bool enabled) = 0; + virtual void ShowSuperCraftingSlots(int iIndex) = 0; + virtual void ShowDescriptionPanel(bool show) = 0; + virtual void SetCraftingMenu() = 0; +}; diff --git a/Minecraft.Client/Common/UI/IUIScene_CraftingMenuTabs.cpp b/Minecraft.Client/Common/UI/IUIScene_CraftingMenuTabs.cpp new file mode 100644 index 00000000..87a5acac --- /dev/null +++ b/Minecraft.Client/Common/UI/IUIScene_CraftingMenuTabs.cpp @@ -0,0 +1,1984 @@ +#include "stdafx.h" + +#include "../../../Minecraft.World/net.minecraft.world.item.crafting.h" +#include "../../../Minecraft.World/net.minecraft.world.level.tile.h" +#include "../../../Minecraft.World/net.minecraft.world.item.h" +#include "../../../Minecraft.World/CraftingContainer.h" +#include "../../../Minecraft.World/FireworksRecipe.h" +#include "../../../Minecraft.World/FireworksItem.h" +#include "../../../Minecraft.World/DyePowderItem.h" +#include "../../../Minecraft.World/BannerPatternRecipe.h" +#include "../../../Minecraft.World/Rose.h" +#include "../../../Minecraft.World/HtmlString.h" +#include "../../LocalPlayer.h" +#include "IUIScene_CraftingMenu.h" + +#include "UI.h" + +namespace +{ + struct BannerTabPattern + { + const wchar_t* id; + int group; + const char* rows[3]; + }; + + const BannerTabPattern s_bannerTabPatterns[] = + { + { L"cr", 1, { "# #", " # ", "#*#" } }, + { L"ss", 1, { "# #", "#*#", " " } }, + { L"sc", 1, { " # ", "###", "*# " } }, + { L"bs", 1, { " ", " * ", "###" } }, + { L"cs", 1, { " # ", " #*", " # " } }, + { L"dls", 1, { " #", " #*", "# " } }, + { L"drs", 1, { "# ", " #*", " #" } }, + { L"ls", 1, { "# ", "#* ", "# " } }, + { L"ms", 1, { " ", "###", " * " } }, + { L"rs", 1, { " #", " *#", " #" } }, + { L"ts", 1, { "###", " * ", " " } }, + { L"ld", 2, { "## ", "#* ", " " } }, + { L"rud", 2, { " ##", " *#", " " } }, + { L"lud", 2, { " ", "#* ", "## " } }, + { L"rd", 2, { " ", " *#", " ##" } }, + { L"hh", 2, { "###", "###", " * " } }, + { L"hhb", 2, { " * ", "###", "###" } }, + { L"vh", 2, { "## ", "##*", "## " } }, + { L"vhr", 2, { " ##", "*##", " ##" } }, + { L"mc", 3, { " ", " # ", " * " } }, + { L"mr", 3, { " # ", "#*#", " # " } }, + { L"bl", 3, { " ", " * ", "# " } }, + { L"br", 3, { " ", " * ", " #" } }, + { L"tl", 3, { "# ", " * ", " " } }, + { L"tr", 3, { " #", " * ", " " } }, + { L"bt", 3, { " * ", " # ", "# #" } }, + { L"tt", 3, { "# #", " # ", " * " } }, + { L"bts", 3, { " ", "#*#", " # " } }, + { L"tts", 3, { " # ", "#*#", " " } }, + { L"bo", 4, { "###", "#*#", "###" } }, + { L"bri", 4, { nullptr, nullptr, nullptr } }, + { L"cbo", 4, { nullptr, nullptr, nullptr } }, + { L"gra", 4, { "#*#", " # ", " # " } }, + { L"gru", 4, { " # ", " # ", "#*#" } }, + { L"cre", 5, { nullptr, nullptr, nullptr } }, + { L"flo", 5, { nullptr, nullptr, nullptr } }, + { L"moj", 5, { nullptr, nullptr, nullptr } }, + { L"sku", 5, { nullptr, nullptr, nullptr } }, + }; + + const int s_bannerTabPatternC = static_cast(sizeof(s_bannerTabPatterns) / sizeof(s_bannerTabPatterns[0])); + + const wchar_t* s_bannerGroupNames[6] = { L"", L"Stripes", L"Halves", L"Shapes", L"Borders, Backgrounds and Gradients", L"Symbols" }; + + int findPatternIndex(const wchar_t* id) + { + for (int i = 0; i < BannerPatternRecipe::PATTERN_COUNT; i++) + { + if (wcscmp(BannerPatternRecipe::PATTERNS[i].id, id) == 0) return i; + } + return -1; + } + + unsigned int gridEntry(int id, int aux) + { + return static_cast(id) | (static_cast(aux & 0xFF) << 24); + } + + bool sameIngredient(shared_ptr a, shared_ptr b) + { + if (a == nullptr || b == nullptr) return false; + if (a->id != b->id || a->getAuxValue() != b->getAuxValue()) return false; + return ItemInstance::tagMatches(a, b); + } + + const int s_fireworkGroupForRecipe[3] = { 0, 1, 2 }; +} + +bool IUIScene_CraftingMenu::isSpinnerGroup() const +{ + if (m_iGroupVIndex == eGroupVType_Banner) return m_iGroupHIndex == 0; + return m_iGroupVIndex == eGroupVType_Firework; +} + +bool IUIScene_CraftingMenu::isInventoryItem() const +{ + return m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == (m_iContainerType == RECIPE_TYPE_3x3 ? 1 : 0); +} + +bool IUIScene_CraftingMenu::isDuplicateItem() const +{ + return m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == (m_iContainerType == RECIPE_TYPE_3x3 ? 2 : 1); +} + +int IUIScene_CraftingMenu::getNumSpinnerSlots() const +{ + if (!isSpinnerGroup()) return 0; + if (m_iGroupVIndex == eGroupVType_Banner) return m_iContainerType == RECIPE_TYPE_3x3 ? 3 : 2; + return m_iGroupHIndex == 0 ? 3 : 2; +} + +int IUIScene_CraftingMenu::getSpecialGroupCount() const +{ + if (m_iGroupVIndex == eGroupVType_Banner) return m_iContainerType == RECIPE_TYPE_3x3 ? 6 : 3; + if (m_iGroupVIndex == eGroupVType_Firework) return 3; + return 0; +} + +const wchar_t* IUIScene_CraftingMenu::getSpecialGroupName(int group) const +{ + if (m_iGroupVIndex != eGroupVType_Banner) return L""; + if (m_iContainerType == RECIPE_TYPE_2x2) + { + if (group == 1) return s_bannerGroupNames[4]; + if (group == 2) return s_bannerGroupNames[5]; + return L""; + } + if (group < 0 || group > 5) return L""; + return s_bannerGroupNames[group]; +} + +const wchar_t* IUIScene_CraftingMenu::getSpinnerTitle() const +{ + if (m_iGroupVIndex == eGroupVType_Banner) + { + if (isInventoryItem()) return L"Select Banner"; + if (isDuplicateItem()) return L"Copy Banner"; + return L"Create Banner"; + } + if (m_iGroupVIndex == eGroupVType_Firework) + { + if (m_iGroupHIndex == 0) + { + if (m_iCurrentSlotHIndex == 0) return L"Color"; + if (m_iCurrentSlotHIndex == 1) return L"Shape"; + return L"Effect"; + } + if (m_iGroupHIndex == 1) return m_iCurrentSlotHIndex == 0 ? L"Firework Star" : L"Fade Color"; + return m_iCurrentSlotHIndex == 0 ? L"Gunpowder" : L"Firework Star"; + } + return L""; +} + +int IUIScene_CraftingMenu::Special_GetInventoryCount(int id, int aux) const +{ + if (!m_pPlayer || !m_pPlayer->inventory) return 0; + int count = 0; + for (unsigned int i = 0; i < m_pPlayer->inventory->items.length; i++) + { + shared_ptr item = m_pPlayer->inventory->items[i]; + if (item == nullptr || item->id != id) continue; + if (aux != Recipes::ANY_AUX_VALUE && item->getAuxValue() != aux) continue; + count += item->count; + } + return count; +} + +int IUIScene_CraftingMenu::Special_GetUsedCount(int id, int aux) const +{ + if (m_iGroupVIndex != eGroupVType_Banner) return 0; + int used = 0; + for (size_t s = 0; s < m_stackedRecipes.size(); s++) + { + const SpecialRecipe& recipe = m_specialRecipes[m_stackedRecipes[s]]; + for (int i = 0; i < recipe.ingC; i++) + { + if (recipe.ingId[i] != id) continue; + if (aux != Recipes::ANY_AUX_VALUE && recipe.ingAux[i] != Recipes::ANY_AUX_VALUE && recipe.ingAux[i] != aux) continue; + used += recipe.ingCount[i]; + } + } + if (m_iBaseCreateRecipe >= 0) + { + const SpecialRecipe& recipe = m_specialRecipes[m_iBaseCreateRecipe]; + for (int i = 0; i < recipe.ingC; i++) + { + if (recipe.ingId[i] != id) continue; + if (aux != Recipes::ANY_AUX_VALUE && recipe.ingAux[i] != Recipes::ANY_AUX_VALUE && recipe.ingAux[i] != aux) continue; + used += recipe.ingCount[i]; + } + } + return used; +} + +void IUIScene_CraftingMenu::Special_ComputeAvailability(SpecialRecipe& recipe) const +{ + recipe.missingMask = 0; + recipe.available = true; + if (recipe.needs3x3 && m_iContainerType == RECIPE_TYPE_2x2) + { + recipe.available = false; + return; + } + if (isCraftAnything()) return; + + for (int i = 0; i < recipe.ingC; i++) + { + int have = Special_GetInventoryCount(recipe.ingId[i], recipe.ingAux[i]) - Special_GetUsedCount(recipe.ingId[i], recipe.ingAux[i]); + if (have >= recipe.ingCount[i]) continue; + recipe.available = false; + int missing = recipe.ingCount[i] - (have > 0 ? have : 0); + for (int slot = 0; slot < 9 && missing > 0; slot++) + { + unsigned int entry = recipe.grid[slot]; + if (entry == 0) continue; + if (static_cast(entry & 0x00FFFFFF) != recipe.ingId[i]) continue; + if (recipe.ingAux[i] != Recipes::ANY_AUX_VALUE && static_cast((entry >> 24) & 0xFF) != (recipe.ingAux[i] & 0xFF)) continue; + recipe.missingMask |= 1 << slot; + missing--; + } + } +} + +int IUIScene_CraftingMenu::Special_GetBannerPatternCount(shared_ptr banner) const +{ + if (banner == nullptr) return 0; + return BannerPatternRecipe::getBannerPatternCount(banner); +} + +bool IUIScene_CraftingMenu::Special_CanAddMoreStacks() const +{ + if (m_accumulatedItem == nullptr) return false; + return Special_GetBannerPatternCount(m_accumulatedItem) < m_iMaxBannerPatterns; +} + +void IUIScene_CraftingMenu::Special_BuildBannerRecipes() +{ + m_specialRecipes.clear(); + + Recipy::INGREDIENTS_REQUIRED* required = Recipes::getInstance()->getRecipeIngredientsArray(); + RecipyList* recipes = Recipes::getInstance()->getRecipies(); + int index = 0; + for (auto it = recipes->begin(); it != recipes->end(); ++it, ++index) + { + Recipy* r = *it; + if (r->getGroup() != Recipy::eGroupType_Banner_CustomLogic) continue; + shared_ptr result = required[index].pRecipy->assemble(nullptr); + if (result == nullptr || result->id != Tile::standing_banner_Id) continue; + + SpecialRecipe recipe = {}; + recipe.group = 0; + recipe.key = 0; + recipe.patternIndex = -1; + recipe.dye = -1; + recipe.recipeIndex = index; + recipe.needs3x3 = required[index].iType == RECIPE_TYPE_3x3; + for (int g = 0; g < 9; g++) recipe.grid[g] = required[index].uiGridA[g]; + recipe.ingC = required[index].iIngC < m_iMaxSpecialRecipeIngredients ? required[index].iIngC : m_iMaxSpecialRecipeIngredients; + for (int i = 0; i < recipe.ingC; i++) + { + recipe.ingId[i] = required[index].iIngIDA[i]; + recipe.ingAux[i] = required[index].iIngAuxValA[i]; + recipe.ingCount[i] = required[index].iIngValA[i]; + } + recipe.result = result; + m_specialRecipes.push_back(recipe); + } + + for (int p = 0; p < s_bannerTabPatternC; p++) + { + const BannerTabPattern& tabPattern = s_bannerTabPatterns[p]; + int patternIndex = findPatternIndex(tabPattern.id); + if (patternIndex < 0) continue; + const BannerPatternRecipe::PatternInfo& info = BannerPatternRecipe::PATTERNS[patternIndex]; + bool itemPattern = info.specialItemId != 0; + + int group = tabPattern.group; + if (m_iContainerType == RECIPE_TYPE_2x2) + { + if (!itemPattern) continue; + if (group == 4) group = 1; + else if (group == 5) group = 2; + else continue; + } + + for (int dye = 0; dye < 16; dye++) + { + SpecialRecipe recipe = {}; + recipe.group = group; + recipe.key = patternIndex; + recipe.patternIndex = patternIndex; + recipe.dye = dye; + recipe.recipeIndex = -1; + recipe.needs3x3 = !itemPattern; + + if (itemPattern) + { + int specialAux = info.specialItemAux == -1 ? 0 : info.specialItemAux; + recipe.grid[0] = gridEntry(Tile::standing_banner_Id, 0); + recipe.grid[1] = gridEntry(info.specialItemId, specialAux); + recipe.grid[3] = gridEntry(Item::dye_Id, dye); + recipe.ingC = 2; + recipe.ingId[0] = info.specialItemId; + recipe.ingAux[0] = info.specialItemAux; + recipe.ingCount[0] = 1; + recipe.ingId[1] = Item::dye_Id; + recipe.ingAux[1] = dye; + recipe.ingCount[1] = 1; + } + else + { + int dyeCount = 0; + for (int row = 0; row < 3; row++) + { + const char* line = BannerPatternRecipe::getCraftRow(patternIndex, row); + if (line == nullptr) continue; + for (int col = 0; col < 3; col++) + { + char c = line[col]; + if (c == '#') + { + recipe.grid[col + row * 3] = gridEntry(Item::dye_Id, dye); + dyeCount++; + } + else if (c == '*') + { + recipe.grid[col + row * 3] = gridEntry(Tile::standing_banner_Id, 0); + } + } + } + recipe.ingC = 1; + recipe.ingId[0] = Item::dye_Id; + recipe.ingAux[0] = dye; + recipe.ingCount[0] = dyeCount; + } + + recipe.result = BannerPatternRecipe::createBannerWithPattern(info.id, static_cast(dye), BannerItem::eBannerColor_White); + m_specialRecipes.push_back(recipe); + } + } +} + +void IUIScene_CraftingMenu::Special_BuildFireworkRecipes() +{ + m_specialRecipes.clear(); + + Recipy::INGREDIENTS_REQUIRED* required = Recipes::getInstance()->getRecipeIngredientsArray(); + RecipyList* recipes = Recipes::getInstance()->getRecipies(); + + SpecialRecipe found[3] = {}; + bool haveFound[3] = { false, false, false }; + + int index = 0; + for (auto it = recipes->begin(); it != recipes->end(); ++it, ++index) + { + Recipy* r = *it; + if (r->getGroup() != Recipy::eGroupType_Fireworks) continue; + shared_ptr result = required[index].pRecipy->assemble(nullptr); + if (result == nullptr) continue; + + int group = -1; + if (result->id == Item::fireworks_Id) + { + group = 2; + } + else if (result->id == Item::firework_charge_Id) + { + bool usesCharge = false; + for (int i = 0; i < required[index].iIngC; i++) + { + if (required[index].iIngIDA[i] == Item::firework_charge_Id) usesCharge = true; + } + group = usesCharge ? 1 : 0; + } + if (group < 0 || haveFound[group]) continue; + + SpecialRecipe recipe = {}; + recipe.group = group; + recipe.key = group; + recipe.patternIndex = -1; + recipe.dye = -1; + recipe.recipeIndex = index; + recipe.needs3x3 = false; + for (int g = 0; g < 9; g++) recipe.grid[g] = required[index].uiGridA[g]; + recipe.ingC = required[index].iIngC < m_iMaxSpecialRecipeIngredients ? required[index].iIngC : m_iMaxSpecialRecipeIngredients; + for (int i = 0; i < recipe.ingC; i++) + { + recipe.ingId[i] = required[index].iIngIDA[i]; + recipe.ingAux[i] = required[index].iIngAuxValA[i]; + recipe.ingCount[i] = required[index].iIngValA[i]; + } + recipe.result = result; + found[group] = recipe; + haveFound[group] = true; + } + + for (int g = 0; g < 3; g++) + { + if (haveFound[s_fireworkGroupForRecipe[g]]) m_specialRecipes.push_back(found[s_fireworkGroupForRecipe[g]]); + } +} + +void IUIScene_CraftingMenu::Special_BuildRecipes() +{ + if (m_iGroupVIndex == eGroupVType_Banner) Special_BuildBannerRecipes(); + else if (m_iGroupVIndex == eGroupVType_Firework) Special_BuildFireworkRecipes(); + else m_specialRecipes.clear(); +} + +void IUIScene_CraftingMenu::Special_RefreshBaseItemSlots(shared_ptr keepSelected) +{ + m_baseItemSlots.clear(); + m_duplicateItemSlots.clear(); + if (!m_pPlayer || !m_pPlayer->inventory) return; + + auto& items = m_pPlayer->inventory->items; + + if (m_iGroupVIndex == eGroupVType_Banner) + { + for (unsigned int slot = 0; slot < items.length; slot++) + { + shared_ptr item = items[slot]; + if (item == nullptr || item->id != Tile::standing_banner_Id) continue; + + int patterns = Special_GetBannerPatternCount(item); + if (patterns < m_iMaxBannerPatterns) m_baseItemSlots.push_back(static_cast(slot)); + if (patterns > 0) + { + bool hasBlank = false; + for (unsigned int other = 0; other < items.length; other++) + { + shared_ptr o = items[other]; + if (other == slot || o == nullptr || o->id != Tile::standing_banner_Id) continue; + if (Special_GetBannerPatternCount(o) != 0) continue; + if (o->getAuxValue() != item->getAuxValue()) continue; + hasBlank = true; + break; + } + m_duplicateItemSlots.push_back(make_pair(static_cast(slot), hasBlank || isCraftAnything())); + } + } + return; + } + + if (m_iGroupVIndex != eGroupVType_Firework) return; + + shared_ptr selected = nullptr; + if ((m_iGroupHIndex == 1 || m_iGroupHIndex == 2) && !m_recipeIngredients.empty()) + selected = keepSelected; + + m_customRecipes[0].clear(); + m_customRecipes[1].clear(); + m_customRecipes[2].clear(); + m_recipeIngredients.clear(); + + for (unsigned int slot = 0; slot < items.length; slot++) + { + shared_ptr item = items[slot]; + if (item == nullptr || item->id != Item::firework_charge_Id) continue; + shared_ptr ingredient = ItemInstance::clone(item); + ingredient->count = 1; + bool listed = false; + for (size_t i = 0; i < m_recipeIngredients.size(); i++) + { + if (ingredient->sameItemWithTags(m_recipeIngredients[i])) + { + listed = true; + break; + } + } + if (!listed) m_recipeIngredients.push_back(ingredient); + } + + if (m_iGroupHIndex == 1 || m_iGroupHIndex == 2) + { + int& customSlot = m_customRecipeSlots[m_iGroupHIndex != 1 ? 1 : 0]; + int starSpinner = m_iGroupHIndex == 1 ? 0 : 1; + bool found = false; + if (selected != nullptr) + { + for (size_t i = 0; i < m_recipeIngredients.size(); i++) + { + if (selected->sameItemWithTags(m_recipeIngredients[i])) + { + customSlot = static_cast(i); + if (m_iCurrentSlotHIndex == starSpinner) iVSlotIndexA[1] = static_cast(i); + found = true; + break; + } + } + } + if (!found && customSlot >= static_cast(m_recipeIngredients.size())) + { + customSlot = m_recipeIngredients.empty() ? 0 : static_cast(m_recipeIngredients.size()) - 1; + if (m_iCurrentSlotHIndex == starSpinner) iVSlotIndexA[1] = customSlot; + } + } + + for (int i = 15; i >= 0; i--) + { + shared_ptr dye = std::make_shared(Item::dye_Id, 1, i); + m_customRecipes[0].push_back(make_pair(dye, Special_GetInventoryCount(Item::dye_Id, i) > 0 || isCraftAnything())); + } + + const int shapeIds[9] = { Item::fire_charge_Id, Item::gold_nugget_Id, Item::skull_Id, Item::skull_Id, Item::skull_Id, Item::skull_Id, Item::skull_Id, Item::skull_Id, Item::feather_Id }; + const int shapeAux[9] = { 0, 0, 0, 1, 2, 3, 4, 5, 0 }; + for (int i = 0; i < 9; i++) + { + if (Item::items[shapeIds[i]] == nullptr) continue; + shared_ptr shape = std::make_shared(shapeIds[i], 1, shapeAux[i]); + m_customRecipes[1].push_back(make_pair(shape, Special_GetInventoryCount(shapeIds[i], shapeAux[i]) > 0 || isCraftAnything())); + } + + const int effectIds[2] = { Item::glowstone_dust_Id, Item::diamond_Id }; + for (int i = 0; i < 2; i++) + { + shared_ptr effect = std::make_shared(effectIds[i], 1, 0); + m_customRecipes[2].push_back(make_pair(effect, Special_GetInventoryCount(effectIds[i], Recipes::ANY_AUX_VALUE) > 0 || isCraftAnything())); + } + + m_hasGunpowder = Special_GetInventoryCount(Item::gunpowder_Id, Recipes::ANY_AUX_VALUE) > 0 || isCraftAnything(); +} + +int IUIScene_CraftingMenu::getSpecialVSlotCount() const +{ + if (m_iGroupVIndex == eGroupVType_Banner) + { + if (isInventoryItem()) return static_cast(m_baseItemSlots.size()); + if (isDuplicateItem()) return static_cast(m_duplicateItemSlots.size()); + if (m_iCurrentSlotHIndex < m_iSpecialColumnC) return m_specialColumns[m_iCurrentSlotHIndex].count; + return 0; + } + if (m_iGroupVIndex == eGroupVType_Firework) + { + if (m_iGroupHIndex == 0) + { + if (m_iCurrentSlotHIndex >= 0 && m_iCurrentSlotHIndex < 3) return static_cast(m_customRecipes[m_iCurrentSlotHIndex].size()); + return 0; + } + if (m_iGroupHIndex == 1) + { + return m_iCurrentSlotHIndex == 0 ? static_cast(m_recipeIngredients.size()) : static_cast(m_customRecipes[0].size()); + } + return m_iCurrentSlotHIndex == 0 ? 1 : static_cast(m_recipeIngredients.size()); + } + return 0; +} + +int IUIScene_CraftingMenu::getSpecialSelection() const +{ + int count = getSpecialVSlotCount(); + if (count <= 0) return 0; + int selection; + if (isSpinnerGroup()) selection = iVSlotIndexA[1]; + else selection = count > 1 ? iVSlotIndexA[m_iCurrentSlotVIndex] : 0; + if (selection < 0) selection = 0; + if (selection >= count) selection = count - 1; + return selection; +} + +int IUIScene_CraftingMenu::Special_GetSelectedRecipe() const +{ + if (m_iGroupVIndex == eGroupVType_Firework) + { + for (size_t i = 0; i < m_specialRecipes.size(); i++) + { + if (m_specialRecipes[i].group == m_iGroupHIndex) return static_cast(i); + } + return -1; + } + if (m_iGroupVIndex == eGroupVType_Banner) + { + if (isInventoryItem() || isDuplicateItem()) return -1; + if (m_iCurrentSlotHIndex >= m_iSpecialColumnC) return -1; + const SpecialColumn& column = m_specialColumns[m_iCurrentSlotHIndex]; + if (column.count == 0) return -1; + int selection = getSpecialSelection(); + return column.recipes[selection]; + } + return -1; +} + +shared_ptr IUIScene_CraftingMenu::Special_GetBaseItemSlot(int column, int slot, bool& enabled) const +{ + enabled = false; + if (column < 0 || column >= 3) return nullptr; + if (slot < 0 || slot >= static_cast(m_customRecipes[column].size())) return nullptr; + enabled = m_customRecipes[column][slot].second; + return m_customRecipes[column][slot].first; +} + +shared_ptr IUIScene_CraftingMenu::Special_GetSpinnerItem(int spinner, int slot, bool& enabled) const +{ + enabled = false; + if (m_iGroupVIndex == eGroupVType_Banner) + { + if (!m_pPlayer || !m_pPlayer->inventory) return nullptr; + int createSlot = m_iContainerType == RECIPE_TYPE_3x3 ? 0 : -1; + int selectSlot = m_iContainerType == RECIPE_TYPE_3x3 ? 1 : 0; + int copySlot = selectSlot + 1; + if (spinner == createSlot) + { + if (m_iSpecialColumnC == 0 || m_specialColumns[0].count == 0) return nullptr; + if (slot < 0 || slot >= m_specialColumns[0].count) slot = 0; + const SpecialRecipe& recipe = m_specialRecipes[m_specialColumns[0].recipes[slot]]; + enabled = recipe.available; + return recipe.result; + } + if (spinner == selectSlot) + { + if (m_baseItemSlots.empty()) return nullptr; + if (slot < 0 || slot >= static_cast(m_baseItemSlots.size())) slot = 0; + enabled = true; + return m_pPlayer->inventory->items[m_baseItemSlots[slot]]; + } + if (spinner == copySlot) + { + if (m_duplicateItemSlots.empty()) return nullptr; + if (slot < 0 || slot >= static_cast(m_duplicateItemSlots.size())) slot = 0; + enabled = m_duplicateItemSlots[slot].second; + return m_pPlayer->inventory->items[m_duplicateItemSlots[slot].first]; + } + return nullptr; + } + + if (m_iGroupVIndex != eGroupVType_Firework) return nullptr; + + if (m_iGroupHIndex == 0) + { + return Special_GetBaseItemSlot(spinner, slot, enabled); + } + if (m_iGroupHIndex == 1) + { + if (spinner == 0) + { + if (m_recipeIngredients.empty()) return nullptr; + if (slot < 0 || slot >= static_cast(m_recipeIngredients.size())) slot = 0; + enabled = true; + return m_recipeIngredients[slot]; + } + return Special_GetBaseItemSlot(0, slot, enabled); + } + if (spinner == 0) + { + enabled = m_hasGunpowder; + return std::make_shared(Item::gunpowder_Id, 1, 0); + } + if (m_recipeIngredients.empty()) return nullptr; + if (slot < 0 || slot >= static_cast(m_recipeIngredients.size())) slot = 0; + enabled = true; + return m_recipeIngredients[slot]; +} + +int IUIScene_CraftingMenu::Special_GetCustomIngredientCount(shared_ptr item) const +{ + if (item == nullptr || !m_pPlayer || !m_pPlayer->inventory) return 0; + if (isCraftAnything()) return 64; + int count = 0; + for (unsigned int i = 0; i < m_pPlayer->inventory->items.length; i++) + { + shared_ptr inv = m_pPlayer->inventory->items[i]; + if (inv == nullptr || inv->id != item->id || inv->getAuxValue() != item->getAuxValue()) continue; + if (inv->hasTag() && item->hasTag() && !ItemInstance::tagMatches(inv, item)) continue; + count += inv->count; + } + return count; +} + +bool IUIScene_CraftingMenu::Special_IsValidCustomIngredient(int index, shared_ptr item) const +{ + if (item == nullptr) return false; + if (m_iGroupVIndex != eGroupVType_Firework) return true; + + int itemId = item->id; + if (m_iGroupHIndex == 1 && itemId == Item::firework_charge_Id) return false; + + bool isShape = itemId == Item::feather_Id || itemId == Item::gold_nugget_Id || itemId == Item::fire_charge_Id || itemId == Item::skull_Id; + if (isShape) + { + for (size_t i = 0; i < m_customIngredientSlots.size(); i++) + { + int slot = m_customIngredientSlots[i]; + if (slot == index || m_customGridItems[slot] == nullptr) continue; + int slotId = m_customGridItems[slot]->id; + if (slotId == Item::feather_Id || slotId == Item::gold_nugget_Id || slotId == Item::fire_charge_Id || slotId == Item::skull_Id) return false; + } + } + + if (itemId == Item::gunpowder_Id) + { + int gridSlots = m_iContainerType == RECIPE_TYPE_2x2 ? 4 : 9; + int gunpowder = 0; + for (int slot = 0; slot < gridSlots; slot++) + { + if (slot == index || m_customGridItems[slot] == nullptr) continue; + if (m_customGridItems[slot]->id == Item::gunpowder_Id) + { + gunpowder++; + if (gunpowder >= 3) return false; + } + } + } + + int needed = 1; + int gridSlots = m_iContainerType == RECIPE_TYPE_2x2 ? 4 : 9; + for (int slot = 0; slot < gridSlots; slot++) + { + if (slot == index) continue; + if (sameIngredient(m_customGridItems[slot], item)) needed++; + } + return Special_GetCustomIngredientCount(item) >= needed; +} + +bool IUIScene_CraftingMenu::Special_CanAddCustomIngredient(shared_ptr item) const +{ + if (item == nullptr) return false; + if (!m_customRecipeValid) return false; + if (m_iGroupHIndex == 1 && m_iCurrentSlotHIndex == 0) return false; + int gridSlots = m_iContainerType == RECIPE_TYPE_2x2 ? 4 : 9; + return static_cast(m_customIngredientSlots.size()) + m_iSpecialIngredientCount < gridSlots; +} + +void IUIScene_CraftingMenu::Special_ClearCustomIngredients() +{ + m_customIngredientSlots.clear(); + for (int i = 0; i < 9; i++) m_customGridItems[i] = nullptr; +} + +shared_ptr IUIScene_CraftingMenu::Special_GetFireworkResult() +{ + if (m_craftingContainer == nullptr || !m_pPlayer) return nullptr; + if (Recipes::pFireworksRecipes == nullptr) return nullptr; + if (!Recipes::pFireworksRecipes->matches(m_craftingContainer, m_pPlayer->level)) return nullptr; + shared_ptr result = Recipes::pFireworksRecipes->assemble(m_craftingContainer); + return result != nullptr ? ItemInstance::clone(result) : nullptr; +} + +void IUIScene_CraftingMenu::Special_DisplayCustomRecipeIngredients() +{ + int recipeIndex = Special_GetSelectedRecipe(); + int gridSize = m_iContainerType == RECIPE_TYPE_2x2 ? 2 : 3; + int gridSlots = gridSize * gridSize; + + if (m_craftingContainer == nullptr) m_craftingContainer = std::make_shared(nullptr, 3, 3); + for (int i = 0; i < 9; i++) m_craftingContainer->setItem(i, nullptr); + + if (recipeIndex < 0) + { + m_customRecipeValid = false; + for (int slot = 0; slot < gridSlots; slot++) + { + setIngredientSlotItem(getPad(), slot, nullptr); + setIngredientSlotRedBox(slot, false); + } + setCraftingOutputSlotRedBox(true); + return; + } + + SpecialRecipe& recipe = m_specialRecipes[recipeIndex]; + Special_ComputeAvailability(recipe); + + m_iSpecialIngredientCount = 0; + for (int g = 0; g < 9; g++) + { + if (recipe.grid[g] != 0) m_iSpecialIngredientCount++; + } + + m_customRecipeValid = true; + + for (int x = 0; x < gridSize; x++) + { + for (int y = 0; y < gridSize; y++) + { + int gridIndex = x + y * 3; + int slot = x + y * gridSize; + unsigned int entry = recipe.grid[gridIndex]; + if (entry != 0) + { + shared_ptr item = nullptr; + bool missing = !isCraftAnything() && (recipe.missingMask & (1 << gridIndex)) != 0; + setIngredientSlotRedBox(slot, missing); + if (missing) m_customRecipeValid = false; + + int itemId = static_cast(entry & 0x00FFFFFF); + int itemAux = static_cast((entry >> 24) & 0xFF); + if (itemAux == 0xFF) itemAux = 0; + + if (recipe.result != nullptr && recipe.result->id == Item::firework_charge_Id && m_customIngredientSlots.empty()) + { + if (itemId == Item::dye_Id) + { + if (m_iGroupHIndex == 0 || m_iGroupHIndex == 1) + { + bool enabled = false; + item = Special_GetBaseItemSlot(0, m_customRecipeSlots[m_iGroupHIndex != 0 ? 1 : 0], enabled); + setIngredientSlotRedBox(slot, !enabled); + m_customRecipeValid = m_customRecipeValid && enabled; + } + } + else if (itemId == Item::firework_charge_Id && !m_recipeIngredients.empty() && (m_iGroupHIndex == 1 || m_iGroupHIndex == 2)) + { + int starIndex = m_customRecipeSlots[m_iGroupHIndex != 1 ? 1 : 0]; + if (starIndex < 0 || starIndex >= static_cast(m_recipeIngredients.size())) starIndex = 0; + item = ItemInstance::clone(m_recipeIngredients[starIndex]); + item->count = 1; + setIngredientSlotRedBox(slot, false); + } + else if (itemId == Item::firework_charge_Id && m_recipeIngredients.empty()) + { + setIngredientSlotRedBox(slot, true); + m_customRecipeValid = false; + } + } + + if (item == nullptr) + { + if (m_customIngredientSlots.empty() || m_customGridItems[slot] == nullptr) + item = std::make_shared(itemId, 1, itemAux); + else + item = m_customGridItems[slot]; + } + m_customGridItems[slot] = item; + setIngredientSlotItem(getPad(), slot, item); + m_craftingContainer->setItem(slot, item); + } + else + { + bool isCustomSlot = false; + for (size_t i = 0; i < m_customIngredientSlots.size(); i++) + { + if (m_customIngredientSlots[i] == slot) + { + isCustomSlot = true; + break; + } + } + + if (isCustomSlot) + { + shared_ptr item = nullptr; + bool enabled = false; + shared_ptr spinnerItem = Special_GetSpinnerItem(m_iCurrentSlotHIndex, m_customRecipeSlots[m_iCurrentSlotHIndex], enabled); + if (m_customIngredientSlots.back() == slot && spinnerItem != nullptr) + { + item = ItemInstance::clone(spinnerItem); + item->count = 1; + bool valid = Special_IsValidCustomIngredient(slot, item); + if (valid) + { + setIngredientSlotRedBox(slot, !enabled); + m_customRecipeValid = m_customRecipeValid && enabled; + m_customGridItems[slot] = item; + setIngredientSlotItem(getPad(), slot, item); + } + else + { + setIngredientSlotRedBox(slot, true); + m_customRecipeValid = false; + m_customGridItems[slot] = item; + setIngredientSlotItem(getPad(), slot, item); + item = nullptr; + } + } + else + { + item = m_customGridItems[slot]; + bool valid = item != nullptr && Special_IsValidCustomIngredient(slot, item); + setIngredientSlotRedBox(slot, item != nullptr && !valid); + if (item != nullptr && !valid) m_customRecipeValid = false; + setIngredientSlotItem(getPad(), slot, item); + } + m_craftingContainer->setItem(slot, item); + } + else + { + setIngredientSlotRedBox(slot, false); + setIngredientSlotItem(getPad(), slot, nullptr); + } + } + } + } + + if (m_customRecipeValid) + { + bool fireworkPossible = false; + bool chargePossible = false; + bool fadePossible = false; + FireworksRecipe::updatePossibleRecipes(m_craftingContainer, &fireworkPossible, &chargePossible, &fadePossible); + if (!fireworkPossible && !chargePossible && !fadePossible) m_customRecipeValid = false; + else if (Special_GetFireworkResult() == nullptr) m_customRecipeValid = false; + } + + if (isCraftAnything()) m_customRecipeValid = Special_GetFireworkResult() != nullptr; + setCraftingOutputSlotRedBox(!m_customRecipeValid); +} + +void IUIScene_CraftingMenu::Special_UpdateAccumulatedItem() +{ + if (m_baseRecipeItem == nullptr) + { + m_accumulatedItem = nullptr; + setPreviewSlotItem(nullptr); + return; + } + m_accumulatedItem = ItemInstance::clone(m_baseRecipeItem); + m_accumulatedItem->count = 1; + for (size_t i = 0; i < m_stackedRecipes.size(); i++) + { + const SpecialRecipe& recipe = m_specialRecipes[m_stackedRecipes[i]]; + if (recipe.patternIndex < 0) continue; + BannerPatternRecipe::addBannerPattern(m_accumulatedItem, BannerPatternRecipe::PATTERNS[recipe.patternIndex].id, static_cast(recipe.dye)); + } + setPreviewSlotItem(m_accumulatedItem); +} + +void IUIScene_CraftingMenu::Special_ClearBase() +{ + m_baseRecipeItem = nullptr; + m_accumulatedItem = nullptr; + m_stackedRecipes.clear(); + m_iBaseCreateRecipe = -1; + m_iBaseCopySlot = -1; + m_bBaseFromInventory = false; + setPreviewSlotItem(nullptr); +} + +void IUIScene_CraftingMenu::Special_ResetVerticalSlots() +{ + m_iCurrentSlotVIndex = 1; + int count = getSpecialVSlotCount(); + iVSlotIndexA[0] = count > 0 ? count - 1 : 0; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = count > 1 ? 1 : 0; + if (m_iGroupVIndex == eGroupVType_Firework) + { + int current = m_customRecipeSlots[m_iCurrentSlotHIndex >= 0 && m_iCurrentSlotHIndex < 3 ? m_iCurrentSlotHIndex : 0]; + if (count > 0 && current >= count) current = count - 1; + iVSlotIndexA[1] = current < 0 ? 0 : current; + } +} + +void IUIScene_CraftingMenu::Special_UpdateTabs() +{ + m_iSpecialGroupC = getSpecialGroupCount(); + if (isSpinnerGroup()) + { + m_iSpecialHSlotC = getNumSpinnerSlots(); + m_iDisplayDescription = DISPLAY_INVENTORY; + } + else + { + m_iSpecialHSlotC = m_iMaxHSlot; + m_iDisplayDescription = DISPLAY_PREVIEW; + } + + for (int group = 0; group < m_iSpecialGroupC; group++) + { + shared_ptr tabItem = nullptr; + if (m_iGroupVIndex == eGroupVType_Banner) + { + const wchar_t* pattern = nullptr; + if (m_iContainerType == RECIPE_TYPE_2x2) + { + if (group == 1) pattern = L"bo"; + else if (group == 2) pattern = L"cre"; + } + else + { + switch (group) + { + case 1: pattern = L"cr"; break; + case 2: pattern = L"ld"; break; + case 3: pattern = L"mc"; break; + case 4: pattern = L"bo"; break; + case 5: pattern = L"cre"; break; + } + } + if (pattern != nullptr) tabItem = BannerPatternRecipe::createBannerWithPattern(pattern, DyePowderItem::BLACK, BannerItem::eBannerColor_White); + else tabItem = std::make_shared(Tile::standing_banner_Id, 1, 0); + } + else if (m_iGroupVIndex == eGroupVType_Firework) + { + if (group == 0) + { + tabItem = std::make_shared(Item::firework_charge_Id, 1, 0); + } + else if (group == 1) + { + tabItem = std::make_shared(Item::firework_charge_Id, 1, 0); + CompoundTag* tag = new CompoundTag(); + CompoundTag* explosion = new CompoundTag(FireworksItem::TAG_EXPLOSION); + intArray colors(1); + colors[0] = DyePowderItem::COLOR_RGB[DyePowderItem::RED]; + explosion->putIntArray(FireworksItem::TAG_E_COLORS, colors); + tag->put(FireworksItem::TAG_EXPLOSION, explosion); + tabItem->setTag(tag); + } + else + { + tabItem = std::make_shared(Item::fireworks_Id, 1, 0); + } + } + setHTabItem(group, tabItem); + } + + SetCraftingMenu(); + + for (int group = 0; group < m_iSpecialGroupC; group++) + { + bool enabled = true; + if (m_iGroupVIndex == eGroupVType_Banner) + { + enabled = (m_iGroupHIndex == 0) ? (group == 0) : (group > 0); + } + EnableTab(group, enabled); + } + for (int group = m_iSpecialGroupC; group < m_iMaxGroupH3x3; group++) + { + EnableTab(group, false); + } + + setHGroupHighlight(m_iGroupHIndex); + ShowSuperCraftingSlots(getNumSpinnerSlots()); + ShowDescriptionPanel(isSpinnerGroup()); + setSpinnerTitle(isSpinnerGroup() ? getSpinnerTitle() : L""); + UpdateMultiPanel(); +} + +void IUIScene_CraftingMenu::Special_EnterTab() +{ + Special_ClearBase(); + Special_ClearCustomIngredients(); + for (int i = 0; i < 3; i++) m_customRecipeSlots[i] = 0; + m_iGroupHIndex = 0; + m_iCurrentSlotHIndex = 0; + m_iCurrentSlotVIndex = 1; + Special_BuildRecipes(); + setVGroupHighlight(m_iGroupVIndex); + Special_EnterGroup(); +} + +void IUIScene_CraftingMenu::Special_EnterGroup() +{ + if (m_iGroupVIndex == eGroupVType_Firework) + { + for (int i = 0; i < 3; i++) m_customRecipeSlots[i] = 0; + Special_ClearCustomIngredients(); + } + m_iCurrentSlotHIndex = 0; + m_iCurrentSlotVIndex = 1; + Special_RefreshBaseItemSlots(nullptr); + Special_UpdateTabs(); + Special_CheckRecipesAvailable(); + Special_ResetVerticalSlots(); + UpdateCraftingPanels(); + Special_UpdateVerticalSlots(); + Special_UpdateHighlight(); + setGroupText(getSpecialGroupName(m_iGroupHIndex)); + Special_UpdateTooltips(); +} + +void IUIScene_CraftingMenu::Special_CheckRecipesAvailable() +{ + hideAllHSlots(); + m_iSpecialColumnC = 0; + memset(m_specialColumns, 0, sizeof(m_specialColumns)); + + for (size_t i = 0; i < m_specialRecipes.size(); i++) + { + SpecialRecipe& recipe = m_specialRecipes[i]; + Special_ComputeAvailability(recipe); + if (recipe.group != m_iGroupHIndex) continue; + + int column = -1; + for (int c = 0; c < m_iSpecialColumnC; c++) + { + if (m_specialColumns[c].key == recipe.key) + { + column = c; + break; + } + } + if (column < 0) + { + if (m_iSpecialColumnC >= m_iMaxHSlot) continue; + column = m_iSpecialColumnC++; + m_specialColumns[column].key = recipe.key; + m_specialColumns[column].count = 0; + } + if (m_specialColumns[column].count < m_iMaxSpecialColumnRecipes) + m_specialColumns[column].recipes[m_specialColumns[column].count++] = static_cast(i); + } + + Special_UpdateHorizontalSlots(); +} + +void IUIScene_CraftingMenu::Special_UpdateHorizontalSlots() +{ + if (isSpinnerGroup()) + { + clearSpecialSlots(); + int spinners = getNumSpinnerSlots(); + for (int spinner = 0; spinner < spinners; spinner++) + { + bool enabled = false; + int slot = (spinner == m_iCurrentSlotHIndex) ? getSpecialSelection() : (m_iGroupVIndex == eGroupVType_Firework ? m_customRecipeSlots[spinner] : 0); + shared_ptr item = Special_GetSpinnerItem(spinner, slot, enabled); + if (item == nullptr) continue; + if (m_iGroupVIndex == eGroupVType_Firework && m_iGroupHIndex == 0 && spinner == 1 && !Special_IsValidCustomIngredient(8, item)) enabled = false; + setSpecialSlotItem(spinner, item, enabled ? 31 : 16); + } + return; + } + + for (int column = 0; column < m_iSpecialColumnC; column++) + { + const SpecialRecipe& recipe = m_specialRecipes[m_specialColumns[column].recipes[0]]; + bool usable = recipe.available && Special_CanAddMoreStacks(); + setCraftHSlotItem(getPad(), column, recipe.result, usable ? 31 : 16); + } +} + +void IUIScene_CraftingMenu::Special_UpdateVerticalSlots() +{ + hideAllVSlots(); + + if (isSpinnerGroup()) + { + if (m_iGroupVIndex == eGroupVType_Firework) + { + int sel = getSpecialSelection(); + if (m_iCurrentSlotHIndex >= 0 && m_iCurrentSlotHIndex < 3) m_customRecipeSlots[m_iCurrentSlotHIndex] = sel; + } + setSpinnerTitle(getSpinnerTitle()); + Special_UpdateHorizontalSlots(); + return; + } + + if (m_iCurrentSlotHIndex >= m_iSpecialColumnC) return; + const SpecialColumn& column = m_specialColumns[m_iCurrentSlotHIndex]; + if (column.count < 2) return; + + setShowCraftHSlot(m_iCurrentSlotHIndex, false); + int slots = column.count > 2 ? 3 : 2; + + bool noScrollSlots = m_bSplitscreen || (!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()); +#ifdef __PSVITA__ + noScrollSlots = true; +#endif + + for (int i = 0; i < slots; i++) + { + if (noScrollSlots && i != 1) continue; + int index = iVSlotIndexA[i]; + if (index < 0 || index >= column.count) continue; + const SpecialRecipe& recipe = m_specialRecipes[column.recipes[index]]; + bool usable = recipe.available && Special_CanAddMoreStacks(); + setCraftVSlotItem(getPad(), i, recipe.result, usable ? 31 : 16); + updateVSlotPositions(slots, i); + } +} + +void IUIScene_CraftingMenu::Special_DisplayIngredients() +{ + hideAllIngredientsSlots(); + + int gridSize = m_iContainerType == RECIPE_TYPE_2x2 ? 2 : 3; + int gridSlots = gridSize * gridSize; + + if (m_iGroupVIndex == eGroupVType_Firework) + { + Special_DisplayCustomRecipeIngredients(); + int recipeIndex = Special_GetSelectedRecipe(); + shared_ptr result = Special_GetFireworkResult(); + if (result == nullptr && recipeIndex >= 0) result = m_specialRecipes[recipeIndex].result; + setCraftingOutputSlotItem(getPad(), result); + setCraftingOutputSlotRedBox(!m_customRecipeValid); + m_iIngredientsC = 0; + return; + } + + if (isInventoryItem() || isDuplicateItem()) + { + for (int slot = 0; slot < gridSlots; slot++) + { + setIngredientSlotRedBox(slot, false); + setIngredientSlotItem(getPad(), slot, nullptr); + } + m_iIngredientsC = 0; + + bool enabled = false; + shared_ptr item = Special_GetSpinnerItem(m_iCurrentSlotHIndex, getSpecialSelection(), enabled); + if (item == nullptr) + { + setCraftingOutputSlotItem(getPad(), nullptr); + setCraftingOutputSlotRedBox(false); + return; + } + + shared_ptr display = ItemInstance::clone(item); + display->count = 1; + setIngredientSlotItem(getPad(), gridSize + 1, display); + setCraftingOutputSlotItem(getPad(), display); + + if (isDuplicateItem()) + { + shared_ptr blank = std::make_shared(Tile::standing_banner_Id, 1, item->getAuxValue()); + setIngredientSlotItem(getPad(), gridSize, blank); + setIngredientSlotRedBox(gridSize, !enabled); + setCraftingOutputSlotRedBox(!enabled); + } + else + { + setCraftingOutputSlotRedBox(false); + } + return; + } + + int recipeIndex = Special_GetSelectedRecipe(); + if (recipeIndex < 0) + { + setCraftingOutputSlotItem(getPad(), nullptr); + setCraftingOutputSlotRedBox(false); + m_iIngredientsC = 0; + for (int slot = 0; slot < gridSlots; slot++) + { + setIngredientSlotRedBox(slot, false); + setIngredientSlotItem(getPad(), slot, nullptr); + } + return; + } + + SpecialRecipe& recipe = m_specialRecipes[recipeIndex]; + bool available = recipe.available; + + m_iIngredientsC = recipe.ingC; + for (int i = 0; i < recipe.ingC; i++) + { + int aux = recipe.ingAux[i] == Recipes::ANY_AUX_VALUE ? 0 : recipe.ingAux[i]; + shared_ptr item = std::make_shared(recipe.ingId[i], recipe.ingCount[i], aux); + int descId = item->getDescriptionId(); + if (recipe.ingId[i] == Tile::wool_Id && recipe.ingAux[i] == Recipes::ANY_AUX_VALUE) descId = IDS_ANY_WOOL; + setIngredientDescriptionText(i, app.GetString(descId)); + setIngredientDescriptionItem(getPad(), i, item); + setIngredientDescriptionRedBox(i, false); + } + + for (int x = 0; x < gridSize; x++) + { + for (int y = 0; y < gridSize; y++) + { + int gridIndex = x + y * 3; + int slot = x + y * gridSize; + unsigned int entry = recipe.grid[gridIndex]; + if (entry == 0) + { + setIngredientSlotRedBox(slot, false); + setIngredientSlotItem(getPad(), slot, nullptr); + continue; + } + int itemId = static_cast(entry & 0x00FFFFFF); + int itemAux = static_cast((entry >> 24) & 0xFF); + shared_ptr item; + if (itemId == Tile::standing_banner_Id && m_accumulatedItem != nullptr && recipe.patternIndex >= 0) + item = m_accumulatedItem; + else + item = std::make_shared(itemId, 1, itemAux); + setIngredientSlotItem(getPad(), slot, item); + setIngredientSlotRedBox(slot, !isCraftAnything() && (recipe.missingMask & (1 << gridIndex)) != 0); + } + } + + shared_ptr result = recipe.result; + if (recipe.patternIndex >= 0) + { + if (!Special_CanAddMoreStacks()) + { + available = false; + result = m_accumulatedItem; + } + else + { + result = ItemInstance::clone(m_accumulatedItem); + BannerPatternRecipe::addBannerPattern(result, BannerPatternRecipe::PATTERNS[recipe.patternIndex].id, static_cast(recipe.dye)); + } + } + setCraftingOutputSlotItem(getPad(), result); + setCraftingOutputSlotRedBox(isCraftAnything() ? false : !available); +} + +void IUIScene_CraftingMenu::Special_UpdateDescriptionText() +{ + if (!isSpinnerGroup()) + { + setDescriptionTextTop(L""); + setDescriptionText(L""); + return; + } + + shared_ptr item = nullptr; + if (m_iGroupVIndex == eGroupVType_Banner) + { + bool enabled = false; + item = Special_GetSpinnerItem(m_iCurrentSlotHIndex, getSpecialSelection(), enabled); + } + else + { + item = Special_GetFireworkResult(); + if (item == nullptr) + { + int recipeIndex = Special_GetSelectedRecipe(); + if (recipeIndex >= 0) item = m_specialRecipes[recipeIndex].result; + } + } + + if (item == nullptr) + { + setDescriptionTextTop(L""); + return; + } + + vector* lines = item->getHoverText(m_pPlayer, false); + wstring text; + if (lines != nullptr) + { + for (size_t i = 0; i < lines->size(); i++) + (*lines)[i].color = eHTMLColor_Black; + text = HtmlString::Compose(lines); + delete lines; + } + + wchar_t startTags[64]; + swprintf(startTags, 64, L"

", app.GetHTMLColour(eHTMLColor_Black)); + text = wstring(startTags) + text + L"

"; + setDescriptionTextTop(text.c_str()); +} + +void IUIScene_CraftingMenu::Special_UpdateHighlight() +{ + updateHighlightAndScrollPositions(); + + shared_ptr item = nullptr; + if (isSpinnerGroup()) + { + bool enabled = false; + if (m_iGroupVIndex == eGroupVType_Banner) + { + item = Special_GetSpinnerItem(m_iCurrentSlotHIndex, getSpecialSelection(), enabled); + } + else + { + item = Special_GetSpinnerItem(m_iCurrentSlotHIndex, getSpecialSelection(), enabled); + } + } + else + { + int recipeIndex = Special_GetSelectedRecipe(); + if (recipeIndex >= 0) item = m_specialRecipes[recipeIndex].result; + } + + if (item == nullptr) + { + setItemText(L""); + } + else + { + wstring name = item->getHoverName(); + if (!isSpinnerGroup() && m_iGroupVIndex == eGroupVType_Banner) + { + vector* lines = item->getHoverText(m_pPlayer, false); + if (lines != nullptr) + { + if (lines->size() > 1) name = (*lines)[1].text; + delete lines; + } + } + setItemText(name.c_str()); + } + + Special_DisplayIngredients(); + UpdateMultiPanel(); + Special_UpdateTooltips(); + Special_UpdateDescriptionText(); +} + +void IUIScene_CraftingMenu::Special_UpdateTooltips() +{ + int groupTip = IDS_TOOLTIPS_CHANGE_GROUP; + int groupHint = -2; + + if (m_iGroupVIndex == eGroupVType_Firework) + { + bool enabled = false; + shared_ptr item = Special_GetSpinnerItem(m_iCurrentSlotHIndex, m_customRecipeSlots[m_iCurrentSlotHIndex], enabled); + bool canAdd = Special_CanAddCustomIngredient(item) && enabled; + int craftTip = m_customRecipeValid ? IDS_TOOLTIPS_CREATE : -1; + int removeTip = m_customIngredientSlots.empty() ? -1 : IDS_TOOLTIPS_REMOVE; + int addTip = canAdd ? IDS_TOOLTIPS_ADD : -1; + ui.SetTooltips(getPad(), craftTip, IDS_TOOLTIPS_EXIT, removeTip, addTip, -2, IDS_TOOLTIPS_CHANGE_TYPE, groupHint, groupTip); + return; + } + + if (m_iGroupHIndex != 0) + { + int recipeIndex = Special_GetSelectedRecipe(); + bool available = recipeIndex >= 0 && m_specialRecipes[recipeIndex].available; + int craftTip = m_stackedRecipes.empty() ? -1 : IDS_TOOLTIPS_CREATE; + int addTip = (available && Special_CanAddMoreStacks()) ? IDS_TOOLTIPS_ADD : -1; + ui.SetTooltips(getPad(), craftTip, IDS_TOOLTIPS_EXIT, IDS_TOOLTIPS_REMOVE, addTip, -2, IDS_TOOLTIPS_CHANGE_TYPE, groupHint, groupTip); + return; + } + + bool enabled = false; + shared_ptr item = Special_GetSpinnerItem(m_iCurrentSlotHIndex, getSpecialSelection(), enabled); + int craftTip = -1; + int selectTip = -1; + if (item != nullptr) + { + if (isInventoryItem()) + { + selectTip = IDS_TOOLTIPS_SELECT; + } + else if (isDuplicateItem()) + { + if (enabled) + { + craftTip = IDS_TOOLTIPS_CREATE; + if (Special_GetBannerPatternCount(item) < m_iMaxBannerPatterns) selectTip = IDS_TOOLTIPS_SELECT; + } + } + else if (enabled) + { + craftTip = IDS_TOOLTIPS_CREATE; + selectTip = IDS_TOOLTIPS_ADD; + } + } + ui.SetTooltips(getPad(), craftTip, IDS_TOOLTIPS_EXIT, -1, selectTip, -2, IDS_TOOLTIPS_CHANGE_TYPE, -1, -1); +} + +void IUIScene_CraftingMenu::Special_RemoveFromLocalInventory(int id, int aux, int count) +{ + for (int i = 0; i < count; i++) + { + if (aux == Recipes::ANY_AUX_VALUE) m_pPlayer->inventory->removeResource(id); + else m_pPlayer->inventory->removeResource(id, aux); + } +} + +bool IUIScene_CraftingMenu::Special_RemoveMatchingFromLocalInventory(shared_ptr item) +{ + if (item == nullptr) return false; + for (unsigned int i = 0; i < m_pPlayer->inventory->items.length; i++) + { + shared_ptr& inv = m_pPlayer->inventory->items[i]; + if (!sameIngredient(inv, item)) continue; + inv->count--; + if (inv->count <= 0) inv = nullptr; + return true; + } + return false; +} + +void IUIScene_CraftingMenu::Special_GiveLocalItem(shared_ptr item) +{ + if (item == nullptr) return; + if (!m_pPlayer->inventory->add(item)) m_pPlayer->drop(item); +} + +bool IUIScene_CraftingMenu::Special_AddStackedRecipe() +{ + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (m_iGroupHIndex == 0) + { + bool enabled = false; + shared_ptr item = Special_GetSpinnerItem(m_iCurrentSlotHIndex, getSpecialSelection(), enabled); + if (item == nullptr || !enabled) + { + ui.PlayUISFX(eSFX_CraftFail); + return false; + } + + Special_ClearBase(); + if (isInventoryItem()) + { + m_baseRecipeItem = ItemInstance::clone(item); + m_baseRecipeItem->count = 1; + m_bBaseFromInventory = true; + } + else if (isDuplicateItem()) + { + if (Special_GetBannerPatternCount(item) >= m_iMaxBannerPatterns) + { + ui.PlayUISFX(eSFX_CraftFail); + return false; + } + m_baseRecipeItem = ItemInstance::clone(item); + m_baseRecipeItem->count = 1; + m_iBaseCopySlot = m_duplicateItemSlots[getSpecialSelection()].first; + } + else + { + int recipeIndex = m_specialColumns[0].recipes[getSpecialSelection()]; + m_baseRecipeItem = ItemInstance::clone(m_specialRecipes[recipeIndex].result); + m_baseRecipeItem->count = 1; + m_iBaseCreateRecipe = recipeIndex; + } + ui.PlayUISFX(eSFX_Focus); + Special_UpdateAccumulatedItem(); + m_iGroupHIndex = 1; + Special_EnterGroup(); + return true; + } + + if (!Special_CanAddMoreStacks()) + { + ui.PlayUISFX(eSFX_CraftFail); + return false; + } + + int recipeIndex = Special_GetSelectedRecipe(); + if (recipeIndex < 0 || !m_specialRecipes[recipeIndex].available) + { + if (recipeIndex >= 0 && pMinecraft->localgameModes[getPad()] != nullptr) + { + Tutorial* tutorial = pMinecraft->localgameModes[getPad()]->getTutorial(); + if (tutorial != nullptr) tutorial->createItemSelected(m_specialRecipes[recipeIndex].result, false); + } + ui.PlayUISFX(eSFX_CraftFail); + return false; + } + + m_stackedRecipes.push_back(recipeIndex); + Special_UpdateAccumulatedItem(); + ui.PlayUISFX(eSFX_Focus); + Special_CheckRecipesAvailable(); + Special_UpdateVerticalSlots(); + Special_UpdateHighlight(); + return true; +} + +void IUIScene_CraftingMenu::Special_RemoveStackedRecipe() +{ + if (!m_stackedRecipes.empty()) + { + m_stackedRecipes.pop_back(); + Special_UpdateAccumulatedItem(); + ui.PlayUISFX(eSFX_Focus); + if (!m_stackedRecipes.empty() || m_bBaseFromInventory) + { + Special_CheckRecipesAvailable(); + Special_UpdateVerticalSlots(); + Special_UpdateHighlight(); + return; + } + } + + Special_ClearBase(); + m_iGroupHIndex = 0; + ui.PlayUISFX(eSFX_Focus); + Special_EnterGroup(); +} + +void IUIScene_CraftingMenu::Special_AddCustomIngredient(shared_ptr item) +{ + int gridSize = m_iContainerType == RECIPE_TYPE_2x2 ? 2 : 3; + bool placed = false; + for (int y = 0; y < gridSize && !placed; y++) + { + for (int x = 0; x < gridSize && !placed; x++) + { + int slot = y * gridSize + x; + if (m_craftingContainer->getItem(slot) != nullptr) continue; + item->count = 1; + m_craftingContainer->setItem(slot, item); + m_customGridItems[slot] = item; + m_customIngredientSlots.push_back(slot); + placed = true; + } + } + ui.PlayUISFX(placed ? eSFX_Focus : eSFX_CraftFail); + Special_UpdateHighlight(); +} + +void IUIScene_CraftingMenu::Special_RemoveLastCustomIngredient() +{ + if (!m_customIngredientSlots.empty()) + { + m_customGridItems[m_customIngredientSlots.back()] = nullptr; + m_customIngredientSlots.pop_back(); + ui.PlayUISFX(eSFX_Focus); + } + Special_RefreshBaseItemSlots(nullptr); + Special_CheckRecipesAvailable(); + Special_UpdateVerticalSlots(); + Special_UpdateHighlight(); +} + +void IUIScene_CraftingMenu::Special_Craft() +{ + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (!m_pPlayer || !m_pPlayer->inventory) return; + MultiPlayerGameMode* gameMode = pMinecraft->localgameModes[getPad()]; + if (gameMode == nullptr) return; + bool craftAnything = isCraftAnything(); + + if (m_iGroupVIndex == eGroupVType_Firework) + { + Special_DisplayCustomRecipeIngredients(); + shared_ptr result = Special_GetFireworkResult(); + if ((!m_customRecipeValid && !craftAnything) || result == nullptr) + { + ui.PlayUISFX(eSFX_CraftFail); + return; + } + + vector > ingredients; + for (unsigned int slot = 0; slot < m_craftingContainer->getContainerSize(); slot++) + { + shared_ptr item = m_craftingContainer->getItem(slot); + if (item == nullptr) continue; + shared_ptr single = ItemInstance::clone(item); + single->count = 1; + ingredients.push_back(single); + } + + Tutorial* tutorial = gameMode->getTutorial(); + if (tutorial != nullptr) tutorial->onCrafted(result); + + int starSlot = -1; + if (result->id == Item::firework_charge_Id) + { + for (size_t i = 0; i < ingredients.size() && starSlot < 0; i++) + { + if (ingredients[i]->id != Item::firework_charge_Id) continue; + for (unsigned int s = 0; s < m_pPlayer->inventory->items.length; s++) + { + if (sameIngredient(m_pPlayer->inventory->items[s], ingredients[i])) + { + starSlot = static_cast(s); + break; + } + } + } + } + + gameMode->handleCraftCustom(ingredients, m_pPlayer); + if (!craftAnything) + { + for (size_t i = 0; i < ingredients.size(); i++) + Special_RemoveMatchingFromLocalInventory(ingredients[i]); + } + result->onCraftedBy(m_pPlayer->level, dynamic_pointer_cast(m_pPlayer->shared_from_this()), result->count); + shared_ptr selected = ItemInstance::clone(result); + selected->count = 1; + if (starSlot >= 0 && m_pPlayer->inventory->items[starSlot] == nullptr) + m_pPlayer->inventory->items[starSlot] = result; + else + Special_GiveLocalItem(result); + ui.PlayUISFX(eSFX_Craft); + + if (m_iGroupHIndex == 1) Special_ClearCustomIngredients(); + Special_RefreshBaseItemSlots(selected); + Special_CheckRecipesAvailable(); + Special_UpdateVerticalSlots(); + Special_UpdateHighlight(); + return; + } + + if (m_iGroupHIndex == 0) + { + bool enabled = false; + shared_ptr item = Special_GetSpinnerItem(m_iCurrentSlotHIndex, getSpecialSelection(), enabled); + if (item == nullptr) return; + + if (isInventoryItem()) + { + Special_AddStackedRecipe(); + return; + } + + if (isDuplicateItem()) + { + if (!enabled) + { + ui.PlayUISFX(eSFX_CraftFail); + return; + } + gameMode->handleCopyBanner(item, m_pPlayer); + if (!craftAnything) + { + shared_ptr blank = std::make_shared(Tile::standing_banner_Id, 1, item->getAuxValue()); + for (unsigned int i = 0; i < m_pPlayer->inventory->items.length; i++) + { + shared_ptr& inv = m_pPlayer->inventory->items[i]; + if (inv == nullptr || inv->id != Tile::standing_banner_Id || inv->getAuxValue() != item->getAuxValue()) continue; + if (Special_GetBannerPatternCount(inv) != 0) continue; + inv->count--; + if (inv->count <= 0) inv = nullptr; + break; + } + } + shared_ptr copy = ItemInstance::clone(item); + copy->count = 1; + Special_GiveLocalItem(copy); + ui.PlayUISFX(eSFX_Craft); + Special_EnterGroup(); + return; + } + + int recipeIndex = m_specialColumns[0].recipes[getSpecialSelection()]; + SpecialRecipe& recipe = m_specialRecipes[recipeIndex]; + if (!recipe.available && !craftAnything) + { + Tutorial* tutorial = gameMode->getTutorial(); + if (tutorial != nullptr) tutorial->createItemSelected(recipe.result, false); + ui.PlayUISFX(eSFX_CraftFail); + return; + } + shared_ptr result = ItemInstance::clone(recipe.result); + Tutorial* tutorial = gameMode->getTutorial(); + if (tutorial != nullptr) tutorial->onCrafted(result); + gameMode->handleCraftItem(recipe.recipeIndex, m_pPlayer); + if (!craftAnything) + { + for (int i = 0; i < recipe.ingC; i++) + Special_RemoveFromLocalInventory(recipe.ingId[i], recipe.ingAux[i], recipe.ingCount[i]); + } + result->onCraftedBy(m_pPlayer->level, dynamic_pointer_cast(m_pPlayer->shared_from_this()), result->count); + Special_GiveLocalItem(result); + ui.PlayUISFX(eSFX_Craft); + Special_EnterGroup(); + return; + } + + if (m_stackedRecipes.empty() || m_baseRecipeItem == nullptr) + { + ui.PlayUISFX(eSFX_CraftFail); + return; + } + + shared_ptr findBanner = ItemInstance::clone(m_baseRecipeItem); + findBanner->count = 1; + + if (m_iBaseCreateRecipe >= 0) + { + SpecialRecipe& baseRecipe = m_specialRecipes[m_iBaseCreateRecipe]; + gameMode->handleCraftItem(baseRecipe.recipeIndex, m_pPlayer); + if (!craftAnything) + { + for (int i = 0; i < baseRecipe.ingC; i++) + Special_RemoveFromLocalInventory(baseRecipe.ingId[i], baseRecipe.ingAux[i], baseRecipe.ingCount[i]); + } + } + else if (m_iBaseCopySlot >= 0) + { + gameMode->handleCopyBanner(findBanner, m_pPlayer); + if (!craftAnything) + { + for (unsigned int i = 0; i < m_pPlayer->inventory->items.length; i++) + { + shared_ptr& inv = m_pPlayer->inventory->items[i]; + if (inv == nullptr || inv->id != Tile::standing_banner_Id || inv->getAuxValue() != findBanner->getAuxValue()) continue; + if (Special_GetBannerPatternCount(inv) != 0) continue; + inv->count--; + if (inv->count <= 0) inv = nullptr; + break; + } + } + } + + vector patterns; + for (size_t i = 0; i < m_stackedRecipes.size(); i++) + { + const SpecialRecipe& recipe = m_specialRecipes[m_stackedRecipes[i]]; + patterns.push_back(PreviewBannerData(static_cast(recipe.patternIndex), static_cast(recipe.dye))); + } + gameMode->handleCraftBanner(findBanner, patterns, m_pPlayer); + + if (!craftAnything) + { + for (size_t i = 0; i < m_stackedRecipes.size(); i++) + { + const SpecialRecipe& recipe = m_specialRecipes[m_stackedRecipes[i]]; + for (int j = 0; j < recipe.ingC; j++) + Special_RemoveFromLocalInventory(recipe.ingId[j], recipe.ingAux[j], recipe.ingCount[j]); + } + if (m_bBaseFromInventory) Special_RemoveMatchingFromLocalInventory(findBanner); + } + + shared_ptr result = ItemInstance::clone(m_accumulatedItem); + result->count = 1; + Tutorial* tutorial = gameMode->getTutorial(); + if (tutorial != nullptr) tutorial->onCrafted(result); + Special_GiveLocalItem(result); + ui.PlayUISFX(eSFX_Craft); + + Special_ClearBase(); + m_iGroupHIndex = 0; + Special_EnterGroup(); +} + +void IUIScene_CraftingMenu::Special_ChangeGroup(int direction) +{ + int groups = getSpecialGroupCount(); + if (groups <= 0) return; + + if (m_iGroupVIndex == eGroupVType_Banner) + { + if (m_baseRecipeItem == nullptr) return; + m_iGroupHIndex += direction; + if (m_iGroupHIndex >= groups) m_iGroupHIndex = 1; + if (m_iGroupHIndex < 1) m_iGroupHIndex = groups - 1; + } + else + { + m_iGroupHIndex += direction; + if (m_iGroupHIndex >= groups) m_iGroupHIndex = 0; + if (m_iGroupHIndex < 0) m_iGroupHIndex = groups - 1; + } + ui.PlayUISFX(eSFX_Focus); + Special_EnterGroup(); +} + +void IUIScene_CraftingMenu::Special_ScrollHorizontal(int direction) +{ + int slots = isSpinnerGroup() ? getNumSpinnerSlots() : m_iSpecialHSlotC; + if (slots <= 0) return; + int oldSlot = m_iCurrentSlotHIndex; + m_iCurrentSlotHIndex += direction; + if (m_iCurrentSlotHIndex >= slots) m_iCurrentSlotHIndex = 0; + if (m_iCurrentSlotHIndex < 0) m_iCurrentSlotHIndex = slots - 1; + Special_ResetVerticalSlots(); + if (!isSpinnerGroup()) setShowCraftHSlot(oldSlot, true); + ui.PlayUISFX(eSFX_Focus); + UpdateCraftingPanels(); + Special_UpdateVerticalSlots(); + Special_UpdateHighlight(); +} + +void IUIScene_CraftingMenu::Special_ScrollVertical(int direction) +{ + int count = getSpecialVSlotCount(); + if (count <= 1) return; + + bool singleColumn = isSpinnerGroup() || m_bSplitscreen || (!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()); +#ifdef __PSVITA__ + singleColumn = true; +#endif + + if (singleColumn) + { + iVSlotIndexA[1] += direction; + if (iVSlotIndexA[1] >= count) iVSlotIndexA[1] = 0; + if (iVSlotIndexA[1] < 0) iVSlotIndexA[1] = count - 1; + m_iCurrentSlotVIndex = 1; + } + else if (direction < 0) + { + if (count > 2) + { + if (m_iCurrentSlotVIndex != 0) + { + m_iCurrentSlotVIndex--; + } + else + { + iVSlotIndexA[2] = iVSlotIndexA[1]; + iVSlotIndexA[1] = iVSlotIndexA[0]; + iVSlotIndexA[0] = (iVSlotIndexA[0] == 0) ? count - 1 : iVSlotIndexA[0] - 1; + } + } + else if (m_iCurrentSlotVIndex != 1) + { + m_iCurrentSlotVIndex--; + } + } + else + { + if (count > 2) + { + if (m_iCurrentSlotVIndex != 2) + { + m_iCurrentSlotVIndex++; + } + else + { + iVSlotIndexA[0] = iVSlotIndexA[1]; + iVSlotIndexA[1] = iVSlotIndexA[2]; + iVSlotIndexA[2] = (iVSlotIndexA[2] == count - 1) ? 0 : iVSlotIndexA[2] + 1; + } + } + else if (m_iCurrentSlotVIndex != count) + { + m_iCurrentSlotVIndex++; + } + } + + ui.PlayUISFX(eSFX_Focus); + Special_UpdateVerticalSlots(); + Special_UpdateHighlight(); +} + +bool IUIScene_CraftingMenu::Special_HandleKeyDown(int iPad, int iAction, bool bRepeat) +{ + bool handled = false; + + switch (iAction) + { + case ACTION_MENU_PAUSEMENU: + case ACTION_MENU_B: + ui.ShowTooltip(iPad, eToolTipButtonX, false); + ui.ShowTooltip(iPad, eToolTipButtonB, false); + ui.ShowTooltip(iPad, eToolTipButtonA, false); + ui.ShowTooltip(iPad, eToolTipButtonRB, false); + ui.CloseUIScenes(iPad); + return true; + case ACTION_MENU_A: +#ifdef __ORBIS__ + case ACTION_MENU_TOUCHPAD_PRESS: +#endif + Special_Craft(); + Special_UpdateTooltips(); + return true; + case ACTION_MENU_X: + if (bRepeat) return true; + if (m_iGroupVIndex == eGroupVType_Firework) Special_RemoveLastCustomIngredient(); + else if (m_iGroupHIndex > 0) Special_RemoveStackedRecipe(); + Special_UpdateTooltips(); + return true; + case ACTION_MENU_Y: + if (m_iGroupVIndex == eGroupVType_Firework) + { + bool enabled = false; + shared_ptr item = Special_GetSpinnerItem(m_iCurrentSlotHIndex, m_customRecipeSlots[m_iCurrentSlotHIndex], enabled); + if (Special_CanAddCustomIngredient(item) && enabled && Special_IsValidCustomIngredient(-1, item)) + Special_AddCustomIngredient(ItemInstance::clone(item)); + else + ui.PlayUISFX(eSFX_CraftFail); + } + else + { + Special_AddStackedRecipe(); + } + Special_UpdateTooltips(); + return true; + case ACTION_MENU_LEFT_SCROLL: + Special_ChangeGroup(-1); + return true; + case ACTION_MENU_RIGHT_SCROLL: + Special_ChangeGroup(1); + return true; + case ACTION_MENU_OTHER_STICK_UP: + scrollDescriptionUp(); + break; + case ACTION_MENU_OTHER_STICK_DOWN: + scrollDescriptionDown(); + break; + case ACTION_MENU_RIGHT: + Special_ScrollHorizontal(1); + handled = true; + break; + case ACTION_MENU_LEFT: + Special_ScrollHorizontal(-1); + handled = true; + break; + case ACTION_MENU_UP: + Special_ScrollVertical(-1); + handled = true; + break; + case ACTION_MENU_DOWN: + Special_ScrollVertical(1); + handled = true; + break; + } + return handled; +} diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index 8053ecac..cbbe5e58 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -238,22 +238,73 @@ void IUIScene_CreativeMenu::staticCtor() ITEM(Tile::purpur_stairs_Id) ITEM(Tile::hardened_clay_Id) - ITEM_AUX(Tile::stained_hardened_clay_Id,14) // Red - ITEM_AUX(Tile::stained_hardened_clay_Id,1) // Orange - ITEM_AUX(Tile::stained_hardened_clay_Id,4) // Yellow - ITEM_AUX(Tile::stained_hardened_clay_Id,5) // Lime + ITEM_AUX(Tile::stained_hardened_clay_Id,15) // Black + ITEM_AUX(Tile::stained_hardened_clay_Id,11) // Blue ITEM_AUX(Tile::stained_hardened_clay_Id,3) // Light Blue ITEM_AUX(Tile::stained_hardened_clay_Id,9) // Cyan - ITEM_AUX(Tile::stained_hardened_clay_Id,11) // Blue - ITEM_AUX(Tile::stained_hardened_clay_Id,10) // Purple - ITEM_AUX(Tile::stained_hardened_clay_Id,2) // Magenta + ITEM_AUX(Tile::stained_hardened_clay_Id,13) // Green + ITEM_AUX(Tile::stained_hardened_clay_Id,5) // Lime ITEM_AUX(Tile::stained_hardened_clay_Id,6) // Pink + ITEM_AUX(Tile::stained_hardened_clay_Id,2) // Magenta + ITEM_AUX(Tile::stained_hardened_clay_Id,10) // Purple + ITEM_AUX(Tile::stained_hardened_clay_Id,14) // Red + ITEM_AUX(Tile::stained_hardened_clay_Id,12) // Brown + ITEM_AUX(Tile::stained_hardened_clay_Id,1) // Orange + ITEM_AUX(Tile::stained_hardened_clay_Id,4) // Yellow ITEM_AUX(Tile::stained_hardened_clay_Id,0) // White ITEM_AUX(Tile::stained_hardened_clay_Id,8) // Light Gray ITEM_AUX(Tile::stained_hardened_clay_Id,7) // Gray - ITEM_AUX(Tile::stained_hardened_clay_Id,15) // Black - ITEM_AUX(Tile::stained_hardened_clay_Id,13) // Green - ITEM_AUX(Tile::stained_hardened_clay_Id,12) // Brown + + ITEM(Tile::black_glazed_terracotta_Id) + ITEM(Tile::blue_glazed_terracotta_Id) + ITEM(Tile::light_blue_glazed_terracotta_Id) + ITEM(Tile::cyan_glazed_terracotta_Id) + ITEM(Tile::green_glazed_terracotta_Id) + ITEM(Tile::lime_glazed_terracotta_Id) + ITEM(Tile::pink_glazed_terracotta_Id) + ITEM(Tile::magenta_glazed_terracotta_Id) + ITEM(Tile::purple_glazed_terracotta_Id) + ITEM(Tile::red_glazed_terracotta_Id) + ITEM(Tile::brown_glazed_terracotta_Id) + ITEM(Tile::orange_glazed_terracotta_Id) + ITEM(Tile::yellow_glazed_terracotta_Id) + ITEM(Tile::white_glazed_terracotta_Id) + ITEM(Tile::silver_glazed_terracotta_Id) + ITEM(Tile::gray_glazed_terracotta_Id) + + ITEM_AUX(Tile::concrete_Id,15) + ITEM_AUX(Tile::concrete_Id,11) + ITEM_AUX(Tile::concrete_Id,3) + ITEM_AUX(Tile::concrete_Id,9) + ITEM_AUX(Tile::concrete_Id,13) + ITEM_AUX(Tile::concrete_Id,5) + ITEM_AUX(Tile::concrete_Id,6) + ITEM_AUX(Tile::concrete_Id,2) + ITEM_AUX(Tile::concrete_Id,10) + ITEM_AUX(Tile::concrete_Id,14) + ITEM_AUX(Tile::concrete_Id,12) + ITEM_AUX(Tile::concrete_Id,1) + ITEM_AUX(Tile::concrete_Id,4) + ITEM_AUX(Tile::concrete_Id,0) + ITEM_AUX(Tile::concrete_Id,8) + ITEM_AUX(Tile::concrete_Id,7) + + ITEM_AUX(Tile::concrete_powder_Id,15) + ITEM_AUX(Tile::concrete_powder_Id,11) + ITEM_AUX(Tile::concrete_powder_Id,3) + ITEM_AUX(Tile::concrete_powder_Id,9) + ITEM_AUX(Tile::concrete_powder_Id,13) + ITEM_AUX(Tile::concrete_powder_Id,5) + ITEM_AUX(Tile::concrete_powder_Id,6) + ITEM_AUX(Tile::concrete_powder_Id,2) + ITEM_AUX(Tile::concrete_powder_Id,10) + ITEM_AUX(Tile::concrete_powder_Id,14) + ITEM_AUX(Tile::concrete_powder_Id,12) + ITEM_AUX(Tile::concrete_powder_Id,1) + ITEM_AUX(Tile::concrete_powder_Id,4) + ITEM_AUX(Tile::concrete_powder_Id,0) + ITEM_AUX(Tile::concrete_powder_Id,8) + ITEM_AUX(Tile::concrete_powder_Id,7) // Decoration DEF(eCreativeInventory_Decoration) @@ -320,87 +371,93 @@ void IUIScene_CreativeMenu::staticCtor() ITEM(Tile::chorus_flower_Id) ITEM(Tile::chorus_plant_Id) ITEM(Tile::end_rod_Id) - ITEM_AUX(Tile::standing_banner_Id, 14) // Red - ITEM_AUX(Tile::standing_banner_Id, 1) // Orange - ITEM_AUX(Tile::standing_banner_Id, 4) // Yellow - ITEM_AUX(Tile::standing_banner_Id, 5) // Green - ITEM_AUX(Tile::standing_banner_Id, 3) // Light Blue - ITEM_AUX(Tile::standing_banner_Id, 9) // Cyan - ITEM_AUX(Tile::standing_banner_Id, 11) // Blue - ITEM_AUX(Tile::standing_banner_Id, 10) // Purple - ITEM_AUX(Tile::standing_banner_Id, 2) // Magenta - ITEM_AUX(Tile::standing_banner_Id, 6) // Pink - ITEM_AUX(Tile::standing_banner_Id, 0) // White - ITEM_AUX(Tile::standing_banner_Id, 7) // Dark Grey - ITEM_AUX(Tile::standing_banner_Id, 8) // Light Grey - ITEM_AUX(Tile::standing_banner_Id, 15) // Black - ITEM_AUX(Tile::wool_Id,14) // Red - ITEM_AUX(Tile::wool_Id,1) // Orange - ITEM_AUX(Tile::wool_Id,4) // Yellow - ITEM_AUX(Tile::wool_Id,5) // Lime + ITEM_AUX(Tile::standing_banner_Id, 14) + ITEM_AUX(Tile::standing_banner_Id, 1) + ITEM_AUX(Tile::standing_banner_Id, 4) + ITEM_AUX(Tile::standing_banner_Id, 5) + ITEM_AUX(Tile::standing_banner_Id, 3) + ITEM_AUX(Tile::standing_banner_Id, 9) + ITEM_AUX(Tile::standing_banner_Id, 11) + ITEM_AUX(Tile::standing_banner_Id, 10) + ITEM_AUX(Tile::standing_banner_Id, 2) + ITEM_AUX(Tile::standing_banner_Id, 6) + ITEM_AUX(Tile::standing_banner_Id, 0) + ITEM_AUX(Tile::standing_banner_Id, 7) + ITEM_AUX(Tile::standing_banner_Id, 8) + ITEM_AUX(Tile::standing_banner_Id, 15) + ITEM_AUX(Tile::standing_banner_Id, 13) + ITEM_AUX(Tile::standing_banner_Id, 12) + ITEM_AUX(Tile::wool_Id,15) // Black + ITEM_AUX(Tile::wool_Id,11) // Blue ITEM_AUX(Tile::wool_Id,3) // Light Blue ITEM_AUX(Tile::wool_Id,9) // Cyan - ITEM_AUX(Tile::wool_Id,11) // Blue - ITEM_AUX(Tile::wool_Id,10) // Purple - ITEM_AUX(Tile::wool_Id,2) // Magenta + ITEM_AUX(Tile::wool_Id,13) // Green + ITEM_AUX(Tile::wool_Id,5) // Lime ITEM_AUX(Tile::wool_Id,6) // Pink + ITEM_AUX(Tile::wool_Id,2) // Magenta + ITEM_AUX(Tile::wool_Id,10) // Purple + ITEM_AUX(Tile::wool_Id,14) // Red + ITEM_AUX(Tile::wool_Id,12) // Brown + ITEM_AUX(Tile::wool_Id,1) // Orange + ITEM_AUX(Tile::wool_Id,4) // Yellow ITEM_AUX(Tile::wool_Id,0) // White ITEM_AUX(Tile::wool_Id,8) // Light Gray ITEM_AUX(Tile::wool_Id,7) // Gray - ITEM_AUX(Tile::wool_Id,15) // Black - ITEM_AUX(Tile::wool_Id,13) // Green - ITEM_AUX(Tile::wool_Id,12) // Brown - ITEM_AUX(Tile::carpet_Id,14) // Red - ITEM_AUX(Tile::carpet_Id,1) // Orange - ITEM_AUX(Tile::carpet_Id,4) // Yellow - ITEM_AUX(Tile::carpet_Id,5) // Lime + ITEM_AUX(Tile::carpet_Id,15) // Black + ITEM_AUX(Tile::carpet_Id,11) // Blue ITEM_AUX(Tile::carpet_Id,3) // Light Blue ITEM_AUX(Tile::carpet_Id,9) // Cyan - ITEM_AUX(Tile::carpet_Id,11) // Blue - ITEM_AUX(Tile::carpet_Id,10) // Purple - ITEM_AUX(Tile::carpet_Id,2) // Magenta + ITEM_AUX(Tile::carpet_Id,13) // Green + ITEM_AUX(Tile::carpet_Id,5) // Lime ITEM_AUX(Tile::carpet_Id,6) // Pink + ITEM_AUX(Tile::carpet_Id,2) // Magenta + ITEM_AUX(Tile::carpet_Id,10) // Purple + ITEM_AUX(Tile::carpet_Id,14) // Red + ITEM_AUX(Tile::carpet_Id,12) // Brown + ITEM_AUX(Tile::carpet_Id,1) // Orange + ITEM_AUX(Tile::carpet_Id,4) // Yellow ITEM_AUX(Tile::carpet_Id,0) // White ITEM_AUX(Tile::carpet_Id,8) // Light Gray ITEM_AUX(Tile::carpet_Id,7) // Gray - ITEM_AUX(Tile::carpet_Id,15) // Black - ITEM_AUX(Tile::carpet_Id,13) // Green - ITEM_AUX(Tile::carpet_Id,12) // Brown - ITEM_AUX(Tile::stained_glass_Id,14) // Red - ITEM_AUX(Tile::stained_glass_Id,1) // Orange - ITEM_AUX(Tile::stained_glass_Id,4) // Yellow - ITEM_AUX(Tile::stained_glass_Id,5) // Lime + ITEM_AUX(Tile::stained_glass_Id,15) // Black + ITEM_AUX(Tile::stained_glass_Id,11) // Blue ITEM_AUX(Tile::stained_glass_Id,3) // Light Blue ITEM_AUX(Tile::stained_glass_Id,9) // Cyan - ITEM_AUX(Tile::stained_glass_Id,11) // Blue - ITEM_AUX(Tile::stained_glass_Id,10) // Purple - ITEM_AUX(Tile::stained_glass_Id,2) // Magenta + ITEM_AUX(Tile::stained_glass_Id,13) // Green + ITEM_AUX(Tile::stained_glass_Id,5) // Lime ITEM_AUX(Tile::stained_glass_Id,6) // Pink + ITEM_AUX(Tile::stained_glass_Id,2) // Magenta + ITEM_AUX(Tile::stained_glass_Id,10) // Purple + ITEM_AUX(Tile::stained_glass_Id,14) // Red + ITEM_AUX(Tile::stained_glass_Id,12) // Brown + ITEM_AUX(Tile::stained_glass_Id,1) // Orange + ITEM_AUX(Tile::stained_glass_Id,4) // Yellow ITEM_AUX(Tile::stained_glass_Id,0) // White ITEM_AUX(Tile::stained_glass_Id,8) // Light Gray ITEM_AUX(Tile::stained_glass_Id,7) // Gray - ITEM_AUX(Tile::stained_glass_Id,15) // Black - ITEM_AUX(Tile::stained_glass_Id,13) // Green - ITEM_AUX(Tile::stained_glass_Id,12) // Brown - ITEM_AUX(Tile::stained_glass_pane_Id,14) // Red - ITEM_AUX(Tile::stained_glass_pane_Id,1) // Orange - ITEM_AUX(Tile::stained_glass_pane_Id,4) // Yellow - ITEM_AUX(Tile::stained_glass_pane_Id,5) // Lime + ITEM_AUX(Tile::stained_glass_pane_Id,15) // Black + ITEM_AUX(Tile::stained_glass_pane_Id,11) // Blue ITEM_AUX(Tile::stained_glass_pane_Id,3) // Light Blue ITEM_AUX(Tile::stained_glass_pane_Id,9) // Cyan - ITEM_AUX(Tile::stained_glass_pane_Id,11) // Blue - ITEM_AUX(Tile::stained_glass_pane_Id,10) // Purple - ITEM_AUX(Tile::stained_glass_pane_Id,2) // Magenta + ITEM_AUX(Tile::stained_glass_pane_Id,13) // Green + ITEM_AUX(Tile::stained_glass_pane_Id,5) // Lime ITEM_AUX(Tile::stained_glass_pane_Id,6) // Pink + ITEM_AUX(Tile::stained_glass_pane_Id,2) // Magenta + ITEM_AUX(Tile::stained_glass_pane_Id,10) // Purple + ITEM_AUX(Tile::stained_glass_pane_Id,14) // Red + ITEM_AUX(Tile::stained_glass_pane_Id,12) // Brown + ITEM_AUX(Tile::stained_glass_pane_Id,1) // Orange + ITEM_AUX(Tile::stained_glass_pane_Id,4) // Yellow ITEM_AUX(Tile::stained_glass_pane_Id,0) // White ITEM_AUX(Tile::stained_glass_pane_Id,8) // Light Gray ITEM_AUX(Tile::stained_glass_pane_Id,7) // Gray - ITEM_AUX(Tile::stained_glass_pane_Id,15) // Black - ITEM_AUX(Tile::stained_glass_pane_Id,13) // Green - ITEM_AUX(Tile::stained_glass_pane_Id,12) // Brown + ITEM_AUX(Tile::red_mushroom_block_Id,14) + ITEM_AUX(Tile::brown_mushroom_block_Id,14) + ITEM_AUX(Tile::brown_mushroom_block_Id,0) + ITEM_AUX(Tile::brown_mushroom_block_Id,10) #ifndef _CONTENT_PACKAGE @@ -476,6 +533,22 @@ void IUIScene_CreativeMenu::staticCtor() DEF(eCreativeInventory_Misc) ITEM(Tile::chest_Id) ITEM(Tile::ender_chest_Id) + ITEM(Tile::black_shulker_box_Id) + ITEM(Tile::blue_shulker_box_Id) + ITEM(Tile::light_blue_shulker_box_Id) + ITEM(Tile::cyan_shulker_box_Id) + ITEM(Tile::green_shulker_box_Id) + ITEM(Tile::lime_shulker_box_Id) + ITEM(Tile::pink_shulker_box_Id) + ITEM(Tile::magenta_shulker_box_Id) + ITEM(Tile::purple_shulker_box_Id) + ITEM(Tile::red_shulker_box_Id) + ITEM(Tile::brown_shulker_box_Id) + ITEM(Tile::orange_shulker_box_Id) + ITEM(Tile::yellow_shulker_box_Id) + ITEM(Tile::white_shulker_box_Id) + ITEM(Tile::silver_shulker_box_Id) + ITEM(Tile::gray_shulker_box_Id) ITEM(Tile::crafting_table_Id) ITEM(Tile::furnace_Id) ITEM(Item::brewing_stand_Id) @@ -774,6 +847,8 @@ void IUIScene_CreativeMenu::staticCtor() ITEM(Item::slime_ball_Id) ITEM(Item::blaze_rod_Id) ITEM(Item::gold_nugget_Id) + ITEM(Item::iron_nugget_Id) + ITEM(Item::shulker_shell_Id) ITEM(Item::netherwart_seeds_Id) ITEM(Item::chorus_fruit_popped_Id) ITEM_AUX(Item::dye_Id,1) // Red diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.h b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.h index 55778b00..4bcbc1d7 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.h +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.h @@ -110,6 +110,7 @@ public: static void loadFromLocal(); static void loadFromPacket(byteArray packetData); + static const vector< shared_ptr > &GetCategoryGroup(int group) { return categoryGroups[group]; } static std::shared_ptr createUpdatePacket(); protected: diff --git a/Minecraft.Client/Common/UI/IUIScene_InventoryMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_InventoryMenu.cpp index a38c055b..a5f3300f 100644 --- a/Minecraft.Client/Common/UI/IUIScene_InventoryMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_InventoryMenu.cpp @@ -25,7 +25,10 @@ IUIScene_AbstractContainerMenu::ESceneSection IUIScene_InventoryMenu::GetSection { if (app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting) && *piTargetX >= 3) { - if (*piTargetX < 7) { + if (*piTargetX <= 5) { + newSection = eSectionInventoryOffhand; + } + else if (*piTargetX < 7) { newSection = eSectionInventoryCraftingGrid; xOffset = 5; } @@ -33,6 +36,10 @@ IUIScene_AbstractContainerMenu::ESceneSection IUIScene_InventoryMenu::GetSection newSection = eSectionInventoryCraftingResult; } } + else if (!app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting) && *piTargetX >= 4) + { + newSection = eSectionInventoryOffhand; + } else { newSection = eSectionInventoryArmor; @@ -57,6 +64,10 @@ IUIScene_AbstractContainerMenu::ESceneSection IUIScene_InventoryMenu::GetSection newSection = eSectionInventoryCraftingResult; } } + else if (!app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting) && *piTargetX >= 4) + { + newSection = eSectionInventoryOffhand; + } else { newSection = eSectionInventoryArmor; @@ -77,6 +88,10 @@ IUIScene_AbstractContainerMenu::ESceneSection IUIScene_InventoryMenu::GetSection { newSection = eSectionInventoryCraftingResult; } + else if (eTapDirection == eTapStateRight && (!app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting) || *piTargetY >= 3)) + { + newSection = eSectionInventoryOffhand; + } else if (eTapDirection == eTapStateRight && app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting)) { newSection = eSectionInventoryCraftingGrid; @@ -84,6 +99,58 @@ IUIScene_AbstractContainerMenu::ESceneSection IUIScene_InventoryMenu::GetSection yOffset = 1; } break; + + case eSectionInventoryOffhand: + if (app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting)) + { + if (eTapDirection == eTapStateDown) + { + newSection = eSectionInventoryInventory; + xOffset = -5; + } + else if (eTapDirection == eTapStateUp) + { + newSection = eSectionInventoryCraftingGrid; + } + else if (eTapDirection == eTapStateLeft) + { + newSection = eSectionInventoryArmor; + yOffset = -3; + } + else if (eTapDirection == eTapStateRight) + { + newSection = eSectionInventoryCraftingResult; + } + } + else if (eTapDirection == eTapStateDown) + { + newSection = eSectionInventoryInventory; + xOffset = -4; + } + else if (eTapDirection == eTapStateUp) + { + newSection = eSectionInventoryUsing; + xOffset = -4; + } + else if (eTapDirection == eTapStateLeft) + { + newSection = eSectionInventoryArmor; + yOffset = -3; + } + else if (eTapDirection == eTapStateRight) + { + if (app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting)) + { + newSection = eSectionInventoryCraftingGrid; + yOffset = -1; + } + else + { + newSection = eSectionInventoryArmor; + yOffset = -3; + } + } + break; case eSectionInventoryCraftingGrid: if (app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting)) { @@ -92,6 +159,10 @@ IUIScene_AbstractContainerMenu::ESceneSection IUIScene_InventoryMenu::GetSection newSection = eSectionInventoryUsing; xOffset = -5; } + else if (eTapDirection == eTapStateDown && *piTargetX == 0) + { + newSection = eSectionInventoryOffhand; + } else if (eTapDirection == eTapStateDown) { newSection = eSectionInventoryInventory; @@ -163,6 +234,9 @@ int IUIScene_InventoryMenu::getSectionStartOffset(ESceneSection eSection) case eSectionInventoryCraftingResult: offset = InventoryMenu::RESULT_SLOT; break; + case eSectionInventoryOffhand: + offset = InventoryMenu::OFFHAND_SLOT; + break; default: assert(false); break; diff --git a/Minecraft.Client/Common/UI/SuperflatData.cpp b/Minecraft.Client/Common/UI/SuperflatData.cpp new file mode 100644 index 00000000..c9c5d739 --- /dev/null +++ b/Minecraft.Client/Common/UI/SuperflatData.cpp @@ -0,0 +1,568 @@ +#include "stdafx.h" +#include "UI.h" +#include "SuperflatData.h" +#include "IUIScene_CreativeMenu.h" +#include "../../../Minecraft.World/net.minecraft.world.item.h" +#include "../../../Minecraft.World/net.minecraft.world.level.tile.h" +#include "../../../Minecraft.World/net.minecraft.world.level.biome.h" + +#include + +namespace +{ + const SuperflatData::Param s_params[] = + { + { SuperflatData::eParam_Toggle, L"Villages", L"Villages appear in Plains, Savanna, Desert, Taiga and Ice Plains biomes. They are protected by Iron Golems and populated by villagers you can trade with.", L"village", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_SizeSlider, L"Size", L"Changes how large each village grows.", L"village", L"size", 0, 1, 0 }, + { SuperflatData::eParam_DistanceSlider, L"Spacing", L"Changes how far apart villages are placed.", L"village", L"distance", 16, 100, 32 }, + { SuperflatData::eParam_Toggle, L"Caves", L"Winding tunnels carved through the layers of the world.", L"caves", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_Toggle, L"Ravine", L"Deep, narrow canyons cut down through the layers of the world.", L"ravine", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_Toggle, L"Abandoned Mineshafts", L"Old networks of wooden tunnels and rails, often holding chests with loot.", L"mineshaft", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_ChanceSlider, L"Chance", L"Changes how likely a mineshaft is to appear in each area of the world.", L"mineshaft", L"chance", 1, 10, 10 }, + { SuperflatData::eParam_Toggle, L"Strongholds", L"Underground fortresses made of stone brick that hold the portal to The End.", L"stronghold", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_CountSlider, L"Count", L"Changes how many strongholds are placed in the world.", L"stronghold", L"count", 1, 3, 1 }, + { SuperflatData::eParam_DistanceSlider, L"Spacing", L"Changes how far from the centre of the world the strongholds are placed.", L"stronghold", L"distance", 16, 100, 32 }, + { SuperflatData::eParam_Toggle, L"Biome Structures", L"Desert Temples, Jungle Temples, Witch Huts and Igloos, each generated in its own biome.", L"biome_1", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_DistanceSlider, L"Spacing", L"Changes how far apart biome structures are placed.", L"biome_1", L"distance", 16, 100, 32 }, + { SuperflatData::eParam_Toggle, L"Ocean Monuments", L"Huge underwater temples guarded by Guardians. They need an Ocean or Deep Ocean biome and deep water.", L"oceanmonument", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_DistanceSlider, L"Spacing", L"Changes how far apart ocean monuments are placed.", L"oceanmonument", L"spacing", 32, 100, 32 }, + { SuperflatData::eParam_SeparationSlider, L"Separation", L"Changes the minimum gap between ocean monuments, as a share of their spacing.", L"oceanmonument", L"separation", 5, 15, 5 }, + { SuperflatData::eParam_Toggle, L"Dungeons", L"Small rooms of cobblestone with a monster spawner and chests.", L"dungeon", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_Toggle, L"Decorations", L"Trees, flowers, tall grass and other features that suit the chosen biome.", L"decoration", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_Toggle, L"Lakes", L"Small pools of water scattered across the surface.", L"lake", nullptr, 0, 0, 0 }, + { SuperflatData::eParam_Toggle, L"Lava Lakes", L"Small pools of lava scattered across the world.", L"lava_lake", nullptr, 0, 0, 0 }, + }; + + const int s_paramCount = static_cast(sizeof(s_params) / sizeof(s_params[0])); + + struct BiomeEntry + { + int id; + const wchar_t *name; + const wchar_t *description; + int iconId; + int iconData; + }; + + const BiomeEntry s_biomes[] = + { + { 1, L"Plains", L"Open, grassy land with very few trees. Horses and farm animals roam here and villages can appear.", Tile::grass_Id, 0 }, + { 35, L"Savanna", L"Dry, warm grassland dotted with acacia trees. Villages and horses can be found here.", Tile::sapling_Id, 4 }, + { 37, L"Mesa", L"A dry land of layered, coloured hardened clay and red sand.", Tile::sand_Id, 1 }, + { 2, L"Desert", L"Hot, sandy land covered in cacti and dead bushes. Desert temples and villages can appear here.", Tile::sand_Id, 0 }, + { 4, L"Forest", L"Woodland full of oak and birch trees, with flowers growing on the ground.", Tile::log_Id, 0 }, + { 29, L"Roofed Forest", L"A dense forest of dark oak trees and giant mushrooms that blocks out the sunlight.", Tile::log2_Id, 1 }, + { 21, L"Jungle", L"Thick rainforest full of huge trees, vines and cocoa. Jungle temples and ocelots can be found here.", Tile::cocoa_Id, 0 }, + { 6, L"Swampland", L"Wet, murky land of shallow water, lily pads and vines. Witch huts and slimes can appear here.", Tile::waterlily_Id, 0 }, + { 3, L"Extreme Hills", L"Tall, rocky mountains where emerald ore can be found.", Tile::stone_Id, 0 }, + { 0, L"Ocean", L"Wide stretches of water. Squid swim here.", -1, 0 }, + { 24, L"Deep Ocean", L"Deep stretches of water where Ocean Monuments can appear.", -1, 0 }, + { 12, L"Ice Plains", L"A frozen, snow covered plain where water turns to ice. Igloos and villages can appear here.", Tile::ice_Id, 0 }, + { 30, L"Cold Taiga", L"A snowy forest of spruce trees. Wolves and rabbits live here.", Tile::snow_layer_Id, 0 }, + { 5, L"Taiga", L"A cool forest of spruce trees and ferns. Wolves can be found here.", Tile::leaves_Id, 1 }, + { 32, L"Mega Taiga", L"A forest of giant spruce trees with mossy boulders.", Tile::log2_Id, 0 }, + { 14, L"Mushroom Island", L"A rare island covered in mycelium and giant mushrooms, home to mooshrooms.", Tile::mushroom_red_Id, 0 }, + { 8, L"Nether", L"A fiery dimension of netherrack, lava and dangerous creatures.", Tile::netherrack_Id, 0 }, + { 9, L"The End", L"A dark, empty dimension of end stone floating in the void.", Tile::end_stone_Id, 0 }, + }; + + const int s_biomeCount = static_cast(sizeof(s_biomes) / sizeof(s_biomes[0])); + + const wchar_t *s_presetNames[] = + { + L"Classic Flat", + L"Tunnelers' Dream", + L"Water World", + L"Overworld", + L"Snowy Kingdom", + L"Desert", + L"Redstone Ready", + }; + + const int s_presetCount = static_cast(sizeof(s_presetNames) / sizeof(s_presetNames[0])); + + struct BlockEntry + { + int id; + int data; + }; + + vector &Blocks() + { + static vector s_blocks; + return s_blocks; + } + + void BuildBlocks() + { + vector &blocks = Blocks(); + if (!blocks.empty()) + return; + blocks.push_back({ 0, 0 }); + blocks.push_back({ Tile::water_Id, 0 }); + blocks.push_back({ Tile::lava_Id, 0 }); + std::set seen; + seen.insert(0); + seen.insert(Tile::water_Id << 4); + seen.insert(Tile::lava_Id << 4); + const int groups[] = + { + IUIScene_CreativeMenu::eCreativeInventory_BuildingBlocks, + IUIScene_CreativeMenu::eCreativeInventory_Decoration, + IUIScene_CreativeMenu::eCreativeInventory_Redstone, + }; + for (int g = 0; g < static_cast(sizeof(groups) / sizeof(groups[0])); ++g) + { + const vector > &items = IUIScene_CreativeMenu::GetCategoryGroup(groups[g]); + for (auto &item : items) + { + if (item == nullptr) + continue; + int id = item->id; + if (id <= 0 || id >= 256 || Tile::tiles[id] == nullptr || id == Tile::chest_trap_Id) + continue; + int data = item->getAuxValue() & 15; + int key = (id << 4) | data; + if (seen.find(key) != seen.end()) + continue; + seen.insert(key); + blocks.push_back({ id, data }); + } + } + } + + void GetCustomPresetsPath(wchar_t *out, size_t outLen) + { + wchar_t exePath[MAX_PATH] = {}; + GetModuleFileNameW(nullptr, exePath, MAX_PATH); + wchar_t *lastSlash = wcsrchr(exePath, L'\\'); + if (lastSlash) + *(lastSlash + 1) = L'\0'; + _snwprintf_s(out, outLen, _TRUNCATE, L"%lssuperflat_presets.txt", exePath); + } +} + +int SuperflatData::GetParamCount() +{ + return s_paramCount; +} + +const SuperflatData::Param &SuperflatData::GetParam(int index) +{ + return s_params[index]; +} + +int SuperflatData::GetParamParent(int index) +{ + for (int i = index; i >= 0; --i) + { + if (s_params[i].kind == eParam_Toggle) + return i; + } + return -1; +} + +int SuperflatData::ReadParamValue(FlatGeneratorInfo &info, int index) +{ + const Param ¶m = s_params[index]; + if (param.kind == eParam_Toggle) + return info.hasStructure(param.structure) ? 1 : 0; + if (param.kind == eParam_ChanceSlider) + { + wstring raw = info.getOption(param.structure, param.option, L""); + if (raw.empty()) + return param.defaultValue; + double chance = _wtof(raw.c_str()); + int value = static_cast(chance * 1000.0 + 0.5); + if (value < param.minValue) value = param.minValue; + if (value > param.maxValue) value = param.maxValue; + return value; + } + if (param.kind == eParam_SeparationSlider) + { + int spacing = info.getIntOption(param.structure, L"spacing", 32); + int separation = info.getIntOption(param.structure, param.option, -1); + if (separation < 0 || spacing <= 0) + return param.defaultValue; + int value = separation * 100 / (spacing * 5); + if (value < param.minValue) value = param.minValue; + if (value > param.maxValue) value = param.maxValue; + return value; + } + int value = info.getIntOption(param.structure, param.option, param.defaultValue); + if (value < param.minValue) value = param.minValue; + if (value > param.maxValue) value = param.maxValue; + return value; +} + +void SuperflatData::WriteParamValue(FlatGeneratorInfo &info, int index, int value) +{ + const Param ¶m = s_params[index]; + if (param.kind == eParam_Toggle) + { + info.setStructure(param.structure, value != 0); + return; + } + if (!info.hasStructure(param.structure)) + return; + if (param.kind == eParam_SeparationSlider) + { + int spacing = info.getIntOption(param.structure, L"spacing", 32); + int separation = spacing * value * 5 / 100; + if (separation < 5) + separation = 5; + if (separation > spacing - 1) + separation = spacing - 1; + info.setIntOption(param.structure, param.option, separation); + return; + } + if (param.kind == eParam_ChanceSlider) + { + wchar_t buffer[32]; + swprintf(buffer, 32, L"%.3f", value / 1000.0); + info.setOption(param.structure, param.option, buffer); + } + else + { + info.setIntOption(param.structure, param.option, value); + } +} + +wstring SuperflatData::GetParamLabel(int index, int value) +{ + const Param ¶m = s_params[index]; + wchar_t buffer[128]; + switch (param.kind) + { + case eParam_SizeSlider: + swprintf(buffer, 128, L"%ls - %ls", param.name, value == 0 ? L"Small" : L"Large"); + break; + case eParam_DistanceSlider: + swprintf(buffer, 128, L"%ls - %dm", param.name, value * 16); + break; + case eParam_ChanceSlider: + swprintf(buffer, 128, L"%ls - %.1f%%", param.name, value / 10.0); + break; + case eParam_CountSlider: + swprintf(buffer, 128, L"%ls - %d", param.name, value); + break; + case eParam_SeparationSlider: + swprintf(buffer, 128, L"%ls - %d%%", param.name, value * 5); + break; + default: + swprintf(buffer, 128, L"%ls", param.name); + break; + } + return buffer; +} + +int SuperflatData::GetBiomeCount() +{ + return s_biomeCount; +} + +int SuperflatData::GetBiomeId(int index) +{ + if (index < 0 || index >= s_biomeCount) + return 1; + return s_biomes[index].id; +} + +const wchar_t *SuperflatData::GetBiomeName(int index) +{ + if (index < 0 || index >= s_biomeCount) + return L""; + return s_biomes[index].name; +} + +int SuperflatData::GetBiomeIndex(int biomeId) +{ + for (int i = 0; i < s_biomeCount; ++i) + { + if (s_biomes[i].id == biomeId) + return i; + } + return 0; +} + +const wchar_t *SuperflatData::GetBiomeDescription(int index) +{ + if (index < 0 || index >= s_biomeCount) + return L""; + return s_biomes[index].description; +} + +shared_ptr SuperflatData::GetBiomeIcon(int index) +{ + if (index < 0 || index >= s_biomeCount) + return nullptr; + if (s_biomes[index].iconId < 0) + return std::make_shared(Tile::water_Id, 1, 0); + return std::make_shared(s_biomes[index].iconId, 1, s_biomes[index].iconData); +} + +shared_ptr SuperflatData::GetBlockIcon(int id, int data) +{ + if (id <= 0) + return nullptr; + if (id == Tile::water_Id || id == Tile::flowing_water_Id) + return std::make_shared(Tile::water_Id, 1, 0); + if (id == Tile::lava_Id || id == Tile::flowing_lava_Id) + return std::make_shared(Tile::lava_Id, 1, 0); + if (id >= 256 || Tile::tiles[id] == nullptr) + return nullptr; + return std::make_shared(id, 1, data); +} + +wstring SuperflatData::GetBlockDescription(int id, int data) +{ + if (id == 0) + return L"An empty layer that leaves a gap in the world."; + if (id == Tile::water_Id || id == Tile::flowing_water_Id) + return L"A layer of still water."; + if (id == Tile::lava_Id || id == Tile::flowing_lava_Id) + return L"A layer of still lava."; + shared_ptr item = GetBlockIcon(id, data); + if (item == nullptr) + return L""; + unsigned int descId = item->getUseDescriptionId(); + if (descId == 0) + return L""; + LPCWSTR text = app.GetString(descId); + return text ? app.FormatHTMLString(0, wstring(text)) : wstring(L""); +} + +shared_ptr SuperflatData::GetPresetIcon(int index) +{ + switch (index) + { + case 0: return std::make_shared(Tile::grass_Id, 1, 0); + case 1: return std::make_shared(Tile::stone_Id, 1, 0); + case 2: return std::make_shared(Tile::water_Id, 1, 0); + case 3: return std::make_shared(Tile::tallgrass_Id, 1, 1); + case 4: return std::make_shared(Tile::snow_layer_Id, 1, 0); + case 5: return std::make_shared(Tile::sand_Id, 1, 0); + case 6: return std::make_shared(Item::redstone); + } + return nullptr; +} + + +int SuperflatData::GetPresetCount() +{ + return s_presetCount; +} + +const wchar_t *SuperflatData::GetPresetName(int index) +{ + if (index < 0 || index >= s_presetCount) + return L""; + return s_presetNames[index]; +} + +FlatGeneratorInfo SuperflatData::MakePreset(int index) +{ + FlatGeneratorInfo info; + info.clear(); + switch (index) + { + case 0: + info.setBiome(1); + info.setStructure(FlatGeneratorInfo::STRUCTURE_VILLAGE, true); + info.addLayerOnTop(1, Tile::bedrock_Id); + info.addLayerOnTop(2, Tile::dirt_Id); + info.addLayerOnTop(1, Tile::grass_Id); + break; + case 1: + info.setBiome(3); + info.setStructure(FlatGeneratorInfo::STRUCTURE_DUNGEON, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_DECORATION, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_STRONGHOLD, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_MINESHAFT, true); + info.addLayerOnTop(1, Tile::bedrock_Id); + info.addLayerOnTop(100, Tile::stone_Id); + info.addLayerOnTop(5, Tile::dirt_Id); + info.addLayerOnTop(1, Tile::grass_Id); + break; + case 2: + info.setBiome(24); + info.addLayerOnTop(1, Tile::bedrock_Id); + info.addLayerOnTop(5, Tile::stone_Id); + info.addLayerOnTop(5, Tile::dirt_Id); + info.addLayerOnTop(5, Tile::sand_Id); + info.addLayerOnTop(90, Tile::water_Id); + break; + case 3: + info.setBiome(1); + info.setStructure(FlatGeneratorInfo::STRUCTURE_VILLAGE, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_DECORATION, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_STRONGHOLD, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_MINESHAFT, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_DUNGEON, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_LAKE, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_LAVA_LAKE, true); + info.addLayerOnTop(1, Tile::bedrock_Id); + info.addLayerOnTop(59, Tile::stone_Id); + info.addLayerOnTop(3, Tile::dirt_Id); + info.addLayerOnTop(1, Tile::grass_Id); + break; + case 4: + info.setBiome(12); + info.setStructure(FlatGeneratorInfo::STRUCTURE_VILLAGE, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_SPECIFIC, true); + info.addLayerOnTop(1, Tile::bedrock_Id); + info.addLayerOnTop(59, Tile::stone_Id); + info.addLayerOnTop(3, Tile::dirt_Id); + info.addLayerOnTop(1, Tile::grass_Id); + info.addLayerOnTop(1, Tile::snow_layer_Id); + break; + case 5: + info.setBiome(2); + info.setStructure(FlatGeneratorInfo::STRUCTURE_VILLAGE, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_SPECIFIC, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_DECORATION, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_STRONGHOLD, true); + info.setStructure(FlatGeneratorInfo::STRUCTURE_MINESHAFT, true); + info.addLayerOnTop(1, Tile::bedrock_Id); + info.addLayerOnTop(3, Tile::stone_Id); + info.addLayerOnTop(52, Tile::sandstone_Id); + info.addLayerOnTop(8, Tile::sand_Id); + break; + case 6: + info.setBiome(2); + info.addLayerOnTop(1, Tile::bedrock_Id); + info.addLayerOnTop(3, Tile::stone_Id); + info.addLayerOnTop(52, Tile::sandstone_Id); + break; + default: + return FlatGeneratorInfo::getDefault(); + } + return info; +} + +int SuperflatData::GetBlockCount() +{ + BuildBlocks(); + return static_cast(Blocks().size()); +} + +int SuperflatData::GetBlockId(int index) +{ + BuildBlocks(); + return Blocks()[index].id; +} + +int SuperflatData::GetBlockData(int index) +{ + BuildBlocks(); + return Blocks()[index].data; +} + +int SuperflatData::FindBlock(int id, int data) +{ + BuildBlocks(); + vector &blocks = Blocks(); + for (size_t i = 0; i < blocks.size(); ++i) + { + if (blocks[i].id == id && blocks[i].data == data) + return static_cast(i); + } + for (size_t i = 0; i < blocks.size(); ++i) + { + if (blocks[i].id == id) + return static_cast(i); + } + return -1; +} + +wstring SuperflatData::GetBlockName(int id, int data) +{ + if (id == 0) + return L"Air"; + if (id == Tile::water_Id || id == Tile::flowing_water_Id) + return L"Water"; + if (id == Tile::lava_Id || id == Tile::flowing_lava_Id) + return L"Lava"; + if (id < 0 || id >= 256 || Tile::tiles[id] == nullptr) + return L"Unknown"; + shared_ptr item = std::make_shared(id, 1, data); + wstring name = item->getHoverName(); + if (name.empty()) + name = L"Block " + std::to_wstring(id); + return name; +} + +wstring SuperflatData::GetLayerLabel(FlatLayerInfo &layer) +{ + return std::to_wstring(layer.getHeight()) + L" x " + GetBlockName(layer.getId(), layer.getData()); +} + +vector &SuperflatData::GetCustomPresets() +{ + static vector s_presets; + return s_presets; +} + +void SuperflatData::LoadCustomPresets() +{ + vector &presets = GetCustomPresets(); + presets.clear(); + wchar_t path[MAX_PATH] = {}; + GetCustomPresetsPath(path, MAX_PATH); + FILE *f = nullptr; + if (_wfopen_s(&f, path, L"r, ccs=UTF-8") != 0 || !f) + return; + wchar_t line[2048]; + while (fgetws(line, 2048, f)) + { + size_t len = wcslen(line); + while (len > 0 && (line[len - 1] == L'\n' || line[len - 1] == L'\r')) + line[--len] = L'\0'; + wchar_t *tab = wcschr(line, L'\t'); + if (!tab) + continue; + *tab = L'\0'; + CustomPreset preset; + preset.name = line; + preset.value = tab + 1; + if (!preset.name.empty() && !preset.value.empty()) + presets.push_back(preset); + } + fclose(f); +} + +void SuperflatData::SaveCustomPresets() +{ + wchar_t path[MAX_PATH] = {}; + GetCustomPresetsPath(path, MAX_PATH); + FILE *f = nullptr; + if (_wfopen_s(&f, path, L"w, ccs=UTF-8") != 0 || !f) + return; + for (auto &preset : GetCustomPresets()) + fwprintf(f, L"%ls\t%ls\n", preset.name.c_str(), preset.value.c_str()); + fclose(f); +} + +wstring SuperflatData::GetDefaultOptions() +{ + return MakePreset(0).toString(); +} + +wstring SuperflatData::Describe(FlatGeneratorInfo &info) +{ + wstring text = L"Biome: "; + text += GetBiomeName(GetBiomeIndex(info.getBiome())); + text += L"\nLayers:"; + vector &layers = *info.getLayers(); + for (int i = static_cast(layers.size()) - 1; i >= 0; --i) + text += L"\n- " + GetLayerLabel(layers[i]); + wstring features; + for (int i = 0; i < s_paramCount; ++i) + { + if (s_params[i].kind == eParam_Toggle && info.hasStructure(s_params[i].structure)) + features += wstring(L"\n- ") + s_params[i].name; + } + if (!features.empty()) + text += L"\nFeatures:" + features; + return text; +} diff --git a/Minecraft.Client/Common/UI/SuperflatData.h b/Minecraft.Client/Common/UI/SuperflatData.h new file mode 100644 index 00000000..7f9db4a9 --- /dev/null +++ b/Minecraft.Client/Common/UI/SuperflatData.h @@ -0,0 +1,71 @@ +#pragma once + +#include "../../../Minecraft.World/FlatGeneratorInfo.h" + +class ItemInstance; + +namespace SuperflatData +{ + enum EParamKind + { + eParam_Toggle, + eParam_SizeSlider, + eParam_DistanceSlider, + eParam_ChanceSlider, + eParam_CountSlider, + eParam_SeparationSlider, + }; + + struct Param + { + EParamKind kind; + const wchar_t *name; + const wchar_t *description; + const wchar_t *structure; + const wchar_t *option; + int minValue; + int maxValue; + int defaultValue; + }; + + struct CustomPreset + { + wstring name; + wstring value; + }; + + int GetParamCount(); + const Param &GetParam(int index); + int GetParamParent(int index); + int ReadParamValue(FlatGeneratorInfo &info, int index); + void WriteParamValue(FlatGeneratorInfo &info, int index, int value); + wstring GetParamLabel(int index, int value); + + int GetBiomeCount(); + int GetBiomeId(int index); + const wchar_t *GetBiomeName(int index); + int GetBiomeIndex(int biomeId); + const wchar_t *GetBiomeDescription(int index); + shared_ptr GetBiomeIcon(int index); + shared_ptr GetBlockIcon(int id, int data); + wstring GetBlockDescription(int id, int data); + shared_ptr GetPresetIcon(int index); + + int GetPresetCount(); + const wchar_t *GetPresetName(int index); + FlatGeneratorInfo MakePreset(int index); + + int GetBlockCount(); + int GetBlockId(int index); + int GetBlockData(int index); + int FindBlock(int id, int data); + wstring GetBlockName(int id, int data); + wstring GetLayerLabel(FlatLayerInfo &layer); + + vector &GetCustomPresets(); + void LoadCustomPresets(); + void SaveCustomPresets(); + + wstring GetDefaultOptions(); + wstring Describe(FlatGeneratorInfo &info); +} diff --git a/Minecraft.Client/Common/UI/UI.h b/Minecraft.Client/Common/UI/UI.h index ff54bc46..be33957f 100644 --- a/Minecraft.Client/Common/UI/UI.h +++ b/Minecraft.Client/Common/UI/UI.h @@ -89,6 +89,14 @@ #include "UIScene_SkinSelectMenu.h" #include "UIScene_HowToPlayMenu.h" #include "UIScene_LanguageSelector.h" +#ifdef _WINDOWS64 +#include "UIScene_KeybindsMenu.h" +#include "UIScene_BindingsTypeMenu.h" +#include "UIScene_SuperflatMenu.h" +#include "UIScene_SuperflatEditLayerMenu.h" +#include "UIScene_SuperflatPresetsMenu.h" +#include "UIScene_EditServerMenu.h" +#endif #include "UIScene_HowToPlay.h" #include "UIScene_ControlsMenu.h" #include "UIScene_Credits.h" diff --git a/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp b/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp index 28e0cc0c..2f190ad5 100644 --- a/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp +++ b/Minecraft.Client/Common/UI/UIComponent_Tooltips.cpp @@ -2,6 +2,9 @@ #include "UI.h" #include "UIComponent_Tooltips.h" #include "UISplitScreenHelpers.h" +#ifdef _WINDOWS64 +#include "../../Windows64/KeyboardMouseInput.h" +#endif UIComponent_Tooltips::UIComponent_Tooltips(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { @@ -9,6 +12,15 @@ UIComponent_Tooltips::UIComponent_Tooltips(int iPad, void *initData, UILayer *pa m_lastResizeAwareScreenH = -1.0; m_lastResizeAwareNudgeActive = false; + static unsigned int s_tooltipKeyIconGeneration = 0; + wchar_t keyIconPrefix[64]; + swprintf(keyIconPrefix, 64, L"TipKey_%u_", ++s_tooltipKeyIconGeneration); + m_keyIconPrefix = keyIconPrefix; + for(unsigned int i = 0; i < eToolTipNumButtons; ++i) + { + m_keyIconVk[i] = 0; + } + for(int i=0;i= 0 && m_iPad < XUSER_MAX_COUNT) ? m_iPad : ProfileManager.GetPrimaryPad(); + int controlType = app.GetGameSettings(pad, eGameSetting_ControlType); + if(controlType == 1 || controlType == 3 || controlType == 4) vk = -controlType; + } +#endif + if(m_keyIconVk[i] != vk) + { + m_keyIconVk[i] = vk; + _ApplyKeyIcon(i); + changed = true; + } + } + if(changed) _Relayout(); +} + +void UIComponent_Tooltips::ClearTooltipKeyIcons() +{ + int none[eToolTipNumButtons]; + for(unsigned int i = 0; i < eToolTipNumButtons; ++i) + { + none[i] = 0; + } + SetTooltipKeyIcons(none); +} + +void UIComponent_Tooltips::_ApplyKeyIcon(unsigned int iToolTip) +{ + wstring textureName; + double widthScale = 1.0; +#ifdef _WINDOWS64 + if(m_keyIconVk[iToolTip] < 0) + { + const wchar_t *folder = m_keyIconVk[iToolTip] == -3 ? L"PS3" : (m_keyIconVk[iToolTip] == -4 ? L"PS4" : L"xboxOne"); + textureName = m_keyIconPrefix + L"Pad_" + folder + L"_ButtonRightStick"; + if(!hasRegisteredSubstitutionTexture(textureName)) + { + wstring path = wstring(L"Graphics\\PadIcons\\") + folder + L"\\ButtonRightStick.png"; + byteArray data; + if(app.hasArchiveFile(path)) data = app.getArchiveFile(path); + if(data.data != nullptr && data.length > 0) + { + registerSubstitutionTexture(textureName, data.data, data.length, true); + } + else + { + textureName.clear(); + } + } + } + else if(m_keyIconVk[iToolTip] != 0) + { + bool wide = false; + const wchar_t *icon = KeyboardMouseInput::GetKeyIconName(m_keyIconVk[iToolTip], &wide); + if(icon != nullptr) + { + textureName = m_keyIconPrefix + icon; + if(!hasRegisteredSubstitutionTexture(textureName)) + { + wstring path = wstring(L"Graphics\\KeyIcons\\") + icon + L".png"; + byteArray data; + if(app.hasArchiveFile(path)) data = app.getArchiveFile(path); + if(data.data != nullptr && data.length > 0) + { + registerSubstitutionTexture(textureName, data.data, data.length, true); + } + else + { + textureName.clear(); + } + } + if(wide) widthScale = 2.0; + } + } +#endif + + IggyDataValue result; + IggyDataValue value[3]; + value[0].type = IGGY_DATATYPE_number; + value[0].number = iToolTip; + + IggyStringUTF16 stringVal; + stringVal.string = (IggyUTF16*)textureName.c_str(); + stringVal.length = textureName.length(); + value[1].type = IGGY_DATATYPE_string_UTF16; + value[1].string16 = stringVal; + + value[2].type = IGGY_DATATYPE_number; + value[2].number = widthScale; + IggyPlayerCallMethodRS( getMovie(), &result, IggyPlayerRootPath( getMovie() ), m_funcSetToolTipIcon, 3, value ); +} + bool UIComponent_Tooltips::_SetTooltip(unsigned int iToolTip, int iTextID) { bool changed = false; @@ -526,6 +638,10 @@ void UIComponent_Tooltips::handleReload() { _SetTooltip(i, m_tooltipValues[i].iString, m_tooltipValues[i].show, true); } + for(unsigned int i = 0; i < eToolTipNumButtons; ++i) + { + if(m_keyIconVk[i] != 0) _ApplyKeyIcon(i); + } _Relayout(); } diff --git a/Minecraft.Client/Common/UI/UIComponent_Tooltips.h b/Minecraft.Client/Common/UI/UIComponent_Tooltips.h index db5e769b..366761f1 100644 --- a/Minecraft.Client/Common/UI/UIComponent_Tooltips.h +++ b/Minecraft.Client/Common/UI/UIComponent_Tooltips.h @@ -30,8 +30,10 @@ protected: TooltipValues m_tooltipValues[eToolTipNumButtons]; - IggyName m_funcSetTooltip, m_funcSetOpacity, m_funcSetABSwap, m_funcUpdateLayout; - + IggyName m_funcSetTooltip, m_funcSetOpacity, m_funcSetABSwap, m_funcUpdateLayout, m_funcSetToolTipIcon; + int m_keyIconVk[eToolTipNumButtons]; + wstring m_keyIconPrefix; + #ifdef __PSVITA__ enum ETouchInput { @@ -70,6 +72,7 @@ protected: UI_MAP_NAME( m_funcSetOpacity, L"SetOpacity") UI_MAP_NAME( m_funcSetABSwap, L"SetABSwap") UI_MAP_NAME( m_funcUpdateLayout, L"UpdateLayout") + UI_MAP_NAME( m_funcSetToolTipIcon, L"SetToolTipIcon") UI_END_MAP_ELEMENTS_AND_NAMES() virtual wstring getMoviePath(); @@ -102,6 +105,8 @@ public: virtual void ShowTooltip( unsigned int tooltip, bool show ); virtual void SetTooltips( int iA, int iB=-1, int iX=-1, int iY=-1 , int iLT=-1, int iRT=-1, int iLB=-1, int iRB=-1, int iLS=-1, int iRS=-1, int iBack=-1, bool forceUpdate = false); virtual void EnableTooltip( unsigned int tooltip, bool enable ); + void SetTooltipKeyIcons( const int keyVk[eToolTipNumButtons] ); + void ClearTooltipKeyIcons(); virtual void handleReload(); virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); @@ -113,6 +118,7 @@ private: bool _SetTooltip(unsigned int iToolTip, int iTextID); void _SetTooltip(unsigned int iToolTipId, UIString label, bool show, bool force = false); void _Relayout(); + void _ApplyKeyIcon(unsigned int iToolTip); bool m_overrideSFX[XUSER_MAX_COUNT][ACTION_MAX_MENU]; diff --git a/Minecraft.Client/Common/UI/UIControl_MultiList.cpp b/Minecraft.Client/Common/UI/UIControl_MultiList.cpp index 102efa40..da421577 100644 --- a/Minecraft.Client/Common/UI/UIControl_MultiList.cpp +++ b/Minecraft.Client/Common/UI/UIControl_MultiList.cpp @@ -26,12 +26,18 @@ bool UIControl_MultiList::setupControl(UIScene *scene, IggyValuePath *parent, co m_funcGetCheckBox = registerFastName(L"GetCheckBox"); m_funcSetSliderValue = registerFastName(L"SetSliderValue"); m_funcGetSliderValue = registerFastName(L"GetSliderValue"); - m_funcSetItemLabel = registerFastName(L"SetItemLabel"); + m_funcSetItemLabel = registerFastName(L"SetItemLabel"); + m_funcSetItemIcons = registerFastName(L"SetItemIcons"); + m_funcSetItemLabelLeft = registerFastName(L"SetItemLabelLeft"); + m_funcSetItemEnabled = registerFastName(L"SetItemEnabled"); + m_funcSetItemFlat = registerFastName(L"SetItemFlat"); + m_funcSetItemFlatLabel = registerFastName(L"SetItemFlatLabel"); // these use the same pattern as UIControl_ButtonList m_funcHighlightItem = registerFastName(L"HighlightItem"); m_funcEnableItem = registerFastName(L"EnableItem"); m_funcCheckElementExists = registerFastName(L"CheckElementExists"); m_funcSetTouchFocus = registerFastName(L"SetTouchFocus"); + m_funcCanTouchTrigger = registerFastName(L"CanTouchTrigger"); m_removeAllItemsFunc = registerFastName(L"removeAllItems"); return success; @@ -73,7 +79,7 @@ int UIControl_MultiList::getIdFromIndex(int index) const return -1; } -void UIControl_MultiList::AddNewLabel(const wstring &label) +void UIControl_MultiList::AddNewLabel(const wstring &label, int id) { IggyDataValue result; IggyDataValue value[1]; @@ -87,10 +93,34 @@ void UIControl_MultiList::AddNewLabel(const wstring &label) IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcAddNewItem_Label, 1, value); - m_itemIds.push_back(-1); + m_itemIds.push_back(id); ++m_itemCount; } +void UIControl_MultiList::SetItemFlatLabel(int id, int referenceId, const wstring &label) +{ + int listIndex = getListIndex(id); + int referenceIndex = getListIndex(referenceId); + if (listIndex < 0 || referenceIndex < 0) + return; + + IggyDataValue result; + IggyDataValue args[3]; + args[0].type = IGGY_DATATYPE_number; + args[0].number = (double)listIndex; + args[1].type = IGGY_DATATYPE_number; + args[1].number = (double)referenceIndex; + + IggyStringUTF16 stringVal; + stringVal.string = (IggyUTF16*)label.c_str(); + stringVal.length = label.length(); + args[2].type = IGGY_DATATYPE_string_UTF16; + args[2].string16 = stringVal; + + IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, + IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemFlatLabel, 3, args); +} + void UIControl_MultiList::AddNewButton(const wstring &label, int id) { IggyDataValue result; @@ -303,6 +333,87 @@ void UIControl_MultiList::SetSliderLabel(int id, const wstring &label, bool bImm getIggyValuePath(), m_funcSetItemLabel, 2, args); } +void UIControl_MultiList::SetItemEnabled(int id, bool enabled) +{ + int listIndex = getListIndex(id); + if (listIndex < 0) + return; + + IggyDataValue result; + IggyDataValue args[2]; + + args[0].type = IGGY_DATATYPE_number; + args[0].number = (double)listIndex; + + args[1].type = IGGY_DATATYPE_boolean; + args[1].boolval = enabled ? 1 : 0; + + IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, + IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemEnabled, 2, args); +} + +void UIControl_MultiList::SetItemFlat(int id) +{ + int listIndex = getListIndex(id); + if (listIndex < 0) + return; + + IggyDataValue result; + IggyDataValue args[1]; + args[0].type = IGGY_DATATYPE_number; + args[0].number = (double)listIndex; + + IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, + IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemFlat, 1, args); +} + +void UIControl_MultiList::SetItemLabelLeft(int id, const wstring &label) +{ + int listIndex = getListIndex(id); + if (listIndex < 0) + return; + + IggyDataValue result; + IggyDataValue args[2]; + + args[0].type = IGGY_DATATYPE_number; + args[0].number = (double)listIndex; + + IggyStringUTF16 stringVal; + stringVal.string = (IggyUTF16*)label.c_str(); + stringVal.length = label.length(); + args[1].type = IGGY_DATATYPE_string_UTF16; + args[1].string16 = stringVal; + + IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, + IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemLabelLeft, 2, args); +} + +void UIControl_MultiList::SetItemIcons(int id, const wstring &iconNames, int size) +{ + int listIndex = getListIndex(id); + if (listIndex < 0) + return; + + IggyDataValue result; + IggyDataValue args[3]; + + args[0].type = IGGY_DATATYPE_number; + args[0].number = (double)listIndex; + + IggyStringUTF16 stringVal; + stringVal.string = (IggyUTF16*)iconNames.c_str(); + stringVal.length = iconNames.length(); + args[1].type = IGGY_DATATYPE_string_UTF16; + args[1].string16 = stringVal; + + args[2].type = IGGY_DATATYPE_number; + args[2].number = (double)size; + + IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, + IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemIcons, 3, args); +} + void UIControl_MultiList::HighlightItem(int id, bool animate) { IggyDataValue result; @@ -387,3 +498,28 @@ void UIControl_MultiList::SetTouchFocus(S32 iX, S32 iY, bool bRepeat) IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcSetTouchFocus, 3, value); } + +int UIControl_MultiList::GetActiveItemIndex() +{ + S32 index = -1; + if (IggyValueGetS32RS(getIggyValuePath(), 0, "iActiveItem", &index) == IGGY_RESULT_SUCCESS) return index; + F64 fIndex = -1; + if (IggyValueGetF64RS(getIggyValuePath(), 0, "iActiveItem", &fIndex) == IGGY_RESULT_SUCCESS) return static_cast(fIndex); + if (IggyValueGetS32RS(getIggyValuePath(), 0, "m_iActiveItem", &index) == IGGY_RESULT_SUCCESS) return index; + return -1; +} + +bool UIControl_MultiList::CanTouchTrigger(S32 iX, S32 iY) +{ + IggyDataValue result; + IggyDataValue value[2]; + + value[0].type = IGGY_DATATYPE_number; + value[0].number = iX; + value[1].type = IGGY_DATATYPE_number; + value[1].number = iY; + + IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, + getIggyValuePath(), m_funcCanTouchTrigger, 2, value); + return result.type == IGGY_DATATYPE_boolean && result.boolval; +} diff --git a/Minecraft.Client/Common/UI/UIControl_MultiList.h b/Minecraft.Client/Common/UI/UIControl_MultiList.h index 753b4f5e..48e82f09 100644 --- a/Minecraft.Client/Common/UI/UIControl_MultiList.h +++ b/Minecraft.Client/Common/UI/UIControl_MultiList.h @@ -20,10 +20,16 @@ protected: IggyName m_funcSetSliderValue; IggyName m_funcGetSliderValue; IggyName m_funcSetItemLabel; + IggyName m_funcSetItemIcons; + IggyName m_funcSetItemLabelLeft; + IggyName m_funcSetItemEnabled; + IggyName m_funcSetItemFlat; + IggyName m_funcSetItemFlatLabel; IggyName m_funcHighlightItem; IggyName m_funcEnableItem; IggyName m_funcCheckElementExists; IggyName m_funcSetTouchFocus; + IggyName m_funcCanTouchTrigger; IggyName m_removeAllItemsFunc; // stores caller-defined ids in insertion order (label = -1) @@ -40,7 +46,8 @@ public: virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName); void init(int id); - void AddNewLabel(const wstring &label); + void AddNewLabel(const wstring &label, int id = -1); + void SetItemFlatLabel(int id, int referenceId, const wstring &label); void AddNewButton(const wstring &label, int id); void AddNewMenuButton(const wstring &label, int id); void AddNewCheckbox(const wstring &label, int id, bool checked); @@ -51,6 +58,11 @@ public: int GetSliderValue(int id); void SetSliderValue(int id, int value, bool bImmediate = true); void SetSliderLabel(int id, const wstring &label, bool bImmediate = true); + void SetItemLabel(int id, const wstring &label) { SetSliderLabel(id, label); } + void SetItemIcons(int id, const wstring &iconNames, int size); + void SetItemLabelLeft(int id, const wstring &label); + void SetItemEnabled(int id, bool enabled); + void SetItemFlat(int id); void HighlightItem(int id, bool animate = false); void EnableItem(int id, bool bEnable, bool bImmediate = true); void clearList(); @@ -60,6 +72,8 @@ public: int getIdFromIndex(int index) const; int getItemCount() const { return m_itemCount; } void SetTouchFocus(S32 iX, S32 iY, bool bRepeat); + bool CanTouchTrigger(S32 iX, S32 iY); + int GetActiveItemIndex(); void handleSliderMove(int id, int newValue); diff --git a/Minecraft.Client/Common/UI/UIControl_SuperflatLists.cpp b/Minecraft.Client/Common/UI/UIControl_SuperflatLists.cpp new file mode 100644 index 00000000..832fa4ed --- /dev/null +++ b/Minecraft.Client/Common/UI/UIControl_SuperflatLists.cpp @@ -0,0 +1,127 @@ +#include "stdafx.h" +#include "UI.h" +#include "UIControl_SuperflatLists.h" + +namespace +{ + void SetString(IggyDataValue &value, const wstring &text) + { + value.type = IGGY_DATATYPE_string_UTF16; + value.string16.string = (IggyUTF16 *)text.c_str(); + value.string16.length = static_cast(text.length()); + } + + void SetNumber(IggyDataValue &value, double number) + { + value.type = IGGY_DATATYPE_number; + value.number = number; + } + + void SetBool(IggyDataValue &value, bool flag) + { + value.type = IGGY_DATATYPE_boolean; + value.boolval = flag; + } +} + +bool UIControl_IconButtonListBase::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName) +{ + bool success = UIControl_ButtonList::setupControl(scene, parent, controlName); + m_funcUseIggyIcons = registerFastName(L"UseIggyIcons"); + m_funcEnableItem = registerFastName(L"EnableItem"); + m_funcSetItemLabel = registerFastName(L"SetItemLabel"); + return success; +} + +void UIControl_IconButtonListBase::callList(IggyName func, int argc, IggyDataValue *args) +{ + IggyDataValue result; + IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), func, argc, args); +} + +void UIControl_IconButtonListBase::UseIggyIcons() +{ + callList(m_funcUseIggyIcons, 0, nullptr); +} + +void UIControl_IconButtonListBase::EnableListItem(int index, bool enable) +{ + IggyDataValue args[2]; + SetNumber(args[0], index); + SetBool(args[1], enable); + callList(m_funcEnableItem, 2, args); +} + +void UIControl_IconButtonListBase::SetListItemLabel(int index, const wstring &label) +{ + IggyDataValue args[2]; + SetNumber(args[0], index); + SetString(args[1], label); + callList(m_funcSetItemLabel, 2, args); +} + +bool UIControl_LayerIconButtonList::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName) +{ + bool success = UIControl_IconButtonListBase::setupControl(scene, parent, controlName); + m_funcSetLayerLabel = registerFastName(L"SetLayerLabel"); + return success; +} + +void UIControl_LayerIconButtonList::AddNewItem(const wstring &label, const wstring &secondary, int id) +{ + wstring empty; + IggyDataValue args[4]; + SetString(args[0], label); + SetString(args[1], secondary); + SetNumber(args[2], id); + SetString(args[3], empty); + callList(m_addNewItemFunc, 4, args); + ++m_itemCount; +} + +void UIControl_LayerIconButtonList::SetLayerLabel(int index, const wstring &label) +{ + IggyDataValue args[2]; + SetNumber(args[0], index); + SetString(args[1], label); + callList(m_funcSetLayerLabel, 2, args); +} + +bool UIControl_CheckboxButtonList::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName) +{ + bool success = UIControl_IconButtonListBase::setupControl(scene, parent, controlName); + m_funcSetCheckBox = registerFastName(L"SetCheckBox"); + return success; +} + +void UIControl_CheckboxButtonList::AddNewItem(const wstring &label, int id, bool checked) +{ + wstring empty; + IggyDataValue args[4]; + SetString(args[0], label); + SetNumber(args[1], id); + SetBool(args[2], checked); + SetString(args[3], empty); + callList(m_addNewItemFunc, 4, args); + ++m_itemCount; +} + +void UIControl_CheckboxButtonList::SetCheckBox(int index, bool checked) +{ + IggyDataValue args[2]; + SetNumber(args[0], index); + SetBool(args[1], checked); + callList(m_funcSetCheckBox, 2, args); +} + +void UIControl_IconLeftButtonList::AddNewItem(const wstring &label, int id) +{ + wstring empty; + IggyDataValue args[4]; + SetString(args[0], label); + SetNumber(args[1], id); + SetString(args[2], empty); + SetString(args[3], empty); + callList(m_addNewItemFunc, 4, args); + ++m_itemCount; +} diff --git a/Minecraft.Client/Common/UI/UIControl_SuperflatLists.h b/Minecraft.Client/Common/UI/UIControl_SuperflatLists.h new file mode 100644 index 00000000..98a0fe50 --- /dev/null +++ b/Minecraft.Client/Common/UI/UIControl_SuperflatLists.h @@ -0,0 +1,50 @@ +#pragma once + +#include "UIControl_ButtonList.h" + +class UIControl_IconButtonListBase : public UIControl_ButtonList +{ +protected: + IggyName m_funcUseIggyIcons; + IggyName m_funcEnableItem; + IggyName m_funcSetItemLabel; + + void callList(IggyName func, int argc, IggyDataValue *args); + +public: + virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName); + + void UseIggyIcons(); + void EnableListItem(int index, bool enable); + void SetListItemLabel(int index, const wstring &label); +}; + +class UIControl_LayerIconButtonList : public UIControl_IconButtonListBase +{ +private: + IggyName m_funcSetLayerLabel; + +public: + virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName); + + void AddNewItem(const wstring &label, const wstring &secondary, int id); + void SetLayerLabel(int index, const wstring &label); +}; + +class UIControl_CheckboxButtonList : public UIControl_IconButtonListBase +{ +private: + IggyName m_funcSetCheckBox; + +public: + virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName); + + void AddNewItem(const wstring &label, int id, bool checked); + void SetCheckBox(int index, bool checked); +}; + +class UIControl_IconLeftButtonList : public UIControl_IconButtonListBase +{ +public: + void AddNewItem(const wstring &label, int id); +}; diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index d92f3064..79e50666 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -305,6 +305,9 @@ UIController::UIController() m_mouseDraggingSliderScene = eUIScene_COUNT; m_mouseDraggingSliderId = -1; m_mouseClickConsumedByScene = false; + m_mouseClickBlocked = false; + m_wheelScrollCtrl = nullptr; + m_wheelScrollY = 0.0f; m_bMouseHoverHorizontalList = false; m_lastHoverMouseX = -1; m_lastHoverMouseY = -1; @@ -1008,6 +1011,8 @@ void UIController::tickInput() { #ifdef _WINDOWS64 m_mouseClickConsumedByScene = false; + if (!g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT) && !g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) + m_mouseClickBlocked = false; UIControl* currHitCtrl = NULL; if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive()) { @@ -1128,7 +1133,10 @@ void UIController::tickInput() // Simple controls use SetFocusToElement; list controls // use their own SetTouchFocus for Flash-side hit testing. if (mouseMoved) + pScene->handleMouseHover(sceneMouseX, sceneMouseY); + if (mouseMoved || leftPressed) { + UIScene::s_bSuppressFocusSound = true; m_bMouseHoverHorizontalList = false; vector *controls = pScene->GetControls(); if (controls) @@ -1194,12 +1202,12 @@ void UIController::tickInput() } S32 localX = static_cast(sceneMouseX) - cx; - pMulti->SetTouchFocus(localX, adjustedY, leftDown); + pMulti->SetTouchFocus(localX, adjustedY, leftDown && !leftPressed); } else { static_cast(ctrl)->SetTouchFocus( - static_cast(sceneMouseX), adjustedMouseY, leftDown); + static_cast(sceneMouseX), adjustedMouseY, leftDown && !leftPressed); } hitControlId = -1; hitArea = INT_MAX; @@ -1269,6 +1277,7 @@ void UIController::tickInput() currHitCtrl = hitCtrl; UpdateCursorIcon(currHitCtrl); } + UIScene::s_bSuppressFocusSound = false; } if (m_mouseDraggingSliderScene != eUIScene_COUNT && m_mouseDraggingSliderScene != pScene->getSceneType()) @@ -1384,7 +1393,120 @@ void UIController::tickInput() // Let the scene handle mouse clicks for custom navigation (e.g. crafting slots) if (leftPressed && m_mouseDraggingSliderId < 0) { + UIScene::s_bSuppressFocusSound = true; m_mouseClickConsumedByScene = pScene->handleMouseClick(sceneMouseX, sceneMouseY); + UIScene::s_bSuppressFocusSound = false; + if (!m_mouseClickConsumedByScene && dynamic_cast(pScene) == nullptr) + { + bool sceneHasTargets = false; + bool pointerOnTarget = false; + vector *targets = pScene->GetControls(); + if (targets) + { + for (size_t i = 0; i < targets->size() && !pointerOnTarget; ++i) + { + UIControl *ctrl = (*targets)[i]; + if (!ctrl || ctrl->getHidden() || !ctrl->getVisible()) + continue; + UIControl::eUIControlType type = ctrl->getControlType(); + if (type == UIControl::eNoControl || type == UIControl::eLabel || type == UIControl::eHTMLLabel + || type == UIControl::eDynamicLabel || type == UIControl::eProgress || type == UIControl::eBitmapIcon + || type == UIControl::eCursor || type == UIControl::eTouchControl) + continue; + ctrl->UpdateControl(); + S32 offX = 0, offY = 0; + if (pMainPanel && ctrl->getParentPanel() == pMainPanel) + { + offX = panelOffsetX; + offY = panelOffsetY; + } + S32 cx = ctrl->getXPos() + offX; + S32 cy = ctrl->getYPos() + offY; + S32 cw = ctrl->getWidth(); + S32 ch = ctrl->getHeight(); + if (type == UIControl::eTexturePackList) + ch = static_cast(ctrl)->GetRealHeight(); + if (cw <= 0 || ch <= 0) + continue; + sceneHasTargets = true; + if (sceneMouseX >= cx && sceneMouseX <= cx + cw && sceneMouseY >= cy && sceneMouseY <= cy + ch) + { + pointerOnTarget = true; + if (type == UIControl::eButtonList) + { + UIControl_MultiList *pMulti = dynamic_cast(ctrl); + S32 ty = static_cast(sceneMouseY); + if (pMulti) + { + if (pScene->getSceneType() == eUIScene_LoadMenu) ty -= (ch / 7) * 2; + pointerOnTarget = pMulti->CanTouchTrigger(static_cast(sceneMouseX) - cx, ty); + } + else + { + if (pScene->getSceneType() == eUIScene_LoadCreateJoinMenu) ty -= ch / 7; + pointerOnTarget = static_cast(ctrl)->CanTouchTrigger(static_cast(sceneMouseX), ty); + } + } + } + } + } + if (sceneHasTargets && !pointerOnTarget) + m_mouseClickConsumedByScene = true; + } + if (m_mouseClickConsumedByScene) + m_mouseClickBlocked = true; + } + + int wheelNotches = g_KBMInput.PeekMouseWheel(); + if (wheelNotches != 0 && pScene->getSceneType() != eUIScene_JoinMenu && dynamic_cast(pScene) == nullptr) + { + vector *lists = pScene->GetControls(); + UIControl *wheelList = nullptr; + S32 wlx = 0, wlh = 0; + if (lists) + { + for (size_t i = 0; i < lists->size(); ++i) + { + UIControl *ctrl = (*lists)[i]; + if (!ctrl || ctrl->getHidden() || !ctrl->getVisible() || ctrl->getControlType() != UIControl::eButtonList) + continue; + if (pMainPanel && ctrl->getParentPanel() != pMainPanel) + continue; + ctrl->UpdateControl(); + S32 cx = ctrl->getXPos() + panelOffsetX; + S32 cy = ctrl->getYPos() + panelOffsetY; + S32 cw = ctrl->getWidth(); + S32 ch = ctrl->getHeight(); + if (cw <= 0 || ch <= 0) + continue; + bool inside = sceneMouseX >= cx && sceneMouseX <= cx + cw && sceneMouseY >= cy && sceneMouseY <= cy + ch; + if (inside || wheelList == nullptr) + { + wheelList = ctrl; + wlx = cx; + wlh = ch; + } + if (inside) + break; + } + } + if (wheelList != nullptr) + { + UIControl_MultiList *pMulti = dynamic_cast(wheelList); + S32 touchX = pMulti ? static_cast(sceneMouseX) - wlx : static_cast(sceneMouseX); + if (mouseMoved || leftDown || m_wheelScrollCtrl != wheelList) + { + m_wheelScrollCtrl = wheelList; + m_wheelScrollY = -100000.0f; + if (pMulti) pMulti->SetTouchFocus(touchX, static_cast(m_wheelScrollY), false); + else static_cast(wheelList)->SetTouchFocus(touchX, static_cast(m_wheelScrollY), false); + } + float step = max(1.0f, wlh / 5.0f); + m_wheelScrollY += wheelNotches * step; + if (pMulti) pMulti->SetTouchFocus(touchX, static_cast(m_wheelScrollY), true); + else static_cast(wheelList)->SetTouchFocus(touchX, static_cast(m_wheelScrollY), true); + g_KBMInput.ConsumeMouseWheel(); + } } } } @@ -1662,6 +1784,11 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) case ACTION_MENU_PAGEUP: vk = VK_PRIOR; break; case ACTION_MENU_PAGEDOWN: vk = VK_NEXT; break; } + if (key == ACTION_MENU_X) + { + UIScene* pXScene = GetTopScene(0); + if (pXScene && pXScene->getSceneType() == eUIScene_SuperflatMenu) vk = 'C'; + } if (vk != 0) { if (g_KBMInput.IsKeyPressed(vk)) { pressed = true; down = true; } @@ -1671,7 +1798,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) if ((key == ACTION_MENU_OK || key == ACTION_MENU_A) && !g_KBMInput.IsMouseGrabbed()) { - if (m_mouseDraggingSliderId < 0 && !m_mouseClickConsumedByScene) + if (m_mouseDraggingSliderId < 0 && !m_mouseClickConsumedByScene && !m_mouseClickBlocked) { if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)) { pressed = true; down = true; } if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) { released = true; down = false; } @@ -1716,7 +1843,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) { if (m_bMouseHoverHorizontalList) key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_LEFT : ACTION_MENU_RIGHT; - else + else if (dynamic_cast(pTopScene) != nullptr || pTopScene->getSceneType() == eUIScene_CraftingMenu) key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_UP : ACTION_MENU_DOWN; } } @@ -2769,7 +2896,22 @@ void UIController::SetTooltips( unsigned int iPad, int iA, int iB, int iX, int i { group = eUIGroup_Fullscreen; } - if(m_groups[static_cast(group)]->getTooltips()) m_groups[static_cast(group)]->getTooltips()->SetTooltips(iA, iB, iX, iY, iLT, iRT, iLB, iRB, iLS, iRS, iBack, forceUpdate); + if(m_groups[static_cast(group)]->getTooltips()) + { + m_groups[static_cast(group)]->getTooltips()->SetTooltips(iA, iB, iX, iY, iLT, iRT, iLB, iRB, iLS, iRS, iBack, forceUpdate); + m_groups[static_cast(group)]->getTooltips()->ClearTooltipKeyIcons(); + } +} + +void UIController::SetGameplayTooltips( unsigned int iPad, int iA, int iB, int iX, int iY, int iLT, int iRT, int iLB, int iRB, int iLS, int iRS, int iBack, const int keyVk[eToolTipNumButtons]) +{ + EUIGroup group = eUIGroup_Fullscreen; + if( app.GetGameStarted() && iPad != 255 ) group = static_cast(iPad + 1); + + UIComponent_Tooltips *tooltips = m_groups[static_cast(group)]->getTooltips(); + if(tooltips == nullptr) return; + tooltips->SetTooltips(iA, iB, iX, iY, iLT, iRT, iLB, iRB, iLS, iRS, iBack, false); + tooltips->SetTooltipKeyIcons(keyVk); } void UIController::EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable ) diff --git a/Minecraft.Client/Common/UI/UIController.h b/Minecraft.Client/Common/UI/UIController.h index 1e8dd33e..9c20d8d9 100644 --- a/Minecraft.Client/Common/UI/UIController.h +++ b/Minecraft.Client/Common/UI/UIController.h @@ -177,6 +177,9 @@ private: EUIScene m_mouseDraggingSliderScene; int m_mouseDraggingSliderId; bool m_mouseClickConsumedByScene; + bool m_mouseClickBlocked; + UIControl *m_wheelScrollCtrl; + float m_wheelScrollY; bool m_bMouseHoverHorizontalList; int m_lastHoverMouseX; int m_lastHoverMouseY; @@ -367,6 +370,7 @@ public: virtual void SetEnableTooltips( unsigned int iPad, BOOL bVal ); virtual void ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show ); virtual void SetTooltips( unsigned int iPad, int iA, int iB=-1, int iX=-1, int iY=-1 , int iLT=-1, int iRT=-1, int iLB=-1, int iRB=-1, int iLS=-1, int iRS=-1, int iBack=-1, bool forceUpdate = false); + void SetGameplayTooltips( unsigned int iPad, int iA, int iB, int iX, int iY, int iLT, int iRT, int iLB, int iRB, int iLS, int iRS, int iBack, const int keyVk[eToolTipNumButtons]); virtual void EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable ); virtual void RefreshTooltips(unsigned int iPad); diff --git a/Minecraft.Client/Common/UI/UICustomStrings.cpp b/Minecraft.Client/Common/UI/UICustomStrings.cpp new file mode 100644 index 00000000..ec632b62 --- /dev/null +++ b/Minecraft.Client/Common/UI/UICustomStrings.cpp @@ -0,0 +1,38 @@ +#include "stdafx.h" +#include "UICustomStrings.h" + +#include + +namespace +{ + std::deque &Table() + { + static std::deque s_table; + return s_table; + } +} + +int UICustomStrings::Get(const wchar_t *text) +{ + if (text == nullptr) + return -1; + std::deque &table = Table(); + for (size_t i = 0; i < table.size(); ++i) + { + if (table[i] == text) + return BASE_ID + static_cast(i); + } + table.push_back(text); + return BASE_ID + static_cast(table.size() - 1); +} + +const wchar_t *UICustomStrings::Lookup(int id) +{ + if (id < BASE_ID) + return nullptr; + std::deque &table = Table(); + size_t index = static_cast(id - BASE_ID); + if (index >= table.size()) + return nullptr; + return table[index].c_str(); +} diff --git a/Minecraft.Client/Common/UI/UICustomStrings.h b/Minecraft.Client/Common/UI/UICustomStrings.h new file mode 100644 index 00000000..adc4c11b --- /dev/null +++ b/Minecraft.Client/Common/UI/UICustomStrings.h @@ -0,0 +1,9 @@ +#pragma once + +namespace UICustomStrings +{ + static const int BASE_ID = 0x40000000; + + int Get(const wchar_t *text); + const wchar_t *Lookup(int id); +} diff --git a/Minecraft.Client/Common/UI/UIEnums.h b/Minecraft.Client/Common/UI/UIEnums.h index f2b1ccf2..29e4ec3c 100644 --- a/Minecraft.Client/Common/UI/UIEnums.h +++ b/Minecraft.Client/Common/UI/UIEnums.h @@ -130,6 +130,14 @@ enum EUIScene eUIScene_EULA, eUIScene_InGameSaveManagementMenu, eUIScene_LanguageSelector, +#ifdef _WINDOWS64 + eUIScene_KeybindsMenu, + eUIScene_BindingsTypeMenu, + eUIScene_SuperflatMenu, + eUIScene_SuperflatEditLayerMenu, + eUIScene_SuperflatPresetsMenu, + eUIScene_EditServerMenu, +#endif #endif // ndef _XBOX #ifdef _DEBUG_MENUS_ENABLED diff --git a/Minecraft.Client/Common/UI/UILayer.cpp b/Minecraft.Client/Common/UI/UILayer.cpp index 27f91018..a20de452 100644 --- a/Minecraft.Client/Common/UI/UILayer.cpp +++ b/Minecraft.Client/Common/UI/UILayer.cpp @@ -308,6 +308,26 @@ bool UILayer::NavigateToScene(int iPad, EUIScene scene, void *initData) case eUIScene_HowToPlayMenu: newScene = new UIScene_HowToPlayMenu(iPad, initData, this); break; +#ifdef _WINDOWS64 + case eUIScene_BindingsTypeMenu: + newScene = new UIScene_BindingsTypeMenu(iPad, initData, this); + break; + case eUIScene_SuperflatMenu: + newScene = new UIScene_SuperflatMenu(iPad, initData, this); + break; + case eUIScene_SuperflatEditLayerMenu: + newScene = new UIScene_SuperflatEditLayerMenu(iPad, initData, this); + break; + case eUIScene_SuperflatPresetsMenu: + newScene = new UIScene_SuperflatPresetsMenu(iPad, initData, this); + break; + case eUIScene_EditServerMenu: + newScene = new UIScene_EditServerMenu(iPad, initData, this); + break; + case eUIScene_KeybindsMenu: + newScene = new UIScene_KeybindsMenu(iPad, initData, this); + break; +#endif case eUIScene_LanguageSelector: newScene = new UIScene_LanguageSelector(iPad, initData, this); break; diff --git a/Minecraft.Client/Common/UI/UIScene.cpp b/Minecraft.Client/Common/UI/UIScene.cpp index aa3e552b..4c91a181 100644 --- a/Minecraft.Client/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Common/UI/UIScene.cpp @@ -1539,6 +1539,8 @@ bool UIScene::hasRegisteredSubstitutionTexture(const wstring &textureName) return it != m_registeredTextures.end(); } +bool UIScene::s_bSuppressFocusSound = false; + void UIScene::_handleFocusChange(F64 controlId, F64 childId) { int newControl = static_cast(controlId); @@ -1549,7 +1551,8 @@ void UIScene::_handleFocusChange(F64 controlId, F64 childId) m_iFocusChild = newChild; handleFocusChange(controlId, childId); - ui.PlayUISFX(eSFX_Focus); + if (!s_bSuppressFocusSound) + ui.PlayUISFX(eSFX_Focus); } } diff --git a/Minecraft.Client/Common/UI/UIScene.h b/Minecraft.Client/Common/UI/UIScene.h index 4863bbdc..0de6c218 100644 --- a/Minecraft.Client/Common/UI/UIScene.h +++ b/Minecraft.Client/Common/UI/UIScene.h @@ -112,6 +112,7 @@ public: virtual void updateSafeZone(); static bool SceneShouldUse1080p(const std::wstring &moviePath); + static bool s_bSuppressFocusSound; int getRenderWidth() { return m_renderWidth; } int getRenderHeight() { return m_renderHeight; } @@ -204,6 +205,7 @@ public: // Mouse click dispatch. Hit-tests C++ controls and picks the smallest-area // match, then calls handlePress. Override for custom behaviour (e.g. crafting). virtual bool handleMouseClick(F32 x, F32 y); + virtual void handleMouseHover(F32 x, F32 y) {} #endif void removeControl( UIControl_Base *control, bool centreScene); @@ -237,6 +239,7 @@ private: } CachedSlotDrawData; vector m_cachedSlotDraw; +protected: void _customDrawSlotControl(CustomDrawData *region, int iPad, shared_ptr item, float fAlpha, bool isFoil, bool bDecorations, bool usingCommandBuffer); public: diff --git a/Minecraft.Client/Common/UI/UIScene_BindingsTypeMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BindingsTypeMenu.cpp new file mode 100644 index 00000000..5fff4ff0 --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_BindingsTypeMenu.cpp @@ -0,0 +1,115 @@ +#include "stdafx.h" +#include "UI.h" +#include "UIScene_BindingsTypeMenu.h" + +#ifdef _WINDOWS64 + +UIScene_BindingsTypeMenu::UIScene_BindingsTypeMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) +{ + initialiseMovie(); + m_bNeedsMultiListPopulate = true; + m_iNavigateMode = -1; + doHorizontalResizeCheck(); +} + +wstring UIScene_BindingsTypeMenu::getMoviePath() +{ + if (app.GetLocalPlayerCount() > 1) + return L"MultilistMenuSplit"; + return L"MultilistMenu"; +} + +void UIScene_BindingsTypeMenu::tick() +{ + if (m_bNeedsMultiListPopulate) + { + m_bNeedsMultiListPopulate = false; + m_multiList.setupControl(this, m_rootPath, "MultiList"); + m_controls.push_back(&m_multiList); + m_multiList.clearList(); + m_multiList.init(eControl_MultiList); + + m_multiList.AddNewButton(L"Keyboard & Mouse", eControl_Keyboard); + m_multiList.AddNewButton(L"Controller", eControl_Controller); + + IggyName funcDoVert = registerFastName(L"DoVerticalResizeCheck"); + IggyName funcHideDesc = registerFastName(L"HideDescription"); + IggyDataValue result; + IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcDoVert, 0, nullptr); + doHorizontalResizeCheck(); + IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcHideDesc, 0, nullptr); + m_multiList.HighlightItem(app.GetGameSettings(m_iPad, eGameSetting_ControlType) == 0 ? eControl_Keyboard : eControl_Controller); + } + + if (m_iNavigateMode >= 0) + { + int mode = m_iNavigateMode; + m_iNavigateMode = -1; + ui.NavigateToScene(m_iPad, eUIScene_KeybindsMenu, reinterpret_cast(static_cast(mode))); + } + + UIScene::tick(); +} + +void UIScene_BindingsTypeMenu::updateTooltips() +{ + ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK); +} + +void UIScene_BindingsTypeMenu::updateComponents() +{ + bool bNotInGame = (Minecraft::GetInstance()->level == nullptr); + if (bNotInGame) + { + m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true); + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); + } + else + { + m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, false); + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, app.GetLocalPlayerCount() == 1); + } +} + +void UIScene_BindingsTypeMenu::handleGainFocus(bool navBack) +{ + if (navBack) + m_bNeedsMultiListPopulate = true; +} + +void UIScene_BindingsTypeMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) +{ + ui.AnimateKeyPress(iPad, key, repeat, pressed, released); + + switch (key) + { + case ACTION_MENU_CANCEL: + if (pressed) + navigateBack(); + break; + case ACTION_MENU_OK: + case ACTION_MENU_UP: + case ACTION_MENU_DOWN: + case ACTION_MENU_LEFT: + case ACTION_MENU_RIGHT: + sendInputToMovie(key, repeat, pressed, released); + break; + } +} + +void UIScene_BindingsTypeMenu::handlePress(F64 controlId, F64 childId) +{ + ui.PlayUISFX(eSFX_Press); + + switch (static_cast(childId)) + { + case eControl_Keyboard: + m_iNavigateMode = 0; + break; + case eControl_Controller: + m_iNavigateMode = 1; + break; + } +} + +#endif diff --git a/Minecraft.Client/Common/UI/UIScene_BindingsTypeMenu.h b/Minecraft.Client/Common/UI/UIScene_BindingsTypeMenu.h new file mode 100644 index 00000000..72c4d30b --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_BindingsTypeMenu.h @@ -0,0 +1,39 @@ +#pragma once + +#include "UIScene.h" +#include "UIControl_MultiList.h" + +class UIScene_BindingsTypeMenu : public UIScene +{ +private: + enum EControls + { + eControl_MultiList = 0, + eControl_Keyboard = 1, + eControl_Controller = 2, + }; + + UIControl_MultiList m_multiList; + bool m_bNeedsMultiListPopulate; + int m_iNavigateMode; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) + UI_END_MAP_ELEMENTS_AND_NAMES() + +public: + UIScene_BindingsTypeMenu(int iPad, void *initData, UILayer *parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_BindingsTypeMenu; } + + virtual void tick(); + virtual void updateTooltips(); + virtual void updateComponents(); + virtual void handleGainFocus(bool navBack); + +protected: + virtual wstring getMoviePath(); + +public: + virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); + virtual void handlePress(F64 controlId, F64 childId); +}; diff --git a/Minecraft.Client/Common/UI/UIScene_BookAndQuillMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BookAndQuillMenu.cpp index 2e9c0442..cc4c25ae 100644 --- a/Minecraft.Client/Common/UI/UIScene_BookAndQuillMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_BookAndQuillMenu.cpp @@ -558,7 +558,7 @@ void UIScene_BookAndQuillMenu::handlePress(F64 controlId, F64 childId) signing = true; } else { - m_bookTitle = m_typeText.m_editBuffer; + m_bookTitle = m_typeText.m_editBuffer.substr(0, 16); if (m_bookTitle.length() != 0) { SaveChanges(true); navigateBack(); diff --git a/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp index 2c53d2b3..ebf7e5c3 100644 --- a/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_ControlsMenu.cpp @@ -84,7 +84,7 @@ UIScene_ControlsMenu::UIScene_ControlsMenu(int iPad, void *initData, UILayer *pa m_iSchemeTextA[2]=IDS_CONTROLS_SCHEME2; int iSelected=app.GetGameSettings(m_iPad,eGameSetting_ControlScheme); - if (controlType == 0) + if (controlType == 0 && iSelected < 3) { app.SetGameSettings(m_iPad,eGameSetting_ControlScheme,0); iSelected = 0; @@ -92,7 +92,7 @@ UIScene_ControlsMenu::UIScene_ControlsMenu(int iPad, void *initData, UILayer *pa #ifndef __PSVITA__ LPWSTR layoutString = new wchar_t[ 128 ]; - swprintf( layoutString, 128, L"%ls : %ls", app.GetString( IDS_CURRENT_LAYOUT ),app.GetString(m_iSchemeTextA[iSelected])); + swprintf( layoutString, 128, L"%ls : %ls", app.GetString( IDS_CURRENT_LAYOUT ), iSelected < 3 ? app.GetString(m_iSchemeTextA[iSelected]) : L"Custom"); #ifdef __ORBIS__ if (!InputManager.UsingRemoteVita()) #endif @@ -112,7 +112,7 @@ UIScene_ControlsMenu::UIScene_ControlsMenu(int iPad, void *initData, UILayer *pa IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; - value[0].number = static_cast(m_iCurrentNavigatedControlsLayout); + value[0].number = static_cast(m_iCurrentNavigatedControlsLayout < 3 ? m_iCurrentNavigatedControlsLayout : 0); IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetControllerLayout , 1 , value ); } diff --git a/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp index c7b9e83f..162a5f0f 100644 --- a/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CraftingMenu.cpp @@ -62,60 +62,12 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p m_slotListInventory.addSlots(CRAFTING_INVENTORY_SLOT_START,CRAFTING_INVENTORY_SLOT_END - CRAFTING_INVENTORY_SLOT_START); m_slotListHotBar.addSlots(CRAFTING_HOTBAR_SLOT_START, CRAFTING_HOTBAR_SLOT_END - CRAFTING_HOTBAR_SLOT_START); - { - int maxGroupVLimit = ((m_iContainerType == RECIPE_TYPE_2x2) ? m_iMaxGroupV2x2 : m_iMaxGroupV3x3); - { - m_vGroupIconCache[0].VSlot.item = make_shared(Tile::workBench, 1); - m_vGroupIconCache[0].VSlot.show = (1 <= maxGroupVLimit); - } - { - m_vGroupIconCache[1].VSlot.item = make_shared(Tile::standing_banner_Id, 1, 0); - m_vGroupIconCache[1].VSlot.show = (2 <= maxGroupVLimit); - - { - m_vGroupIconCache[1].HSlots.push_back(SlotInfo(make_shared(Tile::standing_banner_Id, 1, 0))); - } - - { - SlotInfo slotInfo = SlotInfo(make_shared(Tile::standing_banner_Id, 1, 0)); - BannerPatternRecipe::addBannerPattern(slotInfo.item, L"cr", DyePowderItem::BLACK); - - m_vGroupIconCache[1].HSlots.push_back(slotInfo); - } - { - SlotInfo slotInfo = SlotInfo(make_shared(Tile::standing_banner_Id, 1, 0)); - BannerPatternRecipe::addBannerPattern(slotInfo.item, L"ld", DyePowderItem::BLACK); - - m_vGroupIconCache[1].HSlots.push_back(slotInfo); - } - { - SlotInfo slotInfo = SlotInfo(make_shared(Tile::standing_banner_Id, 1, 0)); - BannerPatternRecipe::addBannerPattern(slotInfo.item, L"mc", DyePowderItem::BLACK); - - m_vGroupIconCache[1].HSlots.push_back(slotInfo); - } - { - SlotInfo slotInfo = SlotInfo(make_shared(Tile::standing_banner_Id, 1, 0)); - BannerPatternRecipe::addBannerPattern(slotInfo.item, L"bo", DyePowderItem::BLACK); - - m_vGroupIconCache[1].HSlots.push_back(slotInfo); - } - { - SlotInfo slotInfo = SlotInfo(make_shared(Tile::standing_banner_Id, 1, 0)); - BannerPatternRecipe::addBannerPattern(slotInfo.item, L"cre", DyePowderItem::BLACK); - - m_vGroupIconCache[1].HSlots.push_back(slotInfo); - } - } - { - m_vGroupIconCache[2].VSlot.item = make_shared(Item::fireworks_Id, 1, 0); - m_vGroupIconCache[2].VSlot.show = (3 <= maxGroupVLimit); - } - { - m_vGroupIconCache[3].VSlot.item = make_shared(Item::dye_Id, 1, DyePowderItem::CYAN); - m_vGroupIconCache[3].VSlot.show = (4 <= maxGroupVLimit); - } - } + m_vGroupIconCache[0].VSlot.item = make_shared(Tile::workBench, 1); + m_vGroupIconCache[1].VSlot.item = make_shared(Tile::standing_banner_Id, 1, 0); + m_vGroupIconCache[2].VSlot.item = make_shared(Item::fireworks_Id, 1, 0); + m_vGroupIconCache[3].VSlot.item = make_shared(Item::dye_Id, 1, DyePowderItem::CYAN); + for (int i = 0; i < 4; i++) + m_vGroupIconCache[i].VSlot.show = i < m_iMaxGroupV; #if TO_BE_IMPLEMENTED // if we are in splitscreen, then we need to figure out if we want to move this scene @@ -128,29 +80,26 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p XuiElementSetShow(m_hPanel,TRUE); #endif - m_pGroupA = new Recipy::_eGroupType*[m_iMaxGroupV3x3]; - if(m_iContainerType==RECIPE_TYPE_3x3) { m_iIngredientsMaxSlotC = m_iIngredients3x3SlotC; m_pGroupTabA=(_eGroupTab *)&m_GroupTabBkgMapping3x3A; - m_pGroupA[eGroupVType::eGroupVType_Workbench] = (Recipy::_eGroupType*)&m_GroupTypeMapping9GridA; - m_pGroupA[eGroupVType::eGroupVType_Banner] = (Recipy::_eGroupType*)&m_GroupTypeBannerMapping9GridA; + m_pGroupA = (Recipy::_eGroupType*)&m_GroupTypeMapping9GridA; } else { m_iIngredientsMaxSlotC = m_iIngredients2x2SlotC; m_pGroupTabA=(_eGroupTab *)&m_GroupTabBkgMapping2x2A; - m_pGroupA[eGroupVType::eGroupVType_Workbench] = (Recipy::_eGroupType*)&m_GroupTypeMapping4GridA; + m_pGroupA = (Recipy::_eGroupType*)&m_GroupTypeMapping4GridA; } m_iCraftablesMaxHSlotC = m_iMaxHSlot; initializeCraftingTabs(); app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_CRAFTING); - setGroupText(GetGroupNameText(m_pGroupA[m_iGroupVIndex][m_iGroupHIndex])); + setGroupText(GetGroupNameText(m_pGroupA[m_iGroupHIndex])); // Update the tutorial state Minecraft *pMinecraft = Minecraft::GetInstance(); @@ -305,58 +254,56 @@ UIControl* UIScene_CraftingMenu::GetMainPanel() #ifdef _WINDOWS64 void UIScene_CraftingMenu::handleCraftingGroupSwitch() { + if (isSpecialTab()) { + Special_EnterGroup(); + return; + } m_iCurrentSlotHIndex = 0; m_iCurrentSlotVIndex = 1; UpdateCraftingPanels(); CheckRecipesAvailable(); - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - int patternId = m_aBannerCraftPatterns[m_iGroupHIndex - 1][m_iCurrentSlotHIndex]; - bool specialPattern = patternId >= 0 && patternId < BannerPatternRecipe::PATTERN_COUNT && - BannerPatternRecipe::PATTERNS[patternId].specialItemId != 0; - iVSlotIndexA[0] = 15; - iVSlotIndexA[1] = specialPattern ? -1 : 0; - iVSlotIndexA[2] = specialPattern ? 0 : 1; - } else { - iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; - iVSlotIndexA[1] = 0; - iVSlotIndexA[2] = 1; - } + iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = 1; ui.PlayUISFX(eSFX_Focus); UpdateVerticalSlots(); UpdateHighlight(); - setGroupText(GetGroupNameText(m_pGroupA[m_iGroupVIndex][m_iGroupHIndex])); + setGroupText(GetGroupNameText(m_pGroupA[m_iGroupHIndex])); UpdateTooltips(); } void UIScene_CraftingMenu::handleCraftingSlotClick(int iIndex) { if (iIndex == m_iCurrentSlotHIndex) { - // Click on already-selected slot — craft the item - - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { + if (isSpecialTab() && (isSpinnerGroup() || m_iGroupVIndex == eGroupVType_Banner)) { handleKeyDown(m_iPad, ACTION_MENU_Y, false); } else { handleKeyDown(m_iPad, ACTION_MENU_A, false); } - } else { + return; + } + + if (isSpecialTab()) { int iOldHSlot = m_iCurrentSlotHIndex; m_iCurrentSlotHIndex = iIndex; - m_iCurrentSlotVIndex = 1; - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - iVSlotIndexA[0] = 15; // White - iVSlotIndexA[1] = 0; // Black (center) - iVSlotIndexA[2] = 1; // Red - } else { - iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; - iVSlotIndexA[1] = 0; - iVSlotIndexA[2] = 1; - } - UpdateVerticalSlots(); - UpdateHighlight(); - //if (CanBeMadeA[iOldHSlot].iCount > 0) { - setShowCraftHSlot(iOldHSlot, true); - //} + Special_ResetVerticalSlots(); + if (!isSpinnerGroup()) setShowCraftHSlot(iOldHSlot, true); ui.PlayUISFX(eSFX_Focus); + UpdateCraftingPanels(); + Special_UpdateVerticalSlots(); + Special_UpdateHighlight(); + return; } + + int iOldHSlot = m_iCurrentSlotHIndex; + m_iCurrentSlotHIndex = iIndex; + m_iCurrentSlotVIndex = 1; + iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1; + iVSlotIndexA[1] = 0; + iVSlotIndexA[2] = 1; + UpdateVerticalSlots(); + UpdateHighlight(); + setShowCraftHSlot(iOldHSlot, true); + ui.PlayUISFX(eSFX_Focus); } bool isClickInsideControl(F32 x, F32 y, UIControl& control) { @@ -368,7 +315,7 @@ bool isClickInsideControl(F32 x, F32 y, UIControl& control) { void UIScene_CraftingMenu::handleLeftMouseClick(F32 x, F32 y, F32 sceneX, F32 sceneY) { { - int maxHorizontalTabs = (m_iContainerType == RECIPE_TYPE_3x3) ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2; + int maxHorizontalTabs = isSpecialTab() ? getSpecialGroupCount() : ((m_iContainerType == RECIPE_TYPE_3x3) ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2); F32 groupRowX1 = m_GroupH[0].getXPos(); F32 groupRowWidth = m_GroupH[0].getWidth(); @@ -388,8 +335,12 @@ void UIScene_CraftingMenu::handleLeftMouseClick(F32 x, F32 y, F32 sceneX, F32 sc if (iHSlotState[tabIndex]) { m_iGroupHIndex = tabIndex; setHGroupHighlight(m_iGroupHIndex); - - handleCraftingGroupSwitch(); + if (isSpecialTab()) { + ui.PlayUISFX(eSFX_Focus); + Special_EnterGroup(); + } else { + handleCraftingGroupSwitch(); + } } return; } @@ -397,7 +348,7 @@ void UIScene_CraftingMenu::handleLeftMouseClick(F32 x, F32 y, F32 sceneX, F32 sc } } { - int maxVerticalTabs = (m_iContainerType == RECIPE_TYPE_3x3) ? m_iMaxGroupV3x3 : m_iMaxGroupV2x2; + int maxVerticalTabs = getMaxVGroups(); F32 groupRowY1 = m_GroupV[0].getYPos(); F32 groupRowHeight = m_GroupV[0].getHeight(); @@ -416,47 +367,70 @@ void UIScene_CraftingMenu::handleLeftMouseClick(F32 x, F32 y, F32 sceneX, F32 sc if (tabOffset < groupRowHeight) { m_iGroupHIndex = 0; m_iGroupVIndex = tabIndex; - setVGroupHighlight(m_iGroupVIndex); - - handleCraftingGroupSwitch(); + if (isSpecialTab()) { + ui.PlayUISFX(eSFX_Focus); + Special_EnterTab(); + } else { + m_iDisplayDescription = DISPLAY_INVENTORY; + setVGroupHighlight(m_iGroupVIndex); + handleCraftingGroupSwitch(); + } return; } } } } - bool showingSpecial3 = (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0); - bool showingSpecial2 = false; - bool showingNormalSlots = (!showingSpecial3 && !showingSpecial2); - - if (showingSpecial3) { - if (isClickInsideControl(sceneX, sceneY, m_Slot3_1)) { - handleCraftingSlotClick(0); - UpdateCraftingPanels(); - } else if (isClickInsideControl(sceneX, sceneY, m_Slot3_2)) { - handleCraftingSlotClick(1); - UpdateCraftingPanels(); - } else if (isClickInsideControl(sceneX, sceneY, m_Slot3_3)) { - handleCraftingSlotClick(2); - UpdateCraftingPanels(); + if (isSpinnerGroup()) { + int spinners = getNumSpinnerSlots(); + if (spinners == 3) { + if (isClickInsideControl(sceneX, sceneY, m_Slot3_1)) handleCraftingSlotClick(0); + else if (isClickInsideControl(sceneX, sceneY, m_Slot3_2)) handleCraftingSlotClick(1); + else if (isClickInsideControl(sceneX, sceneY, m_Slot3_3)) handleCraftingSlotClick(2); + } else if (spinners == 2) { + if (isClickInsideControl(sceneX, sceneY, m_Slot2_1)) handleCraftingSlotClick(0); + else if (isClickInsideControl(sceneX, sceneY, m_Slot2_2)) handleCraftingSlotClick(1); } - } else if (showingSpecial2) { + return; + } - } else if (showingNormalSlots) { - if (m_hSlotBoundsValid && m_hSlotSpacing > 0) { - F32 rowWidth = m_hSlotSpacing * m_iCraftablesMaxHSlotC; - if (x >= m_hSlotX0 && x < m_hSlotX0 + rowWidth && y >= m_hSlotY0 && y < m_hSlotY1) { - int iNewSlot = (int)((x - m_hSlotX0) / m_hSlotSpacing); - if (iNewSlot >= 0 && iNewSlot < m_iCraftablesMaxHSlotC) { - // Only interact with populated slots - //if (CanBeMadeA[iNewSlot].iCount != 0) { - handleCraftingSlotClick(iNewSlot); - //} + bool bNoScrollSlots = m_bSplitscreen || (!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()); + bool bSpecial = isSpecialTab(); + int count = 0; + if (m_iCurrentSlotHIndex >= 0) count = bSpecial ? getSpecialVSlotCount() : CanBeMadeA[m_iCurrentSlotHIndex].iCount; + if (!bNoScrollSlots && m_hSlotBoundsValid && count > 1) { + F32 colX0 = m_hSlotX0 + m_hSlotSpacing * m_iCurrentSlotHIndex; + F32 rowH = m_hSlotY1 - m_hSlotY0; + F32 pitch = rowH * 1.1f; + int target = -1; + if (rowH > 0.0f && x >= colX0 && x < colX0 + m_hSlotSpacing) { + if (y >= m_hSlotY0 && y <= m_hSlotY1) target = 1; + else if (y < m_hSlotY0 && y >= m_hSlotY0 - pitch && count > 2) target = 0; + else if (y > m_hSlotY1 && y <= m_hSlotY1 + pitch) target = 2; + } + if (target >= 0) { + if (target == m_iCurrentSlotVIndex) { + handleKeyDown(m_iPad, (bSpecial && m_iGroupVIndex == eGroupVType_Banner) ? ACTION_MENU_Y : ACTION_MENU_A, false); + } else { + for (int guard = 0; guard < 3 && m_iCurrentSlotVIndex != target; ++guard) { + int before = m_iCurrentSlotVIndex; + handleKeyDown(m_iPad, target < m_iCurrentSlotVIndex ? ACTION_MENU_UP : ACTION_MENU_DOWN, false); + if (m_iCurrentSlotVIndex == before) break; } } + return; + } + } + + if (m_hSlotBoundsValid && m_hSlotSpacing > 0) { + F32 rowWidth = m_hSlotSpacing * m_iCraftablesMaxHSlotC; + if (x >= m_hSlotX0 && x < m_hSlotX0 + rowWidth && y >= m_hSlotY0 && y < m_hSlotY1) { + int iNewSlot = (int)((x - m_hSlotX0) / m_hSlotSpacing); + if (iNewSlot >= 0 && iNewSlot < m_iCraftablesMaxHSlotC) { + handleCraftingSlotClick(iNewSlot); + } } } - } bool UIScene_CraftingMenu::handleMouseClick(F32 x, F32 y) @@ -494,33 +468,31 @@ void UIScene_CraftingMenu::handleReload() m_slotPreviewSlot.addSlot(CRAFTING_SLOT_EXTRA_START + 0); - // 3 Slot vertical scroll m_slotListCrafting3VSlots[0].addSlot(CRAFTING_V_SLOT_START + 0); m_slotListCrafting3VSlots[1].addSlot(CRAFTING_V_SLOT_START + 1); m_slotListCrafting3VSlots[2].addSlot(CRAFTING_V_SLOT_START + 2); - // 2 Slot vertical scroll - // 2 slot scroll has swapped order m_slotListCrafting2VSlots[0].addSlot(CRAFTING_V_SLOT_START + 1); m_slotListCrafting2VSlots[1].addSlot(CRAFTING_V_SLOT_START + 0); - // 1 Slot scroll (for 480 mainly) m_slotListCrafting1VSlots.addSlot(CRAFTING_V_SLOT_START); m_slotListCraftingHSlots.addSlots(CRAFTING_H_SLOT_START,m_iCraftablesMaxHSlotC); initializeCraftingTabs(); - app.DebugPrintf(app.USER_SR,"Reloading MultiPanel\n"); int temp = m_iDisplayDescription; m_iDisplayDescription = m_iDisplayDescription==0?1:0; UpdateMultiPanel(); m_iDisplayDescription = temp; UpdateMultiPanel(); - app.DebugPrintf(app.USER_SR,"Reloading Highlight and scroll\n"); + if (isSpecialTab()) + { + Special_EnterGroup(); + return; + } - // reset the vertical slots m_iCurrentSlotHIndex = 0; m_iCurrentSlotVIndex = 1; iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; @@ -529,7 +501,6 @@ void UIScene_CraftingMenu::handleReload() UpdateVerticalSlots(); UpdateHighlight(); - app.DebugPrintf(app.USER_SR,"Reloading tabs\n"); setVGroupHighlight(m_iGroupVIndex); UpdateCraftingPanels(); } @@ -628,30 +599,13 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) } else if (slotId >= CRAFTING_SLOT_EXTRA_START && slotId < CRAFTING_SLOT_EXTRA_END) { int iIndex = (slotId - CRAFTING_SLOT_EXTRA_START); - if (iIndex == 0) { - if (m_iGroupHIndex > 0) { - item = m_bannerPreviewHolder; - alpha = 1.0f; - } else { - if (m_hSlotsInfo[0].show) { - item = m_hSlotsInfo[0].item; - alpha = static_cast(m_hSlotsInfo[0].alpha) / 31.0f; - } else { - if (m_craftingOutputSlotInfo.show) - { - item = m_craftingOutputSlotInfo.item; - alpha = static_cast(m_hSlotsInfo[0].alpha) / 31.0f; - } - } - } - } else if (iIndex == 1) { - if (CurrentInventoryBanners.size() > 0) { - if (m_iCurrentSlotHIndex == 1) { - item = CurrentInventoryBanners[m_iCurrentSlotVIndex-1]; - } else { - item = CurrentInventoryBanners[0]; - } + if (isSpinnerGroup()) { + if (m_specialSlotsInfo[iIndex].show) { + item = m_specialSlotsInfo[iIndex].item; + alpha = static_cast(m_specialSlotsInfo[iIndex].alpha) / 31.0f; } + } else if (iIndex == 0 && m_previewSlotInfo.show) { + item = m_previewSlotInfo.item; } } else if (slotId >= CRAFTING_INGREDIENTS_DESCRIPTION_START && slotId < (CRAFTING_INGREDIENTS_DESCRIPTION_START + 9)) @@ -672,26 +626,17 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region) } } } else if (swscanf(static_cast(region->name), L"TabV_%d", &iTabV) == 1) { - GroupIcons& vGroupIconInfo = m_vGroupIconCache[iTabV - 1]; - - if (vGroupIconInfo.VSlot.show) { - item = vGroupIconInfo.VSlot.item; - alpha = static_cast(vGroupIconInfo.VSlot.alpha)/31.0f; + if (iTabV >= 1 && iTabV <= 4) { + GroupIcons& vGroupIconInfo = m_vGroupIconCache[iTabV - 1]; + if (vGroupIconInfo.VSlot.show) { + item = vGroupIconInfo.VSlot.item; + alpha = static_cast(vGroupIconInfo.VSlot.alpha)/31.0f; + } } } else if (swscanf(static_cast(region->name), L"TabH_%d", &iTabH) == 1) { - GroupIcons& vGroupIconInfo = m_vGroupIconCache[m_iGroupVIndex]; - - if (m_selectedBannerEdit == nullptr) { - if (vGroupIconInfo.HSlots.size() >= iTabH && iTabH == 1) { - item = vGroupIconInfo.HSlots[iTabH - 1].item; - } - } else { - if (vGroupIconInfo.HSlots.size() >= iTabH && iTabH != 1) { - item = vGroupIconInfo.HSlots[iTabH - 1].item; - } + if (isSpecialTab() && iTabH >= 1 && iTabH <= m_iMaxGroupH3x3) { + item = m_hTabItems[iTabH - 1]; } - - //alpha = static_cast(vGroupIconInfo.HSlots[iTabH - 1].alpha)/31.0f; } if(item != nullptr) { @@ -814,9 +759,6 @@ void UIScene_CraftingMenu::setCraftVSlotItem(int iPad, int iIndex, shared_ptr item) { - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0) { - setDescriptionTextTop(item->getHoverName().c_str()); - } m_craftingOutputSlotInfo.item = item; m_craftingOutputSlotInfo.alpha = 31; m_craftingOutputSlotInfo.show = item != nullptr; @@ -887,8 +829,6 @@ void UIScene_CraftingMenu::setHGroupHighlight(int iIndex) void UIScene_CraftingMenu::setVGroupHighlight(int iIndex) { setHGroupHighlight(m_iGroupHIndex); - m_selectedBannerEdit = nullptr; - m_bannerPreviewHolder = nullptr; } @@ -942,7 +882,7 @@ void UIScene_CraftingMenu::scrollDescriptionDown() void UIScene_CraftingMenu::updateHighlightAndScrollPositions() { - { + { IggyDataValue result; IggyDataValue value[2]; @@ -950,21 +890,11 @@ void UIScene_CraftingMenu::updateHighlightAndScrollPositions() value[0].number = m_iCurrentSlotHIndex; int selectorType = 0; - - if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) { - if (CurrentInventoryBanners.size() == 2) { - selectorType = 1; - } else if (CurrentInventoryBanners.size() > 2) { - selectorType = 2; - } - } else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) { - selectorType = 2; - } else { - if(CanBeMadeA[m_iCurrentSlotHIndex].iCount == 2) { - selectorType = 1; - } else if( CanBeMadeA[m_iCurrentSlotHIndex].iCount > 2) { - selectorType = 2; - } + if (!isSpinnerGroup()) + { + int count = isSpecialTab() ? getSpecialVSlotCount() : CanBeMadeA[m_iCurrentSlotHIndex].iCount; + if (count == 2) selectorType = 1; + else if (count > 2) selectorType = 2; } value[1].type = IGGY_DATATYPE_number; @@ -978,7 +908,7 @@ void UIScene_CraftingMenu::updateHighlightAndScrollPositions() IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; - value[0].number = m_iCurrentSlotVIndex; + value[0].number = isSpinnerGroup() ? 1 : m_iCurrentSlotVIndex; IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcSelectVerticalItem , 1 , value ); } @@ -1009,19 +939,6 @@ void UIScene_CraftingMenu::HandleMessage(EUIMessage message, void *data) void UIScene_CraftingMenu::handleInventoryUpdated(LPVOID data) { HandleInventoryUpdated(); - - if (m_selectedBannerEdit != nullptr) { - bool stillHasEditingBanner = false; - for (unsigned int i = 0; i < CurrentInventoryBanners.size(); i++) { - if (CurrentInventoryBanners[i] == nullptr) continue; - if (CurrentInventoryBanners[i].get() == m_selectedBannerEdit.get()) { - stillHasEditingBanner = true; - break; - } - } - - if (!stillHasEditingBanner) setSelectedBannerEdit(nullptr); - } } void UIScene_CraftingMenu::updateVSlotPositions(int iSlots, int i) @@ -1042,67 +959,53 @@ void UIScene_CraftingMenu::SetCraftingMenu() { IggyDataValue result; IggyDataValue value[3]; - int currentHGroups = (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2); - if (m_iGroupVIndex == eGroupVType_Banner) { - currentHGroups = m_iMaxBannerGroupH3x3; - } + int currentHGroups = isSpecialTab() ? getSpecialGroupCount() : (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2); value[0].type = IGGY_DATATYPE_number; value[0].number = currentHGroups; value[1].type = IGGY_DATATYPE_number; - value[1].number = (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupV3x3 : m_iMaxGroupV2x2); + value[1].number = getMaxVGroups(); value[2].type = IGGY_DATATYPE_boolean; - value[2].boolval = (m_iGroupVIndex == eGroupVType::eGroupVType_Banner); // false = static icons, true = iggy custom draw ("TabH_N" regions) + value[2].boolval = isSpecialTab(); IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetCraftingMenu, 3, value); } void UIScene_CraftingMenu::UpdateCraftingPanels() { + SetCraftingMenu(); UpdateEnabledTabs(); - if (m_iGroupVIndex == eGroupVType_Workbench) { - m_iDisplayDescription = DISPLAY_INVENTORY; + if (!isSpecialTab()) { ShowSuperCraftingSlots(0); ShowDescriptionPanel(false); - } else if (m_iGroupVIndex == eGroupVType_Banner) { - ShowDescriptionPanel(m_iGroupHIndex == 0); - - if (m_iGroupHIndex == 0) { - ShowSuperCraftingSlots(3); - m_iDisplayDescription = DISPLAY_INVENTORY; - - if (m_iCurrentSlotHIndex == 0) { - m_labelSpinnerTitle.setLabel(L"Create Banner"); - } else if (m_iCurrentSlotHIndex == 1) { - m_labelSpinnerTitle.setLabel(L"Select Banner"); - } - } else { - ShowSuperCraftingSlots(0); - m_iDisplayDescription = DISPLAY_PREVIEW; - } - - + m_labelSpinnerTitle.setLabel(L""); + } else { + ShowSuperCraftingSlots(getNumSpinnerSlots()); + ShowDescriptionPanel(isSpinnerGroup()); + m_labelSpinnerTitle.setLabel(isSpinnerGroup() ? getSpinnerTitle() : L""); } - SetCraftingMenu(); + setHGroupHighlight(m_iGroupHIndex); UpdateMultiPanel(); updateHighlightAndScrollPositions(); } void UIScene_CraftingMenu::UpdateEnabledTabs() { - int maxHGroups = (m_iContainerType == RECIPE_TYPE_2x2) ? m_iMaxGroupH2x2 : m_iMaxGroupH3x3; - for (int i = 0; i < maxHGroups; i++) { - EnableTab(i, true); + if (!isSpecialTab()) { + int maxHGroups = (m_iContainerType == RECIPE_TYPE_2x2) ? m_iMaxGroupH2x2 : m_iMaxGroupH3x3; + for (int i = 0; i < m_iMaxGroupH3x3; i++) { + EnableTab(i, i < maxHGroups); + } + return; } - if (m_iGroupVIndex == eGroupVType_Banner) { - if (m_selectedBannerEdit == nullptr) { - for (int i = 1; i < maxHGroups; i++) { - EnableTab(i, false); - } - } else { - EnableTab(0, false); + int groups = getSpecialGroupCount(); + for (int i = 0; i < m_iMaxGroupH3x3; i++) { + bool enabled = i < groups; + if (enabled && m_iGroupVIndex == eGroupVType_Banner) { + enabled = (m_iGroupHIndex == 0) ? (i == 0) : (i > 0); } + EnableTab(i, enabled); } } @@ -1125,16 +1028,32 @@ void UIScene_CraftingMenu::ShowDescriptionPanel(bool show) { m_labelDescriptionTextTop.setVisible(show); } -void UIScene_CraftingMenu::setSelectedBannerEdit(shared_ptr banner) { - m_selectedBannerEdit = banner; - - if (m_selectedBannerEdit == nullptr) { - m_iGroupHIndex = 0; - m_bannerPreviewHolder = nullptr; - } else { - m_iGroupHIndex = 1; - m_bannerPreviewHolder = ItemInstance::clone(m_selectedBannerEdit); - } - setHGroupHighlight(m_iGroupHIndex); - handleCraftingGroupSwitch(); +void UIScene_CraftingMenu::setSpecialSlotItem(int iIndex, shared_ptr item, unsigned int uiAlpha) { + if (iIndex < 0 || iIndex >= 3) return; + m_specialSlotsInfo[iIndex].item = item; + m_specialSlotsInfo[iIndex].alpha = uiAlpha; + m_specialSlotsInfo[iIndex].show = item != nullptr; +} + +void UIScene_CraftingMenu::clearSpecialSlots() { + for (int i = 0; i < 3; i++) { + m_specialSlotsInfo[i].item = nullptr; + m_specialSlotsInfo[i].alpha = 31; + m_specialSlotsInfo[i].show = false; + } +} + +void UIScene_CraftingMenu::setPreviewSlotItem(shared_ptr item) { + m_previewSlotInfo.item = item; + m_previewSlotInfo.alpha = 31; + m_previewSlotInfo.show = item != nullptr; +} + +void UIScene_CraftingMenu::setSpinnerTitle(LPCWSTR text) { + m_labelSpinnerTitle.setLabel(text); +} + +void UIScene_CraftingMenu::setHTabItem(int iIndex, shared_ptr item) { + if (iIndex < 0 || iIndex >= m_iMaxGroupH3x3) return; + m_hTabItems[iIndex] = item; } diff --git a/Minecraft.Client/Common/UI/UIScene_CraftingMenu.h b/Minecraft.Client/Common/UI/UIScene_CraftingMenu.h index 21d24e2e..78c3f648 100644 --- a/Minecraft.Client/Common/UI/UIScene_CraftingMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_CraftingMenu.h @@ -48,6 +48,9 @@ private: SlotInfo m_ingredientsSlotsInfo[m_iIngredients3x3SlotC]; SlotInfo m_craftingOutputSlotInfo; SlotInfo m_ingredientsInfo[9]; + SlotInfo m_specialSlotsInfo[3]; + SlotInfo m_previewSlotInfo; + shared_ptr m_hTabItems[m_iMaxGroupH3x3]; typedef struct _GroupIcons { SlotInfo VSlot; @@ -256,7 +259,6 @@ protected: virtual void setIngredientSlotItem(int iPad, int index, shared_ptr item); virtual void setIngredientSlotRedBox(int index, bool show); virtual void setIngredientDescriptionItem(int iPad, int index, shared_ptr item); - virtual void setSelectedBannerEdit(shared_ptr banner); virtual void setIngredientDescriptionRedBox(int index, bool show); virtual void setIngredientDescriptionText(int index, LPCWSTR text); virtual void setShowCraftHSlot(int iIndex, bool show); @@ -282,6 +284,12 @@ protected: virtual void SetCraftingMenu(); virtual void EnableTab(int iIndex, bool enabled); + + virtual void setSpecialSlotItem(int iIndex, shared_ptr item, unsigned int uiAlpha); + virtual void clearSpecialSlots(); + virtual void setPreviewSlotItem(shared_ptr item); + virtual void setSpinnerTitle(LPCWSTR text); + virtual void setHTabItem(int iIndex, shared_ptr item); virtual void HandleMessage(EUIMessage message, void *data); void handleInventoryUpdated(LPVOID data); diff --git a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp index e284644c..1ef22902 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp @@ -88,6 +88,7 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void *initData, UILay m_MoreOptionsParams.bDoTileDrops = true; m_MoreOptionsParams.bNaturalRegeneration = true; m_MoreOptionsParams.bDoDaylightCycle = true; + m_MoreOptionsParams.bDoWeatherCycle = true; m_bGameModeCreative = false; m_iGameModeId = GameType::SURVIVAL->getId(); @@ -1208,6 +1209,8 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD NetworkGameInitData *param = new NetworkGameInitData(); param->levelName = wWorldName; + if (isFlat) + param->levelTypeOptions = pClass->m_MoreOptionsParams.superflatOptions; if (wSeed.length() != 0) { @@ -1283,6 +1286,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD app.SetGameHostOption(eGameHostOption_DoTileDrops, pClass->m_MoreOptionsParams.bDoTileDrops); app.SetGameHostOption(eGameHostOption_NaturalRegeneration, pClass->m_MoreOptionsParams.bNaturalRegeneration); app.SetGameHostOption(eGameHostOption_DoDaylightCycle, pClass->m_MoreOptionsParams.bDoDaylightCycle); + app.SetGameHostOption(eGameHostOption_DoWeatherCycle, pClass->m_MoreOptionsParams.bDoWeatherCycle); app.SetGameHostOption(eGameHostOption_WasntSaveOwner, false); #ifdef _LARGE_WORLDS diff --git a/Minecraft.Client/Common/UI/UIScene_EditServerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_EditServerMenu.cpp new file mode 100644 index 00000000..5326b407 --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_EditServerMenu.cpp @@ -0,0 +1,253 @@ +#include "stdafx.h" +#include "UI.h" +#include "UIScene_EditServerMenu.h" +#ifdef _WINDOWS64 +#include "../../Windows64/KeyboardMouseInput.h" +#endif + +namespace +{ + const int kNameLimit = 64; + const int kAddressLimit = 128; +} + +UIScene_EditServerMenu::UIScene_EditServerMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) +{ + initialiseMovie(); + if (initData != nullptr) + m_data = *static_cast(initData); + m_name = m_data.name; + m_address = m_data.address; + m_iOKEnabled = -1; + m_bIgnoreInput = false; + m_bFinished = false; + + m_title.init(L"Edit Server Info"); + m_labelName.init(L"Server Name"); + m_labelAddress.init(L"Server Address"); + m_editName.init(m_name, eControl_Name); + m_editAddress.init(m_address, eControl_Address); + m_editName.SetCharLimit(kNameLimit); + m_editAddress.SetCharLimit(kAddressLimit); + m_buttonCancel.init(app.GetString(IDS_CANCEL), eControl_Cancel); + m_buttonOK.init(app.GetString(IDS_CONFIRM_OK), eControl_OK); +} + +wstring UIScene_EditServerMenu::getMoviePath() +{ + return L"EditServerMenu"; +} + +bool UIScene_EditServerMenu::canConfirm() +{ + wstring address = m_address; +#ifdef _WINDOWS64 + if (m_editAddress.isDirectEditing()) + address = m_editAddress.getEditBuffer(); +#endif + for (size_t i = 0; i < address.length(); ++i) + { + if (address[i] != L' ') + return true; + } + return false; +} + +void UIScene_EditServerMenu::syncOKButton() +{ + int enabled = canConfirm() ? 1 : 0; + if (enabled == m_iOKEnabled) + return; + m_iOKEnabled = enabled; + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_boolean; + value[0].boolval = enabled != 0; + IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetOKEnabled, 1, value); +} + +void UIScene_EditServerMenu::tick() +{ + UIScene::tick(); + syncOKButton(); +} + +void UIScene_EditServerMenu::updateTooltips() +{ + ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK); +} + +void UIScene_EditServerMenu::updateComponents() +{ + m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true); + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false); +} + +wstring UIScene_EditServerMenu::ReadKeyboardText() +{ + uint16_t text[256]; + ZeroMemory(text, sizeof(text)); +#ifdef _WINDOWS64 + Win64_GetKeyboardText(text, 256); +#endif + wstring result; + for (int i = 0; i < 255 && text[i]; ++i) + result += static_cast(text[i]); + return result; +} + +int UIScene_EditServerMenu::NameKeyboardCallback(LPVOID lpParam, const bool bRes) +{ + UIScene_EditServerMenu *pClass = static_cast(lpParam); + pClass->m_bIgnoreInput = false; + if (bRes) + { + pClass->m_name = ReadKeyboardText(); + pClass->m_editName.setLabel(pClass->m_name); + } + return 0; +} + +int UIScene_EditServerMenu::AddressKeyboardCallback(LPVOID lpParam, const bool bRes) +{ + UIScene_EditServerMenu *pClass = static_cast(lpParam); + pClass->m_bIgnoreInput = false; + if (bRes) + { + pClass->m_address = ReadKeyboardText(); + pClass->m_editAddress.setLabel(pClass->m_address); + } + return 0; +} + +void UIScene_EditServerMenu::openKeyboard(int control) +{ + bool isName = control == eControl_Name; + UIControl_TextInput &input = isName ? m_editName : m_editAddress; + int limit = isName ? kNameLimit : kAddressLimit; +#ifdef _WINDOWS64 + if (g_KBMInput.IsKBMActive()) + { + input.beginDirectEdit(limit); + return; + } + UIKeyboardInitData kbData; + kbData.title = isName ? L"Server Name" : L"Server Address"; + kbData.defaultText = isName ? m_name.c_str() : m_address.c_str(); + kbData.maxChars = limit; + kbData.callback = isName ? &UIScene_EditServerMenu::NameKeyboardCallback : &UIScene_EditServerMenu::AddressKeyboardCallback; + kbData.lpParam = this; + kbData.pcMode = false; + m_bIgnoreInput = true; + ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); +#endif +} + +void UIScene_EditServerMenu::finish(bool confirmed) +{ + if (m_bFinished) + return; + if (confirmed && !canConfirm()) + { + ui.PlayUISFX(eSFX_CraftFail); + return; + } + m_bFinished = true; + ui.PlayUISFX(eSFX_Press); + + wstring host = m_address; + while (!host.empty() && host[0] == L' ') + host.erase(0, 1); + while (!host.empty() && host[host.length() - 1] == L' ') + host.erase(host.length() - 1); + wstring port = L"25565"; + size_t colon = host.rfind(L':'); + if (colon != wstring::npos && host.find(L':') == colon) + { + wstring tail = host.substr(colon + 1); + host = host.substr(0, colon); + if (!tail.empty()) + port = tail; + } + wstring name = m_name; + if (name.empty()) + name = L"Minecraft Server"; + + EditServerInitData data = m_data; + navigateBack(); + if (data.callback != nullptr) + data.callback(data.lpParam, confirmed, name, host, port); +} + +void UIScene_EditServerMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) +{ + if (m_bIgnoreInput || m_bFinished) + return; +#ifdef _WINDOWS64 + if (isDirectEditBlocking()) + { + handled = true; + return; + } +#endif + ui.AnimateKeyPress(iPad, key, repeat, pressed, released); + + switch (key) + { + case ACTION_MENU_CANCEL: + if (pressed) + finish(false); + handled = true; + break; + case ACTION_MENU_OK: + case ACTION_MENU_UP: + case ACTION_MENU_DOWN: + case ACTION_MENU_LEFT: + case ACTION_MENU_RIGHT: + sendInputToMovie(key, repeat, pressed, released); + handled = true; + break; + } +} + +void UIScene_EditServerMenu::handlePress(F64 controlId, F64 childId) +{ + if (m_bIgnoreInput || m_bFinished) + return; +#ifdef _WINDOWS64 + if (isDirectEditBlocking()) + return; +#endif + switch (static_cast(controlId)) + { + case eControl_Name: + case eControl_Address: + ui.PlayUISFX(eSFX_Press); + openKeyboard(static_cast(controlId)); + break; + case eControl_Cancel: + finish(false); + break; + case eControl_OK: + finish(true); + break; + } +} + +#ifdef _WINDOWS64 +void UIScene_EditServerMenu::getDirectEditInputs(vector &inputs) +{ + inputs.push_back(&m_editName); + inputs.push_back(&m_editAddress); +} + +void UIScene_EditServerMenu::onDirectEditFinished(UIControl_TextInput *input, UIControl_TextInput::EDirectEditResult result) +{ + if (result != UIControl_TextInput::eDirectEdit_Confirmed) + return; + if (input == &m_editName) + m_name = input->getEditBuffer(); + else if (input == &m_editAddress) + m_address = input->getEditBuffer(); +} +#endif diff --git a/Minecraft.Client/Common/UI/UIScene_EditServerMenu.h b/Minecraft.Client/Common/UI/UIScene_EditServerMenu.h new file mode 100644 index 00000000..35db6667 --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_EditServerMenu.h @@ -0,0 +1,81 @@ +#pragma once + +#include "UIScene.h" + +struct EditServerInitData +{ + wstring name; + wstring address; + int (*callback)(LPVOID lpParam, bool confirmed, const wstring &name, const wstring &ip, const wstring &port); + LPVOID lpParam; + + EditServerInitData() : callback(nullptr), lpParam(nullptr) {} +}; + +class UIScene_EditServerMenu : public UIScene +{ +private: + enum EControls + { + eControl_Name = 0, + eControl_Address = 1, + eControl_Cancel = 2, + eControl_OK = 3, + }; + + UIControl_Label m_title; + UIControl_Label m_labelName; + UIControl_Label m_labelAddress; + UIControl_TextInput m_editName; + UIControl_TextInput m_editAddress; + UIControl_Button m_buttonCancel; + UIControl_Button m_buttonOK; + IggyName m_funcSetOKEnabled; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) + UI_MAP_ELEMENT( m_title, "EditServerTitle") + UI_MAP_ELEMENT( m_labelName, "ServerNameLabel") + UI_MAP_ELEMENT( m_labelAddress, "ServerAddressLabel") + UI_MAP_ELEMENT( m_editName, "ServerNameInput") + UI_MAP_ELEMENT( m_editAddress, "ServerAddressInput") + UI_MAP_ELEMENT( m_buttonCancel, "CancelButton") + UI_MAP_ELEMENT( m_buttonOK, "OKButton") + UI_MAP_NAME( m_funcSetOKEnabled, L"SetOKEnabled") + UI_END_MAP_ELEMENTS_AND_NAMES() + + EditServerInitData m_data; + wstring m_name; + wstring m_address; + int m_iOKEnabled; + bool m_bIgnoreInput; + bool m_bFinished; + + bool canConfirm(); + void syncOKButton(); + void openKeyboard(int control); + void finish(bool confirmed); + + static int NameKeyboardCallback(LPVOID lpParam, const bool bRes); + static int AddressKeyboardCallback(LPVOID lpParam, const bool bRes); + static wstring ReadKeyboardText(); + +public: + UIScene_EditServerMenu(int iPad, void *initData, UILayer *parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_EditServerMenu; } + + virtual void tick(); + virtual void updateTooltips(); + virtual void updateComponents(); + +protected: + virtual wstring getMoviePath(); + +public: + virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); + virtual void handlePress(F64 controlId, F64 childId); +#ifdef _WINDOWS64 + virtual void getDirectEditInputs(vector &inputs); + virtual void onDirectEditFinished(UIControl_TextInput *input, UIControl_TextInput::EDirectEditResult result); +#endif +}; diff --git a/Minecraft.Client/Common/UI/UIScene_HUD.cpp b/Minecraft.Client/Common/UI/UIScene_HUD.cpp index c03f81f4..f87636a1 100644 --- a/Minecraft.Client/Common/UI/UIScene_HUD.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HUD.cpp @@ -5,6 +5,8 @@ #include "BossMobGuiInfo.h" #include "../../Minecraft.h" #include "../../MultiPlayerLocalPlayer.h" +#include "../../Textures.h" +#include "../../Tesselator.h" #include "../../../Minecraft.World/net.minecraft.world.entity.boss.enderdragon.h" #include "../../EnderDragonRenderer.h" #include "../../../Minecraft.World/net.minecraft.world.inventory.h" @@ -44,6 +46,18 @@ UIScene_HUD::UIScene_HUD(int iPad, void *initData, UILayer *parentLayer) : UISce } }*/ + { + IggyValuePath classPath; + IggyValuePathMakeNameRef(&classPath, m_rootPath, "SelectedLabel"); + const char *labelNames[5] = { "Label1", "Label2", "Label3", "Label4", "Label5" }; + for (int i = 0; i < 5; i++) + { + IggyValuePath labelPath; + IggyValuePathMakeNameRef(&labelPath, &classPath, labelNames[i]); + IggyValueSetBooleanRS(&labelPath, 0, "m_bUseHtmlText", true); + } + } + //enable colors for boss bar { IggyValuePath classPath; @@ -200,6 +214,12 @@ void UIScene_HUD::customDraw(IggyCustomDrawCallbackRegion *region) Minecraft *pMinecraft = Minecraft::GetInstance(); if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return; + if (wcscmp(static_cast(region->name), L"offhand") == 0) + { + customDrawOffhandSlot(region); + return; + } + int slot = -1; swscanf(static_cast(region->name),L"slot_%d",&slot); if (slot == -1) @@ -308,6 +328,18 @@ void UIScene_HUD::handleReload() IggyValueSetBooleanRS(&labelPath, 0, "m_bUseHtmlText", true); }*/ + { + IggyValuePath classPath; + IggyValuePathMakeNameRef(&classPath, m_rootPath, "SelectedLabel"); + const char *labelNames[5] = { "Label1", "Label2", "Label3", "Label4", "Label5" }; + for (int i = 0; i < 5; i++) + { + IggyValuePath labelPath; + IggyValuePathMakeNameRef(&labelPath, &classPath, labelNames[i]); + IggyValueSetBooleanRS(&labelPath, 0, "m_bUseHtmlText", true); + } + } + //enable colors for boss bar { IggyValuePath classPath; @@ -661,47 +693,47 @@ void UIScene_HUD::SetSelectedLabel(const wstring &label1, const wstring& label2, // 4J Stu - Timing here is kept the same as on Xbox360, even though we do it differently now and do the fade out in Flash rather than directly setting opacity if(!label1.empty()) m_uiSelectedItemOpacityCountDown = SharedConstants::TICKS_PER_SECOND * 3; - IggyDataValue result; - IggyDataValue value[5]; - - wstring empty = L"\n"; - - for (int i = 0; i < 5; i++) { - IggyStringUTF16 stringVal; - stringVal.string = (IggyUTF16*)empty.c_str(); - stringVal.length = 0; - - value[i].type = IGGY_DATATYPE_string_UTF16; - value[i].string16 = stringVal; - } - - wstring labels[4] = { label1, label2, label3, label4 }; - - int count = 0; - for (const wstring& label : labels) { - if (!label.empty()) count++; - } - - int startSlot = 5 - count; - for (int i = 0; i < count; i++) { - - IggyStringUTF16 stringVal; - stringVal.string = (IggyUTF16*)labels[i].c_str(); - stringVal.length = labels[i].length(); - - value[(startSlot-1) + i].type = IGGY_DATATYPE_string_UTF16; - value[(startSlot-1) + i].string16 = stringVal; - } - - if (count == 4) { - wstring string = L"..."; - - IggyStringUTF16 stringVal; - stringVal.string = (IggyUTF16*)string.c_str(); - stringVal.length = string.length(); - - value[4].type = IGGY_DATATYPE_string_UTF16; - value[4].string16 = stringVal; + IggyDataValue result; + IggyDataValue value[5]; + + wstring empty = L"\n"; + + for (int i = 0; i < 5; i++) { + IggyStringUTF16 stringVal; + stringVal.string = (IggyUTF16*)empty.c_str(); + stringVal.length = 0; + + value[i].type = IGGY_DATATYPE_string_UTF16; + value[i].string16 = stringVal; + } + + wstring labels[4] = { label1, label2, label3, label4 }; + + int count = 0; + for (const wstring& label : labels) { + if (!label.empty()) count++; + } + + int startSlot = 5 - count; + for (int i = 0; i < count; i++) { + + IggyStringUTF16 stringVal; + stringVal.string = (IggyUTF16*)labels[i].c_str(); + stringVal.length = labels[i].length(); + + value[(startSlot-1) + i].type = IGGY_DATATYPE_string_UTF16; + value[(startSlot-1) + i].string16 = stringVal; + } + + if (count == 4) { + wstring string = L"..."; + + IggyStringUTF16 stringVal; + stringVal.string = (IggyUTF16*)string.c_str(); + stringVal.length = string.length(); + + value[4].type = IGGY_DATATYPE_string_UTF16; + value[4].string16 = stringVal; } IggyResult out = IggyPlayerCallMethodRS ( getMovie(), &result, IggyPlayerRootPath( getMovie() ), m_funcSetSelectedLabel, 5, value ); @@ -1027,24 +1059,96 @@ void UIScene_HUD::handleGameTick() m_parentLayer->showComponent(m_iPad, eUIScene_HUD,true); updateFrameTick(); + updateCrosshairVisibility(pMinecraft->localplayers[m_iPad]->ThirdPersonView() != 0); } } - -void UIScene_HUD::updateCrosshairVisibility(bool thirdPerson) -{ - if (thirdPerson == m_crosshairHidden) return; - - for (int i = 0; i < 3; i++) - { - if (thirdPerson) - { - m_crosshairWasVisible[i] = m_crosshair[i].getVisible(); - m_crosshair[i].setVisible(false); - } - else - { - m_crosshair[i].setVisible(m_crosshairWasVisible[i]); - } - } - m_crosshairHidden = thirdPerson; -} + +void UIScene_HUD::updateCrosshairVisibility(bool thirdPerson) +{ + if (thirdPerson == m_crosshairHidden) return; + + for (int i = 0; i < 3; i++) + { + if (thirdPerson) + { + m_crosshairWasVisible[i] = m_crosshair[i].getVisible(); + m_crosshair[i].setVisible(false); + } + else + { + m_crosshair[i].setVisible(m_crosshairWasVisible[i]); + } + } + m_crosshairHidden = thirdPerson; +} + +float UIScene_HUD::getHudSlotAlpha() +{ + unsigned char ucAlpha = app.GetGameSettings(ProfileManager.GetPrimaryPad(), eGameSetting_InterfaceOpacity); + if (ucAlpha >= 80) + { + return 0.01f * static_cast(ucAlpha); + } + unsigned int uiOpacityTimer = app.GetOpacityTimer(m_iPad); + if (uiOpacityTimer == 0) + { + return 0.01f * static_cast(ucAlpha); + } + if (uiOpacityTimer < 10) + { + float fStep = (80.0f - static_cast(ucAlpha)) / 10.0f; + return 0.01f * (80.0f - ((10.0f - static_cast(uiOpacityTimer)) * fStep)); + } + return 0.01f * 80.0f; +} + +void UIScene_HUD::customDrawOffhandSlot(IggyCustomDrawCallbackRegion *region) +{ + Minecraft *pMinecraft = Minecraft::GetInstance(); + shared_ptr player = pMinecraft->localplayers[m_iPad]; + if (player == nullptr) return; + + shared_ptr item = player->inventory->getOffhand(); + if (item == nullptr) return; + + float fAlpha = getHudSlotAlpha(); + + CustomDrawData *customDrawRegion = ui.setupCustomDraw(this, region); + + shared_ptr oldPlayer = pMinecraft->player; + pMinecraft->player = player; + + RenderManager.StateSetBlendEnable(true); + RenderManager.StateSetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + pMinecraft->textures->bindTexture(L"gui/offhand_slot.png"); + glColor4f(1.0f, 1.0f, 1.0f, fAlpha); + + float x0 = customDrawRegion->x0; + float y0 = customDrawRegion->y0; + float x1 = customDrawRegion->x1; + float y1 = customDrawRegion->y1; + float uv = 1.0f; + + Tesselator *t = Tesselator::getInstance(); + t->begin(); + t->vertexUV(x0, y1, 0.0f, 0.0f, uv); + t->vertexUV(x1, y1, 0.0f, uv, uv); + t->vertexUV(x1, y0, 0.0f, uv, 0.0f); + t->vertexUV(x0, y0, 0.0f, 0.0f, 0.0f); + t->end(); + + float w = x1 - x0; + float h = y1 - y0; + CustomDrawData itemRegion = *customDrawRegion; + float itemW = floorf(w * 17.0f / 22.0f + 0.5f); + float itemH = floorf(h * 17.0f / 22.0f + 0.5f); + itemRegion.x0 = floorf(x0 + (w - itemW) * 0.5f + 0.5f); + itemRegion.y0 = floorf(y0 + (h - itemH) * 0.5f + 0.5f); + itemRegion.x1 = itemRegion.x0 + itemW; + itemRegion.y1 = itemRegion.y0 + itemH; + _customDrawSlotControl(&itemRegion, m_iPad, item, fAlpha, item->isFoil(), true, false); + + pMinecraft->player = oldPlayer; + delete customDrawRegion; + ui.endCustomDraw(region); +} diff --git a/Minecraft.Client/Common/UI/UIScene_HUD.h b/Minecraft.Client/Common/UI/UIScene_HUD.h index 5208c3f6..9fe71dfd 100644 --- a/Minecraft.Client/Common/UI/UIScene_HUD.h +++ b/Minecraft.Client/Common/UI/UIScene_HUD.h @@ -124,6 +124,8 @@ public: virtual bool hidesLowerScenes() { return false; } virtual void customDraw(IggyCustomDrawCallbackRegion *region); + void customDrawOffhandSlot(IggyCustomDrawCallbackRegion *region); + float getHudSlotAlpha(); virtual void handleReload(); diff --git a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp index 5e12654c..d45d8201 100644 --- a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp @@ -213,7 +213,11 @@ void UIScene_HelpAndOptionsMenu::handlePress(F64 controlId, F64 childId) ui.NavigateToScene(m_iPad, eUIScene_HowToPlayMenu); break; case BUTTON_HAO_CONTROLS: +#ifdef _WINDOWS64 + ui.NavigateToScene(m_iPad, eUIScene_BindingsTypeMenu); +#else ui.NavigateToScene(m_iPad, eUIScene_ControlsMenu); +#endif break; case BUTTON_HAO_SETTINGS: ui.NavigateToScene(m_iPad, eUIScene_SettingsMenu); diff --git a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp index 91c066fa..68a7a109 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp @@ -3,64 +3,223 @@ #include "UIScene_InGameHostOptionsMenu.h" #include "../../Minecraft.h" #include "../../MultiPlayerLocalPlayer.h" +#include "../../MultiPlayerLevel.h" #include "../../ClientConnection.h" #include "../../../Minecraft.World/net.minecraft.network.h" #include "../../../Minecraft.World/net.minecraft.network.packet.h" +#include "../../../Minecraft.World/net.minecraft.world.level.h" +#include "../../../Minecraft.World/net.minecraft.commands.common.h" +#include "../../../Minecraft.World/LevelSettings.h" + +static const int s_difficultyTitles[4] = +{ + IDS_DIFFICULTY_TITLE_PEACEFUL, + IDS_DIFFICULTY_TITLE_EASY, + IDS_DIFFICULTY_TITLE_NORMAL, + IDS_DIFFICULTY_TITLE_HARD +}; + +static const int s_gameModeTitles[3] = +{ + IDS_GAMEMODE_SURVIVAL, + IDS_GAMEMODE_CREATIVE, + IDS_GAMEMODE_ADVENTURE +}; UIScene_InGameHostOptionsMenu::UIScene_InGameHostOptionsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { - // Setup all the Iggy references we need for this scene initialiseMovie(); - m_checkboxFireSpreads.init(app.GetString(IDS_FIRE_SPREADS), eControl_FireSpreads, app.GetGameHostOption(eGameHostOption_FireSpreads)!=0); - m_checkboxTNT.init(app.GetString(IDS_TNT_EXPLODES), eControl_TNT, app.GetGameHostOption(eGameHostOption_TNT)!=0); + m_bNeedsMultiListPopulate = true; + m_bInitialPopulateDone = false; + m_bPendingSliderUpdate = false; + m_iPendingSliderId = 0; + m_iPendingSliderValue = 0; + m_iPendingTeleport = -1; - m_checkboxDoMobLoot.init(app.GetString(IDS_MOB_LOOT), eControl_DoMobLoot, app.GetGameHostOption(eGameHostOption_DoMobLoot)); - m_checkboxDoTileDrops.init(app.GetString(IDS_TILE_DROPS), eControl_DoTileDrops, app.GetGameHostOption(eGameHostOption_DoTileDrops)); - m_checkboxNaturalRegeneration.init(app.GetString(IDS_NATURAL_REGEN), eControl_NaturalRegeneration, app.GetGameHostOption(eGameHostOption_NaturalRegeneration)); + for (int i = 0; i < eControl_Count; ++i) m_bChecked[i] = false; + m_bChecked[eControl_FireSpreads] = app.GetGameHostOption(eGameHostOption_FireSpreads) != 0; + m_bChecked[eControl_TNT] = app.GetGameHostOption(eGameHostOption_TNT) != 0; + m_bChecked[eControl_DoDaylightCycle] = app.GetGameHostOption(eGameHostOption_DoDaylightCycle) != 0; + m_bChecked[eControl_KeepInventory] = app.GetGameHostOption(eGameHostOption_KeepInventory) != 0; + m_bChecked[eControl_DoMobSpawning] = app.GetGameHostOption(eGameHostOption_DoMobSpawning) != 0; + m_bChecked[eControl_MobGriefing] = app.GetGameHostOption(eGameHostOption_MobGriefing) != 0; + m_bChecked[eControl_DoWeatherCycle] = app.GetGameHostOption(eGameHostOption_DoWeatherCycle) != 0; + m_bChecked[eControl_DoMobLoot] = app.GetGameHostOption(eGameHostOption_DoMobLoot) != 0; + m_bChecked[eControl_DoTileDrops] = app.GetGameHostOption(eGameHostOption_DoTileDrops) != 0; + m_bChecked[eControl_NaturalRegeneration] = app.GetGameHostOption(eGameHostOption_NaturalRegeneration) != 0; - // If cheats are disabled, remove checkboxes - if (!app.GetGameHostOption(eGameHostOption_CheatsEnabled)) + m_iDifficulty = app.GetGameHostOption(eGameHostOption_Difficulty); + if (m_iDifficulty < 0 || m_iDifficulty > 3) m_iDifficulty = 2; + m_iGameType = app.GetGameHostOption(eGameHostOption_GameType); + if (m_iGameType < 0 || m_iGameType > 2) m_iGameType = 0; + + m_iWeather = 0; + Minecraft *pMinecraft = Minecraft::GetInstance(); + m_bHasWeather = pMinecraft->level != nullptr; + if (m_bHasWeather) { - removeControl(&m_checkboxMobGriefing, true); - removeControl(&m_checkboxKeepInventory, true); - removeControl(&m_checkboxDoMobSpawning, true); - removeControl(&m_checkboxDoDaylightCycle, true); + if (pMinecraft->level->isThundering()) m_iWeather = 2; + else if (pMinecraft->level->isRaining()) m_iWeather = 1; } - m_checkboxMobGriefing.init(app.GetString(IDS_MOB_GRIEFING), eControl_MobGriefing, app.GetGameHostOption(eGameHostOption_MobGriefing)); - m_checkboxKeepInventory.init(app.GetString(IDS_KEEP_INVENTORY), eControl_KeepInventory, app.GetGameHostOption(eGameHostOption_KeepInventory)); - m_checkboxDoMobSpawning.init(app.GetString(IDS_MOB_SPAWNING), eControl_DoMobSpawning, app.GetGameHostOption(eGameHostOption_DoMobSpawning)); - m_checkboxDoDaylightCycle.init(app.GetString(IDS_DAYLIGHT_CYCLE), eControl_DoDaylightCycle, app.GetGameHostOption(eGameHostOption_DoDaylightCycle)); + m_iStartDifficulty = m_iDifficulty; + m_iStartGameType = m_iGameType; + m_iStartWeather = m_iWeather; - INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); - unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId()); - if(app.GetGameHostOption(eGameHostOption_CheatsEnabled) - && Player::getPlayerGamePrivilege(privs,Player::ePlayerGamePrivilege_CanTeleport) - && g_NetworkManager.GetPlayerCount() > 1) - { - m_buttonTeleportToPlayer.init(app.GetString(IDS_TELEPORT_TO_PLAYER), eControl_TeleportToPlayer); - m_buttonTeleportToMe.init(app.GetString(IDS_TELEPORT_TO_ME), eControl_TeleportToMe); - } - else - { - removeControl(&m_buttonTeleportToPlayer, true); - removeControl(&m_buttonTeleportToMe, true); - } + doHorizontalResizeCheck(); } wstring UIScene_InGameHostOptionsMenu::getMoviePath() { if(app.GetLocalPlayerCount() > 1) { - return L"InGameHostOptionsSplit"; + return L"MultilistMenuSplit"; } else { - return L"InGameHostOptions"; + return L"MultilistMenu"; } } +bool UIScene_InGameHostOptionsMenu::cheatsEnabled() +{ + return app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; +} + +bool UIScene_InGameHostOptionsMenu::canTeleport() +{ + INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(m_iPad); + if (localPlayer == nullptr) return false; + unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId()); + return cheatsEnabled() + && Player::getPlayerGamePrivilege(privs, Player::ePlayerGamePrivilege_CanTeleport) + && g_NetworkManager.GetPlayerCount() > 1; +} + +wstring UIScene_InGameHostOptionsMenu::difficultyLabel(int value) +{ + if (value < 0 || value > 3) value = 2; + WCHAR TempString[256]; + swprintf(TempString, 256, L"%ls: %ls", app.GetString(IDS_SLIDER_DIFFICULTY), app.GetString(s_difficultyTitles[value])); + return TempString; +} + +wstring UIScene_InGameHostOptionsMenu::gameModeLabel(int value) +{ + if (value < 0 || value > 2) value = 0; + return app.GetString(s_gameModeTitles[value]); +} + +wstring UIScene_InGameHostOptionsMenu::weatherLabel(int value) +{ + if (value == 2) return app.GetString(IDS_WEATHER_THUNDER); + if (value == 1) return app.GetString(IDS_WEATHER_RAIN); + return app.GetString(IDS_WEATHER_CLEAR); +} + +void UIScene_InGameHostOptionsMenu::populateList() +{ + bool alreadyRegistered = false; + for (size_t i = 0; i < m_controls.size(); ++i) + { + if (m_controls[i] == &m_multiList) alreadyRegistered = true; + } + m_multiList.setupControl(this, m_rootPath, "MultiList"); + if (!alreadyRegistered) m_controls.push_back(&m_multiList); + m_multiList.clearList(); + m_multiList.init(eControl_MultiList); + + bool cheats = cheatsEnabled(); + bool hardcore = app.GetGameHostOption(eGameHostOption_Hardcore) != 0; + + m_multiList.AddNewCheckbox(app.GetString(IDS_FIRE_SPREADS), eControl_FireSpreads, m_bChecked[eControl_FireSpreads]); + m_multiList.AddNewCheckbox(app.GetString(IDS_TNT_EXPLODES), eControl_TNT, m_bChecked[eControl_TNT]); + if (cheats) + { + m_multiList.AddNewCheckbox(app.GetString(IDS_DAYLIGHT_CYCLE), eControl_DoDaylightCycle, m_bChecked[eControl_DoDaylightCycle]); + m_multiList.AddNewCheckbox(app.GetString(IDS_KEEP_INVENTORY), eControl_KeepInventory, m_bChecked[eControl_KeepInventory]); + m_multiList.AddNewCheckbox(app.GetString(IDS_MOB_SPAWNING), eControl_DoMobSpawning, m_bChecked[eControl_DoMobSpawning]); + m_multiList.AddNewCheckbox(app.GetString(IDS_MOB_GRIEFING), eControl_MobGriefing, m_bChecked[eControl_MobGriefing]); + m_multiList.AddNewButton(app.GetString(IDS_TIME_SET_DAY), eControl_SetDay); + m_multiList.AddNewButton(app.GetString(IDS_TIME_SET_NIGHT), eControl_SetNight); + if (!hardcore) + { + m_multiList.AddNewSlider(difficultyLabel(m_iDifficulty), eControl_Difficulty, 0, 3, 1, m_iDifficulty); + m_multiList.AddNewSlider(gameModeLabel(m_iGameType), eControl_GameMode, 0, 2, 1, m_iGameType); + } + m_multiList.AddNewButton(app.GetString(IDS_SET_WORLD_SPAWN), eControl_SetWorldSpawn); + if (m_bHasWeather) + { + m_multiList.AddNewLabel(L" "); + m_multiList.AddNewLabel(app.GetString(IDS_WEATHER)); + m_multiList.AddNewSlider(weatherLabel(m_iWeather), eControl_Weather, 0, 2, 1, m_iWeather); + } + m_multiList.AddNewCheckbox(app.GetString(IDS_WEATHER_CYCLE), eControl_DoWeatherCycle, m_bChecked[eControl_DoWeatherCycle]); + } + m_multiList.AddNewCheckbox(app.GetString(IDS_MOB_LOOT), eControl_DoMobLoot, m_bChecked[eControl_DoMobLoot]); + m_multiList.AddNewCheckbox(app.GetString(IDS_TILE_DROPS), eControl_DoTileDrops, m_bChecked[eControl_DoTileDrops]); + m_multiList.AddNewCheckbox(app.GetString(IDS_NATURAL_REGEN), eControl_NaturalRegeneration, m_bChecked[eControl_NaturalRegeneration]); + + if (canTeleport()) + { + m_multiList.AddNewButton(app.GetString(IDS_TELEPORT_TO_PLAYER), eControl_TeleportToPlayer); + m_multiList.AddNewButton(app.GetString(IDS_TELEPORT_TO_ME), eControl_TeleportToMe); + } + + IggyName funcDoVert = registerFastName(L"DoVerticalResizeCheck"); + IggyName funcHideDesc = registerFastName(L"HideDescription"); + IggyDataValue result; + IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcDoVert, 0, nullptr); + doHorizontalResizeCheck(); + IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcHideDesc, 0, nullptr); + m_multiList.HighlightItem(eControl_TNT); + m_multiList.HighlightItem(eControl_FireSpreads); +} + +void UIScene_InGameHostOptionsMenu::tick() +{ + if (m_bNeedsMultiListPopulate) + { + m_bNeedsMultiListPopulate = false; + m_bInitialPopulateDone = false; + populateList(); + } + + if (m_bPendingSliderUpdate) + { + m_bPendingSliderUpdate = false; + m_multiList.SetSliderValue(m_iPendingSliderId, m_iPendingSliderValue); + switch (m_iPendingSliderId) + { + case eControl_Difficulty: + m_iDifficulty = m_iPendingSliderValue; + m_multiList.SetSliderLabel(eControl_Difficulty, difficultyLabel(m_iDifficulty)); + break; + case eControl_GameMode: + m_iGameType = m_iPendingSliderValue; + m_multiList.SetSliderLabel(eControl_GameMode, gameModeLabel(m_iGameType)); + break; + case eControl_Weather: + m_iWeather = m_iPendingSliderValue; + m_multiList.SetSliderLabel(eControl_Weather, weatherLabel(m_iWeather)); + break; + } + } + + if (m_iPendingTeleport >= 0) + { + TeleportMenuInitData *initData = new TeleportMenuInitData(); + initData->iPad = m_iPad; + initData->teleportToPlayer = m_iPendingTeleport == eControl_TeleportToPlayer; + m_iPendingTeleport = -1; + ui.NavigateToScene(m_iPad, eUIScene_TeleportMenu, (void*)initData); + } + + UIScene::tick(); + m_bInitialPopulateDone = true; +} + void UIScene_InGameHostOptionsMenu::updateTooltips() { ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); @@ -69,69 +228,97 @@ void UIScene_InGameHostOptionsMenu::updateTooltips() void UIScene_InGameHostOptionsMenu::handleReload() { UIScene::handleReload(); + m_bNeedsMultiListPopulate = true; +} - // If cheats are disabled, remove checkboxes - if (!app.GetGameHostOption(eGameHostOption_CheatsEnabled)) +void UIScene_InGameHostOptionsMenu::handleGainFocus(bool navBack) +{ + if (navBack) { - removeControl(&m_checkboxMobGriefing, true); - removeControl(&m_checkboxKeepInventory, true); - removeControl(&m_checkboxDoMobSpawning, true); - removeControl(&m_checkboxDoDaylightCycle, true); + m_bNeedsMultiListPopulate = true; + } +} + +void UIScene_InGameHostOptionsMenu::sendCommand(shared_ptr packet) +{ + Minecraft *pMinecraft = Minecraft::GetInstance(); + shared_ptr player = pMinecraft->localplayers[m_iPad]; + if (player != nullptr && player->connection && packet != nullptr) + { + player->connection->send(packet); + } +} + +void UIScene_InGameHostOptionsMenu::applyAndClose() +{ + for (int i = 0; i < m_multiList.getItemCount(); ++i) + { + int id = m_multiList.getIdFromIndex(i); + switch (id) + { + case eControl_FireSpreads: + case eControl_TNT: + case eControl_DoDaylightCycle: + case eControl_KeepInventory: + case eControl_DoMobSpawning: + case eControl_MobGriefing: + case eControl_DoWeatherCycle: + case eControl_DoMobLoot: + case eControl_DoTileDrops: + case eControl_NaturalRegeneration: + m_bChecked[id] = m_multiList.GetCheckboxValue(id); + break; + } } - INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); - unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId()); - if(app.GetGameHostOption(eGameHostOption_CheatsEnabled) - && Player::getPlayerGamePrivilege(privs,Player::ePlayerGamePrivilege_CanTeleport) - && g_NetworkManager.GetPlayerCount() > 1) + unsigned int hostOptions = app.GetGameHostOption(eGameHostOption_All); + app.SetGameHostOption(hostOptions, eGameHostOption_FireSpreads, m_bChecked[eControl_FireSpreads]); + app.SetGameHostOption(hostOptions, eGameHostOption_TNT, m_bChecked[eControl_TNT]); + if (cheatsEnabled()) { + app.SetGameHostOption(hostOptions, eGameHostOption_DoDaylightCycle, m_bChecked[eControl_DoDaylightCycle]); + app.SetGameHostOption(hostOptions, eGameHostOption_KeepInventory, m_bChecked[eControl_KeepInventory]); + app.SetGameHostOption(hostOptions, eGameHostOption_DoMobSpawning, m_bChecked[eControl_DoMobSpawning]); + app.SetGameHostOption(hostOptions, eGameHostOption_MobGriefing, m_bChecked[eControl_MobGriefing]); + app.SetGameHostOption(hostOptions, eGameHostOption_DoWeatherCycle, m_bChecked[eControl_DoWeatherCycle]); + + if (app.GetGameHostOption(eGameHostOption_Hardcore) == 0) + { + if (m_iDifficulty != m_iStartDifficulty) + { + sendCommand(GameDifficultyCommand::preparePacket(m_iDifficulty)); + } + if (m_iGameType != m_iStartGameType) + { + sendCommand(DefaultGameModeCommand::preparePacket(m_iGameType)); + } + } + if (m_bHasWeather && m_iWeather != m_iStartWeather) + { + sendCommand(WeatherCommand::preparePacket(m_iWeather)); + } } - else + app.SetGameHostOption(hostOptions, eGameHostOption_DoMobLoot, m_bChecked[eControl_DoMobLoot]); + app.SetGameHostOption(hostOptions, eGameHostOption_DoTileDrops, m_bChecked[eControl_DoTileDrops]); + app.SetGameHostOption(hostOptions, eGameHostOption_NaturalRegeneration, m_bChecked[eControl_NaturalRegeneration]); + + if (hostOptions != app.GetGameHostOption(eGameHostOption_All)) { - removeControl(&m_buttonTeleportToPlayer, true); - removeControl(&m_buttonTeleportToMe, true); + sendCommand(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions)); } + + navigateBack(); } void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) { - //app.DebugPrintf("UIScene_DebugOverlay handling input for pad %d, key %d, down- %s, pressed- %s, released- %s\n", iPad, key, down?"TRUE":"FALSE", pressed?"TRUE":"FALSE", released?"TRUE":"FALSE"); - ui.AnimateKeyPress(iPad, key, repeat, pressed, released); switch(key) { case ACTION_MENU_CANCEL: if(pressed) { - unsigned int hostOptions = app.GetGameHostOption(eGameHostOption_All); - app.SetGameHostOption(hostOptions, eGameHostOption_FireSpreads, m_checkboxFireSpreads.IsChecked()); - app.SetGameHostOption(hostOptions, eGameHostOption_TNT, m_checkboxTNT.IsChecked()); - app.SetGameHostOption(hostOptions, eGameHostOption_DoMobLoot, m_checkboxDoMobLoot.IsChecked()); - app.SetGameHostOption(hostOptions, eGameHostOption_DoTileDrops, m_checkboxDoTileDrops.IsChecked()); - app.SetGameHostOption(hostOptions, eGameHostOption_NaturalRegeneration, m_checkboxNaturalRegeneration.IsChecked()); - - // If cheats are enabled, set cheat values - if (app.GetGameHostOption(eGameHostOption_CheatsEnabled)) - { - app.SetGameHostOption(hostOptions, eGameHostOption_MobGriefing, m_checkboxMobGriefing.IsChecked()); - app.SetGameHostOption(hostOptions, eGameHostOption_KeepInventory, m_checkboxKeepInventory.IsChecked()); - app.SetGameHostOption(hostOptions, eGameHostOption_DoMobSpawning, m_checkboxDoMobSpawning.IsChecked()); - app.SetGameHostOption(hostOptions, eGameHostOption_DoDaylightCycle, m_checkboxDoDaylightCycle.IsChecked()); - } - - // Send update settings packet to server - if(hostOptions != app.GetGameHostOption(eGameHostOption_All) ) - { - Minecraft *pMinecraft = Minecraft::GetInstance(); - shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player->connection) - { - player->connection->send(std::make_shared(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions)); - } - } - - navigateBack(); - + applyAndClose(); handled = true; } break; @@ -139,10 +326,12 @@ void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat, #ifdef __ORBIS__ case ACTION_MENU_TOUCHPAD_PRESS: #endif - sendInputToMovie(key, repeat, pressed, released); - break; case ACTION_MENU_UP: case ACTION_MENU_DOWN: + case ACTION_MENU_LEFT: + case ACTION_MENU_RIGHT: + case ACTION_MENU_PAGEUP: + case ACTION_MENU_PAGEDOWN: sendInputToMovie(key, repeat, pressed, released); break; } @@ -150,12 +339,50 @@ void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat, void UIScene_InGameHostOptionsMenu::handlePress(F64 controlId, F64 childId) { - TeleportMenuInitData *initData = new TeleportMenuInitData(); - initData->iPad = m_iPad; - initData->teleportToPlayer = false; - if( static_cast(controlId) == eControl_TeleportToPlayer ) + ui.PlayUISFX(eSFX_Press); + switch (static_cast(childId)) { - initData->teleportToPlayer = true; + case eControl_TeleportToPlayer: + case eControl_TeleportToMe: + m_iPendingTeleport = static_cast(childId); + break; + case eControl_SetDay: + sendCommand(TimeCommand::preparePacket(1000)); + break; + case eControl_SetNight: + sendCommand(TimeCommand::preparePacket(14000)); + break; + case eControl_SetWorldSpawn: + sendCommand(SetDefaultSpawnpointCommand::preparePacket()); + break; + } +} + +void UIScene_InGameHostOptionsMenu::handleSliderMove(F64 sliderId, F64 currentValue) +{ + int id = static_cast(sliderId); + int value = static_cast(currentValue); + m_multiList.handleSliderMove(id, value); + + switch (id) + { + case eControl_Difficulty: + case eControl_GameMode: + case eControl_Weather: + if (m_bInitialPopulateDone) ui.PlayUISFX(eSFX_Scroll); + m_bPendingSliderUpdate = true; + m_iPendingSliderId = id; + m_iPendingSliderValue = value; + break; + } +} + +void UIScene_InGameHostOptionsMenu::handleCheckboxToggled(F64 controlId, bool selected) +{ + if (m_bInitialPopulateDone) ui.PlayUISFX(eSFX_Press); + int id = static_cast(controlId); + if (id > eControl_MultiList && id < eControl_Count) + { + m_bChecked[id] = selected; } - ui.NavigateToScene(m_iPad,eUIScene_TeleportMenu,(void*)initData); } diff --git a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.h b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.h index b198974f..60c2d57a 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.h @@ -1,54 +1,80 @@ #pragma once #include "UIScene.h" +#include "UIControl_MultiList.h" class UIScene_InGameHostOptionsMenu : public UIScene { private: enum EControls { + eControl_MultiList = 0, eControl_FireSpreads, eControl_TNT, - eControl_MobGriefing, + eControl_DoDaylightCycle, eControl_KeepInventory, eControl_DoMobSpawning, + eControl_MobGriefing, + eControl_SetDay, + eControl_SetNight, + eControl_Difficulty, + eControl_GameMode, + eControl_SetWorldSpawn, + eControl_Weather, + eControl_DoWeatherCycle, eControl_DoMobLoot, eControl_DoTileDrops, eControl_NaturalRegeneration, - eControl_DoDaylightCycle, eControl_TeleportToPlayer, eControl_TeleportToMe, + eControl_Count, }; - - UIControl_CheckBox m_checkboxFireSpreads, m_checkboxTNT, m_checkboxMobGriefing, m_checkboxKeepInventory, m_checkboxDoMobSpawning, m_checkboxDoMobLoot, m_checkboxDoTileDrops, m_checkboxNaturalRegeneration, m_checkboxDoDaylightCycle; - UIControl_Button m_buttonTeleportToPlayer, m_buttonTeleportToMe; + + UIControl_MultiList m_multiList; + bool m_bNeedsMultiListPopulate; + bool m_bInitialPopulateDone; + bool m_bPendingSliderUpdate; + int m_iPendingSliderId; + int m_iPendingSliderValue; + int m_iPendingTeleport; + + bool m_bChecked[eControl_Count]; + int m_iDifficulty; + int m_iGameType; + int m_iWeather; + int m_iStartDifficulty; + int m_iStartGameType; + int m_iStartWeather; + bool m_bHasWeather; + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) - UI_MAP_ELEMENT( m_checkboxFireSpreads, "CheckboxFireSpreads") - UI_MAP_ELEMENT( m_checkboxTNT, "CheckboxTNT") - UI_MAP_ELEMENT( m_checkboxMobGriefing, "CheckboxMobGriefing") - UI_MAP_ELEMENT( m_checkboxKeepInventory, "CheckboxKeepInventory") - UI_MAP_ELEMENT( m_checkboxDoMobSpawning, "CheckboxMobSpawning") - UI_MAP_ELEMENT( m_checkboxDoMobLoot, "CheckboxMobLoot") - UI_MAP_ELEMENT( m_checkboxDoTileDrops, "CheckboxTileDrops") - UI_MAP_ELEMENT( m_checkboxNaturalRegeneration, "CheckboxNaturalRegeneration") - UI_MAP_ELEMENT( m_checkboxDoDaylightCycle, "CheckboxDayLightCycle") - UI_MAP_ELEMENT( m_buttonTeleportToPlayer, "TeleportToPlayer") - UI_MAP_ELEMENT( m_buttonTeleportToMe, "TeleportPlayerToMe") UI_END_MAP_ELEMENTS_AND_NAMES() + public: UIScene_InGameHostOptionsMenu(int iPad, void *initData, UILayer *parentLayer); virtual EUIScene getSceneType() { return eUIScene_InGameHostOptionsMenu;} + virtual void tick(); virtual void updateTooltips(); - virtual void handleReload(); protected: - // TODO: This should be pure virtual in this class virtual wstring getMoviePath(); public: - // INPUT virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); virtual void handlePress(F64 controlId, F64 childId); -}; \ No newline at end of file + virtual void handleSliderMove(F64 sliderId, F64 currentValue); + virtual void handleCheckboxToggled(F64 controlId, bool selected); + virtual void handleGainFocus(bool navBack); + +private: + void populateList(); + void applyAndClose(); + void sendCommand(shared_ptr packet); + bool cheatsEnabled(); + bool canTeleport(); + wstring difficultyLabel(int value); + wstring gameModeLabel(int value); + wstring weatherLabel(int value); +}; diff --git a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp index f7ed8697..f68acecb 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp @@ -5,16 +5,25 @@ #include "../../MultiPlayerLocalPlayer.h" #include "../../ClientConnection.h" #include "../../../Minecraft.World/net.minecraft.network.packet.h" +#include "../../../Minecraft.World/net.minecraft.commands.common.h" -#define CHECKBOXES_TIMER_ID 0 -#define CHECKBOXES_TIMER_TIME 100 +static const int s_playerGameModeTitles[3] = +{ + IDS_GAMEMODE_SURVIVAL, + IDS_GAMEMODE_CREATIVE, + IDS_GAMEMODE_ADVENTURE +}; UIScene_InGamePlayerOptionsMenu::UIScene_InGamePlayerOptionsMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { - // Setup all the Iggy references we need for this scene initialiseMovie(); m_bShouldNavBack = false; + m_bNeedsMultiListPopulate = true; + m_bInitialPopulateDone = false; + m_bPendingSliderUpdate = false; + m_iPendingSliderValue = 0; + m_bPendingCheatRefresh = false; InGamePlayerOptionsInitData *initData = static_cast(_initData); m_networkSmallId = initData->networkSmallId; @@ -22,304 +31,237 @@ UIScene_InGamePlayerOptionsMenu::UIScene_InGamePlayerOptionsMenu(int iPad, void INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); - - if(editingPlayer != nullptr) - { - m_labelGamertag.init(editingPlayer->GetDisplayName()); - } - - bool trustPlayers = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; - bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; m_editingSelf = (localPlayer != nullptr && localPlayer == editingPlayer); - if( m_editingSelf || trustPlayers || editingPlayer->IsHost()) + for (int i = 0; i < eControl_Count; ++i) { - removeControl( &m_checkboxes[eControl_BuildAndMine], true ); - removeControl( &m_checkboxes[eControl_UseDoorsAndSwitches], true ); - removeControl( &m_checkboxes[eControl_UseContainers], true ); - removeControl( &m_checkboxes[eControl_AttackPlayers], true ); - removeControl( &m_checkboxes[eControl_AttackAnimals], true ); + m_bChecked[i] = false; + m_bPresent[i] = false; + } + + m_bChecked[eControl_BuildAndMine] = !privilege(Player::ePlayerGamePrivilege_CannotMine) && !privilege(Player::ePlayerGamePrivilege_CannotBuild); + m_bChecked[eControl_UseDoorsAndSwitches] = privilege(Player::ePlayerGamePrivilege_CanUseDoorsAndSwitches); + m_bChecked[eControl_UseContainers] = privilege(Player::ePlayerGamePrivilege_CanUseContainers); + m_bChecked[eControl_AttackPlayers] = !privilege(Player::ePlayerGamePrivilege_CannotAttackPlayers); + m_bChecked[eControl_AttackAnimals] = !privilege(Player::ePlayerGamePrivilege_CannotAttackAnimals); + m_bChecked[eControl_Op] = privilege(Player::ePlayerGamePrivilege_Op); + if (m_editingSelf) + { + bool canInvisible = privilege(Player::ePlayerGamePrivilege_CanToggleInvisible); + m_bChecked[eControl_HostInvisible] = canInvisible && privilege(Player::ePlayerGamePrivilege_Invisible) && privilege(Player::ePlayerGamePrivilege_Invulnerable); + m_bChecked[eControl_HostFly] = privilege(Player::ePlayerGamePrivilege_CanToggleFly) && privilege(Player::ePlayerGamePrivilege_CanFly); + m_bChecked[eControl_HostHunger] = privilege(Player::ePlayerGamePrivilege_CanToggleClassicHunger) && privilege(Player::ePlayerGamePrivilege_ClassicHunger); } else { - bool checked = (Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CannotMine)==0 && Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CannotBuild)==0); - m_checkboxes[eControl_BuildAndMine].init( app.GetString(IDS_CAN_BUILD_AND_MINE), eControl_BuildAndMine, checked); - - checked = (Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanUseDoorsAndSwitches)!=0); - m_checkboxes[eControl_UseDoorsAndSwitches].init( app.GetString(IDS_CAN_USE_DOORS_AND_SWITCHES), eControl_UseDoorsAndSwitches, checked); - - checked = (Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanUseContainers)!=0); - m_checkboxes[eControl_UseContainers].init( app.GetString(IDS_CAN_OPEN_CONTAINERS), eControl_UseContainers, checked); - - checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CannotAttackPlayers)==0; - m_checkboxes[eControl_AttackPlayers].init( app.GetString(IDS_CAN_ATTACK_PLAYERS), eControl_AttackPlayers, checked); - - checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CannotAttackAnimals)==0; - m_checkboxes[eControl_AttackAnimals].init( app.GetString(IDS_CAN_ATTACK_ANIMALS), eControl_AttackAnimals, checked); + m_bChecked[eControl_HostInvisible] = privilege(Player::ePlayerGamePrivilege_CanToggleInvisible); + m_bChecked[eControl_HostFly] = privilege(Player::ePlayerGamePrivilege_CanToggleFly); + m_bChecked[eControl_HostHunger] = privilege(Player::ePlayerGamePrivilege_CanToggleClassicHunger); + m_bChecked[eControl_CheatTeleport] = privilege(Player::ePlayerGamePrivilege_CanTeleport); } - if(m_editingSelf) - { -#ifndef _DEBUG // (defined(_CONTENT_PACKAGE) || defined(_FINAL_BUILD) && !defined(_DEBUG_MENUS_ENABLED)) - removeControl( &m_checkboxes[eControl_Op], true ); -#else - m_checkboxes[eControl_Op].init(L"DEBUG: Creative",eControl_Op,Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode)); -#endif - - removeControl( &m_buttonKick, true ); - removeControl( &m_checkboxes[eControl_CheatTeleport], true ); + m_iGameType = 0; + if (privilege(Player::ePlayerGamePrivilege_AdventureMode)) m_iGameType = 2; + else if (privilege(Player::ePlayerGamePrivilege_CreativeMode)) m_iGameType = 1; + m_iStartGameType = m_iGameType; - if(cheats) - { - bool canBeInvisible = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleInvisible) != 0; - m_checkboxes[eControl_HostInvisible].SetEnable(canBeInvisible); - bool checked = canBeInvisible && (Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_Invisible)!=0 && Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_Invulnerable)!=0); - m_checkboxes[eControl_HostInvisible].init( app.GetString(IDS_INVISIBLE), eControl_HostInvisible, checked); - - bool inCreativeMode = Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) != 0; - if(inCreativeMode) - { - removeControl( &m_checkboxes[eControl_HostFly], true ); - removeControl( &m_checkboxes[eControl_HostHunger], true ); - } - else - { - bool canFly = Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanToggleFly); - bool canChangeHunger = Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanToggleClassicHunger); - - m_checkboxes[eControl_HostFly].SetEnable(canFly); - checked = canFly && Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanFly)!=0; - m_checkboxes[eControl_HostFly].init( app.GetString(IDS_CAN_FLY), eControl_HostFly, checked); - - m_checkboxes[eControl_HostHunger].SetEnable(canChangeHunger); - checked = canChangeHunger && Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_ClassicHunger)!=0; - m_checkboxes[eControl_HostHunger].init( app.GetString(IDS_DISABLE_EXHAUSTION), eControl_HostHunger, checked); - } - } - else - { - removeControl( &m_checkboxes[eControl_HostInvisible], true ); - removeControl( &m_checkboxes[eControl_HostFly], true ); - removeControl( &m_checkboxes[eControl_HostHunger], true ); - } - } - else - { - if(localPlayer->IsHost()) - { - // Only host can make people moderators, or enable teleporting for them - m_checkboxes[eControl_Op].init( app.GetString(IDS_MODERATOR), eControl_Op, Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_Op)!=0); - } - else - { - removeControl( &m_checkboxes[eControl_Op], true ); - } - - /*if(localPlayer->IsHost() && cheats ) - { - m_checkboxes[eControl_HostInvisible].SetEnable(true); - bool checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleInvisible)!=0; - m_checkboxes[eControl_HostInvisible].init( app.GetString(IDS_CAN_INVISIBLE), eControl_HostInvisible, checked); - - m_checkboxes[eControl_HostFly].SetEnable(true); - checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleFly)!=0; - m_checkboxes[eControl_HostFly].init( app.GetString(IDS_CAN_FLY), eControl_HostFly, checked); - - m_checkboxes[eControl_HostHunger].SetEnable(true); - checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleClassicHunger)!=0; - m_checkboxes[eControl_HostHunger].init( app.GetString(IDS_CAN_DISABLE_EXHAUSTION), eControl_HostHunger, checked); - - checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanTeleport)!=0; - m_checkboxes[eControl_CheatTeleport].init(app.GetString(IDS_ENABLE_TELEPORT),eControl_CheatTeleport,checked); - } - else - { - removeControl( &m_checkboxes[eControl_HostInvisible], true ); - removeControl( &m_checkboxes[eControl_HostFly], true ); - removeControl( &m_checkboxes[eControl_HostHunger], true ); - removeControl( &m_checkboxes[eControl_CheatTeleport], true ); - }*/ - - if(localPlayer->IsHost() && cheats ) - { - m_checkboxes[eControl_HostInvisible].SetEnable(true); - bool checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleInvisible)!=0; - m_checkboxes[eControl_HostInvisible].init( app.GetString(IDS_CAN_INVISIBLE), eControl_HostInvisible, checked); - - - bool inCreativeMode = Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) != 0; - if(inCreativeMode) - { - removeControl( &m_checkboxes[eControl_HostFly], true ); - removeControl( &m_checkboxes[eControl_HostHunger], true ); - } - else - { - m_checkboxes[eControl_HostFly].SetEnable(true); - checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleFly)!=0; - m_checkboxes[eControl_HostFly].init( app.GetString(IDS_CAN_FLY), eControl_HostFly, checked); - - m_checkboxes[eControl_HostHunger].SetEnable(true); - checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleClassicHunger)!=0; - m_checkboxes[eControl_HostHunger].init( app.GetString(IDS_CAN_DISABLE_EXHAUSTION), eControl_HostHunger, checked); - } - - checked = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanTeleport)!=0; - m_checkboxes[eControl_CheatTeleport].init(app.GetString(IDS_ENABLE_TELEPORT),eControl_CheatTeleport,checked); - } - else - { - removeControl( &m_checkboxes[eControl_HostInvisible], true ); - removeControl( &m_checkboxes[eControl_HostFly], true ); - removeControl( &m_checkboxes[eControl_HostHunger], true ); - removeControl( &m_checkboxes[eControl_CheatTeleport], true ); - } - - - // Can only kick people if they are not local, and not local to the host - if(editingPlayer->IsLocal() != TRUE && editingPlayer->IsSameSystem(g_NetworkManager.GetHostPlayer()) != TRUE) - { - m_buttonKick.init( app.GetString(IDS_KICK_PLAYER), eControl_Kick); - } - else - { - removeControl( &m_buttonKick, true ); - } - } - - short colourIndex = app.GetPlayerColour( m_networkSmallId ); - IggyDataValue result; - IggyDataValue value[1]; - value[0].type = IGGY_DATATYPE_number; - value[0].number = colourIndex; - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetPlayerIcon , 1 , value ); - -#if TO_BE_IMPLEMENTED - if(app.GetLocalPlayerCount()>1) - { - app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad); - } -#endif - - m_bModeratorState = m_checkboxes[eControl_Op].IsChecked(); - - resetCheatCheckboxes(); - - addTimer(CHECKBOXES_TIMER_ID,CHECKBOXES_TIMER_TIME); + doHorizontalResizeCheck(); g_NetworkManager.RegisterPlayerChangedCallback(m_iPad, &UIScene_InGamePlayerOptionsMenu::OnPlayerChanged, this); - -#ifdef __PSVITA__ - ui.TouchBoxRebuild(this); -#endif } wstring UIScene_InGamePlayerOptionsMenu::getMoviePath() { if(app.GetLocalPlayerCount() > 1) { - return L"InGamePlayerOptionsSplit"; + return L"MultilistMenuSplit"; } else { - return L"InGamePlayerOptions"; + return L"MultilistMenu"; } } +bool UIScene_InGamePlayerOptionsMenu::privilege(int priv) +{ + return Player::getPlayerGamePrivilege(m_playerPrivileges, static_cast(priv)) != 0; +} + +bool UIScene_InGamePlayerOptionsMenu::isCreative() +{ + return privilege(Player::ePlayerGamePrivilege_CreativeMode); +} + +wstring UIScene_InGamePlayerOptionsMenu::gameModeLabel(int value) +{ + if (value < 0 || value > 2) value = 0; + return app.GetString(s_playerGameModeTitles[value]); +} + void UIScene_InGamePlayerOptionsMenu::updateTooltips() { ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); } -void UIScene_InGamePlayerOptionsMenu::handleReload() +void UIScene_InGamePlayerOptionsMenu::addCheckbox(int id, int stringId, bool enabled) { - UIScene::handleReload(); + m_multiList.AddNewCheckbox(app.GetString(stringId), id, m_bChecked[id]); + if (!enabled) m_multiList.EnableItem(id, false); + m_bPresent[id] = true; +} + +void UIScene_InGamePlayerOptionsMenu::populateList() +{ + bool alreadyRegistered = false; + for (size_t i = 0; i < m_controls.size(); ++i) + { + if (m_controls[i] == &m_multiList) alreadyRegistered = true; + } + m_multiList.setupControl(this, m_rootPath, "MultiList"); + if (!alreadyRegistered) m_controls.push_back(&m_multiList); + m_multiList.clearList(); + m_multiList.init(eControl_MultiList); + for (int i = 0; i < eControl_Count; ++i) m_bPresent[i] = false; INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); - bool trustPlayers = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; - m_editingSelf = (localPlayer != nullptr && localPlayer == editingPlayer); + int firstId = -1; - if( m_editingSelf || trustPlayers || editingPlayer->IsHost()) + if (editingPlayer != nullptr) { - removeControl( &m_checkboxes[eControl_BuildAndMine], true ); - removeControl( &m_checkboxes[eControl_UseDoorsAndSwitches], true ); - removeControl( &m_checkboxes[eControl_UseContainers], true ); - removeControl( &m_checkboxes[eControl_AttackPlayers], true ); - removeControl( &m_checkboxes[eControl_AttackAnimals], true ); + m_multiList.AddNewLabel(editingPlayer->GetDisplayName()); } - if(m_editingSelf) + if (m_editingSelf) { -#ifndef _DEBUG //(defined(_CONTENT_PACKAGE) || defined(_FINAL_BUILD) && !defined(_DEBUG_MENUS_ENABLED)) - removeControl( &m_checkboxes[eControl_Op], true ); -#endif - - removeControl( &m_buttonKick, true ); - removeControl( &m_checkboxes[eControl_CheatTeleport], true ); - - if(cheats) + if (cheats) { - bool inCreativeMode = Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) != 0; - if(inCreativeMode) + addCheckbox(eControl_HostInvisible, IDS_INVISIBLE, privilege(Player::ePlayerGamePrivilege_CanToggleInvisible)); + if (!isCreative()) { - removeControl( &m_checkboxes[eControl_HostFly], true ); - removeControl( &m_checkboxes[eControl_HostHunger], true ); + addCheckbox(eControl_HostFly, IDS_CAN_FLY, privilege(Player::ePlayerGamePrivilege_CanToggleFly)); + addCheckbox(eControl_HostHunger, IDS_DISABLE_EXHAUSTION, privilege(Player::ePlayerGamePrivilege_CanToggleClassicHunger)); } - } - else - { - removeControl( &m_checkboxes[eControl_HostInvisible], true ); - removeControl( &m_checkboxes[eControl_HostFly], true ); - removeControl( &m_checkboxes[eControl_HostHunger], true ); + if (app.GetGameHostOption(eGameHostOption_Hardcore) == 0) + { + m_multiList.AddNewSlider(gameModeLabel(m_iGameType), eControl_GameMode, 0, 2, 1, m_iGameType); + m_bPresent[eControl_GameMode] = true; + } + m_multiList.AddNewButton(app.GetString(IDS_SET_PLAYER_SPAWN), eControl_SetSpawn); + m_bPresent[eControl_SetSpawn] = true; + firstId = eControl_HostInvisible; } } else { - if(!localPlayer->IsHost()) + if (!trustPlayers && editingPlayer != nullptr && !editingPlayer->IsHost()) { - removeControl( &m_checkboxes[eControl_Op], true ); + addCheckbox(eControl_BuildAndMine, IDS_CAN_BUILD_AND_MINE); + addCheckbox(eControl_UseDoorsAndSwitches, IDS_CAN_USE_DOORS_AND_SWITCHES); + addCheckbox(eControl_UseContainers, IDS_CAN_OPEN_CONTAINERS); + addCheckbox(eControl_AttackPlayers, IDS_CAN_ATTACK_PLAYERS); + addCheckbox(eControl_AttackAnimals, IDS_CAN_ATTACK_ANIMALS); + firstId = eControl_BuildAndMine; } - if(localPlayer->IsHost() && cheats ) + if (localPlayer != nullptr && localPlayer->IsHost()) { - - bool inCreativeMode = Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) != 0; - if(inCreativeMode) + addCheckbox(eControl_Op, IDS_MODERATOR); + if (firstId < 0) firstId = eControl_Op; + if (cheats) { - removeControl( &m_checkboxes[eControl_HostFly], true ); - removeControl( &m_checkboxes[eControl_HostHunger], true ); + addCheckbox(eControl_HostInvisible, IDS_CAN_INVISIBLE); + if (!isCreative()) + { + addCheckbox(eControl_HostFly, IDS_CAN_FLY); + addCheckbox(eControl_HostHunger, IDS_CAN_DISABLE_EXHAUSTION); + } + addCheckbox(eControl_CheatTeleport, IDS_ENABLE_TELEPORT); + if (app.GetGameHostOption(eGameHostOption_Hardcore) == 0) + { + m_multiList.AddNewSlider(gameModeLabel(m_iGameType), eControl_GameMode, 0, 2, 1, m_iGameType); + m_bPresent[eControl_GameMode] = true; + } + m_multiList.AddNewButton(app.GetString(IDS_SET_PLAYER_SPAWN), eControl_SetSpawn); + m_bPresent[eControl_SetSpawn] = true; } } - else - { - removeControl( &m_checkboxes[eControl_HostInvisible], true ); - removeControl( &m_checkboxes[eControl_HostFly], true ); - removeControl( &m_checkboxes[eControl_HostHunger], true ); - removeControl( &m_checkboxes[eControl_CheatTeleport], true ); - } - - // Can only kick people if they are not local, and not local to the host - if(editingPlayer->IsLocal() == TRUE || editingPlayer->IsSameSystem(g_NetworkManager.GetHostPlayer()) == TRUE) + if (editingPlayer != nullptr && editingPlayer->IsLocal() != TRUE && editingPlayer->IsSameSystem(g_NetworkManager.GetHostPlayer()) != TRUE) { - removeControl( &m_buttonKick, true ); + m_multiList.AddNewButton(app.GetString(IDS_KICK_PLAYER), eControl_Kick); + m_bPresent[eControl_Kick] = true; + if (firstId < 0) firstId = eControl_Kick; } } - short colourIndex = app.GetPlayerColour( m_networkSmallId ); + IggyName funcDoVert = registerFastName(L"DoVerticalResizeCheck"); + IggyName funcHideDesc = registerFastName(L"HideDescription"); IggyDataValue result; - IggyDataValue value[1]; - value[0].type = IGGY_DATATYPE_number; - value[0].number = colourIndex; - IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetPlayerIcon , 1 , value ); + IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcDoVert, 0, nullptr); + doHorizontalResizeCheck(); + IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcHideDesc, 0, nullptr); + + resetCheatCheckboxes(); + if (firstId >= 0) m_multiList.HighlightItem(firstId); +} + +void UIScene_InGamePlayerOptionsMenu::resetCheatCheckboxes() +{ + if (m_editingSelf || !m_bPresent[eControl_Op]) return; + bool isModerator = m_bChecked[eControl_Op]; + const int cheatIds[4] = { eControl_HostInvisible, eControl_HostFly, eControl_HostHunger, eControl_CheatTeleport }; + for (int i = 0; i < 4; ++i) + { + int id = cheatIds[i]; + if (!m_bPresent[id]) continue; + if (!isModerator && m_bChecked[id]) + { + m_bChecked[id] = false; + m_multiList.SetCheckboxValue(id, false); + } + m_multiList.EnableItem(id, isModerator); + } +} + +void UIScene_InGamePlayerOptionsMenu::handleReload() +{ + UIScene::handleReload(); + m_bNeedsMultiListPopulate = true; +} + +void UIScene_InGamePlayerOptionsMenu::handleGainFocus(bool navBack) +{ + if (navBack) m_bNeedsMultiListPopulate = true; } void UIScene_InGamePlayerOptionsMenu::tick() { + if (m_bNeedsMultiListPopulate) + { + m_bNeedsMultiListPopulate = false; + m_bInitialPopulateDone = false; + populateList(); + } + + if (m_bPendingSliderUpdate) + { + m_bPendingSliderUpdate = false; + m_iGameType = m_iPendingSliderValue; + m_multiList.SetSliderValue(eControl_GameMode, m_iGameType); + m_multiList.SetSliderLabel(eControl_GameMode, gameModeLabel(m_iGameType)); + } + + if (m_bPendingCheatRefresh) + { + m_bPendingCheatRefresh = false; + resetCheatCheckboxes(); + } + UIScene::tick(); + m_bInitialPopulateDone = true; if(m_bShouldNavBack) { @@ -333,82 +275,100 @@ void UIScene_InGamePlayerOptionsMenu::handleDestroy() g_NetworkManager.UnRegisterPlayerChangedCallback(m_iPad, &UIScene_InGamePlayerOptionsMenu::OnPlayerChanged, this); } +void UIScene_InGamePlayerOptionsMenu::sendPacket(shared_ptr packet) +{ + Minecraft *pMinecraft = Minecraft::GetInstance(); + shared_ptr player = pMinecraft->localplayers[m_iPad]; + if (player != nullptr && player->connection && packet != nullptr) + { + player->connection->send(packet); + } +} + +void UIScene_InGamePlayerOptionsMenu::applyAndClose() +{ + for (int id = eControl_BuildAndMine; id <= eControl_CheatTeleport; ++id) + { + if (m_bPresent[id]) m_bChecked[id] = m_multiList.GetCheckboxValue(id); + } + + bool trustPlayers = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; + bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; + INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); + INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); + bool gameModeChanged = m_bPresent[eControl_GameMode] && m_iGameType != m_iStartGameType; + + if (m_editingSelf) + { + if (cheats) + { + if (privilege(Player::ePlayerGamePrivilege_CanToggleInvisible)) + { + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_Invisible, m_bChecked[eControl_HostInvisible]); + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_Invulnerable, m_bChecked[eControl_HostInvisible]); + } + if (!isCreative()) + { + if (privilege(Player::ePlayerGamePrivilege_CanToggleFly)) Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanFly, m_bChecked[eControl_HostFly]); + if (privilege(Player::ePlayerGamePrivilege_CanToggleClassicHunger)) Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_ClassicHunger, m_bChecked[eControl_HostHunger]); + } + if (gameModeChanged) + { + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CreativeMode, m_iGameType == 1); + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_AdventureMode, m_iGameType == 2); + } + } + } + else + { + if (m_bPresent[eControl_BuildAndMine] && !trustPlayers && editingPlayer != nullptr && !editingPlayer->IsHost()) + { + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CannotMine, !m_bChecked[eControl_BuildAndMine]); + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CannotBuild, !m_bChecked[eControl_BuildAndMine]); + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CannotAttackPlayers, !m_bChecked[eControl_AttackPlayers]); + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CannotAttackAnimals, !m_bChecked[eControl_AttackAnimals]); + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanUseDoorsAndSwitches, m_bChecked[eControl_UseDoorsAndSwitches]); + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanUseContainers, m_bChecked[eControl_UseContainers]); + } + + if (localPlayer != nullptr && localPlayer->IsHost()) + { + if (cheats) + { + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleInvisible, m_bChecked[eControl_HostInvisible]); + if (m_bPresent[eControl_HostFly]) + { + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleFly, m_bChecked[eControl_HostFly]); + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleClassicHunger, m_bChecked[eControl_HostHunger]); + } + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanTeleport, m_bChecked[eControl_CheatTeleport]); + + if (gameModeChanged && editingPlayer != nullptr) + { + sendPacket(GameModeCommand::preparePacket(editingPlayer->GetUID(), m_iGameType)); + } + } + Player::setPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_Op, m_bChecked[eControl_Op]); + } + } + + unsigned int originalPrivileges = app.GetPlayerPrivileges(m_networkSmallId); + if (originalPrivileges != m_playerPrivileges) + { + sendPacket(std::make_shared(m_networkSmallId, -1, m_playerPrivileges)); + } + navigateBack(); +} + void UIScene_InGamePlayerOptionsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) { - //app.DebugPrintf("UIScene_DebugOverlay handling input for pad %d, key %d, down- %s, pressed- %s, released- %s\n", iPad, key, down?"TRUE":"FALSE", pressed?"TRUE":"FALSE", released?"TRUE":"FALSE"); - ui.AnimateKeyPress(iPad, key, repeat, pressed, released); switch(key) { case ACTION_MENU_CANCEL: if(pressed) { - bool trustPlayers = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; - bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; - if(m_editingSelf) - { -#ifndef _DEBUG // (defined(_CONTENT_PACKAGE) || defined(_FINAL_BUILD) && !defined(_DEBUG_MENUS_ENABLED)) -#else - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode,m_checkboxes[eControl_Op].IsChecked()); -#endif - if(cheats) - { - bool canBeInvisible = Player::getPlayerGamePrivilege(m_playerPrivileges, Player::ePlayerGamePrivilege_CanToggleInvisible) != 0; - if(canBeInvisible) Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_Invisible,m_checkboxes[eControl_HostInvisible].IsChecked()); - if(canBeInvisible) Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_Invulnerable,m_checkboxes[eControl_HostInvisible].IsChecked()); - - bool inCreativeMode = Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) != 0; - if(!inCreativeMode) - { - bool canFly = Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanToggleFly); - bool canChangeHunger = Player::getPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanToggleClassicHunger); - - if(canFly) Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanFly,m_checkboxes[eControl_HostFly].IsChecked()); - if(canChangeHunger) Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_ClassicHunger,m_checkboxes[eControl_HostHunger].IsChecked()); - } - } - } - else - { - INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); - if(!trustPlayers && (editingPlayer != nullptr && !editingPlayer->IsHost() ) ) - { - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CannotMine,!m_checkboxes[eControl_BuildAndMine].IsChecked()); - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CannotBuild,!m_checkboxes[eControl_BuildAndMine].IsChecked()); - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CannotAttackPlayers,!m_checkboxes[eControl_AttackPlayers].IsChecked()); - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CannotAttackAnimals, !m_checkboxes[eControl_AttackAnimals].IsChecked()); - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanUseDoorsAndSwitches, m_checkboxes[eControl_UseDoorsAndSwitches].IsChecked()); - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanUseContainers, m_checkboxes[eControl_UseContainers].IsChecked()); - } - - INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad ); - - if(localPlayer->IsHost()) - { - if(cheats) - { - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanToggleInvisible,m_checkboxes[eControl_HostInvisible].IsChecked()); - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanToggleFly,m_checkboxes[eControl_HostFly].IsChecked()); - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanToggleClassicHunger,m_checkboxes[eControl_HostHunger].IsChecked()); - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_CanTeleport,m_checkboxes[eControl_CheatTeleport].IsChecked()); - } - - Player::setPlayerGamePrivilege(m_playerPrivileges,Player::ePlayerGamePrivilege_Op,m_checkboxes[eControl_Op].IsChecked()); - } - } - unsigned int originalPrivileges = app.GetPlayerPrivileges(m_networkSmallId); - if(originalPrivileges != m_playerPrivileges) - { - // Send update settings packet to server - Minecraft *pMinecraft = Minecraft::GetInstance(); - shared_ptr player = pMinecraft->localplayers[m_iPad]; - if(player->connection) - { - player->connection->send(std::make_shared(m_networkSmallId, -1, m_playerPrivileges)); - } - } - navigateBack(); - + applyAndClose(); handled = true; } break; @@ -416,10 +376,12 @@ void UIScene_InGamePlayerOptionsMenu::handleInput(int iPad, int key, bool repeat #ifdef __ORBIS__ case ACTION_MENU_TOUCHPAD_PRESS: #endif - sendInputToMovie(key, repeat, pressed, released); - break; case ACTION_MENU_UP: case ACTION_MENU_DOWN: + case ACTION_MENU_LEFT: + case ACTION_MENU_RIGHT: + case ACTION_MENU_PAGEUP: + case ACTION_MENU_PAGEDOWN: sendInputToMovie(key, repeat, pressed, released); break; } @@ -427,7 +389,8 @@ void UIScene_InGamePlayerOptionsMenu::handleInput(int iPad, int key, bool repeat void UIScene_InGamePlayerOptionsMenu::handlePress(F64 controlId, F64 childId) { - switch(static_cast(controlId)) + ui.PlayUISFX(eSFX_Press); + switch(static_cast(childId)) { case eControl_Kick: { @@ -440,27 +403,55 @@ void UIScene_InGamePlayerOptionsMenu::handlePress(F64 controlId, F64 childId) ui.RequestAlertMessage(IDS_UNLOCK_KICK_PLAYER_TITLE, IDS_UNLOCK_KICK_PLAYER, uiIDA, 2, m_iPad,&UIScene_InGamePlayerOptionsMenu::KickPlayerReturned,smallId); } break; + case eControl_SetSpawn: + { + INetworkPlayer *editingPlayer = g_NetworkManager.GetPlayerBySmallId(m_networkSmallId); + if (editingPlayer != nullptr) + { + sendPacket(SetSpawnpointCommand::preparePacket(editingPlayer->GetUID())); + } + } + break; }; } +void UIScene_InGamePlayerOptionsMenu::handleSliderMove(F64 sliderId, F64 currentValue) +{ + int id = static_cast(sliderId); + int value = static_cast(currentValue); + m_multiList.handleSliderMove(id, value); + if (id == eControl_GameMode) + { + if (m_bInitialPopulateDone) ui.PlayUISFX(eSFX_Scroll); + m_bPendingSliderUpdate = true; + m_iPendingSliderValue = value; + } +} + +void UIScene_InGamePlayerOptionsMenu::handleCheckboxToggled(F64 controlId, bool selected) +{ + if (m_bInitialPopulateDone) ui.PlayUISFX(eSFX_Press); + int id = static_cast(controlId); + if (id > eControl_MultiList && id < eControl_Count) + { + m_bChecked[id] = selected; + if (id == eControl_Op) m_bPendingCheatRefresh = true; + } +} + int UIScene_InGamePlayerOptionsMenu::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { BYTE smallId = *static_cast(pParam); delete pParam; if(result==C4JStorage::EMessage_ResultAccept) - { + { Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr localPlayer = pMinecraft->localplayers[iPad]; if(localPlayer->connection) { localPlayer->connection->send(std::make_shared(smallId)); } - - // Fix for #61494 - [CRASH]: TU7: Code: Multiplayer: Title may crash while kicking a player from an online game. - // We cannot do a navigate back here is this actually occurs on a thread other than the main thread. On rare occasions this can clash - // with the XUI render and causes a crash. The OnPlayerChanged event should perform the navigate back on the main thread - //app.NavigateBack(iPad); } return 0; @@ -479,45 +470,3 @@ void UIScene_InGamePlayerOptionsMenu::OnPlayerChanged(void *callbackParam, INetw scene->m_bShouldNavBack = true; } } - -void UIScene_InGamePlayerOptionsMenu::resetCheatCheckboxes() -{ - bool isModerator = m_checkboxes[eControl_Op].IsChecked(); - //bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; - - if (!m_editingSelf) - { - m_checkboxes[eControl_HostInvisible].SetEnable(isModerator); - m_checkboxes[eControl_HostFly].SetEnable(isModerator); - m_checkboxes[eControl_HostHunger].SetEnable(isModerator); - m_checkboxes[eControl_CheatTeleport].SetEnable(isModerator); - } -} - -void UIScene_InGamePlayerOptionsMenu::handleCheckboxToggled(F64 controlId, bool selected) -{ - switch(static_cast(controlId)) - { - case eControl_Op: - // flag that the moderator state has changed - //resetCheatCheckboxes(); - break; - } -} - -void UIScene_InGamePlayerOptionsMenu::handleTimerComplete(int id) -{ - switch(id) - { - case CHECKBOXES_TIMER_ID: - { - bool bIsModerator = m_checkboxes[eControl_Op].IsChecked(); - if(m_bModeratorState!=bIsModerator) - { - m_bModeratorState=bIsModerator; - resetCheatCheckboxes(); - } - } - break; - } -} diff --git a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.h b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.h index e78b6748..6d0c3400 100644 --- a/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_InGamePlayerOptionsMenu.h @@ -1,92 +1,79 @@ #pragma once #include "UIScene.h" +#include "UIControl_MultiList.h" class UIScene_InGamePlayerOptionsMenu : public UIScene { private: enum EControls { - // Checkboxes + eControl_MultiList = 0, eControl_BuildAndMine, eControl_UseDoorsAndSwitches, eControl_UseContainers, eControl_AttackPlayers, eControl_AttackAnimals, eControl_Op, - eControl_CheatTeleport, + eControl_HostInvisible, eControl_HostFly, eControl_HostHunger, - eControl_HostInvisible, - - eControl_CHECKBOXES_COUNT, - - // Others - eControl_Kick = eControl_CHECKBOXES_COUNT, + eControl_CheatTeleport, + eControl_GameMode, + eControl_SetSpawn, + eControl_Kick, + eControl_Count, }; bool m_bShouldNavBack; bool m_editingSelf; BYTE m_networkSmallId; unsigned int m_playerPrivileges; - - UIControl_Label m_labelGamertag; - UIControl_CheckBox m_checkboxes[eControl_CHECKBOXES_COUNT]; - UIControl_Button m_buttonKick; - IggyName m_funcSetPlayerIcon; + + UIControl_MultiList m_multiList; + bool m_bNeedsMultiListPopulate; + bool m_bInitialPopulateDone; + bool m_bPendingSliderUpdate; + int m_iPendingSliderValue; + bool m_bPendingCheatRefresh; + + bool m_bChecked[eControl_Count]; + bool m_bPresent[eControl_Count]; + int m_iGameType; + int m_iStartGameType; + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) - UI_MAP_ELEMENT( m_checkboxes[eControl_BuildAndMine], "CheckboxBuildAndMine") - UI_MAP_ELEMENT( m_checkboxes[eControl_UseDoorsAndSwitches], "CheckboxUseDoorsAndSwitches") - UI_MAP_ELEMENT( m_checkboxes[eControl_UseContainers], "CheckboxUseContainers") - UI_MAP_ELEMENT( m_checkboxes[eControl_AttackPlayers], "CheckboxAttackPlayers") - UI_MAP_ELEMENT( m_checkboxes[eControl_AttackAnimals], "CheckboxAttackAnimals") - UI_MAP_ELEMENT( m_checkboxes[eControl_Op], "CheckboxOp") - UI_MAP_ELEMENT( m_checkboxes[eControl_CheatTeleport], "CheckboxTeleport") - UI_MAP_ELEMENT( m_checkboxes[eControl_HostFly], "CheckboxHostFly") - UI_MAP_ELEMENT( m_checkboxes[eControl_HostHunger], "CheckboxHostHunger") - UI_MAP_ELEMENT( m_checkboxes[eControl_HostInvisible], "CheckboxHostInvisible") - - UI_MAP_ELEMENT( m_buttonKick, "ButtonKick") - - UI_MAP_ELEMENT( m_labelGamertag, "Gamertag") - - UI_MAP_NAME( m_funcSetPlayerIcon, L"SetPlayerIcon" ); UI_END_MAP_ELEMENTS_AND_NAMES() - bool m_bModeratorState; - - public: UIScene_InGamePlayerOptionsMenu(int iPad, void *initData, UILayer *parentLayer); virtual EUIScene getSceneType() { return eUIScene_InGamePlayerOptionsMenu;} virtual void updateTooltips(); - virtual void handleReload(); protected: - // TODO: This should be pure virtual in this class virtual wstring getMoviePath(); virtual void handleCheckboxToggled(F64 controlId, bool selected); - virtual void handleTimerComplete(int id); + virtual void handleSliderMove(F64 sliderId, F64 currentValue); public: virtual void tick(); - - // INPUT virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); - virtual void handleDestroy(); virtual void handlePress(F64 controlId, F64 childId); - + virtual void handleGainFocus(bool navBack); static int KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static void OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving); private: - /** 4J-JEV: - For enabling/disabling 'Can Fly', 'Can Teleport', 'Can Disable Hunger' etc - used after changing the moderator checkbox. - */ + void populateList(); + void addCheckbox(int id, int stringId, bool enabled = true); void resetCheatCheckboxes(); -}; \ No newline at end of file + void applyAndClose(); + void sendPacket(shared_ptr packet); + bool privilege(int priv); + bool isCreative(); + wstring gameModeLabel(int value); +}; diff --git a/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp index 9031cb92..f7a3354d 100644 --- a/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_InventoryMenu.cpp @@ -56,6 +56,8 @@ UIScene_InventoryMenu::UIScene_InventoryMenu(int iPad, void* _initData, UILayer* Initialize(initData->iPad, menu, false, InventoryMenu::INV_SLOT_START, eSectionInventoryUsing, eSectionInventoryCraftingGrid, initData->bNavigateBack); m_slotListArmor.addSlots(InventoryMenu::ARMOR_SLOT_START, InventoryMenu::ARMOR_SLOT_END - InventoryMenu::ARMOR_SLOT_START); + positionOffhandSlot(); + m_slotListOffhand.addSlots(InventoryMenu::OFFHAND_SLOT, 1); if (initData) delete initData; @@ -81,6 +83,8 @@ void UIScene_InventoryMenu::handleReload() SetClassicCrafting(this->m_bIsClassicCrafting); m_slotListArmor.addSlots(InventoryMenu::ARMOR_SLOT_START, InventoryMenu::ARMOR_SLOT_END - InventoryMenu::ARMOR_SLOT_START); + positionOffhandSlot(); + m_slotListOffhand.addSlots(InventoryMenu::OFFHAND_SLOT, 1); if (this->m_bIsClassicCrafting) { @@ -112,6 +116,9 @@ int UIScene_InventoryMenu::getSectionColumns(ESceneSection eSection) case eSectionInventoryCraftingResult: cols = 1; break; + case eSectionInventoryOffhand: + cols = 1; + break; default: assert(false); break; @@ -139,6 +146,9 @@ int UIScene_InventoryMenu::getSectionRows(ESceneSection eSection) case eSectionInventoryCraftingResult: rows = 1; break; + case eSectionInventoryOffhand: + rows = 1; + break; default: assert(false); break; @@ -170,6 +180,10 @@ void UIScene_InventoryMenu::GetPositionOfSection(ESceneSection eSection, UIVec2D pPosition->x = m_slotListResult.getXPos(); pPosition->y = m_slotListResult.getYPos(); break; + case eSectionInventoryOffhand: + pPosition->x = m_slotListOffhand.getXPos(); + pPosition->y = m_slotListOffhand.getYPos(); + break; default: assert(false); break; @@ -202,6 +216,10 @@ void UIScene_InventoryMenu::GetItemScreenData(ESceneSection eSection, int iItemI sectionSize.x = m_slotListResult.getWidth(); sectionSize.y = m_slotListResult.getHeight(); break; + case eSectionInventoryOffhand: + sectionSize.x = m_slotListOffhand.getWidth(); + sectionSize.y = m_slotListOffhand.getHeight(); + break; default: assert(false); break; @@ -244,6 +262,9 @@ void UIScene_InventoryMenu::setSectionSelectedSlot(ESceneSection eSection, int x case eSectionInventoryCraftingResult: slotList = &m_slotListResult; break; + case eSectionInventoryOffhand: + slotList = &m_slotListOffhand; + break; default: assert(false); break; @@ -272,6 +293,9 @@ UIControl* UIScene_InventoryMenu::getSection(ESceneSection eSection) case eSectionInventoryCraftingResult: control = &m_slotListResult; break; + case eSectionInventoryOffhand: + control = &m_slotListOffhand; + break; default: assert(false); break; @@ -405,4 +429,39 @@ void UIScene_InventoryMenu::SetClassicCrafting(bool m_bIsClassicCrafting) m_slotListArmor.UpdateControl(); m_playerPreview.UpdateControl(); } -} \ No newline at end of file +} +void UIScene_InventoryMenu::positionOffhandSlot() +{ + m_slotListOffhand.UpdateControl(); + + F64 armorY = 0, previewX = 0, previewW = 0, invX = 0, invW = 0; + IggyValueGetF64RS(m_slotListArmor.getIggyValuePath(), 0, "y", &armorY); + IggyValueGetF64RS(m_playerPreview.getIggyValuePath(), 0, "x", &previewX); + IggyValueGetF64RS(m_playerPreview.getIggyValuePath(), 0, "width", &previewW); + IggyValueGetF64RS(m_slotListInventory.getIggyValuePath(), 0, "x", &invX); + IggyValueGetF64RS(m_slotListInventory.getIggyValuePath(), 0, "width", &invW); + + S32 slotSize = 0; + IggyValueGetS32RS(m_slotListArmor.getIggyValuePath(), 0, "m_iSlotSize", &slotSize); + if (slotSize <= 0) slotSize = m_slotListOffhand.getHeight(); + IggyValueSetS32RS(m_slotListOffhand.getIggyValuePath(), 0, "m_iSlotSize", slotSize); + + IggyValueSetBooleanRS(m_slotListOffhand.getIggyValuePath(), 0, "m_bHideIconHolder", false); + + S32 x = static_cast(previewX + previewW) - slotSize; + S32 y = static_cast(armorY) + 3 * slotSize; + if (!m_bIsClassicCrafting) + { + S32 pitch = static_cast(invW) / 9; + if (pitch <= 0) pitch = slotSize; + x = static_cast(invX) + 7 * pitch; + } + else + { + F64 gridX = 0; + IggyValueGetF64RS(m_slotListCrafting.getIggyValuePath(), 0, "x", &gridX); + x = static_cast(gridX); + } + m_slotListOffhand.setXPos(x); + m_slotListOffhand.setYPos(y); +} diff --git a/Minecraft.Client/Common/UI/UIScene_InventoryMenu.h b/Minecraft.Client/Common/UI/UIScene_InventoryMenu.h index c854bdbb..328d0cf3 100644 --- a/Minecraft.Client/Common/UI/UIScene_InventoryMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_InventoryMenu.h @@ -16,6 +16,7 @@ private: void updateEffectsDisplay(); void SetClassicCrafting(bool m_bIsClassicCrafting); + void positionOffhandSlot(); public: UIScene_InventoryMenu(int iPad, void* initData, UILayer* parentLayer); @@ -23,7 +24,7 @@ public: virtual EUIScene getSceneType() { return eUIScene_InventoryMenu; } protected: - UIControl_SlotList m_slotListArmor, m_slotListCrafting, m_slotListResult; + UIControl_SlotList m_slotListArmor, m_slotListCrafting, m_slotListResult, m_slotListOffhand; UIControl_MinecraftPlayer m_playerPreview; UIControl_Label m_labelCrafting; @@ -32,6 +33,7 @@ protected: UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene_AbstractContainerMenu) UI_BEGIN_MAP_CHILD_ELEMENTS(m_controlMainPanel) UI_MAP_ELEMENT(m_slotListArmor, "armorList") + UI_MAP_ELEMENT(m_slotListOffhand, "offhandList") UI_MAP_ELEMENT(m_playerPreview, "iggy_player") UI_MAP_ELEMENT(m_slotListCrafting, "craftingList") UI_MAP_ELEMENT(m_slotListResult, "Result") diff --git a/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp index 92ab7e58..b8c86337 100644 --- a/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp @@ -38,6 +38,7 @@ UIScene_JoinMenu::UIScene_JoinMenu(int iPad, void *_initData, UILayer *parentLay #ifdef _WINDOWS64 m_serverIndex = initData->serverIndex; m_editServerPhase = eEditServer_Idle; + m_bPendingEditClose = false; m_editServerButtonIndex = -1; m_deleteServerButtonIndex = -1; @@ -132,6 +133,14 @@ void UIScene_JoinMenu::updateTooltips() void UIScene_JoinMenu::tick() { if (this == nullptr) return; +#ifdef _WINDOWS64 + if (m_bPendingEditClose && hasFocus(m_iPad)) + { + m_bPendingEditClose = false; + navigateBack(); + return; + } +#endif if (!m_friendInfoRequestIssued) { ui.NavigateToScene(m_iPad, eUIScene_Timer); @@ -946,21 +955,34 @@ int UIScene_JoinMenu::DeleteServerDialogReturned(void *pParam, int iPad, C4JStor void UIScene_JoinMenu::BeginEditServer() { m_bIgnoreInput = true; - m_editServerPhase = eEditServer_IP; - m_editServerIP.clear(); - m_editServerPort.clear(); + m_editServerPhase = eEditServer_Idle; - wchar_t wDefaultIP[64] = {}; - mbstowcs(wDefaultIP, m_selectedSession->data.hostIP, 63); + wchar_t wIP[256] = {}; + mbstowcs(wIP, m_selectedSession->data.hostIP, 255); + wchar_t wPort[16] = {}; + swprintf(wPort, 16, L"%d", m_selectedSession->data.hostPort); - UIKeyboardInitData kbData; - kbData.title = L"Server Address"; - kbData.defaultText = wDefaultIP; - kbData.maxChars = 128; - kbData.callback = &UIScene_JoinMenu::EditServerKeyboardCallback; - kbData.lpParam = this; - kbData.pcMode = g_KBMInput.IsKBMActive(); - ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); + m_editServerData = EditServerInitData(); + m_editServerData.name = m_selectedSession->displayLabel ? m_selectedSession->displayLabel : L""; + m_editServerData.address = wstring(wIP); + if (wcscmp(wPort, L"25565") != 0) + m_editServerData.address += wstring(L":") + wPort; + m_editServerData.callback = &UIScene_JoinMenu::EditServerDoneCallback; + m_editServerData.lpParam = this; + ui.NavigateToScene(m_iPad, eUIScene_EditServerMenu, &m_editServerData); +} + +int UIScene_JoinMenu::EditServerDoneCallback(LPVOID lpParam, bool confirmed, const wstring &name, const wstring &ip, const wstring &port) +{ + UIScene_JoinMenu *pClass = static_cast(lpParam); + pClass->m_bIgnoreInput = false; + if (confirmed && !ip.empty()) + { + pClass->UpdateServerInFile(ip, port, name); + g_NetworkManager.ForceFriendsSessionRefresh(); + pClass->m_bPendingEditClose = true; + } + return 0; } int UIScene_JoinMenu::EditServerKeyboardCallback(LPVOID lpParam, bool bRes) diff --git a/Minecraft.Client/Common/UI/UIScene_JoinMenu.h b/Minecraft.Client/Common/UI/UIScene_JoinMenu.h index 5042a91a..7b6f3794 100644 --- a/Minecraft.Client/Common/UI/UIScene_JoinMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_JoinMenu.h @@ -1,6 +1,9 @@ #pragma once #include "UIScene.h" +#ifdef _WINDOWS64 +#include "UIScene_EditServerMenu.h" +#endif class UIScene_JoinMenu : public UIScene { @@ -119,6 +122,9 @@ protected: void BeginEditServer(); void BeginDeleteServer(); static int EditServerKeyboardCallback(LPVOID lpParam, bool bRes); + EditServerInitData m_editServerData; + bool m_bPendingEditClose; + static int EditServerDoneCallback(LPVOID lpParam, bool confirmed, const wstring &name, const wstring &ip, const wstring &port); static int DeleteServerDialogReturned(void *pParam, int iPad, C4JStorage::EMessageResult result); void UpdateServerInFile(const wstring& newIP, const wstring& newPort, const wstring& newName); void RemoveServerFromFile(); diff --git a/Minecraft.Client/Common/UI/UIScene_KeybindsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_KeybindsMenu.cpp new file mode 100644 index 00000000..25a8ece0 --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_KeybindsMenu.cpp @@ -0,0 +1,582 @@ +#include "stdafx.h" +#include "UI.h" +#include "UIScene_KeybindsMenu.h" + +#ifdef _WINDOWS64 + +#include "../../Windows64/KeyboardMouseInput.h" +#include "../../Windows64/ControllerBinds.h" + +static const wchar_t* s_bindNames[KeyboardMouseInput::KB_COUNT] = +{ + L"Walk Forwards", + L"Walk Backwards", + L"Strafe Left", + L"Strafe Right", + L"Jump", + L"Sneak", + L"Sprint", + L"Inventory", + L"Drop Item", + L"Crafting", + L"Crafting (Alternate)", + L"Chat", + L"Change Camera Mode", + L"Pick Block", + L"Hotbar Slot 1", + L"Hotbar Slot 2", + L"Hotbar Slot 3", + L"Hotbar Slot 4", + L"Hotbar Slot 5", + L"Hotbar Slot 6", + L"Hotbar Slot 7", + L"Hotbar Slot 8", + L"Hotbar Slot 9", + L"Toggle HUD", + L"Take Screenshot", + L"Debug Info", + L"Toggle Fullscreen", +}; + +struct KeybindSection +{ + const wchar_t* title; + int first; + int last; +}; + +static const KeybindSection s_sections[] = +{ + { L"Movement", KeyboardMouseInput::KB_FORWARD, KeyboardMouseInput::KB_SPRINT }, + { L"Gameplay", KeyboardMouseInput::KB_INVENTORY, KeyboardMouseInput::KB_PICK_BLOCK }, + { L"Hotbar", KeyboardMouseInput::KB_HOTBAR_1, KeyboardMouseInput::KB_HOTBAR_9 }, + { L"Miscellaneous", KeyboardMouseInput::KB_TOGGLE_HUD, KeyboardMouseInput::KB_FULLSCREEN }, +}; + +UIScene_KeybindsMenu::UIScene_KeybindsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) +{ + initialiseMovie(); + m_bController = reinterpret_cast(initData) != 0; + m_bNeedsMultiListPopulate = true; + m_bInitialPopulateDone = false; + m_bChanged = false; + m_iCaptureBind = -1; + m_bCaptureArmed = false; + m_bIgnoreInputUntilRelease = false; + m_bPendingReset = false; + m_uiPrevPadButtons = 0; + m_bPendingLayout = false; + m_bPendingCheckboxes = false; + m_iPendingLayout = 0; + doHorizontalResizeCheck(); +} + +UIScene_KeybindsMenu::~UIScene_KeybindsMenu() +{ + g_KBMInput.SetBindCapture(false); +} + +wstring UIScene_KeybindsMenu::getMoviePath() +{ + if (app.GetLocalPlayerCount() > 1) + return L"MultilistMenuSplit"; + return L"MultilistMenu"; +} + +int UIScene_KeybindsMenu::getBindCount() const +{ + return m_bController ? ControllerBinds::GetBindCount() : static_cast(KeyboardMouseInput::KB_COUNT); +} + +wstring UIScene_KeybindsMenu::getBindLabel(int bind, bool waiting) +{ + wchar_t valueName[96]; + bool clash = false; + + if (waiting) + { + wcsncpy_s(valueName, m_bController ? L"Press a button..." : L"> Press a key <", _TRUNCATE); + } + else if (m_bController) + { + const unsigned char layout = static_cast(currentLayout()); + unsigned int button = ControllerBinds::GetFromMap(bind, layout); + for (int i = 0; i < ControllerBinds::GetBindCount(); ++i) + { + if (i != bind && (ControllerBinds::GetFromMap(i, layout) & button) != 0) + { + clash = true; + break; + } + } + + wstring text = ControllerBinds::GetBindName(bind); + if (button == 0) + text += L": None"; + if (clash) + text += L" (!)"; + return text; + } + else + { + for (int i = 0; i < KeyboardMouseInput::KB_COUNT; ++i) + { + if (i != bind && g_KBMInput.GetBind(i) == g_KBMInput.GetBind(bind)) + { + clash = true; + break; + } + } + + if (KeyboardMouseInput::GetKeyIconName(g_KBMInput.GetBind(bind), nullptr) != nullptr) + { + wstring text = s_bindNames[bind]; + if (clash) + text += L" (!)"; + return text; + } + + KeyboardMouseInput::GetKeyName(g_KBMInput.GetBind(bind), valueName, 96); + } + + const wchar_t* name = m_bController ? ControllerBinds::GetBindName(bind) : s_bindNames[bind]; + wchar_t text[256]; + swprintf(text, 256, clash ? L"%ls: %ls (!)" : L"%ls: %ls", name, valueName); + return text; +} + +void UIScene_KeybindsMenu::registerPadIcons() +{ + const wchar_t* folder = L"xboxOne"; + switch (app.GetGameSettings(m_iPad, eGameSetting_ControlType)) + { + case 2: folder = L"xbox360"; break; + case 3: folder = L"PS3"; break; + case 4: folder = L"PS4"; break; + case 5: folder = L"WiiU"; break; + } + + static unsigned int s_padIconGeneration = 0; + wchar_t prefix[64]; + swprintf(prefix, 64, L"PadIcon_%ls_%u_", folder, ++s_padIconGeneration); + m_padIconPrefix = prefix; + + vector iconNames; + iconNames.push_back(L"ButtonLeftStick"); + iconNames.push_back(L"ButtonRightStick"); + unsigned int mask = ControllerBinds::GetBindableButtonMask(); + for (unsigned int bit = 1; bit != 0; bit <<= 1) + { + if ((mask & bit) == 0) + continue; + const wchar_t* icon = ControllerBinds::GetButtonIconName(bit); + if (icon) + iconNames.push_back(icon); + } + + for (const wchar_t* icon : iconNames) + { + wstring textureName = m_padIconPrefix + icon; + if (hasRegisteredSubstitutionTexture(textureName)) + continue; + wstring path = wstring(L"Graphics\\PadIcons\\") + folder + L"\\" + icon + L".png"; + if (!app.hasArchiveFile(path)) + continue; + byteArray data = app.getArchiveFile(path); + if (data.data && data.length > 0) + registerSubstitutionTexture(textureName, data.data, data.length, true); + } +} + +wstring UIScene_KeybindsMenu::registerKeyIcon(int vkCode) +{ + bool wide = false; + const wchar_t* icon = KeyboardMouseInput::GetKeyIconName(vkCode, &wide); + if (!icon) + return L""; + + wstring textureName = m_padIconPrefix + icon; + if (!hasRegisteredSubstitutionTexture(textureName)) + { + wstring path = wstring(L"Graphics\\KeyIcons\\") + icon + L".png"; + if (!app.hasArchiveFile(path)) + return L""; + byteArray data = app.getArchiveFile(path); + if (!data.data || data.length == 0) + return L""; + registerSubstitutionTexture(textureName, data.data, data.length, true); + } + return wide ? textureName + L"@2" : textureName; +} + +void UIScene_KeybindsMenu::setBindRow(int bind, bool waiting) +{ + m_multiList.SetItemLabelLeft(eControl_BindBase + bind, getBindLabel(bind, waiting)); + int iconSize = (getSceneResolution() == UIScene::eSceneResolution_1080) ? 36 : 24; + if (!m_bController) + { + m_multiList.SetItemIcons(eControl_BindBase + bind, waiting ? wstring() : registerKeyIcon(g_KBMInput.GetBind(bind)), iconSize); + return; + } + + wstring icons; + if (!waiting) + { + unsigned int shown = InputManager.ApplyButtonSwap(m_iPad, ControllerBinds::GetFromMap(bind, static_cast(currentLayout()))); + for (unsigned int bit = 1; bit != 0; bit <<= 1) + { + if ((shown & bit) == 0) + continue; + const wchar_t* icon = ControllerBinds::GetButtonIconName(bit); + if (!icon) + continue; + if (!icons.empty()) + icons += L","; + icons += m_padIconPrefix; + icons += icon; + } + } + m_multiList.SetItemIcons(eControl_BindBase + bind, icons, iconSize); +} + +void UIScene_KeybindsMenu::setStickRows() +{ + const bool southpaw = app.GetGameSettings(m_iPad, eGameSetting_ControlSouthPaw) != 0; + int iconSize = (getSceneResolution() == UIScene::eSceneResolution_1080) ? 36 : 24; + m_multiList.SetItemIcons(eControl_Look, m_padIconPrefix + (southpaw ? L"ButtonLeftStick" : L"ButtonRightStick"), iconSize); + m_multiList.SetItemIcons(eControl_Move, m_padIconPrefix + (southpaw ? L"ButtonRightStick" : L"ButtonLeftStick"), iconSize); +} + +void UIScene_KeybindsMenu::refreshBindLabels() +{ + for (int i = 0; i < getBindCount(); ++i) + setBindRow(i, i == m_iCaptureBind); +} + +void UIScene_KeybindsMenu::beginCapture(int bind) +{ + m_iCaptureBind = bind; + m_bCaptureArmed = false; + g_KBMInput.SetBindCapture(true); + setBindRow(bind, true); +} + +void UIScene_KeybindsMenu::endCapture() +{ + int bind = m_iCaptureBind; + m_iCaptureBind = -1; + m_bCaptureArmed = false; + m_bIgnoreInputUntilRelease = true; + if (bind >= 0) + refreshBindLabels(); +} + +bool UIScene_KeybindsMenu::anyInputHeld() +{ + if (g_KBMInput.IsAnyKeyDown()) + return true; + return (InputManager.GetRawButtons(m_iPad) & ControllerBinds::GetBindableButtonMask()) != 0; +} + +int UIScene_KeybindsMenu::currentLayout() +{ + int layout = app.GetGameSettings(m_iPad, eGameSetting_ControlScheme); + if (layout < 0 || layout >= ControllerBinds::MAP_COUNT) + layout = 0; + return layout; +} + +wstring UIScene_KeybindsMenu::getLayoutLabel(int layout) +{ + static const int s_schemeText[3] = { IDS_CONTROLS_SCHEME0, IDS_CONTROLS_SCHEME1, IDS_CONTROLS_SCHEME2 }; + wchar_t text[128]; + swprintf(text, 128, L"%ls : %ls", app.GetString(IDS_CURRENT_LAYOUT), layout < 3 ? app.GetString(s_schemeText[layout]) : L"Custom"); + return text; +} + +void UIScene_KeybindsMenu::setLayout(int layout) +{ + if (layout < 0 || layout >= ControllerBinds::MAP_COUNT) + return; + if (currentLayout() != layout) + { + app.SetGameSettings(m_iPad, eGameSetting_ControlScheme, static_cast(layout)); + InputManager.SetJoypadMapVal(m_iPad, static_cast(layout)); + } + refreshBindLabels(); +} + +void UIScene_KeybindsMenu::tick() +{ + if (m_bNeedsMultiListPopulate) + { + m_bNeedsMultiListPopulate = false; + m_bInitialPopulateDone = false; + m_multiList.setupControl(this, m_rootPath, "MultiList"); + m_controls.push_back(&m_multiList); + m_multiList.clearList(); + m_multiList.init(eControl_MultiList); + + { + IggyName funcSpacing = registerFastName(L"SetListSpacing"); + IggyDataValue spacingResult; + IggyDataValue spacingArg[1]; + spacingArg[0].type = IGGY_DATATYPE_number; + spacingArg[0].number = (getSceneResolution() == UIScene::eSceneResolution_1080) ? 4.0 : 2.0; + IggyPlayerCallMethodRS(getMovie(), &spacingResult, m_rootPath, funcSpacing, 1, spacingArg); + } + + m_multiList.AddNewButton(app.GetString(IDS_RESET_TO_DEFAULTS), eControl_ResetToDefaults); + + if (m_bController) + { + registerPadIcons(); + m_multiList.AddNewLabel(L" "); + m_multiList.AddNewLabel(L"Movement"); + m_multiList.AddNewCheckbox(app.GetString(IDS_INVERT_LOOK), eControl_InvertLook, app.GetGameSettings(m_iPad, eGameSetting_ControlInvertLook) != 0); + m_multiList.AddNewCheckbox(app.GetString(IDS_SOUTHPAW), eControl_SouthPaw, app.GetGameSettings(m_iPad, eGameSetting_ControlSouthPaw) != 0); + m_multiList.AddNewLabel(L"Look", eControl_Look); + m_multiList.SetItemFlatLabel(eControl_Look, eControl_ResetToDefaults, L"Look"); + m_multiList.AddNewLabel(L"Move/Sprint", eControl_Move); + m_multiList.SetItemFlatLabel(eControl_Move, eControl_ResetToDefaults, L"Move/Sprint"); + setStickRows(); + const wchar_t* currentSection = nullptr; + for (int b = 0; b < ControllerBinds::GetBindCount(); ++b) + { + const wchar_t* section = ControllerBinds::GetBindSection(b); + if (currentSection == nullptr || wcscmp(currentSection, section) != 0) + { + m_multiList.AddNewLabel(L" "); + m_multiList.AddNewLabel(section); + currentSection = section; + } + m_multiList.AddNewButton(ControllerBinds::GetBindName(b), eControl_BindBase + b); + setBindRow(b, false); + } + } + else + { + static unsigned int s_keyIconGeneration = 0; + wchar_t prefix[64]; + swprintf(prefix, 64, L"KeyIcon_%u_", ++s_keyIconGeneration); + m_padIconPrefix = prefix; + + m_multiList.AddNewLabel(L" "); + m_multiList.AddNewLabel(L"Options"); + m_multiList.AddNewCheckbox(app.GetString(IDS_INVERT_LOOK), eControl_InvertLook, app.GetGameSettings(m_iPad, eGameSetting_ControlInvertLook) != 0); + + for (int s = 0; s < static_cast(sizeof(s_sections) / sizeof(s_sections[0])); ++s) + { + m_multiList.AddNewLabel(L" "); + m_multiList.AddNewLabel(s_sections[s].title); + for (int b = s_sections[s].first; b <= s_sections[s].last; ++b) + { + m_multiList.AddNewButton(getBindLabel(b, false), eControl_BindBase + b); + setBindRow(b, false); + } + } + } + + IggyName funcDoVert = registerFastName(L"DoVerticalResizeCheck"); + IggyName funcHideDesc = registerFastName(L"HideDescription"); + IggyDataValue result; + IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcDoVert, 0, nullptr); + doHorizontalResizeCheck(); + IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcHideDesc, 0, nullptr); + m_multiList.HighlightItem(eControl_ResetToDefaults); + } + + if (m_bPendingLayout) + { + m_bPendingLayout = false; + setLayout(m_iPendingLayout); + } + + if (m_bPendingCheckboxes) + { + m_bPendingCheckboxes = false; + app.SetGameSettings(m_iPad, eGameSetting_ControlInvertLook, m_multiList.GetCheckboxValue(eControl_InvertLook) ? 1 : 0); + if (m_bController) + { + app.SetGameSettings(m_iPad, eGameSetting_ControlSouthPaw, m_multiList.GetCheckboxValue(eControl_SouthPaw) ? 1 : 0); + setStickRows(); + } + } + + if (m_bPendingReset) + { + m_bPendingReset = false; + m_bChanged = true; + if (m_bController) + { + ControllerBinds::ResetToDefaults(); + setLayout(MAP_STYLE_0); + } + else + { + g_KBMInput.ResetBinds(); + refreshBindLabels(); + } + } + + unsigned int padButtons = InputManager.GetRawButtons(m_iPad) & ControllerBinds::GetBindableButtonMask(); + + if (m_iCaptureBind >= 0) + { + if (!m_bCaptureArmed) + { + if (!anyInputHeld()) + m_bCaptureArmed = true; + } + else if (g_KBMInput.IsKeyPressed(VK_ESCAPE)) + { + endCapture(); + } + else if (m_bController) + { + unsigned int newButtons = padButtons & ~m_uiPrevPadButtons; + if (newButtons != 0) + { + unsigned int button = newButtons & (~newButtons + 1); + if (currentLayout() != ControllerBinds::CUSTOM_MAP) + { + ControllerBinds::CopyLayoutToCustom(static_cast(currentLayout())); + setLayout(ControllerBinds::CUSTOM_MAP); + } + ControllerBinds::Set(m_iCaptureBind, InputManager.ApplyButtonSwap(m_iPad, button)); + m_bChanged = true; + ui.PlayUISFX(eSFX_Press); + endCapture(); + } + } + else + { + int vk = g_KBMInput.GetPressedKey(); + if (vk != 0) + { + g_KBMInput.SetBind(m_iCaptureBind, vk); + m_bChanged = true; + ui.PlayUISFX(eSFX_Press); + endCapture(); + } + } + } + else if (m_bIgnoreInputUntilRelease && !anyInputHeld()) + { + m_bIgnoreInputUntilRelease = false; + g_KBMInput.SetBindCapture(false); + } + + m_uiPrevPadButtons = padButtons; + + UIScene::tick(); + m_bInitialPopulateDone = true; +} + +void UIScene_KeybindsMenu::updateTooltips() +{ + ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK); +} + +void UIScene_KeybindsMenu::updateComponents() +{ + bool bNotInGame = (Minecraft::GetInstance()->level == nullptr); + if (bNotInGame) + { + m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true); + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); + } + else + { + m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, false); + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, app.GetLocalPlayerCount() == 1); + } +} + +void UIScene_KeybindsMenu::handleGainFocus(bool navBack) +{ + if (navBack) + m_bNeedsMultiListPopulate = true; +} + +void UIScene_KeybindsMenu::handleDestroy() +{ + g_KBMInput.SetBindCapture(false); +} + +void UIScene_KeybindsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) +{ + if (m_iCaptureBind >= 0 || m_bIgnoreInputUntilRelease) + { + handled = true; + return; + } + + ui.AnimateKeyPress(iPad, key, repeat, pressed, released); + + switch (key) + { + case ACTION_MENU_CANCEL: + if (pressed) + { + if (m_bChanged) + { + if (m_bController) + ControllerBinds::Save(); + else + g_KBMInput.SaveBinds(); + } + g_KBMInput.SetBindCapture(false); + app.CheckGameSettingsChanged(true, iPad); + navigateBack(); + } + break; + case ACTION_MENU_OK: + case ACTION_MENU_UP: + case ACTION_MENU_DOWN: + case ACTION_MENU_LEFT: + case ACTION_MENU_RIGHT: + sendInputToMovie(key, repeat, pressed, released); + break; + } +} + +void UIScene_KeybindsMenu::handlePress(F64 controlId, F64 childId) +{ + if (m_iCaptureBind >= 0 || m_bIgnoreInputUntilRelease) + return; + + ui.PlayUISFX(eSFX_Press); + + int id = static_cast(childId); + if (id == eControl_ResetToDefaults) + { + m_bPendingReset = true; + } + else if (id >= eControl_BindBase && id < eControl_BindBase + getBindCount()) + { + beginCapture(id - eControl_BindBase); + } +} + +void UIScene_KeybindsMenu::handleCheckboxToggled(F64 controlId, bool selected) +{ + if (!m_bInitialPopulateDone) + return; + ui.PlayUISFX(eSFX_Press); + m_bPendingCheckboxes = true; +} + +void UIScene_KeybindsMenu::handleSliderMove(F64 sliderId, F64 currentValue) +{ + int id = static_cast(sliderId); + int value = static_cast(currentValue); + m_multiList.handleSliderMove(id, value); + if (id == eControl_Layout && m_bController && m_bInitialPopulateDone) + { + m_bPendingLayout = true; + m_iPendingLayout = value; + } +} + +#endif diff --git a/Minecraft.Client/Common/UI/UIScene_KeybindsMenu.h b/Minecraft.Client/Common/UI/UIScene_KeybindsMenu.h new file mode 100644 index 00000000..ea74e97d --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_KeybindsMenu.h @@ -0,0 +1,75 @@ +#pragma once + +#include "UIScene.h" +#include "UIControl_MultiList.h" + +class UIScene_KeybindsMenu : public UIScene +{ +private: + enum EControls + { + eControl_MultiList = 0, + eControl_ResetToDefaults = 1, + eControl_Layout = 2, + eControl_InvertLook = 3, + eControl_SouthPaw = 4, + eControl_SafeSprint = 5, + eControl_Swap = 6, + eControl_Look = 7, + eControl_Move = 8, + eControl_BindBase = 100, + }; + + UIControl_MultiList m_multiList; + bool m_bController; + wstring m_padIconPrefix; + bool m_bNeedsMultiListPopulate; + bool m_bInitialPopulateDone; + bool m_bChanged; + int m_iCaptureBind; + bool m_bCaptureArmed; + bool m_bIgnoreInputUntilRelease; + bool m_bPendingReset; + unsigned int m_uiPrevPadButtons; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) + UI_END_MAP_ELEMENTS_AND_NAMES() + + int getBindCount() const; + wstring getBindLabel(int bind, bool waiting); + void registerPadIcons(); + wstring registerKeyIcon(int vkCode); + void setBindRow(int bind, bool waiting); + void refreshBindLabels(); + void setStickRows(); + void beginCapture(int bind); + void endCapture(); + bool anyInputHeld(); + int currentLayout(); + wstring getLayoutLabel(int layout); + void setLayout(int layout); + bool m_bPendingLayout; + bool m_bPendingCheckboxes; + int m_iPendingLayout; + +public: + UIScene_KeybindsMenu(int iPad, void *initData, UILayer *parentLayer); + virtual ~UIScene_KeybindsMenu(); + + virtual EUIScene getSceneType() { return eUIScene_KeybindsMenu; } + + virtual void tick(); + virtual void updateTooltips(); + virtual void updateComponents(); + virtual void handleGainFocus(bool navBack); + virtual void handleDestroy(); + +protected: + virtual wstring getMoviePath(); + +public: + virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); + virtual void handlePress(F64 controlId, F64 childId); + virtual void handleCheckboxToggled(F64 controlId, bool selected); + virtual void handleSliderMove(F64 sliderId, F64 currentValue); +}; diff --git a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index 3a0b9f51..583531ec 100644 --- a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "UI.h" #include "UIScene_LaunchMoreOptionsMenu.h" +#include "SuperflatData.h" #define GAME_CREATE_ONLINE_TIMER_ID 0 #define GAME_CREATE_ONLINE_TIMER_TIME 100 @@ -96,6 +97,13 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu(int iPad, void *ini m_checkboxes[eLaunchCheckbox_Structures].init(app.GetString(IDS_GENERATE_STRUCTURES),eLaunchCheckbox_Structures,m_params->bStructures); m_checkboxes[eLaunchCheckbox_FlatWorld].init(app.GetString(IDS_SUPERFLAT_WORLD),eLaunchCheckbox_FlatWorld,m_params->bFlatWorld); m_checkboxes[eLaunchCheckbox_BonusChest].init(app.GetString(IDS_BONUS_CHEST),eLaunchCheckbox_BonusChest,m_params->bBonusChest); +#ifdef _WINDOWS64 + if (m_params->bGenerateOptions) + { + m_buttonCustomiseSuperflat.init(L"Customize Superflat", eControl_CustomiseSuperflat); + } + m_iCustomiseEnabled = -1; +#endif m_checkboxes[eLaunchCheckbox_KeepInventory].init(app.GetString(IDS_KEEP_INVENTORY), eLaunchCheckbox_KeepInventory, m_params->bKeepInventory); m_checkboxes[eLaunchCheckbox_MobSpawning].init(app.GetString(IDS_MOB_SPAWNING), eLaunchCheckbox_MobSpawning, m_params->bDoMobSpawning); @@ -195,6 +203,15 @@ void UIScene_LaunchMoreOptionsMenu::updateTooltips() ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, -1, -1, -1, -1, lb, changeTabTooltip); } +void UIScene_LaunchMoreOptionsMenu::openSuperflatCustomise() +{ +#ifdef _WINDOWS64 + if (!m_params->bGenerateOptions || !m_params->bFlatWorld) return; + ui.PlayUISFX(eSFX_Press); + ui.NavigateToScene(m_iPad, eUIScene_SuperflatMenu, m_params); +#endif +} + void UIScene_LaunchMoreOptionsMenu::updateComponents() { m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); @@ -214,6 +231,22 @@ void UIScene_LaunchMoreOptionsMenu::tick() { UIScene::tick(); +#ifdef _WINDOWS64 + if (m_params->bGenerateOptions) + { + int enabled = m_params->bFlatWorld ? 1 : 0; + if (enabled != m_iCustomiseEnabled) + { + m_iCustomiseEnabled = enabled; + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_boolean; + value[0].boolval = enabled != 0; + IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetCustomiseEnabled, 1, value); + } + } +#endif + bool bMultiplayerAllowed = ProfileManager.IsSignedInLive(m_params->iPad) && ProfileManager.AllowedToPlayMultiplayer(m_params->iPad); if (bMultiplayerAllowed != m_bMultiplayerAllowed) @@ -478,8 +511,23 @@ void UIScene_LaunchMoreOptionsMenu::handleCheckboxToggled(F64 controlId, bool se void UIScene_LaunchMoreOptionsMenu::handleFocusChange(F64 controlId, F64 childId) { int stringId = 0; + wstring customText; switch(static_cast(controlId)) { +#ifdef _WINDOWS64 + case eControl_CustomiseSuperflat: + { + customText = L"Customise the layers, biome and structures of your Superflat world."; + if (m_params->bFlatWorld) + { + FlatGeneratorInfo info = m_params->superflatOptions.empty() ? FlatGeneratorInfo::getDefault() : FlatGeneratorInfo::fromValue(m_params->superflatOptions); + customText += L"\n\n" + SuperflatData::Describe(info); + } + for (size_t pos = customText.find(L'\n'); pos != wstring::npos; pos = customText.find(L'\n', pos)) + customText.replace(pos, 1, L"
"); + } + break; +#endif case eLaunchCheckbox_Online: stringId = IDS_GAMEOPTION_ONLINE; break; @@ -559,7 +607,7 @@ void UIScene_LaunchMoreOptionsMenu::handleFocusChange(F64 controlId, F64 childId #endif }; - wstring wsText=app.GetString(stringId); + wstring wsText = customText.empty() ? wstring(app.GetString(stringId)) : customText; EHTMLFontSize size = eHTMLSize_Normal; if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) { @@ -650,6 +698,9 @@ void UIScene_LaunchMoreOptionsMenu::handlePress(F64 controlId, F64 childId) switch(static_cast(controlId)) { + case eControl_CustomiseSuperflat: + openSuperflatCustomise(); + break; case eControl_EditSeed: { #ifdef _WINDOWS64 diff --git a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.h b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.h index ba475357..ec4f6b02 100644 --- a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.h @@ -39,6 +39,7 @@ private: eControl_EditSeed, eControl_WorldSize, eControl_WorldResize, + eControl_CustomiseSuperflat, eControl_Count }; @@ -62,7 +63,12 @@ private: UIControl_TextInput m_editSeed; UIControl_Slider m_sliderWorldSize; UIControl_Slider m_sliderWorldResize; +#ifdef _WINDOWS64 + UIControl_Button m_buttonCustomiseSuperflat; + int m_iCustomiseEnabled; +#endif IggyName m_funcSetMenuType, m_funcChangeTab, m_funcSetDescription; + IggyName m_funcSetCustomiseEnabled; UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) UI_MAP_ELEMENT( m_labelGameOptions, "LabelGame") UI_MAP_ELEMENT( m_labelWorldOptions, "LabelWorld") @@ -104,6 +110,9 @@ private: UI_MAP_ELEMENT( m_checkboxes[eLaunchCheckbox_Structures], "CheckboxStructures") UI_MAP_ELEMENT( m_checkboxes[eLaunchCheckbox_BonusChest], "CheckboxBonusChest") UI_MAP_ELEMENT( m_checkboxes[eLaunchCheckbox_FlatWorld], "CheckboxFlatWorld") +#ifdef _WINDOWS64 + UI_MAP_ELEMENT( m_buttonCustomiseSuperflat, "ButtonCustomise") +#endif UI_MAP_ELEMENT( m_checkboxes[eLaunchCheckbox_ResetNether], "CheckboxResetNether") UI_MAP_ELEMENT( m_checkboxes[eLaunchCheckbox_ResetEnd], "CheckboxResetEnd") @@ -120,6 +129,7 @@ private: UI_MAP_NAME( m_funcChangeTab, L"ChangeTab") UI_MAP_NAME( m_funcSetMenuType, L"SetMenuType") + UI_MAP_NAME( m_funcSetCustomiseEnabled, L"SetCustomiseEnabled") UI_END_MAP_ELEMENTS_AND_NAMES() LaunchMoreOptionsMenuInitData *m_params; @@ -169,6 +179,7 @@ private: bool m_bPendingTabSwitch; int m_iPendingTabIndex; + void openSuperflatCustomise(); #ifdef __PSVITA__ virtual void handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased); diff --git a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp index 56b49d93..100a6b84 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp @@ -4655,12 +4655,9 @@ void UIScene_LoadCreateJoinMenu::RebuildJoinGamesListVisual(bool syncFocus) #ifdef _WINDOWS64 - m_buttonListGames.addItem(wstring(L"Add Server")); - TrySetButtonListIcon( - m_buttonListGames, - m_buttonListGames.getItemCount() - 1, - L"lceheadwer.png", - L"lceheadwer"); + TrySetButtonListIcon(m_buttonListGames, -1, L"lceheadwer.png", L"lceheadwer"); + TrySetButtonListIcon(m_buttonListGames, -1, L"CreateWorldIcon.png", L"CreateWorldIcon"); + m_buttonListGames.addItem(wstring(L"Add Server"), wstring(L"lceheadwer"), wstring(L"CreateWorldIcon")); RefreshServerListHtmlPatch(); #endif @@ -8952,36 +8949,27 @@ int UIScene_LoadCreateJoinMenu::CopySaveErrorDialogFinishedCallback(void *pParam void UIScene_LoadCreateJoinMenu::BeginAddServer() - { - - m_addServerPhase = eAddServer_IP; - - m_addServerIP.clear(); - - m_addServerPort.clear(); - - - - UIKeyboardInitData kbData; - - kbData.title = L"Server Address"; - - kbData.defaultText = L""; - - kbData.maxChars = 128; - - kbData.callback = &UIScene_LoadCreateJoinMenu::AddServerKeyboardCallback; - - kbData.lpParam = this; - - kbData.pcMode = g_KBMInput.IsKBMActive(); - - ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); - + m_addServerPhase = eAddServer_Idle; + m_editServerData = EditServerInitData(); + m_editServerData.name = L"Minecraft Server"; + m_editServerData.address = L""; + m_editServerData.callback = &UIScene_LoadCreateJoinMenu::AddServerDoneCallback; + m_editServerData.lpParam = this; + ui.NavigateToScene(m_iPad, eUIScene_EditServerMenu, &m_editServerData); } - +int UIScene_LoadCreateJoinMenu::AddServerDoneCallback(LPVOID lpParam, bool confirmed, const wstring &name, const wstring &ip, const wstring &port) +{ + UIScene_LoadCreateJoinMenu *pClass = static_cast(lpParam); + pClass->m_bIgnoreInput = false; + if (confirmed && !ip.empty()) + { + pClass->AppendServerToFile(ip, port, name); + g_NetworkManager.ForceFriendsSessionRefresh(); + } + return 0; +} int UIScene_LoadCreateJoinMenu::AddServerKeyboardCallback(LPVOID lpParam, bool bRes) diff --git a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.h b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.h index 54a8199f..c4690206 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.h @@ -1,6 +1,9 @@ #pragma once #include "UIScene.h" +#ifdef _WINDOWS64 +#include "UIScene_EditServerMenu.h" +#endif class LevelGenerationOptions; class C4JThread; @@ -270,6 +273,8 @@ private: void BeginAddServer(); void AppendServerToFile(const wstring& ip, const wstring& port, const wstring& name); static int AddServerKeyboardCallback(LPVOID lpParam, bool bRes); + EditServerInitData m_editServerData; + static int AddServerDoneCallback(LPVOID lpParam, bool confirmed, const wstring &name, const wstring &ip, const wstring &port); void RefreshServerListHtmlPatch(); #endif diff --git a/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp index 44c6e225..49da13ca 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp @@ -516,6 +516,7 @@ void UIScene_LoadMenu::tick() m_MoreOptionsParams.bDoTileDrops = app.GetGameHostOption(uiHostOptions, eGameHostOption_DoTileDrops); m_MoreOptionsParams.bNaturalRegeneration = app.GetGameHostOption(uiHostOptions, eGameHostOption_NaturalRegeneration); m_MoreOptionsParams.bDoDaylightCycle = app.GetGameHostOption(uiHostOptions, eGameHostOption_DoDaylightCycle); + m_MoreOptionsParams.bDoWeatherCycle = app.GetGameHostOption(uiHostOptions, eGameHostOption_DoWeatherCycle); unsigned int saveDifficulty = app.GetGameHostOption(uiHostOptions, eGameHostOption_Difficulty); if (saveDifficulty <= 3) @@ -536,6 +537,7 @@ void UIScene_LoadMenu::tick() m_MoreOptionsParams.bKeepInventory = false; m_MoreOptionsParams.bDoMobSpawning = true; m_MoreOptionsParams.bDoDaylightCycle = true; + m_MoreOptionsParams.bDoWeatherCycle = true; } // turn off creative mode on the save @@ -951,7 +953,9 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() #if defined _XBOX_ONE || defined __ORBIS__ app.SetGameHostOption(eGameHostOption_DisableSaving, m_MoreOptionsParams.bDisableSaving?1:0); StorageManager.SetSaveDisabled(m_MoreOptionsParams.bDisableSaving); +#endif +#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 int newWorldSize = 0; int newHellScale = 0; switch(m_MoreOptionsParams.newWorldSize) @@ -1732,6 +1736,7 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocal app.SetGameHostOption(eGameHostOption_DoTileDrops, pClass->m_MoreOptionsParams.bDoTileDrops); app.SetGameHostOption(eGameHostOption_NaturalRegeneration, pClass->m_MoreOptionsParams.bNaturalRegeneration); app.SetGameHostOption(eGameHostOption_DoDaylightCycle, pClass->m_MoreOptionsParams.bDoDaylightCycle); + app.SetGameHostOption(eGameHostOption_DoWeatherCycle, pClass->m_MoreOptionsParams.bDoWeatherCycle); app.SetGameHostOption(eGameHostOption_Hardcore, pClass->m_bHardcore ? 1 : 0); #ifdef _LARGE_WORLDS diff --git a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp index 180ae8c0..558f6c3e 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp @@ -4183,18 +4183,25 @@ int UIScene_LoadOrJoinMenu::CopySaveErrorDialogFinishedCallback(void *pParam,int void UIScene_LoadOrJoinMenu::BeginAddServer() { - m_addServerPhase = eAddServer_IP; - m_addServerIP.clear(); - m_addServerPort.clear(); + m_addServerPhase = eAddServer_Idle; + m_editServerData = EditServerInitData(); + m_editServerData.name = L"Minecraft Server"; + m_editServerData.address = L""; + m_editServerData.callback = &UIScene_LoadOrJoinMenu::AddServerDoneCallback; + m_editServerData.lpParam = this; + ui.NavigateToScene(m_iPad, eUIScene_EditServerMenu, &m_editServerData); +} - UIKeyboardInitData kbData; - kbData.title = L"Server Address"; - kbData.defaultText = L""; - kbData.maxChars = 128; - kbData.callback = &UIScene_LoadOrJoinMenu::AddServerKeyboardCallback; - kbData.lpParam = this; - kbData.pcMode = g_KBMInput.IsKBMActive(); - ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); +int UIScene_LoadOrJoinMenu::AddServerDoneCallback(LPVOID lpParam, bool confirmed, const wstring &name, const wstring &ip, const wstring &port) +{ + UIScene_LoadOrJoinMenu *pClass = static_cast(lpParam); + pClass->m_bIgnoreInput = false; + if (confirmed && !ip.empty()) + { + pClass->AppendServerToFile(ip, port, name); + g_NetworkManager.ForceFriendsSessionRefresh(); + } + return 0; } int UIScene_LoadOrJoinMenu::AddServerKeyboardCallback(LPVOID lpParam, bool bRes) diff --git a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.h b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.h index 76a7ed43..df5ea454 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.h @@ -1,6 +1,9 @@ #pragma once #include "UIScene.h" +#ifdef _WINDOWS64 +#include "UIScene_EditServerMenu.h" +#endif class LevelGenerationOptions; @@ -185,6 +188,8 @@ private: void BeginAddServer(); void AppendServerToFile(const wstring& ip, const wstring& port, const wstring& name); static int AddServerKeyboardCallback(LPVOID lpParam, bool bRes); + EditServerInitData m_editServerData; + static int AddServerDoneCallback(LPVOID lpParam, bool confirmed, const wstring &name, const wstring &ip, const wstring &port); #endif #if defined(__PS3__) || defined(__PSVITA__) || defined(__ORBIS__) diff --git a/Minecraft.Client/Common/UI/UIScene_ReinstallMenu.cpp b/Minecraft.Client/Common/UI/UIScene_ReinstallMenu.cpp index c713a390..b4012e3d 100644 --- a/Minecraft.Client/Common/UI/UIScene_ReinstallMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_ReinstallMenu.cpp @@ -91,7 +91,11 @@ void UIScene_ReinstallMenu::handlePress(F64 controlId, F64 childId) ui.NavigateToScene(m_iPad, eUIScene_HowToPlayMenu); break; case BUTTON_HAO_CONTROLS: +#ifdef _WINDOWS64 + ui.NavigateToScene(m_iPad, eUIScene_BindingsTypeMenu); +#else ui.NavigateToScene(m_iPad, eUIScene_ControlsMenu); +#endif break; case BUTTON_HAO_SETTINGS: ui.NavigateToScene(m_iPad, eUIScene_SettingsMenu); diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp index 44a00b40..d9fd92c9 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp @@ -3,6 +3,9 @@ #include "UIScene_SkinSelectMenu.h" #include "../../../Minecraft.World/StringHelpers.h" #include "TexturePackRepository.h" +#ifdef _WINDOWS64 +#include "../../Windows64/KeyboardMouseInput.h" +#endif #ifdef __ORBIS__ #include #elif defined __PSVITA__ @@ -64,6 +67,10 @@ UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void *initData, UILayer m_bSlidingSkins = false; m_bAnimatingMove = false; + m_bMouseDragging = false; + m_bMouseDragMoved = false; + m_iMouseDragLastX = 0; + m_dwLastMouseClickTime = 0; m_bSkinIndexChanged = false; m_bFocusDirty = false; m_bNeedButtonListRefresh = true; @@ -197,6 +204,8 @@ void UIScene_SkinSelectMenu::tick() handlePackIndexChanged(); } + tickMouseDrag(); + if(m_bSkinIndexChanged) { m_bSkinIndexChanged = false; @@ -391,6 +400,124 @@ void UIScene_SkinSelectMenu::handleInput(int iPad, int key, bool repeat, bool pr } } +bool UIScene_SkinSelectMenu::handleMouseClick(F32 x, F32 y) +{ + if (m_bIgnoreInput) return true; + + S32 offX = 0, offY = 0; + UIControl *pMainPanel = GetMainPanel(); + if (pMainPanel && m_controlSkinButtonList.getParentPanel() == pMainPanel) + { + pMainPanel->UpdateControl(); + offX = pMainPanel->getXPos(); + offY = pMainPanel->getYPos(); + } + + m_controlSkinButtonList.UpdateControl(); + S32 cx = m_controlSkinButtonList.getXPos() + offX; + S32 cy = m_controlSkinButtonList.getYPos() + offY; + S32 cw = m_controlSkinButtonList.getWidth(); + S32 ch = m_controlSkinButtonList.getHeight(); + if (cw > 0 && ch > 0 && x >= cx && x <= cx + cw && y >= cy && y <= cy + ch) + { + S32 localX = static_cast(x) - cx; + S32 itemY = static_cast(y) - offY; + m_controlSkinButtonList.SetTouchFocus(localX, itemY, false); + if (m_controlSkinButtonList.CanTouchTrigger(localX, itemY)) + { + int selection = m_controlSkinButtonList.getCurrentSelection(); + int activeIndex = m_controlSkinButtonList.GetActiveItemIndex(); + int activeId = m_controlSkinButtonList.getIdFromIndex(activeIndex); + if (activeId >= 0) selection = activeId; + if (selection != static_cast(m_packIndex)) + { + m_bFocusDirty = false; + ui.PlayUISFX(eSFX_Press); + m_controlSkinButtonList.updateChildFocus(selection); + handlePackIndexChanged(); + } + } + return true; + } + +#ifdef _WINDOWS64 + m_bMouseDragging = true; + m_bMouseDragMoved = false; + m_iMouseDragLastX = g_KBMInput.GetMouseX(); +#else + InputActionOK(m_iPad); +#endif + return true; +} + +bool UIScene_SkinSelectMenu::slideSkin(bool next) +{ + if (m_bAnimatingMove) return false; + ui.PlayUISFX(eSFX_Scroll); + m_skinIndex = next ? getNextSkinIndex(m_skinIndex) : getPreviousSkinIndex(m_skinIndex); + m_bSlidingSkins = true; + m_bAnimatingMove = true; + if (next) + { + m_characters[eCharacter_Current].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Right, true); + m_characters[eCharacter_Next1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Forward, true); + sendInputToMovie(ACTION_MENU_LEFT, false, true, false); + } + else + { + m_characters[eCharacter_Current].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Left, true); + m_characters[eCharacter_Previous1].SetFacing(UIControl_PlayerSkinPreview::e_SkinPreviewFacing_Forward, true); + sendInputToMovie(ACTION_MENU_RIGHT, false, true, false); + } + return true; +} + +void UIScene_SkinSelectMenu::tickMouseDrag() +{ +#ifdef _WINDOWS64 + if (!m_bMouseDragging) return; + if (m_bIgnoreInput) + { + m_bMouseDragging = false; + return; + } + if (g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT)) + { + S32 threshold = 60; + extern HWND g_hWnd; + RECT rc; + if (g_hWnd && GetClientRect(g_hWnd, &rc) && rc.right - rc.left > 0) + threshold = max(20, static_cast((rc.right - rc.left) / 20)); + S32 dx = g_KBMInput.GetMouseX() - m_iMouseDragLastX; + if (dx <= -threshold || dx >= threshold) + { + if (slideSkin(dx < 0)) + { + m_bMouseDragMoved = true; + m_iMouseDragLastX = g_KBMInput.GetMouseX(); + } + } + return; + } + m_bMouseDragging = false; + if (m_bMouseDragMoved) + { + m_dwLastMouseClickTime = 0; + return; + } + DWORD now = GetTickCount(); + if (m_dwLastMouseClickTime != 0 && now - m_dwLastMouseClickTime <= GetDoubleClickTime()) + { + m_dwLastMouseClickTime = 0; + InputActionOK(m_iPad); + } + else + { + m_dwLastMouseClickTime = now; + } +#endif +} + void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad) { ui.AnimateKeyPress(iPad, ACTION_MENU_OK, false, true, false); diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h index 79f33e6c..9f9e3cb9 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h @@ -106,6 +106,11 @@ private: S32 m_iTouchXStart; bool m_bTouchScrolled; + + bool m_bMouseDragging; + bool m_bMouseDragMoved; + S32 m_iMouseDragLastX; + DWORD m_dwLastMouseClickTime; public: UIScene_SkinSelectMenu(int iPad, void *initData, UILayer *parentLayer); #ifdef __PSVITA__ @@ -130,11 +135,14 @@ protected: public: // INPUT virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); + virtual bool handleMouseClick(F32 x, F32 y); virtual void customDraw(IggyCustomDrawCallbackRegion *region); private: void handleSkinIndexChanged(); + bool slideSkin(bool next); + void tickMouseDrag(); int getNextSkinIndex(DWORD sourceIndex); int getPreviousSkinIndex(DWORD sourceIndex); diff --git a/Minecraft.Client/Common/UI/UIScene_SuperflatEditLayerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SuperflatEditLayerMenu.cpp new file mode 100644 index 00000000..672402dc --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_SuperflatEditLayerMenu.cpp @@ -0,0 +1,662 @@ +#include "stdafx.h" +#include "UI.h" +#include "UIScene_SuperflatEditLayerMenu.h" +#include "SuperflatData.h" +#include "UICustomStrings.h" +#include "../../../Minecraft.World/net.minecraft.world.item.h" +#ifdef _WINDOWS64 +#include "../../Windows64/KeyboardMouseInput.h" +#endif + +namespace +{ + const float kGridX = 567.0f; + const float kGridY = 222.0f; + const float kSlot = 75.0f; + const float kSliderX = 569.0f; + const float kSliderY = 620.0f; + const float kSliderW = 745.0f; + const float kSliderH = 56.0f; + const float kOkX = 685.0f; + const float kOkY = 796.0f; + const float kOkW = 550.0f; + const float kOkH = 64.0f; + const float kPanelX = 510.0f; + const float kPanelY = 160.0f; + const float kPanelW = 900.0f; + const float kPanelH = 720.0f; + const float kTrackX = 1332.0f; + const float kTrackY = 222.0f; + const float kTrackW = 44.0f; + const float kTrackH = 375.0f; + const float kThumbTop = 222.0f; + const float kThumbH = 52.0f; + const float kThumbRange = kTrackH - kThumbH - (kThumbTop - kTrackY) * 2.0f; + + bool InRect(F32 x, F32 y, float rx, float ry, float rw, float rh) + { + return x >= rx && y >= ry && x < rx + rw && y < ry + rh; + } +} + +UIScene_SuperflatEditLayerMenu::UIScene_SuperflatEditLayerMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer), m_original(1, 0) +{ + initialiseMovie(); + m_data = static_cast(initData); + m_original = layer(); + m_iSelectedBlock = SuperflatData::FindBlock(m_original.getId(), m_original.getData()); + m_iCursorBlock = m_iSelectedBlock < 0 ? 0 : m_iSelectedBlock; + m_iScrollRow = 0; + int others = m_data->info->getTotalHeight() - m_original.getHeight(); + m_iMaxHeight = FlatGeneratorInfo::MAX_HEIGHT - others; + if (m_iMaxHeight < 1) + m_iMaxHeight = 1; + m_focus = eFocus_Grid; + m_bNeedsPopulate = true; + m_bPopulated = false; + m_bPendingConfirm = false; + m_bMouseMode = false; + m_fMouseX = kGridX + kSlot * 5.0f; + m_fMouseY = kGridY + kSlot * 2.5f; + m_iHoverBlock = -1; + m_iDrag = eDrag_None; + m_fDragOffset = 0.0f; + + m_title.init(UICustomStrings::Lookup(UICustomStrings::Get(m_data->insert ? L"Add Layer" : L"Edit Layer"))); + int height = layer().getHeight(); + if (height > m_iMaxHeight) + height = m_iMaxHeight; + m_heightSlider.init(heightLabel(height), eControl_Height, 1, m_iMaxHeight, height); + m_confirmButton.init(app.GetString(IDS_CONFIRM_OK), eControl_Confirm); + m_heightLabel.init(L""); + m_typeLabel.init(L""); + +#ifdef _WINDOWS64 + g_KBMInput.SetScreenCursorHidden(true); + g_KBMInput.SetCursorHiddenForUI(true); +#endif +} + +void UIScene_SuperflatEditLayerMenu::handleDestroy() +{ +#ifdef _WINDOWS64 + g_KBMInput.SetScreenCursorHidden(false); + g_KBMInput.SetCursorHiddenForUI(false); +#endif +} + +wstring UIScene_SuperflatEditLayerMenu::getMoviePath() +{ + return L"SuperflatEditLayerMenu"; +} + +FlatLayerInfo &UIScene_SuperflatEditLayerMenu::layer() +{ + return (*m_data->info->getLayers())[m_data->layerIndex]; +} + +wstring UIScene_SuperflatEditLayerMenu::heightLabel(int height) +{ + return L"Layer Height"; +} + +int UIScene_SuperflatEditLayerMenu::totalRows() +{ + return (SuperflatData::GetBlockCount() + kColumns - 1) / kColumns; +} + +void UIScene_SuperflatEditLayerMenu::cancel() +{ + vector &layers = *m_data->info->getLayers(); + if (m_data->insert) + { + layers.erase(layers.begin() + m_data->layerIndex); + } + else + { + layer().setHeight(m_original.getHeight()); + layer().setId(m_original.getId()); + layer().setData(m_original.getData()); + } + m_data->info->updateLayers(); +} + +void UIScene_SuperflatEditLayerMenu::populate() +{ + m_slotList.addSlots(0, kColumns * kRows); + updatePreview(); + setCursorBlock(m_iCursorBlock); + enterGrid(); + m_bPopulated = true; +} + +void UIScene_SuperflatEditLayerMenu::updatePreview() +{ + FlatLayerInfo &l = layer(); + m_typeLabel.setLabel(SuperflatData::GetBlockName(l.getId(), l.getData())); + m_heightLabel.setLabel(std::to_wstring(l.getHeight()) + L"x"); +} + +void UIScene_SuperflatEditLayerMenu::updateScrollBar() +{ + int pages = totalRows() - kRows + 1; + if (pages < 1) + pages = 1; + IggyDataValue result; + IggyDataValue value[2]; + value[0].type = IGGY_DATATYPE_number; + value[0].number = pages; + value[1].type = IGGY_DATATYPE_number; + value[1].number = m_iScrollRow; + IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetScrollBar, 2, value); +} + +void UIScene_SuperflatEditLayerMenu::setCursorLabel(const wstring &plain) +{ + wstring label; + if (!plain.empty()) + { + wchar_t startTags[64]; + swprintf(startTags, 64, L"", app.GetHTMLColour(eHTMLColor_White)); + label = startTags + plain + L""; + } + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_string_UTF16; + value[0].string16.string = (IggyUTF16 *)label.c_str(); + value[0].string16.length = static_cast(label.length()); + IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetCursorLabel, 1, value); +} + +void UIScene_SuperflatEditLayerMenu::setCursorPos(F32 x, F32 y) +{ + IggyDataValue result; + IggyDataValue value[2]; + value[0].type = IGGY_DATATYPE_number; + value[0].number = x; + value[1].type = IGGY_DATATYPE_number; + value[1].number = y; + IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetCursorPos, 2, value); +} + +void UIScene_SuperflatEditLayerMenu::showCursor(bool show) +{ + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_boolean; + value[0].boolval = show; + IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcShowCursor, 1, value); +} + +static wstring BlockNameAt(int block) +{ + return SuperflatData::GetBlockName(SuperflatData::GetBlockId(block), SuperflatData::GetBlockData(block)); +} + +void UIScene_SuperflatEditLayerMenu::updateCursor() +{ + if (m_bMouseMode) + { + refreshMouseHover(); + return; + } + + showCursor(m_focus == eFocus_Grid); + if (m_focus != eFocus_Grid) + { + m_slotList.setHighlightSlot(-1); + return; + } + + int visible = m_iCursorBlock - m_iScrollRow * kColumns; + int col = visible % kColumns; + int row = visible / kColumns; + setCursorPos(kGridX + col * kSlot + kSlot * 0.5f, kGridY + row * kSlot + kSlot * 0.5f); + setCursorLabel(BlockNameAt(m_iCursorBlock)); + m_slotList.setHighlightSlot(visible); +} + +void UIScene_SuperflatEditLayerMenu::refreshMouseHover() +{ + showCursor(true); + setCursorPos(m_fMouseX, m_fMouseY); + int block = slotAt(m_fMouseX, m_fMouseY); + m_iHoverBlock = block; + if (block >= 0) + { + m_iCursorBlock = block; + m_slotList.setHighlightSlot(block - m_iScrollRow * kColumns); + setCursorLabel(BlockNameAt(block)); + } + else + { + m_slotList.setHighlightSlot(-1); + setCursorLabel(L""); + } +} + +void UIScene_SuperflatEditLayerMenu::leaveMouseMode() +{ + if (!m_bMouseMode) + return; + m_bMouseMode = false; + if (m_focus == eFocus_Grid) + setCursorBlock(m_iCursorBlock); + else + updateCursor(); +} + +void UIScene_SuperflatEditLayerMenu::setCursorBlock(int block) +{ + int count = SuperflatData::GetBlockCount(); + if (block < 0) + block = 0; + if (block >= count) + block = count - 1; + m_iCursorBlock = block; + int row = block / kColumns; + if (row < m_iScrollRow) + m_iScrollRow = row; + if (row >= m_iScrollRow + kRows) + m_iScrollRow = row - kRows + 1; + int maxScroll = totalRows() - kRows; + if (maxScroll < 0) + maxScroll = 0; + if (m_iScrollRow > maxScroll) + m_iScrollRow = maxScroll; + if (m_iScrollRow < 0) + m_iScrollRow = 0; + updateScrollBar(); + updateCursor(); +} + +void UIScene_SuperflatEditLayerMenu::selectBlock(int block) +{ + if (block < 0 || block >= SuperflatData::GetBlockCount()) + return; + ui.PlayUISFX(eSFX_Press); + m_iSelectedBlock = block; + layer().setId(SuperflatData::GetBlockId(block)); + layer().setData(SuperflatData::GetBlockData(block)); + m_data->info->updateLayers(); + updatePreview(); +} + +void UIScene_SuperflatEditLayerMenu::enterGrid() +{ + m_focus = eFocus_Grid; + IggyPlayerSetFocusRS(getMovie(), nullptr, 0); + updateCursor(); + updateTooltips(); +} + +int UIScene_SuperflatEditLayerMenu::maxScrollRow() +{ + int maxScroll = totalRows() - kRows; + return maxScroll < 0 ? 0 : maxScroll; +} + +float UIScene_SuperflatEditLayerMenu::thumbPos() +{ + int maxScroll = maxScrollRow(); + if (maxScroll <= 0) + return kThumbTop; + return kThumbTop + kThumbRange * (static_cast(m_iScrollRow) / static_cast(maxScroll)); +} + +void UIScene_SuperflatEditLayerMenu::setScrollRow(int row) +{ + int maxScroll = maxScrollRow(); + if (row < 0) row = 0; + if (row > maxScroll) row = maxScroll; + if (row == m_iScrollRow) + return; + m_iScrollRow = row; + updateScrollBar(); + if (m_bMouseMode) + refreshMouseHover(); + else + updateCursor(); +} + +int UIScene_SuperflatEditLayerMenu::slotAt(F32 x, F32 y) +{ + if (x < kGridX || y < kGridY || x >= kGridX + kSlot * kColumns || y >= kGridY + kSlot * kRows) + return -1; + int col = static_cast((x - kGridX) / kSlot); + int row = static_cast((y - kGridY) / kSlot); + int block = (m_iScrollRow + row) * kColumns + col; + if (block >= SuperflatData::GetBlockCount()) + return -1; + return block; +} + +void UIScene_SuperflatEditLayerMenu::tick() +{ + if (m_bNeedsPopulate) + { + m_bNeedsPopulate = false; + populate(); + } + + if (m_bPendingConfirm) + { + m_bPendingConfirm = false; + m_data->info->updateLayers(); + navigateBack(); + return; + } + +#ifdef _WINDOWS64 + if (m_bPopulated && hasFocus(m_iPad) && g_KBMInput.IsKBMActive() && !g_KBMInput.IsMouseGrabbed()) + { + int dx = g_KBMInput.GetMouseDeltaX(); + int dy = g_KBMInput.GetMouseDeltaY(); + bool leftPressed = g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT); + bool leftDown = g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT); + int wheel = g_KBMInput.GetMouseWheel(); + + if (dx != 0 || dy != 0) + { + extern HWND g_hWnd; + RECT rc; + GetClientRect(g_hWnd, &rc); + int winW = rc.right - rc.left; + int winH = rc.bottom - rc.top; + float scaleX = 1.0f; + float scaleY = 1.0f; + if (winW > 0 && winH > 0) + { + scaleX = static_cast(getRenderWidth()) / static_cast(winW); + scaleY = static_cast(getRenderHeight()) / static_cast(winH); + } + m_fMouseX += dx * scaleX; + m_fMouseY += dy * scaleY; + if (m_fMouseX < kPanelX) m_fMouseX = kPanelX; + if (m_fMouseY < kPanelY) m_fMouseY = kPanelY; + if (m_fMouseX > kPanelX + kPanelW) m_fMouseX = kPanelX + kPanelW; + if (m_fMouseY > kPanelY + kPanelH) m_fMouseY = kPanelY + kPanelH; + m_bMouseMode = true; + if (slotAt(m_fMouseX, m_fMouseY) >= 0 && m_focus != eFocus_Grid) + { + m_focus = eFocus_Grid; + IggyPlayerSetFocusRS(getMovie(), nullptr, 0); + } + else if (InRect(m_fMouseX, m_fMouseY, kSliderX, kSliderY, kSliderW, kSliderH) && m_focus != eFocus_Slider) + { + SetFocusToElement(eControl_Height); + } + else if (InRect(m_fMouseX, m_fMouseY, kOkX, kOkY, kOkW, kOkH) && m_focus != eFocus_Button) + { + SetFocusToElement(eControl_Confirm); + } + refreshMouseHover(); + } + + if (wheel != 0 && m_bMouseMode) + { + setScrollRow(m_iScrollRow + (wheel > 0 ? -1 : 1)); + } + + if (!leftDown) + m_iDrag = eDrag_None; + + if (m_bMouseMode && leftPressed) + { + int block = slotAt(m_fMouseX, m_fMouseY); + if (block >= 0) + { + selectBlock(block); + } + else if (InRect(m_fMouseX, m_fMouseY, kSliderX, kSliderY, kSliderW, kSliderH)) + { + m_iDrag = eDrag_Slider; + } + else if (InRect(m_fMouseX, m_fMouseY, kTrackX, kTrackY, kTrackW, kTrackH)) + { + float thumbY = thumbPos(); + if (m_fMouseY >= thumbY && m_fMouseY < thumbY + kThumbH) + m_fDragOffset = m_fMouseY - thumbY; + else + m_fDragOffset = kThumbH * 0.5f; + m_iDrag = eDrag_Scroll; + } + else if (InRect(m_fMouseX, m_fMouseY, kOkX, kOkY, kOkW, kOkH)) + { + ui.PlayUISFX(eSFX_Press); + m_bPendingConfirm = true; + } + } + + if (m_bMouseMode && leftDown && m_iDrag == eDrag_Slider) + { + float t = (m_fMouseX - kSliderX) / kSliderW; + if (t < 0.0f) t = 0.0f; + if (t > 1.0f) t = 1.0f; + int value = static_cast(floorf((m_iMaxHeight - 1) * t + (t > 0.0f ? 1.0f : 0.0f) + 0.5f)); + if (value < 1) + value = 1; + if (value > m_iMaxHeight) + value = m_iMaxHeight; + if (value != layer().getHeight()) + m_heightSlider.SetSliderTouchPos(t); + } + + if (m_bMouseMode && leftDown && m_iDrag == eDrag_Scroll) + { + int maxScroll = maxScrollRow(); + if (maxScroll > 0 && kThumbRange > 0.0f) + { + float t = (m_fMouseY - m_fDragOffset - kThumbTop) / kThumbRange; + if (t < 0.0f) t = 0.0f; + if (t > 1.0f) t = 1.0f; + int row = static_cast(floorf(t * maxScroll + 0.5f)); + if (row != m_iScrollRow) + setScrollRow(row); + } + } + } +#endif + + UIScene::tick(); +} + +void UIScene_SuperflatEditLayerMenu::updateTooltips() +{ + ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_CANCEL); +} + +void UIScene_SuperflatEditLayerMenu::updateComponents() +{ + m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true); + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false); +} + +void UIScene_SuperflatEditLayerMenu::customDraw(IggyCustomDrawCallbackRegion *region) +{ + shared_ptr item = nullptr; + int list = -1; + int index = -1; + if (swscanf(static_cast(region->name), L"layerslot_%d", &index) == 1) + { + item = SuperflatData::GetBlockIcon(layer().getId(), layer().getData()); + } + else if (swscanf(static_cast(region->name), L"slot_%d", &index) == 1) + { + int block = m_iScrollRow * kColumns + index; + if (block >= 0 && block < SuperflatData::GetBlockCount()) + item = SuperflatData::GetBlockIcon(SuperflatData::GetBlockId(block), SuperflatData::GetBlockData(block)); + } + if (item != nullptr) + customDrawSlotControl(region, m_iPad, item, 1.0f, false, false); +} + +void UIScene_SuperflatEditLayerMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) +{ + ui.AnimateKeyPress(iPad, key, repeat, pressed, released); + + if (key == ACTION_MENU_CANCEL) + { + if (pressed) + { + cancel(); + navigateBack(); + } + handled = true; + return; + } + + if (pressed && (key == ACTION_MENU_LEFT || key == ACTION_MENU_RIGHT || key == ACTION_MENU_UP || key == ACTION_MENU_DOWN)) + leaveMouseMode(); + + if (m_focus == eFocus_Grid) + { + if (!pressed) + { + handled = true; + return; + } + int col = m_iCursorBlock % kColumns; + switch (key) + { + case ACTION_MENU_LEFT: + if (col > 0) + { + ui.PlayUISFX(eSFX_Focus); + setCursorBlock(m_iCursorBlock - 1); + } + break; + case ACTION_MENU_RIGHT: + if (col < kColumns - 1 && m_iCursorBlock + 1 < SuperflatData::GetBlockCount()) + { + ui.PlayUISFX(eSFX_Focus); + setCursorBlock(m_iCursorBlock + 1); + } + break; + case ACTION_MENU_UP: + if (m_iCursorBlock >= kColumns) + { + ui.PlayUISFX(eSFX_Focus); + setCursorBlock(m_iCursorBlock - kColumns); + } + break; + case ACTION_MENU_DOWN: + ui.PlayUISFX(eSFX_Focus); + if (m_iCursorBlock / kColumns < totalRows() - 1) + { + setCursorBlock(m_iCursorBlock + kColumns); + } + else + { + m_focus = eFocus_Slider; + updateCursor(); + SetFocusToElement(eControl_Height); + } + break; + case ACTION_MENU_PAGEUP: + case ACTION_MENU_OTHER_STICK_UP: + if (!m_bMouseMode) + setCursorBlock(m_iCursorBlock - kColumns * kRows); + break; + case ACTION_MENU_PAGEDOWN: + case ACTION_MENU_OTHER_STICK_DOWN: + if (!m_bMouseMode) + setCursorBlock(m_iCursorBlock + kColumns * kRows); + break; + case ACTION_MENU_OK: + if (m_bMouseMode) + { + if (m_iHoverBlock >= 0) + selectBlock(m_iHoverBlock); + } + else + { + selectBlock(m_iCursorBlock); + } + break; + } + handled = true; + return; + } + + switch (key) + { + case ACTION_MENU_UP: + if (m_focus == eFocus_Slider) + { + if (pressed) + { + ui.PlayUISFX(eSFX_Focus); + enterGrid(); + } + handled = true; + return; + } + sendInputToMovie(key, repeat, pressed, released); + handled = true; + break; + case ACTION_MENU_OK: + case ACTION_MENU_DOWN: + case ACTION_MENU_LEFT: + case ACTION_MENU_RIGHT: + sendInputToMovie(key, repeat, pressed, released); + handled = true; + break; + } +} + +void UIScene_SuperflatEditLayerMenu::handlePress(F64 controlId, F64 childId) +{ + if (!m_bPopulated) + return; + if (static_cast(controlId) == eControl_Confirm) + { + ui.PlayUISFX(eSFX_Press); + m_bPendingConfirm = true; + } +} + +void UIScene_SuperflatEditLayerMenu::handleFocusChange(F64 controlId, F64 childId) +{ + int id = static_cast(controlId); + if (id == eControl_Height) + m_focus = eFocus_Slider; + else if (id == eControl_Confirm) + m_focus = eFocus_Button; + else + return; + updateCursor(); +} + +void UIScene_SuperflatEditLayerMenu::handleSliderMove(F64 sliderId, F64 currentValue) +{ + if (static_cast(sliderId) != eControl_Height) + return; + int value = static_cast(currentValue); + if (value < 1) + value = 1; + if (value > m_iMaxHeight) + value = m_iMaxHeight; + m_heightSlider.handleSliderMove(value); + m_heightSlider.setLabel(heightLabel(value)); + layer().setHeight(value); + m_data->info->updateLayers(); + if (m_bPopulated) + updatePreview(); +} + +#ifdef _WINDOWS64 +bool UIScene_SuperflatEditLayerMenu::canMoveSlider(F64 sliderId) +{ + return false; +} + +bool UIScene_SuperflatEditLayerMenu::handleMouseClick(F32 x, F32 y) +{ + return true; +} + +void UIScene_SuperflatEditLayerMenu::handleMouseHover(F32 x, F32 y) +{ +} +#endif diff --git a/Minecraft.Client/Common/UI/UIScene_SuperflatEditLayerMenu.h b/Minecraft.Client/Common/UI/UIScene_SuperflatEditLayerMenu.h new file mode 100644 index 00000000..bfa1456d --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_SuperflatEditLayerMenu.h @@ -0,0 +1,121 @@ +#pragma once + +#include "UIScene.h" +#include "UIControl_SuperflatLists.h" +#include "UIScene_SuperflatMenu.h" + +class UIScene_SuperflatEditLayerMenu : public UIScene +{ +private: + enum EControls + { + eControl_Grid = 0, + eControl_Preview = 1, + eControl_Height = 2, + eControl_Confirm = 3, + }; + + enum EFocus + { + eFocus_Grid = 0, + eFocus_Slider, + eFocus_Button, + }; + + enum EDrag + { + eDrag_None = 0, + eDrag_Slider, + eDrag_Scroll, + }; + + static const int kColumns = 10; + static const int kRows = 5; + + UIControl_Label m_title; + UIControl_SlotList m_slotList; + UIControl_Slider m_heightSlider; + UIControl_Button m_confirmButton; + UIControl_Label m_heightLabel; + UIControl_Label m_typeLabel; + IggyName m_funcSetScrollBar; + IggyName m_funcSetCursorPos; + IggyName m_funcShowCursor; + IggyName m_funcSetCursorLabel; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) + UI_MAP_ELEMENT( m_title, "EditLayerTitle") + UI_MAP_ELEMENT( m_slotList, "containerList") + UI_MAP_ELEMENT( m_heightSlider, "LayerHeight") + UI_MAP_ELEMENT( m_confirmButton, "ConfirmLayer") + UI_MAP_ELEMENT( m_heightLabel, "LayerHeightLabel") + UI_MAP_ELEMENT( m_typeLabel, "LayerTypeLabel") + UI_MAP_NAME( m_funcSetScrollBar, L"SetScrollBar") + UI_MAP_NAME( m_funcSetCursorPos, L"SetCursorPos") + UI_MAP_NAME( m_funcShowCursor, L"ShowCursor") + UI_MAP_NAME( m_funcSetCursorLabel, L"SetCursorLabel") + UI_END_MAP_ELEMENTS_AND_NAMES() + + SuperflatEditLayerInitData *m_data; + FlatLayerInfo m_original; + int m_iSelectedBlock; + int m_iCursorBlock; + int m_iScrollRow; + int m_iMaxHeight; + int m_focus; + bool m_bNeedsPopulate; + bool m_bPopulated; + bool m_bPendingConfirm; + bool m_bMouseMode; + F32 m_fMouseX; + F32 m_fMouseY; + int m_iHoverBlock; + int m_iDrag; + F32 m_fDragOffset; + + FlatLayerInfo &layer(); + wstring heightLabel(int height); + int totalRows(); + void cancel(); + void populate(); + void updatePreview(); + void updateCursor(); + void updateScrollBar(); + void setCursorBlock(int block); + void selectBlock(int block); + void enterGrid(); + int slotAt(F32 x, F32 y); + int maxScrollRow(); + float thumbPos(); + void setScrollRow(int row); + void setCursorLabel(const wstring &label); + void setCursorPos(F32 x, F32 y); + void showCursor(bool show); + void refreshMouseHover(); + void leaveMouseMode(); + +public: + UIScene_SuperflatEditLayerMenu(int iPad, void *initData, UILayer *parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_SuperflatEditLayerMenu; } + + virtual void tick(); + virtual void updateTooltips(); + virtual void updateComponents(); + virtual void handleDestroy(); + virtual void customDraw(IggyCustomDrawCallbackRegion *region); + +protected: + virtual wstring getMoviePath(); + +public: + virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); + virtual void handlePress(F64 controlId, F64 childId); + virtual void handleFocusChange(F64 controlId, F64 childId); + virtual void handleSliderMove(F64 sliderId, F64 currentValue); +#ifdef _WINDOWS64 + virtual bool handleMouseClick(F32 x, F32 y); + virtual bool canMoveSlider(F64 sliderId); + virtual void handleMouseHover(F32 x, F32 y); +#endif +}; diff --git a/Minecraft.Client/Common/UI/UIScene_SuperflatMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SuperflatMenu.cpp new file mode 100644 index 00000000..46903e7f --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_SuperflatMenu.cpp @@ -0,0 +1,750 @@ +#include "stdafx.h" +#include "UI.h" +#include "UIScene_SuperflatMenu.h" +#include "SuperflatData.h" +#include "UICustomStrings.h" +#include "../../../Minecraft.World/net.minecraft.world.item.h" +#include "../../../Minecraft.World/net.minecraft.world.level.tile.h" + +namespace +{ + const float kTabX = 284.0f; + const float kTabY = 110.0f; + const float kTabW = 266.0f; + const float kTabH = 76.0f; +} + +UIScene_SuperflatMenu::UIScene_SuperflatMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) +{ + initialiseMovie(); + m_params = static_cast(initData); + if (m_params != nullptr && !m_params->superflatOptions.empty()) + m_info = FlatGeneratorInfo::fromValue(m_params->superflatOptions); + else + m_info = SuperflatData::MakePreset(0); + m_editData.info = &m_info; + m_editData.layerIndex = 0; + m_editData.insert = false; + m_activeTab = eTab_Layers; + m_layerSelection = 0; + m_biomeSelection = SuperflatData::GetBiomeIndex(m_info.getBiome()); + m_paramSelection = 0; + m_pendingAction = ePending_None; + m_pendingBiome = -1; + m_pendingSelectRow = -1; + m_pendingSliderId = -1; + m_pendingSliderValue = 0; + m_bMovingLayer = false; + m_bBusy = false; + m_bPopulated = false; + m_bNeedsPopulate = true; + + m_labelLayersTab.init(UICustomStrings::Lookup(UICustomStrings::Get(L"Layers"))); + m_labelBiomesTab.init(UICustomStrings::Lookup(UICustomStrings::Get(L"Biomes"))); + m_labelPropertiesTab.init(UICustomStrings::Lookup(UICustomStrings::Get(L"Properties"))); + m_layersList.init(eControl_LayersList); + m_biomesList.init(eControl_BiomesList); + m_propertiesList.init(eControl_PropertiesList); + m_layersList.UseIggyIcons(); + m_biomesList.UseIggyIcons(); +} + +wstring UIScene_SuperflatMenu::getMoviePath() +{ + return L"SuperflatMenu"; +} + +int UIScene_SuperflatMenu::layerCount() +{ + return static_cast(m_info.getLayers()->size()); +} + +int UIScene_SuperflatMenu::rowToLayer(int row) +{ + return layerCount() - 1 - row; +} + +bool UIScene_SuperflatMenu::isBottomRow(int row) +{ + return row >= layerCount() - 1; +} + +void UIScene_SuperflatMenu::populateAll() +{ + populateLayers(); + populateBiomes(); + populateProperties(); + m_bPopulated = true; +} + +void UIScene_SuperflatMenu::populateLayers() +{ + m_layersList.clearList(); + vector &layers = *m_info.getLayers(); + int row = 0; + for (int i = static_cast(layers.size()) - 1; i >= 0; --i, ++row) + { + wstring name = SuperflatData::GetBlockName(layers[i].getId(), layers[i].getData()); + wstring height = std::to_wstring(layers[i].getHeight()) + L"x"; + m_layersList.AddNewItem(name, height, row); + } + if (m_layerSelection >= layerCount()) + m_layerSelection = layerCount() - 1; + if (m_layerSelection < 0) + m_layerSelection = 0; +} + +void UIScene_SuperflatMenu::populateBiomes() +{ + m_biomesList.clearList(); + for (int i = 0; i < SuperflatData::GetBiomeCount(); ++i) + m_biomesList.AddNewItem(SuperflatData::GetBiomeName(i), i, i == m_biomeSelection); +} + +void UIScene_SuperflatMenu::updateBiomeChecks() +{ + int selected = SuperflatData::GetBiomeIndex(m_info.getBiome()); + for (int i = 0; i < SuperflatData::GetBiomeCount(); ++i) + m_biomesList.SetCheckBox(i, i == selected); +} + +void UIScene_SuperflatMenu::populateProperties() +{ + m_propertiesList.clearList(); + for (int i = 0; i < SuperflatData::GetParamCount(); ++i) + { + const SuperflatData::Param ¶m = SuperflatData::GetParam(i); + int value = SuperflatData::ReadParamValue(m_info, i); + if (param.kind == SuperflatData::eParam_Toggle) + m_propertiesList.AddNewCheckbox(param.name, i, value != 0); + else + m_propertiesList.AddNewSlider(SuperflatData::GetParamLabel(i, value), i, param.minValue, param.maxValue, 1, value); + } + updateParamStates(); +} + +void UIScene_SuperflatMenu::updateParamStates() +{ + for (int i = 0; i < SuperflatData::GetParamCount(); ++i) + { + const SuperflatData::Param ¶m = SuperflatData::GetParam(i); + if (param.kind == SuperflatData::eParam_Toggle) + continue; + int parent = SuperflatData::GetParamParent(i); + bool enabled = parent >= 0 && m_info.hasStructure(SuperflatData::GetParam(parent).structure); + m_propertiesList.EnableItem(i, enabled); + m_propertiesList.SetSliderLabel(i, enabled ? SuperflatData::GetParamLabel(i, m_propertiesList.GetSliderValue(i)) : wstring(param.name)); + } +} + +void UIScene_SuperflatMenu::readParams() +{ + for (int i = 0; i < SuperflatData::GetParamCount(); ++i) + { + const SuperflatData::Param ¶m = SuperflatData::GetParam(i); + if (param.kind != SuperflatData::eParam_Toggle) + continue; + bool checked = m_propertiesList.GetCheckboxValue(i); + bool had = m_info.hasStructure(param.structure); + if (checked == had) + continue; + SuperflatData::WriteParamValue(m_info, i, checked ? 1 : 0); + if (checked) + { + for (int c = i + 1; c < SuperflatData::GetParamCount() && SuperflatData::GetParam(c).kind != SuperflatData::eParam_Toggle; ++c) + SuperflatData::WriteParamValue(m_info, c, m_propertiesList.GetSliderValue(c)); + } + } + updateParamStates(); + commit(); +} + +void UIScene_SuperflatMenu::commit() +{ + if (m_params != nullptr) + m_params->superflatOptions = m_info.toString(); +} + +void UIScene_SuperflatMenu::stepSelection(int direction) +{ + if (!m_bPopulated || m_bBusy) + return; + int count = 0; + int current = 0; + if (m_activeTab == eTab_Layers) + { + count = layerCount(); + current = m_layerSelection; + } + else if (m_activeTab == eTab_Biomes) + { + count = SuperflatData::GetBiomeCount(); + current = m_biomeSelection; + } + else + { + count = SuperflatData::GetParamCount(); + current = m_paramSelection; + } + int next = current + direction; + if (next < 0 || next >= count) + return; + ui.PlayUISFX(eSFX_Focus); + if (m_activeTab == eTab_Layers) + { + m_layerSelection = next; + m_layersList.setCurrentSelection(next); + m_layersList.updateChildFocus(next); + } + else if (m_activeTab == eTab_Biomes) + { + m_biomeSelection = next; + m_biomesList.setCurrentSelection(next); + m_biomesList.updateChildFocus(next); + } + else + { + m_paramSelection = next; + m_propertiesList.HighlightItem(next); + } + updateHelp(); + updateTooltips(); +} + +void UIScene_SuperflatMenu::focusList(int tab) +{ + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_number; + value[0].number = static_cast(tab); + IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcFocusList, 1, value); +} + +void UIScene_SuperflatMenu::setActiveTab(int tab, bool setFocus) +{ + if (tab < 0) + tab = eTab_Count - 1; + if (tab >= eTab_Count) + tab = 0; + m_activeTab = tab; + + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_number; + value[0].number = static_cast(tab); + IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetActiveTab, 1, value); + + m_layersPanel.setVisible(tab == eTab_Layers); + m_biomesPanel.setVisible(tab == eTab_Biomes); + m_propertiesPanel.setVisible(tab == eTab_Properties); + m_layersList.setVisible(tab == eTab_Layers); + m_biomesList.setVisible(tab == eTab_Biomes); + m_propertiesList.setVisible(tab == eTab_Properties); + + if (setFocus) + { + if (tab == eTab_Layers) + { + SetFocusToElement(eControl_LayersList); + focusList(tab); + m_layersList.setCurrentSelection(m_layerSelection); + } + else if (tab == eTab_Biomes) + { + SetFocusToElement(eControl_BiomesList); + focusList(tab); + m_biomesList.setCurrentSelection(m_biomeSelection); + } + else + { + SetFocusToElement(eControl_PropertiesList); + focusList(tab); + m_propertiesList.HighlightItem(m_paramSelection); + } + } + updateHelp(); + updateTooltips(); +} + +void UIScene_SuperflatMenu::setHelp(const wstring &title, const wstring &body) +{ + wchar_t startTags[64]; + swprintf(startTags, 64, L"", app.GetHTMLColour(eHTMLColor_White)); + wstring text = startTags + title + L"

" + body + L"
"; + m_description.setLabel(text); +} + +void UIScene_SuperflatMenu::updateHelp() +{ + if (m_activeTab == eTab_Layers) + { + int layer = rowToLayer(m_layerSelection); + vector &layers = *m_info.getLayers(); + if (layer >= 0 && layer < static_cast(layers.size())) + { + int id = layers[layer].getId(); + int data = layers[layer].getData(); + setHelp(SuperflatData::GetBlockName(id, data), SuperflatData::GetBlockDescription(id, data)); + } + else + { + setHelp(L"", L""); + } + } + else if (m_activeTab == eTab_Biomes) + { + setHelp(SuperflatData::GetBiomeName(m_biomeSelection), SuperflatData::GetBiomeDescription(m_biomeSelection)); + } + else + { + if (m_paramSelection < 0 || m_paramSelection >= SuperflatData::GetParamCount()) + { + setHelp(L"", L""); + return; + } + int parent = SuperflatData::GetParamParent(m_paramSelection); + const SuperflatData::Param &parentParam = SuperflatData::GetParam(parent); + wstring body = parentParam.description; + if (parent != m_paramSelection) + { + const SuperflatData::Param ¶m = SuperflatData::GetParam(m_paramSelection); + body += wstring(L"

") + param.name + L"
" + param.description; + } + setHelp(parentParam.name, body); + } +} + +void UIScene_SuperflatMenu::openEditLayer(int layerIndex, bool insert) +{ + commit(); + m_editData.layerIndex = layerIndex; + m_editData.insert = insert; + ui.NavigateToScene(m_iPad, eUIScene_SuperflatEditLayerMenu, &m_editData); +} + +void UIScene_SuperflatMenu::addLayerAbove(int row) +{ + if (m_info.getTotalHeight() >= FlatGeneratorInfo::MAX_HEIGHT || layerCount() >= FlatGeneratorInfo::MAX_LAYERS) + { + m_pendingAction = ePending_MaxHeight; + return; + } + int layer = rowToLayer(row); + vector &layers = *m_info.getLayers(); + int insertAt = layer + 1; + if (insertAt < 0) + insertAt = 0; + if (insertAt > static_cast(layers.size())) + insertAt = static_cast(layers.size()); + layers.insert(layers.begin() + insertAt, FlatLayerInfo(1, Tile::stone_Id)); + m_info.updateLayers(); + m_layerSelection = layerCount() - 1 - insertAt; + openEditLayer(insertAt, true); +} + +void UIScene_SuperflatMenu::moveSelectedLayer(int direction) +{ + int row = m_layerSelection; + int target = row + direction; + if (target < 0 || isBottomRow(target) || isBottomRow(row)) + { + ui.PlayUISFX(eSFX_CraftFail); + return; + } + vector &layers = *m_info.getLayers(); + std::swap(layers[rowToLayer(row)], layers[rowToLayer(target)]); + m_info.updateLayers(); + m_layerSelection = target; + populateLayers(); + m_layersList.setCurrentSelection(m_layerSelection); + ui.PlayUISFX(eSFX_Press); + commit(); + updateHelp(); +} + +void UIScene_SuperflatMenu::showLayerOptions() +{ + UINT options[3]; + options[0] = UICustomStrings::Get(L"Edit Layer"); + options[1] = UICustomStrings::Get(L"Add Layer"); + options[2] = UICustomStrings::Get(L"Delete Layer"); + m_bBusy = true; + ui.RequestAlertMessage(UICustomStrings::Get(L"Layer Options"), UICustomStrings::Get(L"Add, edit or delete a layer."), options, 3, m_iPad, &UIScene_SuperflatMenu::LayerOptionsCallback, this); +} + +int UIScene_SuperflatMenu::LayerOptionsCallback(LPVOID lpParam, int iPad, const C4JStorage::EMessageResult result) +{ + UIScene_SuperflatMenu *scene = static_cast(lpParam); + scene->m_bBusy = false; + switch (result) + { + case C4JStorage::EMessage_ResultAccept: + scene->m_pendingAction = ePending_EditLayer; + break; + case C4JStorage::EMessage_ResultDecline: + scene->m_pendingAction = ePending_AddLayer; + break; + case C4JStorage::EMessage_ResultThirdOption: + scene->m_pendingAction = ePending_DeleteLayer; + break; + default: + break; + } + return 0; +} + +void UIScene_SuperflatMenu::tick() +{ + if (m_bNeedsPopulate) + { + m_bNeedsPopulate = false; + populateAll(); + setActiveTab(m_activeTab, true); + } + + if (m_pendingSliderId >= 0) + { + int id = m_pendingSliderId; + m_pendingSliderId = -1; + applySliderChange(id, m_pendingSliderValue); + } + + int action = m_pendingAction; + m_pendingAction = ePending_None; + switch (action) + { + case ePending_EditLayer: + openEditLayer(rowToLayer(m_layerSelection), false); + break; + case ePending_AddLayer: + addLayerAbove(m_layerSelection); + break; + case ePending_DeleteLayer: + if (layerCount() > 1 && !isBottomRow(m_layerSelection)) + { + vector &layers = *m_info.getLayers(); + layers.erase(layers.begin() + rowToLayer(m_layerSelection)); + m_info.updateLayers(); + populateLayers(); + m_layersList.setCurrentSelection(m_layerSelection); + commit(); + updateHelp(); + updateTooltips(); + } + break; + case ePending_Presets: + commit(); + ui.NavigateToScene(m_iPad, eUIScene_SuperflatPresetsMenu, &m_info); + break; + case ePending_MaxHeight: + { + UINT options[1]; + options[0] = IDS_CONFIRM_OK; + ui.RequestAlertMessage(UICustomStrings::Get(L"Maximum Height Reached"), UICustomStrings::Get(L"The world cannot be any taller. Remove or shrink a layer before adding another."), options, 1, m_iPad); + } + break; + case ePending_ReadParams: + readParams(); + updateHelp(); + break; + case ePending_Biome: + if (m_pendingBiome >= 0) + { + m_info.setBiome(SuperflatData::GetBiomeId(m_pendingBiome)); + m_pendingBiome = -1; + updateBiomeChecks(); + commit(); + } + break; + case ePending_Help: + updateHelp(); + break; + } + + UIScene::tick(); +} + +void UIScene_SuperflatMenu::updateTooltips() +{ + int a = -1; + int x = -1; + int y = -1; + int lb = -1; + int rb = -1; + if (m_bMovingLayer) + { + a = IDS_TOOLTIPS_PLACE; + } + else + { + x = UICustomStrings::Get(L"Presets"); + lb = -2; + rb = UICustomStrings::Get(L"Select Tab"); + if (m_activeTab == eTab_Layers) + { + if (isBottomRow(m_layerSelection)) + { + a = UICustomStrings::Get(L"Add Layer"); + } + else + { + a = UICustomStrings::Get(L"Layer Options"); + y = UICustomStrings::Get(L"Move Layer"); + } + } + else + { + a = IDS_TOOLTIPS_SELECT; + } + } + ui.SetTooltips(m_iPad, a, IDS_TOOLTIPS_BACK, x, y, -1, -1, lb, rb); +} + +void UIScene_SuperflatMenu::updateComponents() +{ + m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true); + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false); +} + +void UIScene_SuperflatMenu::handleGainFocus(bool navBack) +{ + UIScene::handleGainFocus(navBack); + if (navBack) + { + m_bMovingLayer = false; + m_bBusy = false; + m_biomeSelection = SuperflatData::GetBiomeIndex(m_info.getBiome()); + m_bNeedsPopulate = true; + commit(); + } +} + +void UIScene_SuperflatMenu::customDraw(IggyCustomDrawCallbackRegion *region) +{ + int list = -1; + int index = -1; + if (swscanf(static_cast(region->name), L"slot_%d_%d", &list, &index) != 2) + return; + shared_ptr item = nullptr; + if (list == eControl_LayersList) + { + int layer = rowToLayer(index); + vector &layers = *m_info.getLayers(); + if (layer >= 0 && layer < static_cast(layers.size())) + item = SuperflatData::GetBlockIcon(layers[layer].getId(), layers[layer].getData()); + } + else if (list == eControl_BiomesList) + { + item = SuperflatData::GetBiomeIcon(index); + } + if (item != nullptr) + customDrawSlotControl(region, m_iPad, item, 1.0f, false, false); +} + +void UIScene_SuperflatMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) +{ + if (m_bBusy) + return; + + ui.AnimateKeyPress(iPad, key, repeat, pressed, released); + + switch (key) + { + case ACTION_MENU_CANCEL: + if (pressed) + { + if (m_bMovingLayer) + { + m_bMovingLayer = false; + updateTooltips(); + } + else + { + commit(); + navigateBack(); + } + } + handled = true; + break; + case ACTION_MENU_X: + if (pressed && !repeat && !m_bMovingLayer) + { + ui.PlayUISFX(eSFX_Press); + m_pendingAction = ePending_Presets; + } + handled = true; + break; + case ACTION_MENU_Y: + if (pressed && !repeat && m_activeTab == eTab_Layers && !isBottomRow(m_layerSelection)) + { + ui.PlayUISFX(eSFX_Press); + m_bMovingLayer = !m_bMovingLayer; + updateTooltips(); + } + handled = true; + break; + case ACTION_MENU_LEFT_SCROLL: + case ACTION_MENU_RIGHT_SCROLL: + if (pressed && !repeat && !m_bMovingLayer) + { + ui.PlayUISFX(eSFX_Focus); + setActiveTab(m_activeTab + (key == ACTION_MENU_RIGHT_SCROLL ? 1 : -1), true); + } + handled = true; + break; + case ACTION_MENU_UP: + case ACTION_MENU_DOWN: + if (m_bMovingLayer) + { + if (pressed) + moveSelectedLayer(key == ACTION_MENU_UP ? -1 : 1); + handled = true; + break; + } + if (pressed) + stepSelection(key == ACTION_MENU_UP ? -1 : 1); + handled = true; + break; + case ACTION_MENU_OK: + if (m_bMovingLayer) + { + if (pressed) + { + ui.PlayUISFX(eSFX_Press); + m_bMovingLayer = false; + updateTooltips(); + } + handled = true; + break; + } + sendInputToMovie(key, repeat, pressed, released); + handled = true; + break; + case ACTION_MENU_LEFT: + case ACTION_MENU_RIGHT: + case ACTION_MENU_PAGEUP: + case ACTION_MENU_OTHER_STICK_UP: + case ACTION_MENU_OTHER_STICK_DOWN: + if (!m_bMovingLayer && (key == ACTION_MENU_OTHER_STICK_UP || key == ACTION_MENU_OTHER_STICK_DOWN)) + { + if (pressed) + stepSelection(key == ACTION_MENU_OTHER_STICK_UP ? -1 : 1); + handled = true; + break; + } + case ACTION_MENU_PAGEDOWN: + if (!m_bMovingLayer) + sendInputToMovie(key, repeat, pressed, released); + handled = true; + break; + } +} + +void UIScene_SuperflatMenu::handlePress(F64 controlId, F64 childId) +{ + if (!m_bPopulated || m_bBusy || m_bMovingLayer) + return; + int list = static_cast(controlId); + int id = static_cast(childId); + switch (list) + { + case eControl_LayersList: + ui.PlayUISFX(eSFX_Press); + m_layerSelection = id; + if (isBottomRow(id)) + m_pendingAction = ePending_AddLayer; + else + showLayerOptions(); + break; + case eControl_BiomesList: + ui.PlayUISFX(eSFX_Press); + m_biomeSelection = id; + m_pendingBiome = id; + m_pendingAction = ePending_Biome; + break; + case eControl_PropertiesList: + ui.PlayUISFX(eSFX_Press); + m_paramSelection = id; + m_pendingAction = ePending_ReadParams; + break; + } +} + +void UIScene_SuperflatMenu::handleCheckboxToggled(F64 controlId, bool selected) +{ + if (!m_bPopulated || m_bBusy || m_bMovingLayer) + return; + if (static_cast(controlId) == eControl_PropertiesList) + m_pendingAction = ePending_ReadParams; +} + +void UIScene_SuperflatMenu::handleFocusChange(F64 controlId, F64 childId) +{ + int list = static_cast(controlId); + int id = static_cast(childId); + if (list == eControl_LayersList && m_activeTab == eTab_Layers) + { + m_layersList.updateChildFocus(id); + m_layerSelection = id; + } + else if (list == eControl_BiomesList && m_activeTab == eTab_Biomes) + { + m_biomesList.updateChildFocus(id); + m_biomeSelection = id; + } + else if (list == eControl_PropertiesList && m_activeTab == eTab_Properties) + { + m_propertiesList.updateChildFocus(id); + m_paramSelection = id; + } + else + { + return; + } + if (m_pendingAction == ePending_None) + m_pendingAction = ePending_Help; + updateTooltips(); +} + +void UIScene_SuperflatMenu::handleSliderMove(F64 sliderId, F64 currentValue) +{ + int id = static_cast(sliderId); + int value = static_cast(currentValue); + m_propertiesList.handleSliderMove(id, value); + if (!m_bPopulated) + return; + if (id >= 0 && id < SuperflatData::GetParamCount()) + { + m_pendingSliderId = id; + m_pendingSliderValue = value; + } +} + +void UIScene_SuperflatMenu::applySliderChange(int id, int value) +{ + SuperflatData::WriteParamValue(m_info, id, value); + m_propertiesList.SetSliderLabel(id, SuperflatData::GetParamLabel(id, value)); + int next = id + 1; + if (next < SuperflatData::GetParamCount() && SuperflatData::GetParam(next).kind == SuperflatData::eParam_SeparationSlider && SuperflatData::GetParamParent(next) == SuperflatData::GetParamParent(id)) + SuperflatData::WriteParamValue(m_info, next, m_propertiesList.GetSliderValue(next)); + commit(); +} + +#ifdef _WINDOWS64 +bool UIScene_SuperflatMenu::handleMouseClick(F32 x, F32 y) +{ + if (m_bBusy) + return true; + if (y >= kTabY && y <= kTabY + kTabH && x >= kTabX && x <= kTabX + kTabW * eTab_Count) + { + int tab = static_cast((x - kTabX) / kTabW); + if (!m_bMovingLayer && tab != m_activeTab) + { + ui.PlayUISFX(eSFX_Focus); + setActiveTab(tab, true); + } + return true; + } + return UIScene::handleMouseClick(x, y); +} +#endif diff --git a/Minecraft.Client/Common/UI/UIScene_SuperflatMenu.h b/Minecraft.Client/Common/UI/UIScene_SuperflatMenu.h new file mode 100644 index 00000000..9419cd8f --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_SuperflatMenu.h @@ -0,0 +1,146 @@ +#pragma once + +#include "UIScene.h" +#include "UIControl_MultiList.h" +#include "UIControl_SuperflatLists.h" +#include "../../../Minecraft.World/FlatGeneratorInfo.h" + +struct _LaunchMoreOptionsMenuInitData; + +struct SuperflatEditLayerInitData +{ + FlatGeneratorInfo *info; + int layerIndex; + bool insert; +}; + +class UIScene_SuperflatMenu : public UIScene +{ +private: + enum ETabs + { + eTab_Layers = 0, + eTab_Biomes, + eTab_Properties, + eTab_Count, + }; + + enum EControls + { + eControl_LayersList = 0, + eControl_BiomesList = 1, + eControl_PropertiesList = 2, + }; + + enum EPendingAction + { + ePending_None = 0, + ePending_EditLayer, + ePending_AddLayer, + ePending_DeleteLayer, + ePending_Presets, + ePending_MaxHeight, + ePending_ReadParams, + ePending_Biome, + ePending_Help, + }; + + UIControl_Label m_labelLayersTab; + UIControl_Label m_labelBiomesTab; + UIControl_Label m_labelPropertiesTab; + UIControl m_layersPanel; + UIControl m_biomesPanel; + UIControl m_propertiesPanel; + UIControl_LayerIconButtonList m_layersList; + UIControl_CheckboxButtonList m_biomesList; + UIControl_MultiList m_propertiesList; + UIControl_HTMLLabel m_description; + IggyName m_funcSetActiveTab; + IggyName m_funcFocusList; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) + UI_MAP_ELEMENT( m_layersPanel, "LayersPanel") + UI_BEGIN_MAP_CHILD_ELEMENTS(m_layersPanel) + UI_MAP_ELEMENT( m_layersList, "LayersList") + UI_END_MAP_CHILD_ELEMENTS() + UI_MAP_ELEMENT( m_biomesPanel, "BiomesPanel") + UI_BEGIN_MAP_CHILD_ELEMENTS(m_biomesPanel) + UI_MAP_ELEMENT( m_biomesList, "BiomesList") + UI_END_MAP_CHILD_ELEMENTS() + UI_MAP_ELEMENT( m_propertiesPanel, "PropertiesPanel") + UI_BEGIN_MAP_CHILD_ELEMENTS(m_propertiesPanel) + UI_MAP_ELEMENT( m_propertiesList, "PropertiesList") + UI_END_MAP_CHILD_ELEMENTS() + UI_MAP_ELEMENT( m_description, "Description") + UI_MAP_ELEMENT( m_labelLayersTab, "LayersTabTitle") + UI_MAP_ELEMENT( m_labelBiomesTab, "BiomesTabTitle") + UI_MAP_ELEMENT( m_labelPropertiesTab, "PropertiesTabTitle") + UI_MAP_NAME( m_funcSetActiveTab, L"SetActiveTab") + UI_MAP_NAME( m_funcFocusList, L"FocusList") + UI_END_MAP_ELEMENTS_AND_NAMES() + + _LaunchMoreOptionsMenuInitData *m_params; + FlatGeneratorInfo m_info; + SuperflatEditLayerInitData m_editData; + int m_activeTab; + int m_layerSelection; + int m_biomeSelection; + int m_paramSelection; + int m_pendingAction; + int m_pendingBiome; + int m_pendingSelectRow; + int m_pendingSliderId; + int m_pendingSliderValue; + bool m_bMovingLayer; + bool m_bBusy; + bool m_bPopulated; + bool m_bNeedsPopulate; + + void populateAll(); + void populateLayers(); + void populateBiomes(); + void populateProperties(); + void updateBiomeChecks(); + void updateParamStates(); + void readParams(); + void commit(); + void setActiveTab(int tab, bool setFocus); + void focusList(int tab); + void stepSelection(int direction); + void updateHelp(); + void setHelp(const wstring &title, const wstring &body); + int layerCount(); + int rowToLayer(int row); + bool isBottomRow(int row); + void openEditLayer(int layerIndex, bool insert); + void addLayerAbove(int row); + void moveSelectedLayer(int direction); + void showLayerOptions(); + void applySliderChange(int id, int value); + + static int LayerOptionsCallback(LPVOID lpParam, int iPad, const C4JStorage::EMessageResult result); + +public: + UIScene_SuperflatMenu(int iPad, void *initData, UILayer *parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_SuperflatMenu; } + + virtual void tick(); + virtual void updateTooltips(); + virtual void updateComponents(); + virtual void handleGainFocus(bool navBack); + virtual void customDraw(IggyCustomDrawCallbackRegion *region); + +protected: + virtual wstring getMoviePath(); + +public: + virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); + virtual void handlePress(F64 controlId, F64 childId); + virtual void handleFocusChange(F64 controlId, F64 childId); + virtual void handleSliderMove(F64 sliderId, F64 currentValue); + virtual void handleCheckboxToggled(F64 controlId, bool selected); +#ifdef _WINDOWS64 + virtual bool handleMouseClick(F32 x, F32 y); +#endif +}; diff --git a/Minecraft.Client/Common/UI/UIScene_SuperflatPresetsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SuperflatPresetsMenu.cpp new file mode 100644 index 00000000..fe1d5406 --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_SuperflatPresetsMenu.cpp @@ -0,0 +1,235 @@ +#include "stdafx.h" +#include "UI.h" +#include "UIScene_SuperflatPresetsMenu.h" +#include "SuperflatData.h" +#include "UICustomStrings.h" +#include "../../../Minecraft.World/net.minecraft.world.item.h" +#include "../../../Minecraft.World/net.minecraft.world.level.tile.h" +#ifdef _WINDOWS64 +#include "../../Windows64/KeyboardMouseInput.h" +#endif + +UIScene_SuperflatPresetsMenu::UIScene_SuperflatPresetsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) +{ + initialiseMovie(); + m_info = static_cast(initData); + m_bNeedsPopulate = true; + m_bPopulated = false; + m_bIgnoreInput = false; + m_iFocusId = eControl_PresetBase; + m_iPendingPress = -1; + m_iPendingDelete = -1; + m_bPendingSaveName = false; + SuperflatData::LoadCustomPresets(); + m_title.init(UICustomStrings::Lookup(UICustomStrings::Get(L"Presets"))); + m_list.init(eControl_PresetsList); + m_list.UseIggyIcons(); +} + +wstring UIScene_SuperflatPresetsMenu::getMoviePath() +{ + return L"SuperflatPresetsMenu"; +} + +bool UIScene_SuperflatPresetsMenu::isCustomId(int id) +{ + return id >= eControl_CustomBase && id < eControl_CustomBase + static_cast(SuperflatData::GetCustomPresets().size()); +} + +void UIScene_SuperflatPresetsMenu::populate() +{ + m_list.clearList(); + m_list.AddNewItem(L"Save Current as Preset", eControl_Save); + vector &custom = SuperflatData::GetCustomPresets(); + for (int i = 0; i < static_cast(custom.size()); ++i) + m_list.AddNewItem(custom[i].name, eControl_CustomBase + i); + for (int i = 0; i < SuperflatData::GetPresetCount(); ++i) + m_list.AddNewItem(SuperflatData::GetPresetName(i), eControl_PresetBase + i); + SetFocusToElement(eControl_PresetsList); + m_list.setCurrentSelection(0); + m_iFocusId = eControl_Save; + m_bPopulated = true; + updateTooltips(); +} + +int UIScene_SuperflatPresetsMenu::KeyboardCompleteCallback(LPVOID lpParam, bool bRes) +{ + UIScene_SuperflatPresetsMenu *pClass = static_cast(lpParam); + pClass->m_bIgnoreInput = false; + if (bRes) + { + uint16_t pchText[128]; + ZeroMemory(pchText, 128 * sizeof(uint16_t)); +#ifdef _WINDOWS64 + Win64_GetKeyboardText(pchText, 128); +#else + InputManager.GetText(pchText); +#endif + pClass->m_pendingName = reinterpret_cast(pchText); + pClass->m_bPendingSaveName = true; + } + return 0; +} + +void UIScene_SuperflatPresetsMenu::tick() +{ + if (m_bNeedsPopulate) + { + m_bNeedsPopulate = false; + populate(); + } + + if (m_bPendingSaveName) + { + m_bPendingSaveName = false; + wstring name = m_pendingName; + for (auto &c : name) + { + if (c == L'\t' || c == L'\n' || c == L'\r') + c = L' '; + } + while (!name.empty() && name.back() == L' ') + name.pop_back(); + if (name.empty()) + name = L"Custom Preset " + std::to_wstring(SuperflatData::GetCustomPresets().size() + 1); + SuperflatData::CustomPreset preset; + preset.name = name; + preset.value = m_info->toString(); + SuperflatData::GetCustomPresets().push_back(preset); + SuperflatData::SaveCustomPresets(); + m_bNeedsPopulate = true; + } + + if (m_iPendingDelete >= 0) + { + int index = m_iPendingDelete; + m_iPendingDelete = -1; + vector &custom = SuperflatData::GetCustomPresets(); + if (index < static_cast(custom.size())) + { + custom.erase(custom.begin() + index); + SuperflatData::SaveCustomPresets(); + m_bNeedsPopulate = true; + } + } + + if (m_iPendingPress >= 0) + { + int id = m_iPendingPress; + m_iPendingPress = -1; + if (id == eControl_Save) + { + m_bIgnoreInput = true; + UIKeyboardInitData kbData; + kbData.title = L"Preset Name"; + kbData.defaultText = L""; + kbData.maxChars = 40; + kbData.callback = &UIScene_SuperflatPresetsMenu::KeyboardCompleteCallback; + kbData.lpParam = this; +#ifdef _WINDOWS64 + kbData.pcMode = g_KBMInput.IsKBMActive(); +#endif + ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); + } + else if (id >= eControl_PresetBase && id < eControl_PresetBase + SuperflatData::GetPresetCount()) + { + *m_info = SuperflatData::MakePreset(id - eControl_PresetBase); + navigateBack(); + return; + } + else if (isCustomId(id)) + { + *m_info = FlatGeneratorInfo::fromValue(SuperflatData::GetCustomPresets()[id - eControl_CustomBase].value); + navigateBack(); + return; + } + } + + UIScene::tick(); +} + +void UIScene_SuperflatPresetsMenu::updateTooltips() +{ + int deleteTip = isCustomId(m_iFocusId) ? IDS_TOOLTIPS_DELETE : -1; + ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, deleteTip); +} + +void UIScene_SuperflatPresetsMenu::updateComponents() +{ + m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true); + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false); +} + +void UIScene_SuperflatPresetsMenu::handleGainFocus(bool navBack) +{ + UIScene::handleGainFocus(navBack); + if (navBack) + m_bNeedsPopulate = true; +} + +void UIScene_SuperflatPresetsMenu::customDraw(IggyCustomDrawCallbackRegion *region) +{ + int list = -1; + int id = -1; + if (swscanf(static_cast(region->name), L"slot_%d_%d", &list, &id) != 2) + return; + shared_ptr item = nullptr; + if (id >= eControl_PresetBase && id < eControl_PresetBase + SuperflatData::GetPresetCount()) + item = SuperflatData::GetPresetIcon(id - eControl_PresetBase); + else if (id == eControl_Save) + item = std::make_shared(Tile::crafting_table_Id, 1, 0); + else if (isCustomId(id)) + item = std::make_shared(Item::painting); + if (item != nullptr) + customDrawSlotControl(region, m_iPad, item, 1.0f, false, false); +} + +void UIScene_SuperflatPresetsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) +{ + if (m_bIgnoreInput) + return; + + ui.AnimateKeyPress(iPad, key, repeat, pressed, released); + + switch (key) + { + case ACTION_MENU_CANCEL: + if (pressed) + navigateBack(); + handled = true; + break; + case ACTION_MENU_X: + if (pressed && !repeat && isCustomId(m_iFocusId)) + { + ui.PlayUISFX(eSFX_Press); + m_iPendingDelete = m_iFocusId - eControl_CustomBase; + } + handled = true; + break; + case ACTION_MENU_OK: + case ACTION_MENU_UP: + case ACTION_MENU_DOWN: + case ACTION_MENU_PAGEUP: + case ACTION_MENU_PAGEDOWN: + case ACTION_MENU_OTHER_STICK_UP: + case ACTION_MENU_OTHER_STICK_DOWN: + sendInputToMovie(key, repeat, pressed, released); + handled = true; + break; + } +} + +void UIScene_SuperflatPresetsMenu::handlePress(F64 controlId, F64 childId) +{ + if (!m_bPopulated || m_bIgnoreInput) + return; + ui.PlayUISFX(eSFX_Press); + m_iPendingPress = static_cast(childId); +} + +void UIScene_SuperflatPresetsMenu::handleFocusChange(F64 controlId, F64 childId) +{ + m_iFocusId = static_cast(childId); + m_list.updateChildFocus(m_iFocusId); + updateTooltips(); +} diff --git a/Minecraft.Client/Common/UI/UIScene_SuperflatPresetsMenu.h b/Minecraft.Client/Common/UI/UIScene_SuperflatPresetsMenu.h new file mode 100644 index 00000000..d6255313 --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_SuperflatPresetsMenu.h @@ -0,0 +1,58 @@ +#pragma once + +#include "UIScene.h" +#include "UIControl_SuperflatLists.h" +#include "../../../Minecraft.World/FlatGeneratorInfo.h" + +class UIScene_SuperflatPresetsMenu : public UIScene +{ +private: + enum EControls + { + eControl_PresetsList = 0, + eControl_Save = 100, + eControl_PresetBase = 0, + eControl_CustomBase = 200, + }; + + UIControl_Label m_title; + UIControl_IconLeftButtonList m_list; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) + UI_MAP_ELEMENT( m_title, "PresetsTitle") + UI_MAP_ELEMENT( m_list, "PresetsList") + UI_END_MAP_ELEMENTS_AND_NAMES() + + FlatGeneratorInfo *m_info; + bool m_bNeedsPopulate; + bool m_bPopulated; + bool m_bIgnoreInput; + int m_iFocusId; + int m_iPendingPress; + int m_iPendingDelete; + bool m_bPendingSaveName; + wstring m_pendingName; + + void populate(); + bool isCustomId(int id); + static int KeyboardCompleteCallback(LPVOID lpParam, bool bRes); + +public: + UIScene_SuperflatPresetsMenu(int iPad, void *initData, UILayer *parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_SuperflatPresetsMenu; } + + virtual void tick(); + virtual void updateTooltips(); + virtual void updateComponents(); + virtual void handleGainFocus(bool navBack); + virtual void customDraw(IggyCustomDrawCallbackRegion *region); + +protected: + virtual wstring getMoviePath(); + +public: + virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); + virtual void handlePress(F64 controlId, F64 childId); + virtual void handleFocusChange(F64 controlId, F64 childId); +}; diff --git a/Minecraft.Client/Common/UI/UIStructs.h b/Minecraft.Client/Common/UI/UIStructs.h index 11d3f070..9df3e21b 100644 --- a/Minecraft.Client/Common/UI/UIStructs.h +++ b/Minecraft.Client/Common/UI/UIStructs.h @@ -364,6 +364,7 @@ typedef struct _LaunchMoreOptionsMenuInitData bool bDoTileDrops; bool bNaturalRegeneration; bool bDoDaylightCycle; + bool bDoWeatherCycle; bool bOnlineSettingChangedBySystem; @@ -372,6 +373,7 @@ typedef struct _LaunchMoreOptionsMenuInitData DWORD dwTexturePack; wstring seed; + wstring superflatOptions; int worldSize; bool bDisableSaving; @@ -401,6 +403,7 @@ typedef struct _LaunchMoreOptionsMenuInitData bDoTileDrops = true; bNaturalRegeneration = true; bDoDaylightCycle = true; + bDoWeatherCycle = true; } } LaunchMoreOptionsMenuInitData; diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/colours.xml b/Minecraft.Client/Common/res/TitleUpdate/res/colours.xml index d066d9c5..498325e7 100644 --- a/Minecraft.Client/Common/res/TitleUpdate/res/colours.xml +++ b/Minecraft.Client/Common/res/TitleUpdate/res/colours.xml @@ -144,7 +144,44 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +