diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp index 7ba874f78..9acb8fa64 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -12,6 +12,7 @@ #ifdef __ORBIS__ #include #endif + IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu() { m_menu = NULL; m_autoDeleteMenu = false; @@ -100,7 +101,7 @@ int IUIScene_AbstractContainerMenu::GetSectionDimensions(ESceneSection eSection, void IUIScene_AbstractContainerMenu::updateSlotPosition( ESceneSection eSection, ESceneSection newSection, ETapState eTapDirection, - int* piTargetX, int* piTargetY, int xOffset) { + int* piTargetX, int* piTargetY, int xOffset, int yOffset) { // Update the target slot based on the size of the current section int columns, rows; @@ -116,8 +117,13 @@ void IUIScene_AbstractContainerMenu::updateSlotPosition( } else if (eTapDirection == eTapStateDown) { (*piTargetY) = 0; } - if ((*piTargetY) < 0) { + int offsetY = (*piTargetY) - yOffset; + if (offsetY < 0) { (*piTargetY) = 0; + } else if (offsetY >= rows) { + (*piTargetY) = rows - 1; + } else { + (*piTargetY) = offsetY; } // Update X @@ -566,6 +572,9 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { } } + // 4J - TomK - set to section none if this is a non-visible section + if (!IsVisible(eSectionUnderPointer)) eSectionUnderPointer = eSectionNone; + // If we are not over any slot, set focus elsewhere. if (eSectionUnderPointer == eSectionNone) { setFocusToPointer(getPad()); @@ -755,19 +764,24 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { } if (bPointerIsOverSlot && bSlotHasItem) { - std::vector unformattedStrings; - std::wstring desc = GetItemDescription(slot, unformattedStrings); - SetPointerText(desc, unformattedStrings, - slot != m_lastPointerLabelSlot); + std::vector* desc = GetItemDescription(slot); + SetPointerText(desc, slot != m_lastPointerLabelSlot); m_lastPointerLabelSlot = slot; + delete desc; + } else if (eSectionUnderPointer != eSectionNone && + !IsSectionSlotList(eSectionUnderPointer)) { + std::vector* desc = + GetSectionHoverText(eSectionUnderPointer); + SetPointerText(desc, false); + m_lastPointerLabelSlot = NULL; + delete desc; } else { - std::vector unformattedStrings; - SetPointerText(L"", unformattedStrings, false); + SetPointerText(NULL, false); m_lastPointerLabelSlot = NULL; } - EToolTipItem buttonA, buttonX, buttonY, buttonRT; - buttonA = buttonX = buttonY = buttonRT = eToolTipNone; + EToolTipItem buttonA, buttonX, buttonY, buttonRT, buttonBack; + buttonA = buttonX = buttonY = buttonRT = buttonBack = eToolTipNone; if (bPointerIsOverSlot) { SetPointerOutsideMenu(false); if (bIsItemCarried) { @@ -828,11 +842,18 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { if (bSlotHasItem) { if (iSlotCount == 1) { buttonA = eToolTipPickUpGeneric; - buttonRT = eToolTipWhatIsThis; } else { // Multiple items in slot. buttonA = eToolTipPickUpAll; buttonX = eToolTipPickUpHalf; + } + +#ifdef __PSVITA__ + if (!InputManager.IsVitaTV()) { + buttonBack = eToolTipWhatIsThis; + } else +#endif + { buttonRT = eToolTipWhatIsThis; } } else { @@ -974,7 +995,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { // bool bValidIngredientBottom=false; if (Item::items[iId]->hasPotionBrewingFormula() || - (iId == Item::netherStalkSeeds_Id)) { + (iId == Item::netherwart_seeds_Id)) { bValidIngredient = true; } @@ -1030,10 +1051,10 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { buttonY = eToolTipQuickMoveWeapon; break; - case Item::helmet_cloth_Id: - case Item::chestplate_cloth_Id: - case Item::leggings_cloth_Id: - case Item::boots_cloth_Id: + case Item::helmet_leather_Id: + case Item::chestplate_leather_Id: + case Item::leggings_leather_Id: + case Item::boots_leather_Id: case Item::helmet_chain_Id: case Item::chestplate_chain_Id: @@ -1099,12 +1120,13 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { item = getSlotItem(eSectionUnderPointer, iNewSlotIndex); overrideTooltips(eSectionUnderPointer, item, bIsItemCarried, bSlotHasItem, bCarriedIsSameAsSlot, iSlotStackSizeRemaining, buttonA, - buttonX, buttonY, buttonRT); + buttonX, buttonY, buttonRT, buttonBack); SetToolTip(eToolTipButtonA, buttonA); SetToolTip(eToolTipButtonX, buttonX); SetToolTip(eToolTipButtonY, buttonY); SetToolTip(eToolTipButtonRT, buttonRT); + SetToolTip(eToolTipButtonBack, buttonBack); // Offset back to image top left. vPointerPos.x -= m_fPointerImageOffsetX; @@ -1165,21 +1187,19 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, #endif int buttonNum = 0; // 0 = LeftMouse, 1 = RightMouse - bool quickKeyHeld = false; // Represents shift key on PC + BOOL quickKeyHeld = FALSE; // Represents shift key on PC - bool validKeyPress = false; - // BOOL itemEditorKeyPress = FALSE; + BOOL validKeyPress = FALSE; + bool itemEditorKeyPress = false; // Ignore input from other players // if(pMinecraft->player->GetXboxPad()!=pInputData->UserIndex) return S_OK; switch (iAction) { #ifdef _DEBUG_MENUS_ENABLED -#if TO_BE_IMPLEMENTED - case VK_PAD_RTHUMB_PRESS: + case ACTION_MENU_OTHER_STICK_PRESS: itemEditorKeyPress = TRUE; break; -#endif #endif case ACTION_MENU_A: #ifdef __ORBIS__ @@ -1275,14 +1295,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, // 4J Stu - Do nothing except stop this being passed anywhere else bHandled = true; } break; -#ifdef __PSVITA__ - // CD - Vita uses select for What's this - key 40 - case MINECRAFT_ACTION_GAME_INFO: -#else - case ACTION_MENU_PAGEDOWN: -#endif - - { + case ACTION_MENU_PAGEDOWN: { if (IsSectionSlotList(m_eCurrSection)) { int currentIndex = getCurrentIndex(m_eCurrSection) - getSectionStartOffset(m_eCurrSection); @@ -1345,48 +1358,18 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bHandled = true; } #ifdef _DEBUG_MENUS_ENABLED -#if TO_BE_IMPLEMENTED else if (itemEditorKeyPress == TRUE) { - HXUIOBJ hFocusObject = GetFocus(pInputData->UserIndex); - HXUIOBJ hFocusObjectParent; - XuiElementGetParent(hFocusObject, &hFocusObjectParent); - - HXUICLASS hClassCXuiCtrlSlotList; - - // TODO Define values for these - hClassCXuiCtrlSlotList = XuiFindClass(L"CXuiCtrlSlotList"); - - // If the press comes from a SlotList, cast it up then send a clicked - // call to it's menu - if (XuiIsInstanceOf(hFocusObjectParent, hClassCXuiCtrlSlotList)) { - CXuiCtrlSlotList* slotList; - void* pObj; - XuiObjectFromHandle(hFocusObjectParent, &pObj); - slotList = (CXuiCtrlSlotList*)pObj; - - int currentIndex = slotList->GetCurSel(); - - CXuiCtrlSlotItemListItem* pCXuiCtrlSlotItem; - slotList->GetCXuiCtrlSlotItem(currentIndex, &(pCXuiCtrlSlotItem)); - - // Minecraft *pMinecraft = Minecraft::GetInstance(); - - CScene_DebugItemEditor::ItemEditorInput* initData = - new CScene_DebugItemEditor::ItemEditorInput(); - initData->iPad = m_iPad; + if (IsSectionSlotList(m_eCurrSection)) { + ItemEditorInput* initData = new ItemEditorInput(); + initData->iPad = getPad(); initData->slot = - pCXuiCtrlSlotItem->getSlot(pCXuiCtrlSlotItem->m_hObj); + getSlot(m_eCurrSection, getCurrentIndex(m_eCurrSection)); initData->menu = m_menu; - // Add timer to poll controller stick input at 60Hz - HRESULT timerResult = KillTimer(POINTER_INPUT_TIMER_ID); - assert(timerResult == S_OK); - - app.NavigateToScene(m_iPad, eUIScene_DebugItemEditor, - (void*)initData, false, TRUE); + ui.NavigateToScene(getPad(), eUIScene_DebugItemEditor, + (void*)initData); } } -#endif #endif else { handleAdditionalKeyPress(iAction); @@ -1411,7 +1394,7 @@ void IUIScene_AbstractContainerMenu::handleOutsideClicked(int iPad, // pMinecraft->localgameModes[m_iPad]->handleInventoryMouseClick(menu->containerId, // AbstractContainerMenu::CLICKED_OUTSIDE, buttonNum, // quickKeyHeld?true:false, pMinecraft->localplayers[m_iPad] ); - slotClicked(AbstractContainerMenu::CLICKED_OUTSIDE, buttonNum, + slotClicked(AbstractContainerMenu::SLOT_CLICKED_OUTSIDE, buttonNum, quickKeyHeld ? true : false); } @@ -1461,10 +1444,10 @@ bool IUIScene_AbstractContainerMenu::IsSameItemAs( std::shared_ptr itemA, std::shared_ptr itemB) { if (itemA == NULL || itemB == NULL) return false; - bool bStackedByData = itemA->isStackedByData(); - return ((itemA->id == itemB->id) && - ((bStackedByData && itemA->getAuxValue() == itemB->getAuxValue()) || - !bStackedByData)); + return (itemA->id == itemB->id && + (!itemB->isStackedByData() || + itemB->getAuxValue() == itemA->getAuxValue()) && + ItemInstance::tagMatches(itemB, itemA)); } int IUIScene_AbstractContainerMenu::GetEmptyStackSpace(Slot* slot) { @@ -1486,35 +1469,26 @@ int IUIScene_AbstractContainerMenu::GetEmptyStackSpace(Slot* slot) { return iResult; } -std::wstring IUIScene_AbstractContainerMenu::GetItemDescription( - Slot* slot, std::vector& unformattedStrings) { - if (slot == NULL) return L""; +std::vector* IUIScene_AbstractContainerMenu::GetItemDescription( + Slot* slot) { + if (slot == NULL) return NULL; - std::wstring desc = L""; - std::vector* strings = - slot->getItem()->getHoverText(nullptr, false, unformattedStrings); - bool firstLine = true; - for (AUTO_VAR(it, strings->begin()); it != strings->end(); ++it) { - std::wstring thisString = *it; - if (!firstLine) { - desc.append(L"
"); - } else { - firstLine = false; - wchar_t formatted[256]; - eMinecraftColour rarityColour = slot->getItem()->getRarity()->color; - int colour = app.GetHTMLColour(rarityColour); + std::vector* lines = + slot->getItem()->getHoverText(nullptr, false); - if (slot->getItem()->hasCustomHoverName()) { - colour = app.GetHTMLColour(eTextColor_RenamedItemTitle); - } + // Add rarity to first line + if (lines->size() > 0) { + lines->at(0).color = slot->getItem()->getRarity()->color; - swprintf(formatted, 256, L"%ls", - colour, thisString.c_str()); - thisString = formatted; + if (slot->getItem()->hasCustomHoverName()) { + lines->at(0).color = eTextColor_RenamedItemTitle; } - desc.append(thisString); } - strings->clear(); - delete strings; - return desc; + + return lines; } + +std::vector* IUIScene_AbstractContainerMenu::GetSectionHoverText( + ESceneSection eSection) { + return NULL; +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.h index 53e6779be..153a25b9e 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.h @@ -54,7 +54,6 @@ protected: eSectionInventoryCreativeUsing, eSectionInventoryCreativeSelector, -#ifndef _XBOX eSectionInventoryCreativeTab_0, eSectionInventoryCreativeTab_1, eSectionInventoryCreativeTab_2, @@ -64,7 +63,6 @@ protected: eSectionInventoryCreativeTab_6, eSectionInventoryCreativeTab_7, eSectionInventoryCreativeSlider, -#endif eSectionInventoryCreativeMax, eSectionEnchantUsing, @@ -90,6 +88,37 @@ protected: eSectionAnvilResult, eSectionAnvilName, eSectionAnvilMax, + + eSectionBeaconUsing, + eSectionBeaconInventory, + eSectionBeaconItem, + eSectionBeaconPrimaryTierOneOne, + eSectionBeaconPrimaryTierOneTwo, + eSectionBeaconPrimaryTierTwoOne, + eSectionBeaconPrimaryTierTwoTwo, + eSectionBeaconPrimaryTierThree, + eSectionBeaconSecondaryOne, + eSectionBeaconSecondaryTwo, + eSectionBeaconConfirm, + eSectionBeaconMax, + + eSectionHopperUsing, + eSectionHopperInventory, + eSectionHopperContents, + eSectionHopperMax, + + eSectionHorseUsing, + eSectionHorseInventory, + eSectionHorseChest, + eSectionHorseArmor, + eSectionHorseSaddle, + eSectionHorseMax, + + eSectionFireworksUsing, + eSectionFireworksInventory, + eSectionFireworksResult, + eSectionFireworksIngredients, + eSectionFireworksMax, }; AbstractContainerMenu* m_menu; @@ -170,6 +199,7 @@ protected: return eSection != eSectionNone; } virtual bool CanHaveFocus(ESceneSection eSection) { return true; } + virtual bool IsVisible(ESceneSection eSection) { return true; } int GetSectionDimensions(ESceneSection eSection, int* piNumColumns, int* piNumRows); virtual int getSectionColumns(ESceneSection eSection) = 0; @@ -184,7 +214,7 @@ protected: UIVec2D* pPosition, UIVec2D* pSize) = 0; void updateSlotPosition(ESceneSection eSection, ESceneSection newSection, ETapState eTapDirection, int* piTargetX, - int* piTargetY, int xOffset); + int* piTargetY, int xOffset = 0, int yOffset = 0); #ifdef TAP_DETECTION ETapState GetTapInputType(float fInputX, float fInputY); @@ -227,11 +257,13 @@ protected: virtual void setSectionSelectedSlot(ESceneSection eSection, int x, int y) = 0; virtual void setFocusToPointer(int iPad) = 0; - virtual void SetPointerText(const std::wstring& description, - std::vector& unformattedStrings, + virtual void SetPointerText(std::vector* description, bool newSlot) = 0; + virtual std::vector* GetSectionHoverText( + ESceneSection eSection); virtual std::shared_ptr getSlotItem(ESceneSection eSection, int iSlot) = 0; + virtual Slot* getSlot(ESceneSection eSection, int iSlot) = 0; virtual bool isSlotEmpty(ESceneSection eSection, int iSlot) = 0; virtual void adjustPointerForSafeZone() = 0; @@ -240,7 +272,8 @@ protected: std::shared_ptr itemUnderPointer, bool bIsItemCarried, bool bSlotHasItem, bool bCarriedIsSameAsSlot, int iSlotStackSizeRemaining, EToolTipItem& buttonA, - EToolTipItem& buttonX, EToolTipItem& buttonY, EToolTipItem& buttonRT) { + EToolTipItem& buttonX, EToolTipItem& buttonY, EToolTipItem& buttonRT, + EToolTipItem& buttonBack) { return false; } @@ -248,8 +281,8 @@ private: bool IsSameItemAs(std::shared_ptr itemA, std::shared_ptr itemB); int GetEmptyStackSpace(Slot* slot); - std::wstring GetItemDescription( - Slot* slot, std::vector& unformattedStrings); + + std::vector* GetItemDescription(Slot* slot); protected: IUIScene_AbstractContainerMenu(); diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp index 265c06d6c..90022c2e0 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp @@ -164,14 +164,14 @@ void IUIScene_AnvilMenu::handleTick() { !pMinecraft->localplayers[getPad()]->abilities.instabuild) { m_costString = app.GetString(IDS_REPAIR_EXPENSIVE); canAfford = false; - } else if (!m_repairMenu->getSlot(RepairMenu::RESULT_SLOT)->hasItem()) { + } else if (!m_repairMenu->getSlot(AnvilMenu::RESULT_SLOT)->hasItem()) { // Do nothing } else { const wchar_t* costString = app.GetString(IDS_REPAIR_COST); wchar_t temp[256]; swprintf(temp, 256, costString, m_repairMenu->cost); m_costString = temp; - if (!m_repairMenu->getSlot(RepairMenu::RESULT_SLOT) + if (!m_repairMenu->getSlot(AnvilMenu::RESULT_SLOT) ->mayPickup(std::dynamic_pointer_cast( m_inventory->player->shared_from_this()))) { canAfford = false; @@ -181,14 +181,14 @@ void IUIScene_AnvilMenu::handleTick() { setCostLabel(m_costString, canAfford); bool crossVisible = - (m_repairMenu->getSlot(RepairMenu::INPUT_SLOT)->hasItem() || - m_repairMenu->getSlot(RepairMenu::ADDITIONAL_SLOT)->hasItem()) && - !m_repairMenu->getSlot(RepairMenu::RESULT_SLOT)->hasItem(); + (m_repairMenu->getSlot(AnvilMenu::INPUT_SLOT)->hasItem() || + m_repairMenu->getSlot(AnvilMenu::ADDITIONAL_SLOT)->hasItem()) && + !m_repairMenu->getSlot(AnvilMenu::RESULT_SLOT)->hasItem(); showCross(crossVisible); } void IUIScene_AnvilMenu::updateItemName() { - Slot* slot = m_repairMenu->getSlot(RepairMenu::INPUT_SLOT); + Slot* slot = m_repairMenu->getSlot(AnvilMenu::INPUT_SLOT); if (slot != NULL && slot->hasItem()) { if (!slot->getItem()->hasCustomHoverName() && m_itemName.compare(slot->getItem()->getHoverName()) == 0) { @@ -210,14 +210,14 @@ void IUIScene_AnvilMenu::updateItemName() { void IUIScene_AnvilMenu::refreshContainer( AbstractContainerMenu* container, std::vector >* items) { - slotChanged(container, RepairMenu::INPUT_SLOT, + slotChanged(container, AnvilMenu::INPUT_SLOT, container->getSlot(0)->getItem()); } void IUIScene_AnvilMenu::slotChanged(AbstractContainerMenu* container, int slotIndex, std::shared_ptr item) { - if (slotIndex == RepairMenu::INPUT_SLOT) { + if (slotIndex == AnvilMenu::INPUT_SLOT) { m_itemName = item == NULL ? L"" : item->getHoverName(); setEditNameValue(m_itemName); setEditNameEditable(item != NULL); diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.h index d1789a860..5833471f8 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.h @@ -11,14 +11,14 @@ #define ANVIL_SCENE_ITEM2_SLOT_DOWN_OFFSET 4 class Inventory; -class RepairMenu; +class AnvilMenu; class IUIScene_AnvilMenu : public virtual IUIScene_AbstractContainerMenu, public net_minecraft_world_inventory::ContainerListener { protected: std::shared_ptr m_inventory; - RepairMenu* m_repairMenu; + AnvilMenu* m_repairMenu; std::wstring m_itemName; protected: diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp new file mode 100644 index 000000000..833b43076 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp @@ -0,0 +1,380 @@ +#include "../../stdafx.h" +#include "../../../../Minecraft.World/Network/Packets/CustomPayloadPacket.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.effect.h" +#include "../../../../Minecraft.World/Util/HtmlString.h" +#include "IUIScene_BeaconMenu.h" +#include "../../../Minecraft.h" +#include "../../../Player/MultiPlayerLocalPlayer.h" +#include "../../../Network/ClientConnection.h" + +IUIScene_BeaconMenu::IUIScene_BeaconMenu() { + m_beacon = nullptr; + m_initPowerButtons = true; +} + +IUIScene_AbstractContainerMenu::ESceneSection +IUIScene_BeaconMenu::GetSectionAndSlotInDirection(ESceneSection eSection, + ETapState eTapDirection, + int* piTargetX, + int* piTargetY) { + ESceneSection newSection = eSection; + + int xOffset = 0; + + // Find the new section if there is one + switch (eSection) { + case eSectionBeaconInventory: + if (eTapDirection == eTapStateDown) + newSection = eSectionBeaconUsing; + else if (eTapDirection == eTapStateUp) { + if (*piTargetX < 4) { + newSection = eSectionBeaconPrimaryTierThree; + } else if (*piTargetX < 7) { + newSection = eSectionBeaconItem; + } else { + newSection = eSectionBeaconConfirm; + } + } + break; + case eSectionBeaconUsing: + if (eTapDirection == eTapStateDown) { + if (*piTargetX < 2) { + newSection = eSectionBeaconPrimaryTierOneOne; + } else if (*piTargetX < 5) { + newSection = eSectionBeaconPrimaryTierOneTwo; + } else if (*piTargetX > 8 && + GetPowerButtonId(eSectionBeaconSecondaryTwo) > 0) { + newSection = eSectionBeaconSecondaryTwo; + } else { + newSection = eSectionBeaconSecondaryOne; + } + } else if (eTapDirection == eTapStateUp) + newSection = eSectionBeaconInventory; + break; + case eSectionBeaconItem: + if (eTapDirection == eTapStateDown) { + newSection = eSectionBeaconInventory; + xOffset = -5; + } else if (eTapDirection == eTapStateUp) + newSection = eSectionBeaconSecondaryOne; + else if (eTapDirection == eTapStateLeft) + newSection = eSectionBeaconConfirm; + else if (eTapDirection == eTapStateRight) + newSection = eSectionBeaconConfirm; + break; + case eSectionBeaconPrimaryTierOneOne: + if (eTapDirection == eTapStateDown) + newSection = eSectionBeaconPrimaryTierTwoOne; + else if (eTapDirection == eTapStateUp) { + newSection = eSectionBeaconUsing; + xOffset = -1; + } else if (eTapDirection == eTapStateLeft) + newSection = eSectionBeaconPrimaryTierOneTwo; + else if (eTapDirection == eTapStateRight) + newSection = eSectionBeaconPrimaryTierOneTwo; + break; + case eSectionBeaconPrimaryTierOneTwo: + if (eTapDirection == eTapStateDown) + newSection = eSectionBeaconPrimaryTierTwoTwo; + else if (eTapDirection == eTapStateUp) { + newSection = eSectionBeaconUsing; + xOffset = -3; + } else if (eTapDirection == eTapStateLeft) + newSection = eSectionBeaconPrimaryTierOneOne; + else if (eTapDirection == eTapStateRight) + newSection = eSectionBeaconPrimaryTierOneOne; + break; + case eSectionBeaconPrimaryTierTwoOne: + if (eTapDirection == eTapStateDown) + newSection = eSectionBeaconPrimaryTierThree; + else if (eTapDirection == eTapStateUp) + newSection = eSectionBeaconPrimaryTierOneOne; + else if (eTapDirection == eTapStateLeft) { + if (GetPowerButtonId(eSectionBeaconSecondaryTwo) > 0) { + newSection = eSectionBeaconSecondaryTwo; + } else { + newSection = eSectionBeaconSecondaryOne; + } + } else if (eTapDirection == eTapStateRight) + newSection = eSectionBeaconPrimaryTierTwoTwo; + break; + case eSectionBeaconPrimaryTierTwoTwo: + if (eTapDirection == eTapStateDown) + newSection = eSectionBeaconPrimaryTierThree; + else if (eTapDirection == eTapStateUp) + newSection = eSectionBeaconPrimaryTierOneTwo; + else if (eTapDirection == eTapStateLeft) + newSection = eSectionBeaconPrimaryTierTwoOne; + else if (eTapDirection == eTapStateRight) + newSection = eSectionBeaconSecondaryOne; + break; + case eSectionBeaconPrimaryTierThree: + if (eTapDirection == eTapStateDown) { + newSection = eSectionBeaconInventory; + xOffset = -3; + } else if (eTapDirection == eTapStateUp) + newSection = eSectionBeaconPrimaryTierTwoOne; + break; + case eSectionBeaconSecondaryOne: + if (eTapDirection == eTapStateDown) + newSection = eSectionBeaconItem; + else if (eTapDirection == eTapStateUp) { + newSection = eSectionBeaconUsing; + xOffset = -7; + } else if (eTapDirection == eTapStateLeft) + newSection = eSectionBeaconPrimaryTierTwoTwo; + else if (eTapDirection == eTapStateRight) { + if (GetPowerButtonId(eSectionBeaconSecondaryTwo) > 0) { + newSection = eSectionBeaconSecondaryTwo; + } else { + newSection = eSectionBeaconPrimaryTierTwoOne; + } + } + break; + case eSectionBeaconSecondaryTwo: + if (eTapDirection == eTapStateDown) + newSection = eSectionBeaconItem; + else if (eTapDirection == eTapStateUp) { + newSection = eSectionBeaconUsing; + xOffset = -8; + } else if (eTapDirection == eTapStateLeft) + newSection = eSectionBeaconSecondaryOne; + else if (eTapDirection == eTapStateRight) + newSection = eSectionBeaconPrimaryTierTwoOne; + break; + case eSectionBeaconConfirm: + if (eTapDirection == eTapStateDown) { + newSection = eSectionBeaconInventory; + xOffset = -8; + } else if (eTapDirection == eTapStateUp) { + newSection = eSectionBeaconSecondaryOne; + } else if (eTapDirection == eTapStateLeft) + newSection = eSectionBeaconItem; + else if (eTapDirection == eTapStateRight) + newSection = eSectionBeaconItem; + break; + default: + assert(false); + break; + } + + updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, + piTargetY, xOffset); + + return newSection; +} + +int IUIScene_BeaconMenu::getSectionStartOffset( + IUIScene_AbstractContainerMenu::ESceneSection eSection) { + int offset = 0; + switch (eSection) { + case eSectionBeaconItem: + offset = BeaconMenu::PAYMENT_SLOT; + break; + case eSectionBeaconInventory: + offset = BeaconMenu::INV_SLOT_START; + break; + case eSectionBeaconUsing: + offset = BeaconMenu::USE_ROW_SLOT_START; + break; + default: + assert(false); + break; + } + return offset; +} + +bool IUIScene_BeaconMenu::IsSectionSlotList(ESceneSection eSection) { + switch (eSection) { + case eSectionBeaconItem: + case eSectionBeaconInventory: + case eSectionBeaconUsing: + return true; + } + return false; +} + +void IUIScene_BeaconMenu::handleOtherClicked(int iPad, ESceneSection eSection, + int buttonNum, bool quickKey) { + switch (eSection) { + case eSectionBeaconConfirm: { + if ((m_beacon->getItem(0) == NULL) || + (m_beacon->getPrimaryPower() <= 0)) + return; + ByteArrayOutputStream baos; + DataOutputStream dos(&baos); + dos.writeInt(m_beacon->getPrimaryPower()); + dos.writeInt(m_beacon->getSecondaryPower()); + + Minecraft::GetInstance()->localplayers[getPad()]->connection->send( + std::shared_ptr(new CustomPayloadPacket( + CustomPayloadPacket::SET_BEACON_PACKET, + baos.toByteArray()))); + + if (m_beacon->getPrimaryPower() > 0) { + int effectId = m_beacon->getPrimaryPower(); + + bool active = true; + bool selected = false; + + int tier = 3; + if (tier >= m_beacon->getLevels()) { + active = false; + } else if (effectId == m_beacon->getSecondaryPower()) { + selected = true; + } + + AddPowerButton( + GetId(tier, m_beacon->getPrimaryPower()), + MobEffect::effects[m_beacon->getPrimaryPower()]->getIcon(), + tier, 1, active, selected); + } + } break; + case eSectionBeaconPrimaryTierOneOne: + case eSectionBeaconPrimaryTierOneTwo: + case eSectionBeaconPrimaryTierTwoOne: + case eSectionBeaconPrimaryTierTwoTwo: + case eSectionBeaconPrimaryTierThree: + case eSectionBeaconSecondaryOne: + case eSectionBeaconSecondaryTwo: + if (IsPowerButtonSelected(eSection)) { + return; + } + + int id = GetPowerButtonId(eSection); + int effectId = (id & 0xff); + int tier = (id >> 8); + + if (tier < 3) { + m_beacon->setPrimaryPower(effectId); + } else { + m_beacon->setSecondaryPower(effectId); + } + SetPowerButtonSelected(eSection); + break; + }; +} + +void IUIScene_BeaconMenu::handleTick() { + if (m_initPowerButtons && m_beacon->getLevels() >= 0) { + m_initPowerButtons = false; + for (int tier = 0; tier <= 2; tier++) { + int count = BeaconTileEntity:: + BEACON_EFFECTS_EFFECTS; // BEACON_EFFECTS[tier].length; + int totalWidth = count * 22 + (count - 1) * 2; + + for (int c = 0; c < count; c++) { + if (BeaconTileEntity::BEACON_EFFECTS[tier][c] == NULL) continue; + + int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id; + int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon(); + + bool active = true; + bool selected = false; + + if (tier >= m_beacon->getLevels()) { + active = false; + } else if (effectId == m_beacon->getPrimaryPower()) { + selected = true; + } + + AddPowerButton(GetId(tier, effectId), icon, tier, c, active, + selected); + } + } + + { + int tier = 3; + + int count = BeaconTileEntity::BEACON_EFFECTS_EFFECTS + + 1; // BEACON_EFFECTS[tier].length + 1; + int totalWidth = count * 22 + (count - 1) * 2; + + for (int c = 0; c < count - 1; c++) { + if (BeaconTileEntity::BEACON_EFFECTS[tier][c] == NULL) continue; + + int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id; + int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon(); + + bool active = true; + bool selected = false; + + if (tier >= m_beacon->getLevels()) { + active = false; + } else if (effectId == m_beacon->getSecondaryPower()) { + selected = true; + } + + AddPowerButton(GetId(tier, effectId), icon, tier, c, active, + selected); + } + if (m_beacon->getPrimaryPower() > 0) { + int effectId = m_beacon->getPrimaryPower(); + + bool active = true; + bool selected = false; + + if (tier >= m_beacon->getLevels()) { + active = false; + } else if (effectId == m_beacon->getSecondaryPower()) { + selected = true; + } + + AddPowerButton( + GetId(tier, m_beacon->getPrimaryPower()), + MobEffect::effects[m_beacon->getPrimaryPower()]->getIcon(), + tier, 1, active, selected); + } + } + } + + SetConfirmButtonEnabled((m_beacon->getItem(0) != NULL) && + (m_beacon->getPrimaryPower() > 0)); +} + +int IUIScene_BeaconMenu::GetId(int tier, int effectId) { + return (tier << 8) | effectId; +} + +std::vector* IUIScene_BeaconMenu::GetSectionHoverText( + ESceneSection eSection) { + std::vector* desc = NULL; + switch (eSection) { + case eSectionBeaconSecondaryTwo: + if (GetPowerButtonId(eSectionBeaconSecondaryTwo) == 0) { + // This isn't visible + break; + } + // Fall through otherwise + case eSectionBeaconPrimaryTierOneOne: + case eSectionBeaconPrimaryTierOneTwo: + case eSectionBeaconPrimaryTierTwoOne: + case eSectionBeaconPrimaryTierTwoTwo: + case eSectionBeaconPrimaryTierThree: + case eSectionBeaconSecondaryOne: { + int id = GetPowerButtonId(eSection); + int effectId = (id & 0xff); + + desc = new std::vector(); + + HtmlString std::string( + app.GetString(MobEffect::effects[effectId]->getDescriptionId()), + eHTMLColor_White); + desc->push_back(std::string); + } break; + } + return desc; +} + +bool IUIScene_BeaconMenu::IsVisible(ESceneSection eSection) { + switch (eSection) { + case eSectionBeaconSecondaryTwo: + if (GetPowerButtonId(eSectionBeaconSecondaryTwo) == 0) { + // This isn't visible + return false; + } + } + return true; +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.h new file mode 100644 index 000000000..f09bef038 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.h @@ -0,0 +1,35 @@ +#pragma once +#include "Common/UI/IUIScene_AbstractContainerMenu.h" + +class BeaconTileEntity; + +class IUIScene_BeaconMenu : public virtual IUIScene_AbstractContainerMenu { +public: + IUIScene_BeaconMenu(); + + virtual ESceneSection GetSectionAndSlotInDirection(ESceneSection eSection, + ETapState eTapDirection, + int* piTargetX, + int* piTargetY); + int getSectionStartOffset(ESceneSection eSection); + virtual void handleOtherClicked(int iPad, ESceneSection eSection, + int buttonNum, bool quickKey); + virtual bool IsSectionSlotList(ESceneSection eSection); + virtual std::vector* GetSectionHoverText( + ESceneSection eSection); + bool IsVisible(ESceneSection eSection); + +protected: + void handleTick(); + int GetId(int tier, int effectId); + + virtual void SetConfirmButtonEnabled(bool enabled) = 0; + virtual void AddPowerButton(int id, int icon, int tier, int count, + bool active, bool selected) = 0; + virtual int GetPowerButtonId(ESceneSection eSection) = 0; + virtual bool IsPowerButtonSelected(ESceneSection eSection) = 0; + virtual void SetPowerButtonSelected(ESceneSection eSection) = 0; + + std::shared_ptr m_beacon; + bool m_initPowerButtons; +}; diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CommandBlockMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_CommandBlockMenu.cpp new file mode 100644 index 000000000..ae5bbf32f --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CommandBlockMenu.cpp @@ -0,0 +1,25 @@ +#include "../../stdafx.h" +#include "../../../../Minecraft.World/Network/Packets/CustomPayloadPacket.h" +#include "../../../Player/MultiPlayerLocalPlayer.h" +#include "../../../Network/ClientConnection.h" +#include "IUIScene_CommandBlockMenu.h" + +void IUIScene_CommandBlockMenu::Initialise(CommandBlockEntity* commandBlock) { + m_commandBlock = commandBlock; + SetCommand(m_commandBlock->getCommand()); +} + +void IUIScene_CommandBlockMenu::ConfirmButtonClicked() { + ByteArrayOutputStream baos; + DataOutputStream dos(&baos); + + dos.writeInt(m_commandBlock->x); + dos.writeInt(m_commandBlock->y); + dos.writeInt(m_commandBlock->z); + dos.writeUTF(GetCommand()); + + Minecraft::GetInstance()->localplayers[GetPad()]->connection->send( + std::shared_ptr(new CustomPayloadPacket( + CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET, + baos.toByteArray()))); +} diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CommandBlockMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_CommandBlockMenu.h new file mode 100644 index 000000000..67cc20d1c --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CommandBlockMenu.h @@ -0,0 +1,17 @@ +#pragma once +#include "../../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h" + +class IUIScene_CommandBlockMenu { +public: + void Initialise(CommandBlockEntity* commandBlock); + +protected: + void ConfirmButtonClicked(); + + virtual std::wstring GetCommand(); + virtual void SetCommand(std::wstring command); + virtual int GetPad(); + +private: + CommandBlockEntity* m_commandBlock; +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp index 6570b22d3..635258901 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp @@ -254,130 +254,142 @@ bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) { // L"random.pop", 1.0f, 1.0f); ui.PlayUISFX(eSFX_Craft); - // and remove those resources from your inventory - for (int i = 0; - i < pRecipeIngredientsRequired[iRecipe].iIngC; - i++) { - for (int j = 0; - j < pRecipeIngredientsRequired[iRecipe] - .iIngValA[i]; - j++) { - std::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( + if (pTempItemInst->id != Item::fireworksCharge_Id && + pTempItemInst->id != Item::fireworks_Id) { + // and remove those resources from your inventory + for (int i = 0; + i < pRecipeIngredientsRequired[iRecipe].iIngC; + i++) { + for (int j = 0; + j < pRecipeIngredientsRequired[iRecipe] + .iIngValA[i]; + j++) { + std::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]); - m_pPlayer->inventory->removeResource( - pRecipeIngredientsRequired[iRecipe] - .iIngIDA[i], - pRecipeIngredientsRequired[iRecipe] - .iIngAuxValA[i]); - } else { - ingItemInst = - m_pPlayer->inventory->getResourceItem( + } else { + ingItemInst = + m_pPlayer->inventory + ->getResourceItem( + pRecipeIngredientsRequired + [iRecipe] + .iIngIDA[i]); + m_pPlayer->inventory->removeResource( 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 != NULL) { - if (ingItemInst->getItem() - ->hasCraftingRemainingItem()) { - // replace item with remaining result - m_pPlayer->inventory->add( - std::shared_ptr< - ItemInstance>(new ItemInstance( - ingItemInst->getItem() - ->getCraftingRemainingItem()))); + // 4J Stu - Fix for #13097 - Bug: Milk + // Buckets are removed when crafting Cake + if (ingItemInst != NULL) { + if (ingItemInst->getItem() + ->hasCraftingRemainingItem()) { + // replace item with remaining + // result + m_pPlayer->inventory->add( + std::shared_ptr< + ItemInstance>(new ItemInstance( + 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 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::workBench_Id: - m_pPlayer->awardStat( - GenericStats::buildWorkbench(), - GenericStats::param_buildWorkbench()); - break; - case Item::pickAxe_wood_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::hoe_wood_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::pickAxe_stone_Id: - m_pPlayer->awardStat( - GenericStats::buildBetterPickaxe(), - GenericStats::param_buildBetterPickaxe()); - break; - case Item::sword_wood_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::enchantTable_Id: - m_pPlayer->awardStat( - GenericStats::enchantments(), - GenericStats::param_enchantments()); - break; - case Tile::bookshelf_Id: - m_pPlayer->awardStat( - GenericStats::bookcase(), - GenericStats::param_bookcase()); - break; - } + // 4J Gordon: Achievements + switch (pTempItemInst->id) { + case Tile::workBench_Id: + m_pPlayer->awardStat( + GenericStats::buildWorkbench(), + GenericStats::param_buildWorkbench()); + break; + case Item::pickAxe_wood_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::hoe_wood_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::pickAxe_stone_Id: + m_pPlayer->awardStat( + GenericStats::buildBetterPickaxe(), + GenericStats:: + param_buildBetterPickaxe()); + break; + case Item::sword_wood_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::enchantTable_Id: + m_pPlayer->awardStat( + GenericStats::enchantments(), + GenericStats::param_enchantments()); + break; + case Tile::bookshelf_Id: + m_pPlayer->awardStat( + GenericStats::bookcase(), + GenericStats::param_bookcase()); + 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(); + // 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 { // pMinecraft->soundEngine->playUI( // L"btn.back", 1.0f, 1.0f); @@ -1090,6 +1102,27 @@ void IUIScene_CraftingMenu::DisplayIngredients() { int id = pRecipeIngredientsRequired[iRecipe].iIngIDA[i]; int iAuxVal = pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]; Item* item = Item::items[id]; + + std::shared_ptr itemInst = + std::shared_ptr(new ItemInstance( + 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 { + 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; @@ -1100,29 +1133,10 @@ void IUIScene_CraftingMenu::DisplayIngredients() { if (id == Item::clock_Id || id == Item::compass_Id) { iAuxVal = 0xFF; } - - std::shared_ptr itemInst = - std::shared_ptr(new ItemInstance( - item, pRecipeIngredientsRequired[iRecipe].iIngValA[i], - iAuxVal)); + itemInst->setAuxValue(iAuxVal); setIngredientDescriptionItem(getPad(), i, itemInst); setIngredientDescriptionRedBox(i, false); - - // 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::cloth_Id)) || - ((pTempItemInst->id == Item::painting_Id) && - (id == Tile::cloth_Id))) { - idescID = IDS_ANY_WOOL; - } else { - idescID = itemInst->getDescriptionId(); - } - setIngredientDescriptionText(i, app.GetString(idescID)); } // 4J Stu - For clocks and compasses we set the aux value to a special @@ -1166,6 +1180,9 @@ void IUIScene_CraftingMenu::DisplayIngredients() { // 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::fireworksCharge_Id && + id == Item::dye_powder_Id) { + iAuxVal = 1; } std::shared_ptr itemInst = std::shared_ptr( @@ -1378,6 +1395,14 @@ void IUIScene_CraftingMenu::UpdateTooltips() { }*/ } +void IUIScene_CraftingMenu::HandleInventoryUpdated() { + // Check which recipes are available with the resources we have + CheckRecipesAvailable(); + UpdateVerticalSlots(); + UpdateHighlight(); + UpdateTooltips(); +} + bool IUIScene_CraftingMenu::isItemSelected(int itemId) { bool isSelected = false; if (m_pPlayer && m_pPlayer->inventory) { diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.h index c2d5d8cec..f446d8a27 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.h @@ -78,6 +78,7 @@ protected: void DisplayIngredients(); void UpdateTooltips(); void UpdateDescriptionText(bool); + void HandleInventoryUpdated(); public: Recipy::_eGroupType getCurrentGroup() { return m_pGroupA[m_iGroupIndex]; } diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp index dd7527b9e..426d6deb1 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp @@ -27,14 +27,15 @@ void IUIScene_CreativeMenu::staticCtor() { // Building Blocks DEF(eCreativeInventory_BuildingBlocks) - ITEM(Tile::rock_Id) + ITEM(Tile::stone_Id) ITEM(Tile::grass_Id) ITEM(Tile::dirt_Id) - ITEM(Tile::stoneBrick_Id) + ITEM(Tile::cobblestone_Id) ITEM(Tile::sand_Id) ITEM(Tile::sandStone_Id) ITEM_AUX(Tile::sandStone_Id, SandStoneTile::TYPE_SMOOTHSIDE) ITEM_AUX(Tile::sandStone_Id, SandStoneTile::TYPE_HEIROGLYPHS) + ITEM(Tile::coalBlock_Id) ITEM(Tile::goldBlock_Id) ITEM(Tile::ironBlock_Id) ITEM(Tile::lapisBlock_Id) @@ -60,24 +61,29 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM_AUX(Tile::treeTrunk_Id, TreeTile::JUNGLE_TRUNK) ITEM(Tile::gravel_Id) ITEM(Tile::redBrick_Id) - ITEM(Tile::mossStone_Id) + ITEM(Tile::mossyCobblestone_Id) ITEM(Tile::obsidian_Id) ITEM(Tile::clay) ITEM(Tile::ice_Id) ITEM(Tile::snow_Id) - ITEM(Tile::hellRock_Id) - ITEM(Tile::hellSand_Id) - ITEM(Tile::lightGem_Id) - ITEM_AUX(Tile::stoneBrickSmooth_Id, SmoothStoneBrickTile::TYPE_DEFAULT) - ITEM_AUX(Tile::stoneBrickSmooth_Id, SmoothStoneBrickTile::TYPE_MOSSY) - ITEM_AUX(Tile::stoneBrickSmooth_Id, SmoothStoneBrickTile::TYPE_CRACKED) - ITEM_AUX(Tile::stoneBrickSmooth_Id, SmoothStoneBrickTile::TYPE_DETAIL) + ITEM(Tile::netherRack_Id) + ITEM(Tile::soulsand_Id) + ITEM(Tile::glowstone_Id) + ITEM(Tile::fence_Id) + ITEM(Tile::netherFence_Id) + ITEM(Tile::ironFence_Id) + ITEM_AUX(Tile::cobbleWall_Id, WallTile::TYPE_NORMAL) + ITEM_AUX(Tile::cobbleWall_Id, WallTile::TYPE_MOSSY) + ITEM_AUX(Tile::stoneBrick_Id, SmoothStoneBrickTile::TYPE_DEFAULT) + ITEM_AUX(Tile::stoneBrick_Id, SmoothStoneBrickTile::TYPE_MOSSY) + ITEM_AUX(Tile::stoneBrick_Id, SmoothStoneBrickTile::TYPE_CRACKED) + ITEM_AUX(Tile::stoneBrick_Id, SmoothStoneBrickTile::TYPE_DETAIL) ITEM_AUX(Tile::monsterStoneEgg_Id, StoneMonsterTile::HOST_ROCK) ITEM_AUX(Tile::monsterStoneEgg_Id, StoneMonsterTile::HOST_COBBLE) ITEM_AUX(Tile::monsterStoneEgg_Id, StoneMonsterTile::HOST_STONEBRICK) ITEM(Tile::mycel_Id) ITEM(Tile::netherBrick_Id) - ITEM(Tile::whiteStone_Id) + ITEM(Tile::endStone_Id) ITEM_AUX(Tile::quartzBlock_Id, QuartzBlockTile::TYPE_CHISELED) ITEM_AUX(Tile::quartzBlock_Id, QuartzBlockTile::TYPE_LINES_Y) ITEM(Tile::trapdoor_Id) @@ -103,11 +109,29 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM(Tile::stairs_junglewood_Id) ITEM(Tile::stairs_stone_Id) ITEM(Tile::stairs_bricks_Id) - ITEM(Tile::stairs_stoneBrickSmooth_Id) + ITEM(Tile::stairs_stoneBrick_Id) ITEM(Tile::stairs_netherBricks_Id) ITEM(Tile::stairs_sandstone_Id) ITEM(Tile::stairs_quartz_Id) + ITEM(Tile::clayHardened_Id) + ITEM_AUX(Tile::clayHardened_colored_Id, 14) // Red + ITEM_AUX(Tile::clayHardened_colored_Id, 1) // Orange + ITEM_AUX(Tile::clayHardened_colored_Id, 4) // Yellow + ITEM_AUX(Tile::clayHardened_colored_Id, 5) // Lime + ITEM_AUX(Tile::clayHardened_colored_Id, 3) // Light Blue + ITEM_AUX(Tile::clayHardened_colored_Id, 9) // Cyan + ITEM_AUX(Tile::clayHardened_colored_Id, 11) // Blue + ITEM_AUX(Tile::clayHardened_colored_Id, 10) // Purple + ITEM_AUX(Tile::clayHardened_colored_Id, 2) // Magenta + ITEM_AUX(Tile::clayHardened_colored_Id, 6) // Pink + ITEM_AUX(Tile::clayHardened_colored_Id, 0) // White + ITEM_AUX(Tile::clayHardened_colored_Id, 8) // Light Gray + ITEM_AUX(Tile::clayHardened_colored_Id, 7) // Gray + ITEM_AUX(Tile::clayHardened_colored_Id, 15) // Black + ITEM_AUX(Tile::clayHardened_colored_Id, 13) // Green + ITEM_AUX(Tile::clayHardened_colored_Id, 12) // Brown + // Decoration DEF(eCreativeInventory_Decoration) ITEM_AUX(Item::skull_Id, SkullTileEntity::TYPE_SKELETON) @@ -136,8 +160,8 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM(Tile::deadBush_Id) ITEM(Tile::flower_Id) ITEM(Tile::rose_Id) - ITEM(Tile::mushroom1_Id) - ITEM(Tile::mushroom2_Id) + ITEM(Tile::mushroom_brown_Id) + ITEM(Tile::mushroom_red_Id) ITEM(Tile::cactus_Id) ITEM(Tile::topSnow_Id) // 4J-PB - Already got sugar cane in Materials ITEM_11(Tile::reeds_Id) @@ -149,22 +173,23 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM(Item::sign_Id) ITEM(Tile::bookshelf_Id) ITEM(Item::flowerPot_Id) - ITEM_AUX(Tile::cloth_Id, 14) // Red - ITEM_AUX(Tile::cloth_Id, 1) // Orange - ITEM_AUX(Tile::cloth_Id, 4) // Yellow - ITEM_AUX(Tile::cloth_Id, 5) // Lime - ITEM_AUX(Tile::cloth_Id, 3) // Light Blue - ITEM_AUX(Tile::cloth_Id, 9) // Cyan - ITEM_AUX(Tile::cloth_Id, 11) // Blue - ITEM_AUX(Tile::cloth_Id, 10) // Purple - ITEM_AUX(Tile::cloth_Id, 2) // Magenta - ITEM_AUX(Tile::cloth_Id, 6) // Pink - ITEM_AUX(Tile::cloth_Id, 0) // White - ITEM_AUX(Tile::cloth_Id, 8) // Light Gray - ITEM_AUX(Tile::cloth_Id, 7) // Gray - ITEM_AUX(Tile::cloth_Id, 15) // Black - ITEM_AUX(Tile::cloth_Id, 13) // Green - ITEM_AUX(Tile::cloth_Id, 12) // Brown + ITEM(Tile::hayBlock_Id) + 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::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, 6) // Pink + 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::woolCarpet_Id, 14) // Red ITEM_AUX(Tile::woolCarpet_Id, 1) // Orange @@ -183,10 +208,108 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM_AUX(Tile::woolCarpet_Id, 13) // Green ITEM_AUX(Tile::woolCarpet_Id, 12) // Brown +#if 0 + 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,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,6) // Pink + 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,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,6) // Pink + 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 +#endif + +#ifndef _CONTENT_PACKAGE + DEF(eCreativeInventory_ArtToolsDecorations) + if (app.DebugSettingsOn()) { + for (unsigned int i = 0; i < Painting::LAST_VALUE; ++i) { + ITEM_AUX(Item::painting_Id, i + 1) + } + + BuildFirework(list, FireworksItem::TYPE_BIG, DyePowderItem::PURPLE, 1, + false, false); + + BuildFirework(list, FireworksItem::TYPE_SMALL, DyePowderItem::RED, 1, + false, false); + BuildFirework(list, FireworksItem::TYPE_SMALL, DyePowderItem::RED, 2, + false, false); + BuildFirework(list, FireworksItem::TYPE_SMALL, DyePowderItem::RED, 3, + false, false); + + BuildFirework(list, FireworksItem::TYPE_BURST, DyePowderItem::GREEN, 1, + false, true); + BuildFirework(list, FireworksItem::TYPE_CREEPER, DyePowderItem::BLUE, 1, + true, false); + BuildFirework(list, FireworksItem::TYPE_STAR, DyePowderItem::YELLOW, 1, + false, false); + BuildFirework(list, FireworksItem::TYPE_BIG, DyePowderItem::WHITE, 1, + true, true); + + 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, 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, 6) // Pink + 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, 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, 6) // Pink + 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 + } +#endif + // Redstone DEF(eCreativeInventory_Redstone) ITEM(Tile::dispenser_Id) - ITEM(Tile::musicBlock_Id) + ITEM(Tile::noteblock_Id) ITEM(Tile::pistonBase_Id) ITEM(Tile::pistonStickyBase_Id) ITEM(Tile::tnt_Id) @@ -196,20 +319,31 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM(Tile::pressurePlate_stone_Id) ITEM(Tile::pressurePlate_wood_Id) ITEM(Item::redStone_Id) - ITEM(Tile::notGate_on_Id) - ITEM(Item::diode_Id) + ITEM(Tile::redstoneBlock_Id) + ITEM(Tile::redstoneTorch_on_Id) + ITEM(Item::repeater_Id) ITEM(Tile::redstoneLight_Id) ITEM(Tile::tripWireSource_Id) + ITEM(Tile::daylightDetector_Id) + ITEM(Tile::dropper_Id) + ITEM(Tile::hopper_Id) + ITEM(Item::comparator_Id) + ITEM(Tile::chest_trap_Id) + ITEM(Tile::weightedPlate_heavy_Id) + ITEM(Tile::weightedPlate_light_Id) // Transport DEF(eCreativeInventory_Transport) ITEM(Tile::rail_Id) ITEM(Tile::goldenRail_Id) ITEM(Tile::detectorRail_Id) + ITEM(Tile::activatorRail_Id) ITEM(Tile::ladder_Id) ITEM(Item::minecart_Id) ITEM(Item::minecart_chest_Id) ITEM(Item::minecart_furnace_Id) + ITEM(Item::minecart_hopper_Id) + ITEM(Item::minecart_tnt_Id) ITEM(Item::saddle_Id) ITEM(Item::boat_Id) @@ -221,25 +355,51 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM(Tile::furnace_Id) ITEM(Item::brewingStand_Id) ITEM(Tile::enchantTable_Id) + ITEM(Tile::beacon_Id) ITEM(Tile::endPortalFrameTile_Id) - ITEM(Tile::recordPlayer_Id) + ITEM(Tile::jukebox_Id) ITEM(Tile::anvil_Id); - ITEM(Tile::fence_Id) - ITEM(Tile::netherFence_Id) - ITEM(Tile::ironFence_Id) - ITEM_AUX(Tile::cobbleWall_Id, WallTile::TYPE_NORMAL) - ITEM_AUX(Tile::cobbleWall_Id, WallTile::TYPE_MOSSY) ITEM(Item::bed_Id) ITEM(Item::bucket_empty_Id) ITEM(Item::bucket_lava_Id) ITEM(Item::bucket_water_Id) - ITEM(Item::milk_Id) + ITEM(Item::bucket_milk_Id) ITEM(Item::cauldron_Id) ITEM(Item::snowBall_Id) ITEM(Item::paper_Id) ITEM(Item::book_Id) ITEM(Item::enderPearl_Id) ITEM(Item::eyeOfEnder_Id) + ITEM(Item::nameTag_Id) + ITEM(Item::netherStar_Id) + ITEM_AUX(Item::spawnEgg_Id, 50); // Creeper + ITEM_AUX(Item::spawnEgg_Id, 51); // Skeleton + ITEM_AUX(Item::spawnEgg_Id, 52); // Spider + ITEM_AUX(Item::spawnEgg_Id, 54); // Zombie + ITEM_AUX(Item::spawnEgg_Id, 55); // Slime + ITEM_AUX(Item::spawnEgg_Id, 56); // Ghast + ITEM_AUX(Item::spawnEgg_Id, 57); // Zombie Pigman + ITEM_AUX(Item::spawnEgg_Id, 58); // Enderman + ITEM_AUX(Item::spawnEgg_Id, 59); // Cave Spider + ITEM_AUX(Item::spawnEgg_Id, 60); // Silverfish + ITEM_AUX(Item::spawnEgg_Id, 61); // Blaze + ITEM_AUX(Item::spawnEgg_Id, 62); // Magma Cube + ITEM_AUX(Item::spawnEgg_Id, 65); // Bat + ITEM_AUX(Item::spawnEgg_Id, 66); // Witch + ITEM_AUX(Item::spawnEgg_Id, 90); // Pig + ITEM_AUX(Item::spawnEgg_Id, 91); // Sheep + ITEM_AUX(Item::spawnEgg_Id, 92); // Cow + ITEM_AUX(Item::spawnEgg_Id, 93); // Chicken + ITEM_AUX(Item::spawnEgg_Id, 94); // Squid + ITEM_AUX(Item::spawnEgg_Id, 95); // Wolf + ITEM_AUX(Item::spawnEgg_Id, 96); // Mooshroom + ITEM_AUX(Item::spawnEgg_Id, 98); // Ozelot + ITEM_AUX(Item::spawnEgg_Id, 100); // Horse + ITEM_AUX(Item::spawnEgg_Id, + 100 | ((EntityHorse::TYPE_DONKEY + 1) << 12)); // Donkey + ITEM_AUX(Item::spawnEgg_Id, + 100 | ((EntityHorse::TYPE_MULE + 1) << 12)); // Mule + ITEM_AUX(Item::spawnEgg_Id, 120); // Villager ITEM(Item::record_01_Id) ITEM(Item::record_02_Id) ITEM(Item::record_03_Id) @@ -252,27 +412,32 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM(Item::record_10_Id) ITEM(Item::record_11_Id) ITEM(Item::record_12_Id) - ITEM_AUX(Item::monsterPlacer_Id, 50); // Creeper - ITEM_AUX(Item::monsterPlacer_Id, 51); // Skeleton - ITEM_AUX(Item::monsterPlacer_Id, 52); // Spider - ITEM_AUX(Item::monsterPlacer_Id, 54); // Zombie - ITEM_AUX(Item::monsterPlacer_Id, 55); // Slime - ITEM_AUX(Item::monsterPlacer_Id, 56); // Ghast - ITEM_AUX(Item::monsterPlacer_Id, 57); // Zombie Pigman - ITEM_AUX(Item::monsterPlacer_Id, 58); // Enderman - ITEM_AUX(Item::monsterPlacer_Id, 59); // Cave Spider - ITEM_AUX(Item::monsterPlacer_Id, 60); // Silverfish - ITEM_AUX(Item::monsterPlacer_Id, 61); // Blaze - ITEM_AUX(Item::monsterPlacer_Id, 62); // Magma Cube - ITEM_AUX(Item::monsterPlacer_Id, 90); // Pig - ITEM_AUX(Item::monsterPlacer_Id, 91); // Sheep - ITEM_AUX(Item::monsterPlacer_Id, 92); // Cow - ITEM_AUX(Item::monsterPlacer_Id, 93); // Chicken - ITEM_AUX(Item::monsterPlacer_Id, 94); // Squid - ITEM_AUX(Item::monsterPlacer_Id, 95); // Wolf - ITEM_AUX(Item::monsterPlacer_Id, 96); // Mooshroom - ITEM_AUX(Item::monsterPlacer_Id, 98); // Ozelot - ITEM_AUX(Item::monsterPlacer_Id, 120); // Villager + + BuildFirework(list, FireworksItem::TYPE_SMALL, DyePowderItem::LIGHT_BLUE, 1, + true, false); + BuildFirework(list, FireworksItem::TYPE_CREEPER, DyePowderItem::GREEN, 2, + false, false); + BuildFirework(list, FireworksItem::TYPE_MAX, DyePowderItem::RED, 2, false, + false, DyePowderItem::ORANGE); + BuildFirework(list, FireworksItem::TYPE_BURST, DyePowderItem::MAGENTA, 3, + true, false, DyePowderItem::BLUE); + BuildFirework(list, FireworksItem::TYPE_STAR, DyePowderItem::YELLOW, 2, + false, true, DyePowderItem::ORANGE); + +#ifndef _CONTENT_PACKAGE + DEF(eCreativeInventory_ArtToolsMisc) + if (app.DebugSettingsOn()) { + ITEM_AUX(Item::spawnEgg_Id, + 100 | ((EntityHorse::TYPE_SKELETON + 1) << 12)); // Skeleton + ITEM_AUX(Item::spawnEgg_Id, + 100 | ((EntityHorse::TYPE_UNDEAD + 1) << 12)); // Zombie + ITEM_AUX(Item::spawnEgg_Id, 98 | ((Ocelot::TYPE_BLACK + 1) << 12)); + ITEM_AUX(Item::spawnEgg_Id, 98 | ((Ocelot::TYPE_RED + 1) << 12)); + ITEM_AUX(Item::spawnEgg_Id, 98 | ((Ocelot::TYPE_SIAMESE + 1) << 12)); + ITEM_AUX(Item::spawnEgg_Id, 52 | (2 << 12)); // Spider-Jockey + ITEM_AUX(Item::spawnEgg_Id, 63); // Enderdragon + } +#endif // Food DEF(eCreativeInventory_Food) @@ -304,17 +469,17 @@ void IUIScene_CreativeMenu::staticCtor() { // Tools, Armour and Weapons (Complete) DEF(eCreativeInventory_ToolsArmourWeapons) ITEM(Item::compass_Id) - ITEM(Item::helmet_cloth_Id) - ITEM(Item::chestplate_cloth_Id) - ITEM(Item::leggings_cloth_Id) - ITEM(Item::boots_cloth_Id) + ITEM(Item::helmet_leather_Id) + ITEM(Item::chestplate_leather_Id) + ITEM(Item::leggings_leather_Id) + ITEM(Item::boots_leather_Id) ITEM(Item::sword_wood_Id) ITEM(Item::shovel_wood_Id) ITEM(Item::pickAxe_wood_Id) ITEM(Item::hatchet_wood_Id) ITEM(Item::hoe_wood_Id) - ITEM(Item::map_Id) + ITEM(Item::emptyMap_Id) ITEM(Item::helmet_chain_Id) ITEM(Item::chestplate_chain_Id) ITEM(Item::leggings_chain_Id) @@ -363,6 +528,10 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM(Item::shears_Id) ITEM(Item::fishingRod_Id) ITEM(Item::carrotOnAStick_Id) + ITEM(Item::lead_Id) + ITEM(Item::horseArmorDiamond_Id) + ITEM(Item::horseArmorGold_Id) + ITEM(Item::horseArmorMetal_Id) for (unsigned int i = 0; i < Enchantment::enchantments.length; ++i) { Enchantment* enchantment = Enchantment::enchantments[i]; @@ -371,6 +540,17 @@ void IUIScene_CreativeMenu::staticCtor() { new EnchantmentInstance(enchantment, enchantment->getMaxLevel()))); } +#ifndef _CONTENT_PACKAGE + if (app.DebugSettingsOn()) { + std::shared_ptr debugSword = + std::shared_ptr( + new ItemInstance(Item::sword_diamond_Id, 1, 0)); + debugSword->enchant(Enchantment::damageBonus, 50); + debugSword->setHoverName(L"Sword of Debug"); + list->push_back(debugSword); + } +#endif + // Materials DEF(eCreativeInventory_Materials) ITEM(Item::coal_Id) @@ -389,7 +569,7 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM(Item::feather_Id) ITEM(Item::flint_Id) ITEM(Item::leather_Id) - ITEM(Item::sulphur_Id) + ITEM(Item::gunpowder_Id) ITEM(Item::clay_Id) ITEM(Item::yellowDust_Id) ITEM(Item::seeds_wheat_Id) @@ -402,7 +582,7 @@ void IUIScene_CreativeMenu::staticCtor() { ITEM(Item::slimeBall_Id) ITEM(Item::blazeRod_Id) ITEM(Item::goldNugget_Id) - ITEM(Item::netherStalkSeeds_Id) + ITEM(Item::netherwart_seeds_Id) ITEM_AUX(Item::dye_powder_Id, 1) // Red ITEM_AUX(Item::dye_powder_Id, 14) // Orange ITEM_AUX(Item::dye_powder_Id, 11) // Yellow @@ -641,32 +821,42 @@ void IUIScene_CreativeMenu::staticCtor() { ECreative_Inventory_Groups blocksGroup[] = { eCreativeInventory_BuildingBlocks}; specs[eCreativeInventoryTab_BuildingBlocks] = new TabSpec( - L"Structures", IDS_GROUPNAME_BUILDING_BLOCKS, 1, blocksGroup, 0, NULL); + L"Structures", IDS_GROUPNAME_BUILDING_BLOCKS, 1, blocksGroup); +#ifndef _CONTENT_PACKAGE + ECreative_Inventory_Groups decorationsGroup[] = { + eCreativeInventory_Decoration}; + ECreative_Inventory_Groups debugDecorationsGroup[] = { + eCreativeInventory_ArtToolsDecorations}; + specs[eCreativeInventoryTab_Decorations] = + new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, + decorationsGroup, 0, NULL, 1, debugDecorationsGroup); +#else ECreative_Inventory_Groups decorationsGroup[] = { eCreativeInventory_Decoration}; specs[eCreativeInventoryTab_Decorations] = new TabSpec( - L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, NULL); + L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup); +#endif ECreative_Inventory_Groups redAndTranGroup[] = { eCreativeInventory_Transport, eCreativeInventory_Redstone}; - specs[eCreativeInventoryTab_RedstoneAndTransport] = new TabSpec( - L"RedstoneAndTransport", IDS_GROUPNAME_REDSTONE_AND_TRANSPORT, 2, - redAndTranGroup, 0, NULL); + specs[eCreativeInventoryTab_RedstoneAndTransport] = + new TabSpec(L"RedstoneAndTransport", + IDS_GROUPNAME_REDSTONE_AND_TRANSPORT, 2, redAndTranGroup); ECreative_Inventory_Groups materialsGroup[] = { eCreativeInventory_Materials}; - specs[eCreativeInventoryTab_Materials] = new TabSpec( - L"Materials", IDS_GROUPNAME_MATERIALS, 1, materialsGroup, 0, NULL); + specs[eCreativeInventoryTab_Materials] = + new TabSpec(L"Materials", IDS_GROUPNAME_MATERIALS, 1, materialsGroup); ECreative_Inventory_Groups foodGroup[] = {eCreativeInventory_Food}; specs[eCreativeInventoryTab_Food] = - new TabSpec(L"Food", IDS_GROUPNAME_FOOD, 1, foodGroup, 0, NULL); + new TabSpec(L"Food", IDS_GROUPNAME_FOOD, 1, foodGroup); ECreative_Inventory_Groups toolsGroup[] = { eCreativeInventory_ToolsArmourWeapons}; - specs[eCreativeInventoryTab_ToolsWeaponsArmor] = new TabSpec( - L"Tools", IDS_GROUPNAME_TOOLS_WEAPONS_ARMOR, 1, toolsGroup, 0, NULL); + specs[eCreativeInventoryTab_ToolsWeaponsArmor] = + new TabSpec(L"Tools", IDS_GROUPNAME_TOOLS_WEAPONS_ARMOR, 1, toolsGroup); ECreative_Inventory_Groups brewingGroup[] = { eCreativeInventory_Brewing, eCreativeInventory_Potions_Level2_Extended, @@ -677,8 +867,8 @@ void IUIScene_CreativeMenu::staticCtor() { // In 480p there's not enough room for the LT button, so use text instead // if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) { - specs[eCreativeInventoryTab_Brewing] = new TabSpec( - L"Brewing", IDS_GROUPNAME_POTIONS_480, 5, brewingGroup, 0, NULL); + specs[eCreativeInventoryTab_Brewing] = + new TabSpec(L"Brewing", IDS_GROUPNAME_POTIONS_480, 5, brewingGroup); } // else // { @@ -687,9 +877,18 @@ void IUIScene_CreativeMenu::staticCtor() { // potionsGroup); // } +#ifndef _CONTENT_PACKAGE ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc}; - specs[eCreativeInventoryTab_Misc] = new TabSpec( - L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, NULL); + ECreative_Inventory_Groups debugMiscGroup[] = { + eCreativeInventory_ArtToolsMisc}; + specs[eCreativeInventoryTab_Misc] = + new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, NULL, + 1, debugMiscGroup); +#else + ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc}; + specs[eCreativeInventoryTab_Misc] = + new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup); +#endif } IUIScene_CreativeMenu::IUIScene_CreativeMenu() { @@ -718,16 +917,41 @@ void IUIScene_CreativeMenu::switchTab(ECreativeInventoryTabs tab) { m_tabPage[m_curTab]); } +void IUIScene_CreativeMenu::ScrollBar(UIVec2D pointerPos) { + UIVec2D pos; + UIVec2D size; + GetItemScreenData(eSectionInventoryCreativeSlider, 0, &pos, &size); + float fPosition = ((float)pointerPos.y - pos.y) / size.y; + + // clamp + if (fPosition > 1) + fPosition = 1.0f; + else if (fPosition < 0) + fPosition = 0.0f; + + // calculate page position according to page count + int iCurrentPage = + Math::round(fPosition * (specs[m_curTab]->getPageCount() - 1)); + + // set tab page + m_tabPage[m_curTab] = iCurrentPage; + + // update tab + switchTab(m_curTab); +} + // 4J JEV - Tab Spec Struct IUIScene_CreativeMenu::TabSpec::TabSpec( const wchar_t* icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups* staticGroups, int dynamicGroupsCount, - ECreative_Inventory_Groups* dynamicGroups) + ECreative_Inventory_Groups* dynamicGroups, int debugGroupsCount /*= 0*/, + ECreative_Inventory_Groups* debugGroups /*= NULL*/) : m_icon(icon), m_descriptionId(descriptionId), m_staticGroupsCount(staticGroupsCount), - m_dynamicGroupsCount(dynamicGroupsCount) { + m_dynamicGroupsCount(dynamicGroupsCount), + m_debugGroupsCount(debugGroupsCount) { m_pages = 0; m_staticGroupsA = NULL; @@ -742,8 +966,18 @@ IUIScene_CreativeMenu::TabSpec::TabSpec( } } + m_debugGroupsA = NULL; + m_debugItems = 0; + if (debugGroupsCount > 0) { + m_debugGroupsA = new ECreative_Inventory_Groups[debugGroupsCount]; + for (int i = 0; i < debugGroupsCount; ++i) { + m_debugGroupsA[i] = debugGroups[i]; + m_debugItems += categoryGroups[m_debugGroupsA[i]].size(); + } + } + m_dynamicGroupsA = NULL; - if (dynamicGroupsCount > 0) { + if (dynamicGroupsCount > 0 && dynamicGroups != NULL) { m_dynamicGroupsA = new ECreative_Inventory_Groups[dynamicGroupsCount]; for (int i = 0; i < dynamicGroupsCount; ++i) { m_dynamicGroupsA[i] = dynamicGroups[i]; @@ -758,6 +992,7 @@ IUIScene_CreativeMenu::TabSpec::TabSpec( IUIScene_CreativeMenu::TabSpec::~TabSpec() { if (m_staticGroupsA != NULL) delete[] m_staticGroupsA; if (m_dynamicGroupsA != NULL) delete[] m_dynamicGroupsA; + if (m_debugGroupsA != NULL) delete[] m_debugGroupsA; } void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu* menu, @@ -779,45 +1014,103 @@ void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu* menu, // Fill from the static groups unsigned int startIndex = page * m_staticPerPage; - int remainingItems = m_staticItems - startIndex; // Work out the first group with an item the want to display, and which item // in that group unsigned int currentIndex = 0; unsigned int currentGroup = 0; unsigned int currentItem = 0; + bool displayStatic = false; for (; currentGroup < m_staticGroupsCount; ++currentGroup) { int size = categoryGroups[m_staticGroupsA[currentGroup]].size(); if (currentIndex + size < startIndex) { currentIndex += size; continue; } + displayStatic = true; currentItem = size - ((currentIndex + size) - startIndex); break; } - for (; lastSlotIndex < MAX_SIZE;) { - Slot* slot = menu->getSlot(lastSlotIndex++); - slot->set(categoryGroups[m_staticGroupsA[currentGroup]][currentItem]); + int lastStaticPageCount = currentIndex; + while (lastStaticPageCount > m_staticPerPage) + lastStaticPageCount -= m_staticPerPage; - ++currentItem; - if (currentItem >= - categoryGroups[m_staticGroupsA[currentGroup]].size()) { - currentItem = 0; - ++currentGroup; - if (currentGroup >= m_staticGroupsCount) { - break; + if (displayStatic) { + for (; lastSlotIndex < MAX_SIZE;) { + Slot* slot = menu->getSlot(lastSlotIndex++); + slot->set( + categoryGroups[m_staticGroupsA[currentGroup]][currentItem]); + + ++currentItem; + if (currentItem >= + categoryGroups[m_staticGroupsA[currentGroup]].size()) { + currentItem = 0; + ++currentGroup; + if (currentGroup >= m_staticGroupsCount) { + break; + } } } } +#ifndef _CONTENT_PACKAGE + if (app.DebugArtToolsOn()) { + if (m_debugGroupsCount > 0) { + startIndex = 0; + if (lastStaticPageCount != 0) { + startIndex = m_staticPerPage - lastStaticPageCount; + } + currentIndex = 0; + currentGroup = 0; + currentItem = 0; + bool showDebug = false; + for (; currentGroup < m_debugGroupsCount; ++currentGroup) { + int size = categoryGroups[m_debugGroupsA[currentGroup]].size(); + if (currentIndex + size < startIndex) { + currentIndex += size; + continue; + } + currentItem = size - ((currentIndex + size) - startIndex); + break; + } + + for (; lastSlotIndex < MAX_SIZE;) { + Slot* slot = menu->getSlot(lastSlotIndex++); + slot->set( + categoryGroups[m_debugGroupsA[currentGroup]][currentItem]); + + ++currentItem; + if (currentItem >= + categoryGroups[m_debugGroupsA[currentGroup]].size()) { + currentItem = 0; + ++currentGroup; + if (currentGroup >= m_debugGroupsCount) { + break; + } + } + } + } + } +#endif + for (; lastSlotIndex < MAX_SIZE; ++lastSlotIndex) { Slot* slot = menu->getSlot(lastSlotIndex); slot->remove(1); } } -unsigned int IUIScene_CreativeMenu::TabSpec::getPageCount() { return m_pages; } +unsigned int IUIScene_CreativeMenu::TabSpec::getPageCount() { +#ifndef _CONTENT_PACKAGE + if (app.DebugArtToolsOn()) { + return (int)ceil((float)(m_staticItems + m_debugItems) / + m_staticPerPage); + } else +#endif + { + return m_pages; + } +} // 4J JEV - Item Picker Menu IUIScene_CreativeMenu::ItemPickerMenu::ItemPickerMenu( @@ -876,7 +1169,6 @@ IUIScene_CreativeMenu::GetSectionAndSlotInDirection(ESceneSection eSection, newSection = eSectionInventoryCreativeSelector; } break; -#ifndef _XBOX case eSectionInventoryCreativeTab_0: case eSectionInventoryCreativeTab_1: case eSectionInventoryCreativeTab_2: @@ -888,7 +1180,6 @@ IUIScene_CreativeMenu::GetSectionAndSlotInDirection(ESceneSection eSection, case eSectionInventoryCreativeSlider: /* do nothing */ break; -#endif default: assert(false); break; @@ -914,7 +1205,7 @@ bool IUIScene_CreativeMenu::handleValidKeyPress(int iPad, int buttonNum, m_menu->getSlot(i)->set(nullptr); // call this function to synchronize multiplayer item bar pMinecraft->localgameModes[iPad]->handleCreativeModeItemAdd( - nullptr, i - (int)m_menu->slots->size() + 9 + + nullptr, i - (int)m_menu->slots.size() + 9 + InventoryMenu::USE_ROW_SLOT_START); } } @@ -924,7 +1215,7 @@ bool IUIScene_CreativeMenu::handleValidKeyPress(int iPad, int buttonNum, } void IUIScene_CreativeMenu::handleOutsideClicked(int iPad, int buttonNum, - bool quickKeyHeld) { + BOOL quickKeyHeld) { // Drop items. Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -1047,7 +1338,7 @@ void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, m_menu->getSlot(currentIndex)->getItem(); // call this function to synchronize multiplayer item bar pMinecraft->localgameModes[getPad()]->handleCreativeModeItemAdd( - newItem, currentIndex - (int)m_menu->slots->size() + 9 + + newItem, currentIndex - (int)m_menu->slots.size() + 9 + InventoryMenu::USE_ROW_SLOT_START); if (m_bCarryingCreativeItem) { @@ -1095,7 +1386,7 @@ bool IUIScene_CreativeMenu::getEmptyInventorySlot( // Jump to the slot with this item already on it, if we can stack more for (unsigned int i = TabSpec::MAX_SIZE; i < TabSpec::MAX_SIZE + 9; ++i) { std::shared_ptr slotItem = m_menu->getSlot(i)->getItem(); - if (slotItem != NULL && slotItem->sameItem(item) && + if (slotItem != NULL && slotItem->sameItemWithTags(item) && (slotItem->GetCount() + item->GetCount() <= item->getMaxStackSize())) { sameItemFound = true; @@ -1139,13 +1430,12 @@ bool IUIScene_CreativeMenu::overrideTooltips( std::shared_ptr itemUnderPointer, bool bIsItemCarried, bool bSlotHasItem, bool bCarriedIsSameAsSlot, int iSlotStackSizeRemaining, EToolTipItem& buttonA, EToolTipItem& buttonX, EToolTipItem& buttonY, - EToolTipItem& buttonRT) { + EToolTipItem& buttonRT, EToolTipItem& buttonBack) { bool _override = false; if (sectionUnderPointer == eSectionInventoryCreativeSelector) { if (bSlotHasItem) { buttonA = eToolTipPickUpGeneric; - buttonRT = eToolTipWhatIsThis; if (itemUnderPointer->isStackable()) { buttonY = eToolTipPickUpAll; @@ -1161,3 +1451,73 @@ bool IUIScene_CreativeMenu::overrideTooltips( return _override; } + +void IUIScene_CreativeMenu::BuildFirework( + std::vector >* list, uint8_t type, int color, + int sulphur, bool flicker, bool trail, int fadeColor /*= -1*/) { + ///////////////////////////////// + // Create firecharge + ///////////////////////////////// + + CompoundTag* expTag = new CompoundTag(FireworksItem::TAG_EXPLOSION); + + std::vector colors; + + colors.push_back(DyePowderItem::COLOR_RGB[color]); + + // glowstone dust gives flickering + if (flicker) expTag->putBoolean(FireworksItem::TAG_E_FLICKER, true); + + // diamonds give trails + if (trail) expTag->putBoolean(FireworksItem::TAG_E_TRAIL, true); + + intArray colorArray(colors.size()); + for (int i = 0; i < colorArray.length; i++) { + colorArray[i] = colors.at(i); + } + expTag->putIntArray(FireworksItem::TAG_E_COLORS, colorArray); + // delete colorArray.data; + + expTag->putByte(FireworksItem::TAG_E_TYPE, type); + + if (fadeColor != -1) { + //////////////////////////////////// + // Apply fade colors to firecharge + //////////////////////////////////// + + std::vector colors; + colors.push_back(DyePowderItem::COLOR_RGB[fadeColor]); + + intArray colorArray(colors.size()); + for (int i = 0; i < colorArray.length; i++) { + colorArray[i] = colors.at(i); + } + expTag->putIntArray(FireworksItem::TAG_E_FADECOLORS, colorArray); + } + + ///////////////////////////////// + // Create fireworks + ///////////////////////////////// + + std::shared_ptr firework; + + { + firework = + std::shared_ptr(new ItemInstance(Item::fireworks)); + CompoundTag* itemTag = new CompoundTag(); + CompoundTag* fireTag = new CompoundTag(FireworksItem::TAG_FIREWORKS); + ListTag* expTags = + new ListTag(FireworksItem::TAG_EXPLOSIONS); + + expTags->add(expTag); + + fireTag->put(FireworksItem::TAG_EXPLOSIONS, expTags); + fireTag->putByte(FireworksItem::TAG_FLIGHT, (uint8_t)sulphur); + + itemTag->put(FireworksItem::TAG_FIREWORKS, fireTag); + + firework->setTag(itemTag); + } + + list->push_back(firework); +} diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h index acd311021..4080cff2b 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h @@ -4,11 +4,8 @@ // 4J Stu - This class is for code that is common between XUI and Iggy class SimpleContainer; -class CreativeInventoryScreen; class IUIScene_CreativeMenu : public virtual IUIScene_AbstractContainerMenu { - friend class CreativeInventoryScreen; - public: // 4J Stu - These map directly to the tabs seenon the screen enum ECreativeInventoryTabs { @@ -39,6 +36,8 @@ public: eCreativeInventory_Potions_Extended, eCreativeInventory_Potions_Level2_Extended, eCreativeInventory_Misc, + eCreativeInventory_ArtToolsDecorations, + eCreativeInventory_ArtToolsMisc, eCreativeInventoryGroupsCount }; @@ -57,6 +56,8 @@ public: ECreative_Inventory_Groups* m_staticGroupsA; const int m_dynamicGroupsCount; ECreative_Inventory_Groups* m_dynamicGroupsA; + const int m_debugGroupsCount; + ECreative_Inventory_Groups* m_debugGroupsA; private: unsigned int m_pages; @@ -66,8 +67,10 @@ public: public: TabSpec(const wchar_t* icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups* staticGroups, - int dynamicGroupsCount, - ECreative_Inventory_Groups* dynamicGroups); + int dynamicGroupsCount = 0, + ECreative_Inventory_Groups* dynamicGroups = NULL, + int debugGroupsCount = 0, + ECreative_Inventory_Groups* debugGroups = NULL); ~TabSpec(); void populateMenu(AbstractContainerMenu* menu, int dynamicIndex, @@ -113,6 +116,7 @@ protected: int m_tabPage[eCreativeInventoryTab_COUNT]; void switchTab(ECreativeInventoryTabs tab); + void ScrollBar(UIVec2D pointerPos); virtual void updateTabHighlightAndText(ECreativeInventoryTabs tab) = 0; virtual void updateScrollCurrentPage(int currentPage, int pageCount) = 0; virtual ESceneSection GetSectionAndSlotInDirection(ESceneSection eSection, @@ -136,5 +140,10 @@ protected: std::shared_ptr itemUnderPointer, bool bIsItemCarried, bool bSlotHasItem, bool bCarriedIsSameAsSlot, int iSlotStackSizeRemaining, EToolTipItem& buttonA, - EToolTipItem& buttonX, EToolTipItem& buttonY, EToolTipItem& buttonRT); -}; + EToolTipItem& buttonX, EToolTipItem& buttonY, EToolTipItem& buttonRT, + EToolTipItem& buttonBack); + + static void BuildFirework(std::vector >* list, + uint8_t type, int color, int sulphur, + bool flicker, bool trail, int fadeColor = -1); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_FireworksMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_FireworksMenu.cpp new file mode 100644 index 000000000..585092be1 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_FireworksMenu.cpp @@ -0,0 +1,103 @@ +#include "../../stdafx.h" + +#include "IUIScene_FireworksMenu.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" + +IUIScene_AbstractContainerMenu::ESceneSection +IUIScene_FireworksMenu::GetSectionAndSlotInDirection(ESceneSection eSection, + ETapState eTapDirection, + int* piTargetX, + int* piTargetY) { + ESceneSection newSection = eSection; + int xOffset = 0; + int yOffset = 0; + + // Find the new section if there is one + switch (eSection) { + case eSectionFireworksIngredients: + if (eTapDirection == eTapStateDown) { + newSection = eSectionFireworksInventory; + xOffset = -1; + } else if (eTapDirection == eTapStateUp) { + newSection = eSectionFireworksUsing; + xOffset = -1; + } else if (eTapDirection == eTapStateLeft) { + newSection = eSectionFireworksResult; + } else if (eTapDirection == eTapStateRight) { + newSection = eSectionFireworksResult; + } + break; + case eSectionFireworksResult: + if (eTapDirection == eTapStateDown) { + newSection = eSectionFireworksInventory; + xOffset = -7; + } else if (eTapDirection == eTapStateUp) { + newSection = eSectionFireworksUsing; + xOffset = -7; + } else if (eTapDirection == eTapStateLeft) { + newSection = eSectionFireworksIngredients; + yOffset = -1; + *piTargetX = getSectionColumns(eSectionFireworksIngredients); + } else if (eTapDirection == eTapStateRight) { + newSection = eSectionFireworksIngredients; + yOffset = -1; + *piTargetX = 0; + } + break; + case eSectionFireworksInventory: + if (eTapDirection == eTapStateDown) { + newSection = eSectionFireworksUsing; + } else if (eTapDirection == eTapStateUp) { + if (*piTargetX < 6) { + newSection = eSectionFireworksIngredients; + xOffset = 1; + } else { + newSection = eSectionFireworksResult; + } + } + break; + case eSectionFireworksUsing: + if (eTapDirection == eTapStateDown) { + if (*piTargetX < 6) { + newSection = eSectionFireworksIngredients; + xOffset = 1; + } else { + newSection = eSectionFireworksResult; + } + } else if (eTapDirection == eTapStateUp) { + newSection = eSectionFireworksInventory; + } + break; + default: + assert(false); + break; + } + + updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, + piTargetY, xOffset, yOffset); + + return newSection; +} + +int IUIScene_FireworksMenu::getSectionStartOffset(ESceneSection eSection) { + int offset = 0; + switch (eSection) { + case eSectionFireworksIngredients: + offset = FireworksMenu::CRAFT_SLOT_START; + break; + + case eSectionFireworksResult: + offset = FireworksMenu::RESULT_SLOT; + break; + case eSectionFireworksInventory: + offset = FireworksMenu::INV_SLOT_START; + break; + case eSectionFireworksUsing: + offset = FireworksMenu::INV_SLOT_START + 27; + break; + default: + assert(false); + break; + } + return offset; +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_FireworksMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_FireworksMenu.h new file mode 100644 index 000000000..45b790ccb --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_FireworksMenu.h @@ -0,0 +1,11 @@ +#pragma once +#include "IUIScene_AbstractContainerMenu.h" + +class IUIScene_FireworksMenu : public virtual IUIScene_AbstractContainerMenu { +protected: + virtual ESceneSection GetSectionAndSlotInDirection(ESceneSection eSection, + ETapState eTapDirection, + int* piTargetX, + int* piTargetY); + int getSectionStartOffset(ESceneSection eSection); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.cpp new file mode 100644 index 000000000..91d7d3e95 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.cpp @@ -0,0 +1,253 @@ +#include "../../stdafx.h" +#include "../../Minecraft.h" +#include "../../MultiPlayerLocalPlayer.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.effect.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.item.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.entity.ai.attributes.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.entity.monster.h" +#include "IUIScene_HUD.h" + +IUIScene_HUD::IUIScene_HUD() { + m_lastActiveSlot = -1; + m_iGuiScale = -1; + m_bToolTipsVisible = true; + m_lastExpProgress = 0.0f; + m_lastExpLevel = 0; + m_iCurrentHealth = 0; + m_lastMaxHealth = 20; + m_lastHealthBlink = false; + m_lastHealthPoison = false; + m_iCurrentFood = -1; + m_lastFoodPoison = false; + m_lastAir = 10; + m_currentExtraAir = 0; + m_lastArmour = 0; + m_showHealth = true; + m_showHorseHealth = true; + m_showFood = true; + m_showAir = true; + m_showArmour = true; + m_showExpBar = true; + m_bRegenEffectEnabled = false; + m_iFoodSaturation = 0; + m_lastDragonHealth = 0.0f; + m_showDragonHealth = false; + m_ticksWithNoBoss = 0; + m_uiSelectedItemOpacityCountDown = 0; + m_displayName = L""; + m_lastShowDisplayName = true; + m_bRidingHorse = true; + m_horseHealth = 1; + m_lastHealthWither = true; + m_iCurrentHealthAbsorb = -1; + m_horseJumpProgress = 1.0f; + m_iHeartOffsetIndex = -1; + m_bHealthAbsorbActive = false; + m_iHorseMaxHealth = -1; + m_bIsJumpable = false; +} + +void IUIScene_HUD::updateFrameTick() { + int iPad = getPad(); + Minecraft* pMinecraft = Minecraft::GetInstance(); + + int iGuiScale; + + if (pMinecraft->localplayers[iPad]->m_iScreenSection == + C4JRender::VIEWPORT_TYPE_FULLSCREEN) { + iGuiScale = app.GetGameSettings(iPad, eGameSetting_UISize); + } else { + iGuiScale = app.GetGameSettings(iPad, eGameSetting_UISizeSplitscreen); + } + SetHudSize(iGuiScale); + + SetDisplayName(ProfileManager.GetDisplayName(iPad)); + + SetTooltipsEnabled(((ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad())) || + (app.GetGameSettings(ProfileManager.GetPrimaryPad(), + eGameSetting_Tooltips) != 0))); + + SetActiveSlot(pMinecraft->localplayers[iPad]->inventory->selected); + + if (pMinecraft->localgameModes[iPad]->canHurtPlayer()) { + renderPlayerHealth(); + } else { + // SetRidingHorse(false, 0); + std::shared_ptr riding = pMinecraft->localplayers[iPad]->riding; + if (riding == NULL) { + SetRidingHorse(false, false, 0); + } else { + SetRidingHorse( + true, pMinecraft->localplayers[iPad]->isRidingJumpable(), 0); + } + ShowHorseHealth(false); + m_horseHealth = 0; + ShowHealth(false); + ShowFood(false); + ShowAir(false); + ShowArmour(false); + ShowExpBar(false); + SetHealthAbsorb(0); + } + + if (pMinecraft->localplayers[iPad]->isRidingJumpable()) { + SetHorseJumpBarProgress( + pMinecraft->localplayers[iPad]->getJumpRidingScale()); + } else if (pMinecraft->localgameModes[iPad]->hasExperience()) { + // Update xp progress + ShowExpBar(true); + + SetExpBarProgress( + pMinecraft->localplayers[iPad]->experienceProgress, + pMinecraft->localplayers[iPad]->getXpNeededForNextLevel()); + + // Update xp level + SetExpLevel(pMinecraft->localplayers[iPad]->experienceLevel); + } else { + ShowExpBar(false); + SetExpLevel(0); + } + + if (m_uiSelectedItemOpacityCountDown > 0) { + --m_uiSelectedItemOpacityCountDown; + + // 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 (m_uiSelectedItemOpacityCountDown < + (SharedConstants::TICKS_PER_SECOND * 1)) { + HideSelectedLabel(); + m_uiSelectedItemOpacityCountDown = 0; + } + } + + unsigned char ucAlpha = app.GetGameSettings(ProfileManager.GetPrimaryPad(), + eGameSetting_InterfaceOpacity); + float fVal; + + if (ucAlpha < 80) { + // if we are in a menu, set the minimum opacity for tooltips to 15% + if (ui.GetMenuDisplayed(iPad) && (ucAlpha < 15)) { + ucAlpha = 15; + } + + // check if we have the timer running for the opacity + unsigned int uiOpacityTimer = app.GetOpacityTimer(iPad); + if (uiOpacityTimer != 0) { + if (uiOpacityTimer < 10) { + float fStep = (80.0f - (float)ucAlpha) / 10.0f; + fVal = + 0.01f * (80.0f - ((10.0f - (float)uiOpacityTimer) * fStep)); + } else { + fVal = 0.01f * 80.0f; + } + } else { + fVal = 0.01f * (float)ucAlpha; + } + } else { + // if we are in a menu, set the minimum opacity for tooltips to 15% + if (ui.GetMenuDisplayed(iPad) && (ucAlpha < 15)) { + ucAlpha = 15; + } + fVal = 0.01f * (float)ucAlpha; + } + SetOpacity(fVal); + + bool bDisplayGui = app.GetGameStarted() && !ui.GetMenuDisplayed(iPad) && + !(app.GetXuiAction(iPad) == + eAppAction_AutosaveSaveGameCapturedThumbnail) && + app.GetGameSettings(iPad, eGameSetting_DisplayHUD) != 0; + if (bDisplayGui && pMinecraft->localplayers[iPad] != NULL) { + SetVisible(true); + } else { + SetVisible(false); + } +} + +void IUIScene_HUD::renderPlayerHealth() { + Minecraft* pMinecraft = Minecraft::GetInstance(); + int iPad = getPad(); + + ShowHealth(true); + + SetRegenerationEffect( + pMinecraft->localplayers[iPad]->hasEffect(MobEffect::regeneration)); + + // Update health + bool blink = pMinecraft->localplayers[iPad]->invulnerableTime / 3 % 2 == 1; + if (pMinecraft->localplayers[iPad]->invulnerableTime < 10) blink = false; + int currentHealth = pMinecraft->localplayers[iPad]->getHealth(); + int oldHealth = pMinecraft->localplayers[iPad]->lastHealth; + bool bHasPoison = + pMinecraft->localplayers[iPad]->hasEffect(MobEffect::poison); + bool bHasWither = + pMinecraft->localplayers[iPad]->hasEffect(MobEffect::wither); + AttributeInstance* maxHealthAttribute = + pMinecraft->localplayers[iPad]->getAttribute( + SharedMonsterAttributes::MAX_HEALTH); + float maxHealth = (float)maxHealthAttribute->getValue(); + float totalAbsorption = + pMinecraft->localplayers[iPad]->getAbsorptionAmount(); + + // Update armour + int armor = pMinecraft->localplayers[iPad]->getArmorValue(); + + SetHealth(currentHealth, oldHealth, blink, bHasPoison || bHasWither, + bHasWither); + SetHealthAbsorb(totalAbsorption); + + if (armor > 0) { + ShowArmour(true); + SetArmour(armor); + } else { + ShowArmour(false); + } + + std::shared_ptr riding = pMinecraft->localplayers[iPad]->riding; + + if (riding == NULL || riding && !riding->instanceof(eTYPE_LIVINGENTITY)) { + SetRidingHorse(false, false, 0); + + ShowFood(true); + ShowHorseHealth(false); + m_horseHealth = 0; + + // Update food + // bool foodBlink = false; + FoodData* foodData = pMinecraft->localplayers[iPad]->getFoodData(); + int food = foodData->getFoodLevel(); + int oldFood = foodData->getLastFoodLevel(); + bool hasHungerEffect = + pMinecraft->localplayers[iPad]->hasEffect(MobEffect::hunger); + int saturationLevel = + pMinecraft->localplayers[iPad]->getFoodData()->getSaturationLevel(); + + SetFood(food, oldFood, hasHungerEffect); + SetFoodSaturationLevel(saturationLevel); + + // Update air + if (pMinecraft->localplayers[iPad]->isUnderLiquid(Material::water)) { + ShowAir(true); + int count = + (int)ceil((pMinecraft->localplayers[iPad]->getAirSupply() - 2) * + 10.0f / Player::TOTAL_AIR_SUPPLY); + int extra = + (int)ceil((pMinecraft->localplayers[iPad]->getAirSupply()) * + 10.0f / Player::TOTAL_AIR_SUPPLY) - + count; + SetAir(count, extra); + } else { + ShowAir(false); + } + } else if (riding->instanceof(eTYPE_LIVINGENTITY)) { + std::shared_ptr living = + std::dynamic_pointer_cast(riding); + int riderCurrentHealth = (int)ceil(living->getHealth()); + float maxRiderHealth = living->getMaxHealth(); + + SetRidingHorse(true, pMinecraft->localplayers[iPad]->isRidingJumpable(), + maxRiderHealth); + SetHorseHealth(riderCurrentHealth); + ShowHorseHealth(true); + } +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.h b/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.h new file mode 100644 index 000000000..2be2fcc2f --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_HUD.h @@ -0,0 +1,88 @@ +#pragma once + +class IUIScene_HUD { +protected: + int m_lastActiveSlot; + int m_iGuiScale; + bool m_bToolTipsVisible; + float m_lastExpProgress; + int m_lastExpLevel; + int m_iCurrentHealth; + int m_lastMaxHealth; + bool m_lastHealthBlink, m_lastHealthPoison, m_lastHealthWither; + int m_iCurrentFood; + bool m_lastFoodPoison; + int m_lastAir, m_currentExtraAir; + int m_lastArmour; + float m_lastDragonHealth; + bool m_showDragonHealth; + int m_ticksWithNoBoss; + bool m_lastShowDisplayName; + int m_horseHealth; + int m_iCurrentHealthAbsorb; + float m_horseJumpProgress; + int m_iHeartOffsetIndex; + bool m_bHealthAbsorbActive; + int m_iHorseMaxHealth; + + bool m_showHealth, m_showHorseHealth, m_showFood, m_showAir, m_showArmour, + m_showExpBar, m_bRidingHorse, m_bIsJumpable; + bool m_bRegenEffectEnabled; + int m_iFoodSaturation; + + unsigned int m_uiSelectedItemOpacityCountDown; + + std::wstring m_displayName; + + IUIScene_HUD(); + + virtual int getPad() = 0; + virtual void SetOpacity(float opacity) = 0; + virtual void SetVisible(bool visible) = 0; + + virtual void SetHudSize(int scale) = 0; + virtual void SetExpBarProgress(float progress, + int xpNeededForNextLevel) = 0; + virtual void SetExpLevel(int level) = 0; + virtual void SetActiveSlot(int slot) = 0; + + virtual void SetHealth(int iHealth, int iLastHealth, bool bBlink, + bool bPoison, bool bWither) = 0; + virtual void SetFood(int iFood, int iLastFood, bool bPoison) = 0; + virtual void SetAir(int iAir, int extra) = 0; + virtual void SetArmour(int iArmour) = 0; + + virtual void ShowHealth(bool show) = 0; + virtual void ShowHorseHealth(bool show) = 0; + virtual void ShowFood(bool show) = 0; + virtual void ShowAir(bool show) = 0; + virtual void ShowArmour(bool show) = 0; + virtual void ShowExpBar(bool show) = 0; + + virtual void SetRegenerationEffect(bool bEnabled) = 0; + virtual void SetFoodSaturationLevel(int iSaturation) = 0; + + virtual void SetDragonHealth(float health) = 0; + virtual void SetDragonLabel(const std::wstring& label) = 0; + virtual void ShowDragonHealth(bool show) = 0; + + virtual void HideSelectedLabel() = 0; + + virtual void SetDisplayName(const std::wstring& displayName) = 0; + + virtual void SetTooltipsEnabled(bool bEnabled) = 0; + + virtual void SetRidingHorse(bool ridingHorse, bool bIsJumpable, + int maxHorseHealth) = 0; + virtual void SetHorseHealth(int health, bool blink = false) = 0; + virtual void SetHorseJumpBarProgress(float progress) = 0; + + virtual void SetHealthAbsorb(int healthAbsorb) = 0; + + virtual void SetSelectedLabel(const std::wstring& label) = 0; + virtual void ShowDisplayName(bool show) = 0; + +public: + void updateFrameTick(); + void renderPlayerHealth(); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_HopperMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_HopperMenu.cpp new file mode 100644 index 000000000..f13419f34 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_HopperMenu.cpp @@ -0,0 +1,69 @@ +#include "../../stdafx.h" +#include "IUIScene_HopperMenu.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" + +IUIScene_AbstractContainerMenu::ESceneSection +IUIScene_HopperMenu::GetSectionAndSlotInDirection(ESceneSection eSection, + ETapState eTapDirection, + int* piTargetX, + int* piTargetY) { + ESceneSection newSection = eSection; + + int xOffset = 0; + + // Find the new section if there is one + switch (eSection) { + case eSectionHopperContents: + if (eTapDirection == eTapStateDown) { + newSection = eSectionHopperInventory; + xOffset = -2; + } else if (eTapDirection == eTapStateUp) { + xOffset = -2; + newSection = eSectionHopperUsing; + } + break; + case eSectionHopperInventory: + if (eTapDirection == eTapStateDown) { + newSection = eSectionHopperUsing; + } else if (eTapDirection == eTapStateUp) { + xOffset = 2; + newSection = eSectionHopperContents; + } + break; + case eSectionHopperUsing: + if (eTapDirection == eTapStateDown) { + xOffset = 2; + newSection = eSectionHopperContents; + } else if (eTapDirection == eTapStateUp) { + newSection = eSectionHopperInventory; + } + break; + default: + assert(false); + break; + } + + updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, + piTargetY, xOffset); + + return newSection; +} + +int IUIScene_HopperMenu::getSectionStartOffset(ESceneSection eSection) { + int offset = 0; + switch (eSection) { + case eSectionHopperContents: + offset = HopperMenu::CONTENTS_SLOT_START; + break; + case eSectionHopperInventory: + offset = HopperMenu::INV_SLOT_START; + break; + case eSectionHopperUsing: + offset = HopperMenu::USE_ROW_SLOT_START; + break; + default: + assert(false); + break; + } + return offset; +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_HopperMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_HopperMenu.h new file mode 100644 index 000000000..a11d33d85 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_HopperMenu.h @@ -0,0 +1,14 @@ +#pragma once + +#include "IUIScene_AbstractContainerMenu.h" +#include "../../../../Minecraft.World/Containers/Container.h" +#include "../../../../Minecraft.World/Containers/Inventory.h" + +class IUIScene_HopperMenu : public virtual IUIScene_AbstractContainerMenu { +public: + virtual ESceneSection GetSectionAndSlotInDirection(ESceneSection eSection, + ETapState eTapDirection, + int* piTargetX, + int* piTargetY); + int getSectionStartOffset(ESceneSection eSection); +}; diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.cpp new file mode 100644 index 000000000..7ae9307dc --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.cpp @@ -0,0 +1,193 @@ +#include "../../stdafx.h" +#include "IUIScene_HorseInventoryMenu.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h" + +IUIScene_AbstractContainerMenu::ESceneSection +IUIScene_HorseInventoryMenu::GetSectionAndSlotInDirection( + ESceneSection eSection, ETapState eTapDirection, int* piTargetX, + int* piTargetY) { + ESceneSection newSection = eSection; + + int xOffset = 0; + int yOffset = 0; + + // Find the new section if there is one + switch (eSection) { + case eSectionHorseUsing: + if (eTapDirection == eTapStateDown) { + if (m_horse->isChestedHorse() && *piTargetX >= 4) { + newSection = eSectionHorseChest; + xOffset = 4; + } else { + newSection = eSectionHorseSaddle; + } + } else if (eTapDirection == eTapStateUp) { + newSection = eSectionHorseInventory; + } + break; + case eSectionHorseInventory: + if (eTapDirection == eTapStateDown) { + newSection = eSectionHorseUsing; + } else if (eTapDirection == eTapStateUp) { + if (m_horse->isChestedHorse() && *piTargetX >= 4) { + xOffset = 4; + newSection = eSectionHorseChest; + } else if (m_horse->canWearArmor()) { + newSection = eSectionHorseArmor; + } else { + newSection = eSectionHorseSaddle; + } + } + break; + case eSectionHorseChest: + if (eTapDirection == eTapStateDown) { + xOffset = -4; + newSection = eSectionHorseInventory; + } else if (eTapDirection == eTapStateUp) { + xOffset = -4; + newSection = eSectionHorseUsing; + } else if (eTapDirection == eTapStateLeft) { + if (*piTargetX < 0) { + if (m_horse->canWearArmor() && *piTargetY == 1) { + newSection = eSectionHorseArmor; + } else if (*piTargetY == 0) { + newSection = eSectionHorseSaddle; + } + } + } else if (eTapDirection == eTapStateRight) { + if (*piTargetX >= getSectionColumns(eSectionHorseChest)) { + if (m_horse->canWearArmor() && *piTargetY == 1) { + newSection = eSectionHorseArmor; + } else if (*piTargetY == 0) { + newSection = eSectionHorseSaddle; + } + } + } + break; + case eSectionHorseArmor: + if (eTapDirection == eTapStateDown) { + if (m_horse->isChestedHorse()) { + newSection = eSectionHorseChest; + } else { + newSection = eSectionHorseInventory; + } + } else if (eTapDirection == eTapStateUp) { + newSection = eSectionHorseSaddle; + } else if (eTapDirection == eTapStateRight) { + if (m_horse->isChestedHorse()) { + yOffset = -1; + *piTargetX = 0; + newSection = eSectionHorseChest; + } + } else if (eTapDirection == eTapStateLeft) { + if (m_horse->isChestedHorse()) { + yOffset = -1; + *piTargetX = getSectionColumns(eSectionHorseChest); + newSection = eSectionHorseChest; + } + } + break; + case eSectionHorseSaddle: + if (eTapDirection == eTapStateDown) { + if (m_horse->canWearArmor()) { + newSection = eSectionHorseArmor; + } else { + newSection = eSectionHorseInventory; + } + } else if (eTapDirection == eTapStateUp) { + newSection = eSectionHorseUsing; + } else if (eTapDirection == eTapStateRight) { + if (m_horse->isChestedHorse()) { + *piTargetX = 0; + newSection = eSectionHorseChest; + } + } else if (eTapDirection == eTapStateLeft) { + if (m_horse->isChestedHorse()) { + *piTargetX = getSectionColumns(eSectionHorseChest); + newSection = eSectionHorseChest; + } + } + break; + default: + assert(false); + break; + } + + updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, + piTargetY, xOffset, yOffset); + + return newSection; +} + +// TODO: Offset will vary by type of horse, add in once horse menu and horse +// entity are implemented +int IUIScene_HorseInventoryMenu::getSectionStartOffset(ESceneSection eSection) { + int offset = 0; + switch (eSection) { + case eSectionHorseSaddle: + offset = EntityHorse::INV_SLOT_SADDLE; + break; + case eSectionHorseArmor: + offset = EntityHorse::INV_SLOT_ARMOR; + break; + case eSectionHorseChest: + offset = EntityHorse::INV_BASE_COUNT; + break; + case eSectionHorseInventory: + offset = EntityHorse::INV_BASE_COUNT; + if (m_horse->isChestedHorse()) { + offset += EntityHorse::INV_DONKEY_CHEST_COUNT; + } + break; + case eSectionHorseUsing: + offset = EntityHorse::INV_BASE_COUNT + 27; + if (m_horse->isChestedHorse()) { + offset += EntityHorse::INV_DONKEY_CHEST_COUNT; + } + break; + default: + assert(false); + break; + } + return offset; +} + +bool IUIScene_HorseInventoryMenu::IsSectionSlotList(ESceneSection eSection) { + switch (eSection) { + case eSectionHorseChest: + if (!m_horse->isChestedHorse()) + return false; + else + return true; + case eSectionHorseArmor: + if (!m_horse->canWearArmor()) + return false; + else + return true; + case eSectionHorseSaddle: + case eSectionHorseInventory: + case eSectionHorseUsing: + return true; + } + return false; +} + +bool IUIScene_HorseInventoryMenu::IsVisible(ESceneSection eSection) { + switch (eSection) { + case eSectionHorseChest: + if (!m_horse->isChestedHorse()) + return false; + else + return true; + case eSectionHorseArmor: + if (!m_horse->canWearArmor()) + return false; + else + return true; + case eSectionHorseSaddle: + case eSectionHorseInventory: + case eSectionHorseUsing: + return true; + } + return false; +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.h new file mode 100644 index 000000000..86a8f09c8 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.h @@ -0,0 +1,23 @@ +#pragma once + +#include "IUIScene_AbstractContainerMenu.h" +#include "../../../../Minecraft.World/Containers/Container.h" +#include "../../../../Minecraft.World/Containers/Inventory.h" +#include "../../../../Minecraft.World/Entities/Mobs/EntityHorse.h" + +class IUIScene_HorseInventoryMenu + : public virtual IUIScene_AbstractContainerMenu { +protected: + std::shared_ptr m_inventory; + std::shared_ptr m_container; + std::shared_ptr m_horse; + +public: + virtual ESceneSection GetSectionAndSlotInDirection(ESceneSection eSection, + ETapState eTapDirection, + int* piTargetX, + int* piTargetY); + int getSectionStartOffset(ESceneSection eSection); + bool IsSectionSlotList(ESceneSection eSection); + bool IsVisible(ESceneSection eSection); +}; diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp index ff49b192a..9f8f3f052 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp @@ -13,11 +13,16 @@ int IUIScene_PauseMenu::ExitGameDialogReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { - IUIScene_PauseMenu* scene = (IUIScene_PauseMenu*)pParam; +#ifdef _XBOX + IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam; +#else + IUIScene_PauseMenu* pScene = dynamic_cast( + ui.GetSceneFromCallbackId((std::size_t)pParam)); +#endif // Results switched for this dialog if (result == C4JStorage::EMessage_ResultDecline) { - scene->SetIgnoreInput(true); + if (pScene) pScene->SetIgnoreInput(true); app.SetAction(iPad, eAppAction_ExitWorld); } return 0; @@ -25,7 +30,12 @@ int IUIScene_PauseMenu::ExitGameDialogReturned( int IUIScene_PauseMenu::ExitGameSaveDialogReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { - IUIScene_PauseMenu* scene = (IUIScene_PauseMenu*)pParam; +#ifdef _XBOX + IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam; +#else + IUIScene_PauseMenu* pScene = dynamic_cast( + ui.GetSceneFromCallbackId((std::size_t)pParam)); +#endif // Exit with or without saving // Decline means save in this dialog @@ -67,12 +77,12 @@ int IUIScene_PauseMenu::ExitGameSaveDialogReturned( // Give the player a warning about the trial version of the // texture pack - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(), &IUIScene_PauseMenu::WarningTrialTexturePackReturned, - scene, app.GetStringTable(), NULL, 0, false); + pParam); return S_OK; } @@ -88,11 +98,10 @@ int IUIScene_PauseMenu::ExitGameSaveDialogReturned( unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(), - &IUIScene_PauseMenu::ExitGameAndSaveReturned, scene, - app.GetStringTable(), NULL, 0, false); + &IUIScene_PauseMenu::ExitGameAndSaveReturned, pParam); return 0; } else { #if defined(_XBOX_ONE) || defined(__ORBIS__) @@ -105,15 +114,14 @@ int IUIScene_PauseMenu::ExitGameSaveDialogReturned( unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(), - &IUIScene_PauseMenu::ExitGameDeclineSaveReturned, scene, - app.GetStringTable(), NULL, 0, false); + &IUIScene_PauseMenu::ExitGameDeclineSaveReturned, pParam); return 0; } - scene->SetIgnoreInput(true); + if (pScene) pScene->SetIgnoreInput(true); app.SetAction(iPad, eAppAction_ExitWorld); } @@ -123,7 +131,12 @@ int IUIScene_PauseMenu::ExitGameSaveDialogReturned( int IUIScene_PauseMenu::ExitGameAndSaveReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { // 4J-PB - we won't come in here if we have a trial texture pack - IUIScene_PauseMenu* scene = (IUIScene_PauseMenu*)pParam; +#ifdef _XBOX + IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam; +#else + IUIScene_PauseMenu* pScene = dynamic_cast( + ui.GetSceneFromCallbackId((std::size_t)pParam)); +#endif // results switched for this dialog if (result == C4JStorage::EMessage_ResultDecline) { @@ -135,7 +148,7 @@ int IUIScene_PauseMenu::ExitGameAndSaveReturned( #if defined(_XBOX_ONE) || defined(__ORBIS__) StorageManager.SetSaveDisabled(false); #endif - scene->SetIgnoreInput(true); + if (pScene) pScene->SetIgnoreInput(true); MinecraftServer::getInstance()->setSaveOnExit(true); // flag a app action of exit game app.SetAction(iPad, eAppAction_ExitWorld); @@ -151,18 +164,16 @@ int IUIScene_PauseMenu::ExitGameAndSaveReturned( uiIDA[2] = IDS_EXIT_GAME_NO_SAVE; if (g_NetworkManager.GetPlayerCount() > 1) { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, ProfileManager.GetPrimaryPad(), - &IUIScene_PauseMenu::ExitGameSaveDialogReturned, scene, - app.GetStringTable(), NULL, 0, false); + &IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam); } else { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, ProfileManager.GetPrimaryPad(), - &IUIScene_PauseMenu::ExitGameSaveDialogReturned, scene, - app.GetStringTable(), NULL, 0, false); + &IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam); } } } @@ -171,7 +182,12 @@ int IUIScene_PauseMenu::ExitGameAndSaveReturned( int IUIScene_PauseMenu::ExitGameDeclineSaveReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { - IUIScene_PauseMenu* scene = (IUIScene_PauseMenu*)pParam; +#ifdef _XBOX + IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam; +#else + IUIScene_PauseMenu* pScene = dynamic_cast( + ui.GetSceneFromCallbackId((std::size_t)pParam)); +#endif // results switched for this dialog if (result == C4JStorage::EMessage_ResultDecline) { @@ -180,7 +196,7 @@ int IUIScene_PauseMenu::ExitGameDeclineSaveReturned( // though it shouldn't! // StorageManager.SetSaveDisabled(false); #endif - scene->SetIgnoreInput(true); + if (pScene) pScene->SetIgnoreInput(true); MinecraftServer::getInstance()->setSaveOnExit(false); // flag a app action of exit game app.SetAction(iPad, eAppAction_ExitWorld); @@ -196,18 +212,16 @@ int IUIScene_PauseMenu::ExitGameDeclineSaveReturned( uiIDA[2] = IDS_EXIT_GAME_NO_SAVE; if (g_NetworkManager.GetPlayerCount() > 1) { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, ProfileManager.GetPrimaryPad(), - &IUIScene_PauseMenu::ExitGameSaveDialogReturned, scene, - app.GetStringTable(), NULL, 0, false); + &IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam); } else { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, ProfileManager.GetPrimaryPad(), - &IUIScene_PauseMenu::ExitGameSaveDialogReturned, scene, - app.GetStringTable(), NULL, 0, false); + &IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam); } } } @@ -229,9 +243,8 @@ int IUIScene_PauseMenu::WarningTrialTexturePackReturned( if (bContentRestricted) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - iPad, NULL, &app, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad); } else { // need to get info on the pack to see if the user has already // downloaded it @@ -308,9 +321,9 @@ int IUIScene_PauseMenu::WarningTrialTexturePackReturned( // active network connection user is unable to convert from // Trial to Full texture pack and is not messaged why. unsigned int uiIDA[1] = {IDS_CONFIRM_OK}; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, - iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, + iPad); } } } @@ -531,9 +544,9 @@ void IUIScene_PauseMenu::_ExitWorld(void* lpParameter) { // display a message box. This will allow the message box requested // by the libraries to be brought up if (ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) - ui.RequestMessageBox(exitReasonTitleId, exitReasonStringId, - uiIDA, 1, ProfileManager.GetPrimaryPad(), - NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(exitReasonTitleId, exitReasonStringId, + uiIDA, 1, + ProfileManager.GetPrimaryPad()); exitReasonStringId = -1; // 4J - Force a disconnection, this handles the situation that the @@ -640,9 +653,8 @@ void IUIScene_PauseMenu::_ExitWorld(void* lpParameter) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(exitReasonTitleId, exitReasonStringId, uiIDA, - 1, ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable()); + ui.RequestErrorMessage(exitReasonTitleId, exitReasonStringId, uiIDA, + 1, ProfileManager.GetPrimaryPad()); exitReasonStringId = -1; } } @@ -691,10 +703,9 @@ int IUIScene_PauseMenu::SaveGameDialogReturned( unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_TITLE_ENABLE_AUTOSAVE, - IDS_CONFIRM_ENABLE_AUTOSAVE, uiIDA, 2, iPad, - &IUIScene_PauseMenu::EnableAutosaveDialogReturned, - pParam, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage( + IDS_TITLE_ENABLE_AUTOSAVE, IDS_CONFIRM_ENABLE_AUTOSAVE, uiIDA, 2, + iPad, &IUIScene_PauseMenu::EnableAutosaveDialogReturned, pParam); #else // flag a app action of save game app.SetAction(iPad, eAppAction_SaveGame); diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp index 60d13947a..8e93e3e7d 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp @@ -224,11 +224,10 @@ void IUIScene_StartGame::UpdateCurrentTexturePack(int iSlot) { uiIDA[2] = IDS_CONFIRM_CANCEL; // Give the player a warning about the texture pack missing - ui.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, - IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 3, - ProfileManager.GetPrimaryPad(), - & : TexturePackDialogReturned, this, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, + IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 3, + ProfileManager.GetPrimaryPad(), + & : TexturePackDialogReturned, this); // do set the texture pack id, and on the user pressing create world, // check they have it diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.cpp index 4eefb2c83..42618b950 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.cpp @@ -77,6 +77,12 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) { buyAMatches >= buyAItem->count) && (buyBItem == NULL || buyBMatches >= buyBItem->count)) { + // 4J-JEV: Fix for PS4 #7111: [PATCH 1.12] Trading + // Librarian villagers for multiple �Enchanted + // Books� will cause the title to crash. + int actualShopItem = + m_activeOffers.at(selectedShopItem).second; + m_merchant->notifyTrade(activeRecipe); // Remove the items we are purchasing with @@ -91,8 +97,6 @@ bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat) { } // Send a packet to the server - int actualShopItem = - m_activeOffers.at(selectedShopItem).second; player->connection->send( std::shared_ptr( new TradeItemPacket(m_menu->containerId, @@ -235,17 +239,16 @@ void IUIScene_TradingMenu::updateDisplay() { // 4J-PB - need to get the villager type here wsTemp = app.GetString(IDS_VILLAGER_OFFERS_ITEM); wsTemp = replaceAll(wsTemp, L"{*VILLAGER_TYPE*}", - app.GetString(m_merchant->getDisplayName())); + m_merchant->getDisplayName()); int iPos = wsTemp.find(L"%s"); wsTemp.replace(iPos, 2, activeRecipe->getSellItem()->getHoverName()); setTitle(wsTemp.c_str()); - std::vector unformattedStrings; - std::wstring offerDescription = GetItemDescription( - activeRecipe->getSellItem(), unformattedStrings); - setOfferDescription(offerDescription, unformattedStrings); + std::vector* offerDescription = + GetItemDescription(activeRecipe->getSellItem()); + setOfferDescription(offerDescription); std::shared_ptr buyAItem = activeRecipe->getBuyAItem(); @@ -294,13 +297,15 @@ void IUIScene_TradingMenu::updateDisplay() { if (canMake) iA = IDS_TOOLTIPS_TRADE; } else { - setTitle(app.GetString(m_merchant->getDisplayName())); + setTitle(m_merchant->getDisplayName()); setRequest1Name(L""); setRequest2Name(L""); setRequest1RedBox(false); setRequest2RedBox(false); setRequest1Item(nullptr); setRequest2Item(nullptr); + std::vector offerDescription; + setOfferDescription(&offerDescription); } m_bHasUpdatedOnce = true; @@ -345,25 +350,16 @@ void IUIScene_TradingMenu::setRequest2Item(std::shared_ptr item) { void IUIScene_TradingMenu::setTradeItem(int index, std::shared_ptr item) {} -std::wstring IUIScene_TradingMenu::GetItemDescription( - std::shared_ptr item, - std::vector& unformattedStrings) { - if (item == NULL) return L""; +std::vector* IUIScene_TradingMenu::GetItemDescription( + std::shared_ptr item) { + std::vector* lines = item->getHoverText(nullptr, false); - std::wstring desc = L""; - std::vector* strings = - item->getHoverTextOnly(nullptr, false, unformattedStrings); - bool firstLine = true; - for (AUTO_VAR(it, strings->begin()); it != strings->end(); ++it) { - std::wstring thisString = *it; - if (!firstLine) { - desc.append(L"
"); - } else { - firstLine = false; - } - desc.append(thisString); + // Add rarity to first line + if (lines->size() > 0) { + lines->at(0).color = item->getRarity()->color; } - strings->clear(); - delete strings; - return desc; + + return lines; } + +void IUIScene_TradingMenu::HandleInventoryUpdated() { updateDisplay(); } \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.h index 4754e04de..d3e11241c 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_TradingMenu.h @@ -39,20 +39,20 @@ protected: virtual void setRequest2RedBox(bool show) = 0; virtual void setTradeRedBox(int index, bool show) = 0; - virtual void setOfferDescription( - const std::wstring& name, - std::vector& unformattedStrings) = 0; + virtual void setOfferDescription(std::vector* description) = 0; virtual void setRequest1Item(std::shared_ptr item); virtual void setRequest2Item(std::shared_ptr item); virtual void setTradeItem(int index, std::shared_ptr item); -private: void updateDisplay(); + void HandleInventoryUpdated(); + +private: bool canMake(MerchantRecipe* recipe); - std::wstring GetItemDescription( - std::shared_ptr item, - std::vector& unformattedStrings); + + std::vector* GetItemDescription( + std::shared_ptr item); public: std::shared_ptr getMerchant(); diff --git a/Minecraft.Client/Platform/Common/UI/UI.h b/Minecraft.Client/Platform/Common/UI/UI.h index 622ccf846..428b3b904 100644 --- a/Minecraft.Client/Platform/Common/UI/UI.h +++ b/Minecraft.Client/Platform/Common/UI/UI.h @@ -31,10 +31,12 @@ #include "UIControl_HTMLLabel.h" #include "UIControl_DynamicLabel.h" #include "UIControl_MinecraftPlayer.h" +#include "UIControl_MinecraftHorse.h" #include "UIControl_PlayerSkinPreview.h" #include "UIControl_EnchantmentButton.h" #include "UIControl_EnchantmentBook.h" #include "UIControl_SpaceIndicatorBar.h" +#include "UIControl_BeaconEffectButton.h" #ifdef __PSVITA__ #include "UIControl_Touch.h" @@ -85,6 +87,7 @@ #include "UIScene_SettingsUIMenu.h" #include "UIScene_SkinSelectMenu.h" #include "UIScene_HowToPlayMenu.h" +#include "UIScene_LanguageSelector.h" #include "UIScene_HowToPlay.h" #include "UIScene_ControlsMenu.h" #include "UIScene_Credits.h" @@ -101,6 +104,10 @@ #include "UIScene_CreativeMenu.h" #include "UIScene_TradingMenu.h" #include "UIScene_AnvilMenu.h" +#include "UIScene_HorseInventoryMenu.h" +#include "UIScene_HopperMenu.h" +#include "UIScene_BeaconMenu.h" +#include "UIScene_FireworksMenu.h" #include "UIScene_CraftingMenu.h" #include "UIScene_SignEntryMenu.h" @@ -116,3 +123,4 @@ #include "UIScene_TeleportMenu.h" #include "UIScene_EndPoem.h" #include "UIScene_EULA.h" +#include "UIScene_NewUpdateMessage.h" \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIBitmapFont.cpp b/Minecraft.Client/Platform/Common/UI/UIBitmapFont.cpp index 74c9b55cc..6a4a639fe 100644 --- a/Minecraft.Client/Platform/Common/UI/UIBitmapFont.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIBitmapFont.cpp @@ -43,17 +43,19 @@ UIAbstractBitmapFont::UIAbstractBitmapFont(const std::string& fontname) { } void UIAbstractBitmapFont::registerFont() { - if (m_registered) { - return; + if (!m_registered) { + // 4J-JEV: These only need registering the once when we first use this + // font in Iggy. + m_bitmapFontProvider->num_glyphs = m_numGlyphs; + IggyFontInstallBitmapUTF8(m_bitmapFontProvider, m_fontname.c_str(), -1, + IGGY_FONTFLAG_none); + m_registered = true; } - m_bitmapFontProvider->num_glyphs = m_numGlyphs; - - IggyFontInstallBitmapUTF8(m_bitmapFontProvider, m_fontname.c_str(), -1, - IGGY_FONTFLAG_none); + // 4J-JEV: Reset the font redirect to these fonts (we must do this everytime + // in-case we switched away elsewhere). IggyFontSetIndirectUTF8(m_fontname.c_str(), -1, IGGY_FONTFLAG_all, m_fontname.c_str(), -1, IGGY_FONTFLAG_none); - m_registered = true; } IggyFontMetrics* RADLINK UIAbstractBitmapFont::GetFontMetrics_Callback( @@ -110,15 +112,6 @@ UIBitmapFont::UIBitmapFont(SFontData& sfontdata) BufferedImage bimg(sfontdata.m_wstrFilename); int* bimgData = bimg.getData(); - if (bimgData == nullptr) { - fprintf(stderr, - "[UIBitmapFont] ERROR: failed to load font image for '%s' is " - "font included?\n", - sfontdata.m_strFontName.c_str()); - m_cFontData = new CFontData(); // todo: make font work - return; - } - m_cFontData = new CFontData(sfontdata, bimgData); // delete [] bimgData; @@ -392,8 +385,8 @@ bitmap->pixel_scale_max = actualScale * glyphScaleMax * 1.001f; */ } // Callback function type for freeing a bitmap shape returned by GetGlyphBitmap -void RADLINK UIBitmapFont::FreeGlyphBitmap(S32 glyph, F32 pixel_scale, - IggyBitmapCharacter* bitmap) { +void UIBitmapFont::FreeGlyphBitmap(S32 glyph, F32 pixel_scale, + IggyBitmapCharacter* bitmap) { // We don't need to free anything,it just comes from the archive. // app.DebugPrintf("Free bitmap for glyph %d at scale // %f\n",glyph,pixel_scale); diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp b/Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp index baaa7d5ba..9dfcbc053 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp @@ -48,7 +48,8 @@ void UIComponent_Panorama::tick() { // are we in the Nether? - Leave the time as 0 if we are, so we show // daylight if (pMinecraft->level->dimension->id == 0) { - i64TimeOfDay = pMinecraft->level->getLevelData()->getTime() % 24000; + i64TimeOfDay = + pMinecraft->level->getLevelData()->getGameTime() % 24000; } if (i64TimeOfDay > 14000) { diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_PressStartToPlay.cpp b/Minecraft.Client/Platform/Common/UI/UIComponent_PressStartToPlay.cpp index f5015efe4..bcad3c89f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_PressStartToPlay.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_PressStartToPlay.cpp @@ -22,20 +22,24 @@ UIComponent_PressStartToPlay::UIComponent_PressStartToPlay(int iPad, m_labelTrialTimer.init(L""); m_labelTrialTimer.setVisible(false); + // 4J-JEV: This object is persistent, so this string needs to be able to + // handle language changes. #ifdef __ORBIS__ - std::wstring text = app.GetString(IDS_PRESS_X_TO_JOIN); - text = replaceAll(text, L"{*CONTROLLER_VK_A*}", - app.GetVKReplacement(VK_PAD_A)); - - m_labelPressStart.init(text.c_str()); + m_labelPressStart.init((UIString)[] { + return replaceAll(app.GetString(IDS_PRESS_X_TO_JOIN), + L"{*CONTROLLER_VK_A*}", + app.GetVKReplacement(VK_PAD_A)); + }); #elif defined _XBOX_ONE - std::wstring text = app.GetString(IDS_PRESS_START_TO_JOIN); - text = replaceAll(text, L"{*CONTROLLER_VK_START*}", - app.GetVKReplacement(VK_PAD_START)); - m_labelPressStart.init(text.c_str()); + m_labelPressStart.init((UIString)[] { + return replaceAll(app.GetString(IDS_PRESS_START_TO_JOIN), + L"{*CONTROLLER_VK_START*}", + app.GetVKReplacement(VK_PAD_START)); + }); #else - m_labelPressStart.init(app.GetString(IDS_PRESS_START_TO_JOIN)); + m_labelPressStart.init(IDS_PRESS_START_TO_JOIN); #endif + m_controlSaveIcon.setVisible(false); m_controlPressStartPanel.setVisible(false); m_playerDisplayName.setVisible(false); diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.cpp b/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.cpp index aa9c0e63a..d7e43362b 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.cpp @@ -158,6 +158,18 @@ void UIComponent_Tooltips::tick() { fVal = 0.01f * (float)ucAlpha; } setOpacity(fVal); + + bool layoutChanges = false; + for (int i = 0; i < eToolTipNumButtons; i++) { + if (!ui.IsReloadingSkin() && m_tooltipValues[i].show && + m_tooltipValues[i].label.needsUpdating()) { + layoutChanges = true; + _SetTooltip(i, m_tooltipValues[i].label, m_tooltipValues[i].show, + true); + m_tooltipValues[i].label.setUpdated(); + } + } + if (layoutChanges) _Relayout(); } void UIComponent_Tooltips::render(S32 width, S32 height, @@ -247,7 +259,7 @@ void UIComponent_Tooltips::ShowTooltip(unsigned int tooltip, bool show) { void UIComponent_Tooltips::SetTooltips(int iA, int iB, int iX, int iY, int iLT, int iRT, int iLB, int iRB, int iLS, - bool forceUpdate) { + int iRS, int iBack, bool forceUpdate) { bool needsRelayout = false; needsRelayout = _SetTooltip(eToolTipButtonA, iA) || needsRelayout; needsRelayout = _SetTooltip(eToolTipButtonB, iB) || needsRelayout; @@ -258,7 +270,9 @@ void UIComponent_Tooltips::SetTooltips(int iA, int iB, int iX, int iY, int iLT, needsRelayout = _SetTooltip(eToolTipButtonLB, iLB) || needsRelayout; needsRelayout = _SetTooltip(eToolTipButtonRB, iRB) || needsRelayout; needsRelayout = _SetTooltip(eToolTipButtonLS, iLS) || needsRelayout; - + needsRelayout = _SetTooltip(eToolTipButtonRS, iRS) || needsRelayout; + needsRelayout = _SetTooltip(eToolTipButtonRS, iRS) || needsRelayout; + needsRelayout = _SetTooltip(eToolTipButtonBack, iBack) || needsRelayout; if (needsRelayout) _Relayout(); } @@ -271,7 +285,7 @@ bool UIComponent_Tooltips::_SetTooltip(unsigned int iToolTip, int iTextID) { m_tooltipValues[iToolTip].iString = iTextID; changed = true; if (iTextID > -1) - _SetTooltip(iToolTip, app.GetString(iTextID), true); + _SetTooltip(iToolTip, iTextID, true); else if (iTextID == -2) _SetTooltip(iToolTip, L"", true); else @@ -280,13 +294,13 @@ bool UIComponent_Tooltips::_SetTooltip(unsigned int iToolTip, int iTextID) { return changed; } -void UIComponent_Tooltips::_SetTooltip(unsigned int iToolTipId, - const std::wstring& label, bool show, - bool force) { +void UIComponent_Tooltips::_SetTooltip(unsigned int iToolTipId, UIString label, + bool show, bool force) { if (!force && !show && !m_tooltipValues[iToolTipId].show) { return; } m_tooltipValues[iToolTipId].show = show; + m_tooltipValues[iToolTipId].label = label; IggyDataValue result; IggyDataValue value[3]; @@ -308,7 +322,7 @@ void UIComponent_Tooltips::_SetTooltip(unsigned int iToolTipId, IggyPlayerRootPath(getMovie()), m_funcSetTooltip, 3, value); - app.DebugPrintf("Actual tooltip update!\n"); + // app.DebugPrintf("Actual tooltip update!\n"); } void UIComponent_Tooltips::_Relayout() { @@ -330,18 +344,30 @@ void UIComponent_Tooltips::handleTouchInput(unsigned int iPad, S32 x, S32 y, // app.DebugPrintf("ToolTip Touch ID = %i\n", iId); bool handled = false; + // 4J - TomK no tooltips no touch! + if ((!ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad())) && + (app.GetGameSettings(ProfileManager.GetPrimaryPad(), + eGameSetting_Tooltips) == 0)) + return; + // perform action on release if (bReleased) { switch (iId) { case ETouchInput_Touch_A: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_X\n", iId); - InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_X); + if (InputManager.IsCircleCrossSwapped()) + InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_O); + else + InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_X); break; case ETouchInput_Touch_B: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_O\n", iId); - InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_O); + if (InputManager.IsCircleCrossSwapped()) + InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_X); + else + InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_O); break; case ETouchInput_Touch_X: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_SQUARE\n", @@ -358,9 +384,8 @@ void UIComponent_Tooltips::handleTouchInput(unsigned int iPad, S32 x, S32 y, app.DebugPrintf("ToolTip no action\n", iId); break; case ETouchInput_Touch_RightTrigger: - app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_SELECT\n", - iId); - InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_SELECT); + app.DebugPrintf("ToolTip no action\n", iId); + /* no action */ break; case ETouchInput_Touch_LeftBumper: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_L1\n", @@ -376,6 +401,16 @@ void UIComponent_Tooltips::handleTouchInput(unsigned int iPad, S32 x, S32 y, app.DebugPrintf("ToolTip no action\n", iId); /* no action */ break; + case ETouchInput_Touch_RightStick: + app.DebugPrintf( + "ToolTip Map Touch to _PSV_JOY_BUTTON_DPAD_DOWN\n", iId); + InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_DPAD_DOWN); + break; + case ETouchInput_Touch_Select: + app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_SELECT\n", + iId); + InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_SELECT); + break; } } } @@ -397,8 +432,8 @@ void UIComponent_Tooltips::handleReload() { #endif for (unsigned int i = 0; i < eToolTipNumButtons; ++i) { - _SetTooltip(i, app.GetString(m_tooltipValues[i].iString), - m_tooltipValues[i].show, true); + _SetTooltip(i, m_tooltipValues[i].iString, m_tooltipValues[i].show, + true); } _Relayout(); } @@ -406,7 +441,7 @@ void UIComponent_Tooltips::handleReload() { void UIComponent_Tooltips::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool& handled) { - if (m_overrideSFX[iPad][key]) { + if ((0 <= iPad) && (iPad <= 3) && m_overrideSFX[iPad][key]) { // don't play a sound for this action switch (key) { case ACTION_MENU_A: diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.h b/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.h index fcee19443..c0dbb83a6 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.h +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_Tooltips.h @@ -11,6 +11,8 @@ protected: bool show; int iString; + UIString label; + _TooltipValues() { show = false; iString = -1; @@ -33,6 +35,8 @@ protected: ETouchInput_Touch_LeftBumper, ETouchInput_Touch_RightBumper, ETouchInput_Touch_LeftStick, + ETouchInput_Touch_RightStick, + ETouchInput_Touch_Select, ETouchInput_Count, }; @@ -54,6 +58,9 @@ protected: "Touch_RightBumper") UI_MAP_ELEMENT(m_TouchController[ETouchInput_Touch_LeftStick], "Touch_LeftStick") + UI_MAP_ELEMENT(m_TouchController[ETouchInput_Touch_RightStick], + "Touch_RightStick") + UI_MAP_ELEMENT(m_TouchController[ETouchInput_Touch_Select], "Touch_Select") #endif UI_MAP_NAME(m_funcSetTooltip, L"SetToolTip") UI_MAP_NAME(m_funcSetOpacity, L"SetOpacity") @@ -93,8 +100,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, - bool forceUpdate = false); + int iRB = -1, int iLS = -1, int iRS = -1, + int iBack = -1, bool forceUpdate = false); virtual void EnableTooltip(unsigned int tooltip, bool enable); virtual void handleReload(); @@ -105,8 +112,8 @@ public: private: bool _SetTooltip(unsigned int iToolTip, int iTextID); - void _SetTooltip(unsigned int iToolTipId, const std::wstring& label, - bool show, bool force = false); + void _SetTooltip(unsigned int iToolTipId, UIString label, bool show, + bool force = false); void _Relayout(); bool m_overrideSFX[XUSER_MAX_COUNT][ACTION_MAX_MENU]; diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp index 1a1c6ea97..da796fc7c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp @@ -22,6 +22,7 @@ UIComponent_TutorialPopup::UIComponent_TutorialPopup(int iPad, void* initData, m_bContainerMenuVisible = false; m_bSplitscreenGamertagVisible = false; + m_iconType = e_ICON_TYPE_IGGY; m_labelDescription.init(L""); @@ -76,6 +77,8 @@ void UIComponent_TutorialPopup::handleReload() { IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcAdjustLayout, 1, value); + + setupIconHolder(m_iconType); } void UIComponent_TutorialPopup::SetTutorialDescription( @@ -327,7 +330,7 @@ std::wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, setupIconHolder(e_ICON_TYPE_TOOLS); } else if (temp.find(L"{*StoneIcon*}") != std::wstring::npos) { m_iconItem = std::shared_ptr( - new ItemInstance(Tile::rock_Id, 1, 0)); + new ItemInstance(Tile::stone_Id, 1, 0)); } else { m_iconItem = nullptr; } @@ -437,6 +440,8 @@ void UIComponent_TutorialPopup::UpdateInteractScenePosition(bool visible) { (m_interactScene->getSceneType() == eUIScene_Crafting3x3Menu); bool isCreativeScene = (m_interactScene->getSceneType() == eUIScene_CreativeMenu); + bool isTradingScene = + (m_interactScene->getSceneType() == eUIScene_TradingMenu); switch (Minecraft::GetInstance()->localplayers[m_iPad]->m_iScreenSection) { case C4JRender::VIEWPORT_TYPE_FULLSCREEN: case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: @@ -446,7 +451,7 @@ void UIComponent_TutorialPopup::UpdateInteractScenePosition(bool visible) { default: // anim allowed for everything except the crafting 2x2 and 3x3, and // the creative menu - if (!isCraftingScene && !isCreativeScene) { + if (!isCraftingScene && !isCreativeScene && !isTradingScene) { bAllowAnim = true; } break; @@ -543,4 +548,6 @@ void UIComponent_TutorialPopup::setupIconHolder(EIcons icon) { IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetupIconHolder, 1, value); + + m_iconType = icon; } diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.h b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.h index c86587737..040d62761 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.h +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.h @@ -37,6 +37,8 @@ private: e_ICON_TYPE_TRANSPORT = 11, }; + EIcons m_iconType; + public: UIComponent_TutorialPopup(int iPad, void* initData, UILayer* parentLayer); @@ -96,8 +98,7 @@ private: void _SetDescription(UIScene* interactScene, const std::wstring& desc, const std::wstring& title, bool allowFade, bool isReminder); - std::wstring _SetIcon(int icon, int iAuxVal, bool isFoil, - const wchar_t* desc); + std::wstring _SetIcon(int icon, int iAuxVal, bool isFoil, LPCWSTR desc); std::wstring _SetImage(std::wstring& desc); std::wstring ParseDescription(int iPad, std::wstring& text); void UpdateInteractScenePosition(bool visible); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl.h b/Minecraft.Client/Platform/Common/UI/UIControl.h index 259eb6c05..19cdb9ad4 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl.h @@ -17,6 +17,7 @@ public: eLabel, eLeaderboardList, eMinecraftPlayer, + eMinecraftHorse, ePlayerList, ePlayerSkinPreview, eProgress, diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp index 4694b3376..b35fae22c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp @@ -6,7 +6,7 @@ UIControl_Base::UIControl_Base() { m_bLabelChanged = false; - m_label = L""; + m_label; m_id = 0; } @@ -25,7 +25,7 @@ bool UIControl_Base::setupControl(UIScene* scene, IggyValuePath* parent, void UIControl_Base::tick() { UIControl::tick(); - if (m_bLabelChanged) { + if (m_label.needsUpdating() || m_bLabelChanged) { // app.DebugPrintf("Calling SetLabel - '%ls'\n", m_label.c_str()); m_bLabelChanged = false; @@ -43,11 +43,12 @@ void UIControl_Base::tick() { IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_setLabelFunc, 1, value); + + m_label.setUpdated(); } } -void UIControl_Base::setLabel(const std::wstring& label, bool instant, - bool force) { +void UIControl_Base::setLabel(UIString label, bool instant, bool force) { if (force || ((!m_label.empty() || !label.empty()) && m_label.compare(label) != 0)) m_bLabelChanged = true; @@ -73,11 +74,6 @@ void UIControl_Base::setLabel(const std::wstring& label, bool instant, } } -void UIControl_Base::setLabel(const std::string& label) { - std::wstring wlabel = convStringToWstring(label); - setLabel(wlabel); -} - const wchar_t* UIControl_Base::getLabel() { IggyDataValue result; IggyResult out = diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Base.h b/Minecraft.Client/Platform/Common/UI/UIControl_Base.h index 13ddfae43..0aa25e053 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Base.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Base.h @@ -1,6 +1,7 @@ #pragma once #include "UIControl.h" +#include "UIString.h" // This class maps to the FJ_Base class in actionscript class UIControl_Base : public UIControl { @@ -11,7 +12,7 @@ protected: IggyName m_funcCheckLabelWidths; bool m_bLabelChanged; - std::wstring m_label; + UIString m_label; public: UIControl_Base(); @@ -21,9 +22,12 @@ public: virtual void tick(); - virtual void setLabel(const std::wstring& label, bool instant = false, + virtual void setLabel(UIString label, bool instant = false, bool force = false); - virtual void setLabel(const std::string& label); + // virtual void setLabel(std::wstring label, bool instant = false, bool + // force = false) { this->setLabel(UIString::CONSTANT(label), instant, + // force); } + const wchar_t* getLabel(); virtual void setAllPossibleLabels(int labelCount, wchar_t labels[][256]); int getId() { return m_id; } diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_BeaconEffectButton.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_BeaconEffectButton.cpp new file mode 100644 index 000000000..62578a3ec --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIControl_BeaconEffectButton.cpp @@ -0,0 +1,101 @@ +#include "../../stdafx.h" +#include "UI.h" +#include "UIControl_BeaconEffectButton.h" + +UIControl_BeaconEffectButton::UIControl_BeaconEffectButton() { + m_data = 0; + m_icon = 0; + m_selected = false; + m_active = false; + m_focus = false; +} + +bool UIControl_BeaconEffectButton::setupControl( + UIScene* scene, IggyValuePath* parent, const std::string& controlName) { + bool success = UIControl::setupControl(scene, parent, controlName); + + m_funcChangeState = registerFastName(L"ChangeState"); + m_funcSetIcon = registerFastName(L"SetIcon"); + + return success; +} + +void UIControl_BeaconEffectButton::SetData(int data, int icon, bool active, + bool selected) { + m_data = data; + m_active = active; + m_selected = selected; + + SetIcon(icon); + UpdateButtonState(); +} + +int UIControl_BeaconEffectButton::GetData() { return m_data; } + +void UIControl_BeaconEffectButton::SetButtonSelected(bool selected) { + if (selected != m_selected) { + m_selected = selected; + + UpdateButtonState(); + } +} + +bool UIControl_BeaconEffectButton::IsButtonSelected() { return m_selected; } + +void UIControl_BeaconEffectButton::SetButtonActive(bool active) { + if (m_active != active) { + m_active = active; + + UpdateButtonState(); + } +} + +void UIControl_BeaconEffectButton::setFocus(bool focus) { + if (m_focus != focus) { + m_focus = focus; + + UpdateButtonState(); + } +} + +void UIControl_BeaconEffectButton::SetIcon(int icon) { + if (icon != m_icon) { + m_icon = icon; + + IggyDataValue result; + IggyDataValue value[1]; + + value[0].type = IGGY_DATATYPE_number; + value[0].number = m_icon; + IggyResult out = + IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, + getIggyValuePath(), m_funcSetIcon, 1, value); + } +} + +void UIControl_BeaconEffectButton::UpdateButtonState() { + EState state = eState_Disabled; + + if (!m_active) { + state = eState_Disabled; + } else if (m_selected) { + state = eState_Pressed; + } else if (m_focus) { + state = eState_Enabled_Selected; + } else { + state = eState_Enabled_Unselected; + } + + if (state != m_lastState) { + IggyDataValue result; + IggyDataValue value[1]; + + value[0].type = IGGY_DATATYPE_number; + value[0].number = state; + IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), + &result, getIggyValuePath(), + m_funcChangeState, 1, value); + + if (out == IGGY_RESULT_SUCCESS) m_lastState = state; + } +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_BeaconEffectButton.h b/Minecraft.Client/Platform/Common/UI/UIControl_BeaconEffectButton.h new file mode 100644 index 000000000..5206e2871 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIControl_BeaconEffectButton.h @@ -0,0 +1,48 @@ +#pragma once + +#include "UIControl.h" + +class UIControl_BeaconEffectButton : public UIControl { +private: + static const int BUTTON_DISABLED = 0; + static const int BUTTON_ENABLED_UNSELECTED = 1; + static const int BUTTON_ENABLED_SELECTED = 2; + static const int BUTTON_PRESSED = 3; + + enum EState { + eState_Disabled, + eState_Enabled_Unselected, + eState_Enabled_Selected, + eState_Pressed + }; + EState m_lastState; + + int m_data; + int m_icon; + bool m_selected; + bool m_active; + bool m_focus; + + IggyName m_funcChangeState, m_funcSetIcon; + +public: + UIControl_BeaconEffectButton(); + + virtual bool setupControl(UIScene* scene, IggyValuePath* parent, + const std::string& controlName); + + void SetData(int data, int icon, bool active, bool selected); + int GetData(); + + void SetButtonSelected(bool selected); + bool IsButtonSelected(); + + void SetButtonActive(bool active); + + virtual void setFocus(bool focus); + + void SetIcon(int icon); + +private: + void UpdateButtonState(); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Button.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_Button.cpp index 184a7ee2a..66e7857f5 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Button.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Button.cpp @@ -15,7 +15,7 @@ bool UIControl_Button::setupControl(UIScene* scene, IggyValuePath* parent, return success; } -void UIControl_Button::init(const std::wstring& label, int id) { +void UIControl_Button::init(UIString label, int id) { m_label = label; m_id = id; diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Button.h b/Minecraft.Client/Platform/Common/UI/UIControl_Button.h index 1db4af24b..1c9a4d1ba 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Button.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Button.h @@ -12,7 +12,10 @@ public: virtual bool setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName); - void init(const std::wstring& label, int id); + void init(UIString label, int id); + // void init(const std::wstring &label, int id) { + // init(UIString::CONSTANT(label), id); } + virtual void ReInit(); void setEnable(bool enable); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.cpp index 2c26ee714..8d955e773 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.cpp @@ -199,3 +199,37 @@ bool UIControl_ButtonList::CanTouchTrigger(S32 iX, S32 iY) { return bCanTouchTrigger; } #endif + +void UIControl_DynamicButtonList::tick() { + UIControl_ButtonList::tick(); + + int buttonIndex = 0; + std::vector::iterator itr; + for (itr = m_labels.begin(); itr != m_labels.end(); itr++) { + if (itr->needsUpdating()) { + setButtonLabel(buttonIndex, itr->getString()); + itr->setUpdated(); + } + buttonIndex++; + } +} + +void UIControl_DynamicButtonList::addItem(UIString label, int data) { + if (data < 0) data = m_itemCount; + + if (data < m_labels.size()) { + m_labels[data] = label; + } else { + while (data > m_labels.size()) { + m_labels.push_back(UIString()); + } + m_labels.push_back(label); + } + + UIControl_ButtonList::addItem(label.getString(), data); +} + +void UIControl_DynamicButtonList::removeItem(int index) { + m_labels.erase(m_labels.begin() + index); + UIControl_ButtonList::removeItem(index); +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.h b/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.h index 0aa7b8cd3..422e2c7ed 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_ButtonList.h @@ -44,3 +44,15 @@ public: bool CanTouchTrigger(S32 iX, S32 iY); #endif }; + +class UIControl_DynamicButtonList : public UIControl_ButtonList { +protected: + std::vector m_labels; + +public: + virtual void tick(); + + virtual void addItem(UIString label, int data = -1); + + virtual void removeItem(int index); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_CheckBox.h b/Minecraft.Client/Platform/Common/UI/UIControl_CheckBox.h index 2c0b6b316..87de86bb5 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_CheckBox.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_CheckBox.h @@ -14,7 +14,7 @@ public: virtual bool setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName); - void init(const std::wstring& label, int id, bool checked); + void init(UIString label, int id, bool checked); bool IsChecked(); bool IsEnabled(); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentBook.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentBook.cpp index fd21e6b06..faf8c7fa1 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentBook.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentBook.cpp @@ -32,9 +32,7 @@ void UIControl_EnchantmentBook::render(IggyCustomDrawCallbackRegion* region) { glTranslatef(m_width / 2, m_height / 2, 50.0f); // Add a uniform scale - glScalef(1 / ssX, 1 / ssX, 1.0f); - - glScalef(50.0f, 50.0f, 1.0f); + glScalef(-57 / ssX, 57 / ssX, 360.0f); glRotatef(45 + 90, 0, 1, 0); Lighting::turnOn(); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentButton.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentButton.cpp index e20dce885..465c33554 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentButton.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentButton.cpp @@ -36,6 +36,15 @@ bool UIControl_EnchantmentButton::setupControl(UIScene* scene, void UIControl_EnchantmentButton::init(int index) { m_index = index; } +void UIControl_EnchantmentButton::ReInit() { + UIControl_Button::ReInit(); + + m_lastState = eState_Inactive; + m_lastCost = 0; + m_bHasFocus = false; + updateState(); +} + void UIControl_EnchantmentButton::tick() { updateState(); UIControl_Button::tick(); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentButton.h b/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentButton.h index 826498d82..5005ba71f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentButton.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_EnchantmentButton.h @@ -44,7 +44,7 @@ public: virtual void tick(); void init(int index); - + virtual void ReInit(); void render(IggyCustomDrawCallbackRegion* region); void updateState(); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Label.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_Label.cpp index 2196361e9..2e9b5dd89 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Label.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Label.cpp @@ -15,35 +15,17 @@ bool UIControl_Label::setupControl(UIScene* scene, IggyValuePath* parent, return success; } -void UIControl_Label::init(const std::wstring& label) { +void UIControl_Label::init(UIString label) { m_label = label; - const std::u16string convLabel = convWstringToU16string(label); - IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_string_UTF16; IggyStringUTF16 stringVal; - stringVal.string = convLabel.c_str(); - stringVal.length = convLabel.length(); - value[0].string16 = stringVal; - IggyResult out = - IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, - getIggyValuePath(), m_initFunc, 1, value); -} - -void UIControl_Label::init(const std::string& label) { - m_label = convStringToWstring(label); - - IggyDataValue result; - IggyDataValue value[1]; - value[0].type = IGGY_DATATYPE_string_UTF8; - IggyStringUTF8 stringVal; - - stringVal.string = (char*)label.c_str(); + stringVal.string = (IggyUTF16*)label.c_str(); stringVal.length = label.length(); - value[0].string8 = stringVal; + value[0].string16 = stringVal; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_initFunc, 1, value); @@ -51,5 +33,9 @@ void UIControl_Label::init(const std::string& label) { void UIControl_Label::ReInit() { UIControl_Base::ReInit(); - init(m_label); + + // 4J-JEV: This can't be reinitialised. + if (m_reinitEnabled) { + init(m_label); + } } diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Label.h b/Minecraft.Client/Platform/Common/UI/UIControl_Label.h index a59ccbe94..89230a759 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Label.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Label.h @@ -3,13 +3,17 @@ #include "UIControl_Base.h" class UIControl_Label : public UIControl_Base { +private: + bool m_reinitEnabled; + public: UIControl_Label(); virtual bool setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName); - void init(const std::wstring& label); - void init(const std::string& label); + void init(UIString label); virtual void ReInit(); + + void disableReinitialisation() { m_reinitEnabled = false; } }; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftHorse.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftHorse.cpp new file mode 100644 index 000000000..d27254769 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftHorse.cpp @@ -0,0 +1,108 @@ +#include "../../stdafx.h" +#include "../../Minecraft.h" +#include "../../ScreenSizeCalculator.h" +#include "../../EntityRenderDispatcher.h" + +#include "../../PlayerRenderer.h" +#include "../../HorseRenderer.h" + +#include "../../HumanoidModel.h" +#include "../../ModelHorse.h" + +#include "../../Lighting.h" +#include "../../ModelPart.h" +#include "../../Options.h" + +#include "../../../../Minecraft.World/Headers/net.minecraft.world.entity.player.h" +// #include +// "../../../Minecraft.World/net.minecraft.world.entity.animal.EntityHorse.h" + +#include "../../MultiPlayerLocalPlayer.h" +#include "UI.h" +#include "UIControl_MinecraftHorse.h" + +UIControl_MinecraftHorse::UIControl_MinecraftHorse() { + UIControl::setControlType(UIControl::eMinecraftHorse); + + Minecraft* pMinecraft = Minecraft::GetInstance(); + + ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, + pMinecraft->height_phys); + m_fScreenWidth = (float)pMinecraft->width_phys; + m_fRawWidth = (float)ssc.rawWidth; + m_fScreenHeight = (float)pMinecraft->height_phys; + m_fRawHeight = (float)ssc.rawHeight; +} + +void UIControl_MinecraftHorse::render(IggyCustomDrawCallbackRegion* region) { + Minecraft* pMinecraft = Minecraft::GetInstance(); + glEnable(GL_RESCALE_NORMAL); + glEnable(GL_COLOR_MATERIAL); + glPushMatrix(); + + float width = region->x1 - region->x0; + float height = region->y1 - region->y0; + float xo = width / 2; + float yo = height; + + // dynamic y offset according to region height + glTranslatef(xo, yo - (height / 7.5f), 50.0f); + + // UIScene_InventoryMenu *containerMenu = (UIScene_InventoryMenu + // *)m_parentScene; + UIScene_HorseInventoryMenu* containerMenu = + (UIScene_HorseInventoryMenu*)m_parentScene; + + std::shared_ptr entityHorse = containerMenu->m_horse; + + // Base scale on height of this control + // Potentially we might want separate x & y scales here + float ss = width / (m_fScreenWidth / m_fScreenHeight) * 0.71f; + + glScalef(-ss, ss, ss); + glRotatef(180, 0, 0, 1); + + float oybr = entityHorse->yBodyRot; + float oyr = entityHorse->yRot; + float oxr = entityHorse->xRot; + float oyhr = entityHorse->yHeadRot; + + // float xd = ( matrix._41 + ( (bwidth*matrix._11)/2) ) - m_pointerPos.x; + float xd = (m_x + m_width / 2) - containerMenu->m_pointerPos.x; + + // Need to base Y on head position, not centre of mass + // float yd = ( matrix._42 + ( (bheight*matrix._22) / 2) - 40 ) - + // m_pointerPos.y; + float yd = (m_y + m_height / 2 - 40) - containerMenu->m_pointerPos.y; + + glRotatef(45 + 90, 0, 1, 0); + Lighting::turnOn(); + glRotatef(-45 - 90, 0, 1, 0); + + glRotatef(-(float)atan(yd / 40.0f) * 20, 1, 0, 0); + + entityHorse->yBodyRot = (float)atan(xd / 40.0f) * 20; + entityHorse->yRot = (float)atan(xd / 40.0f) * 40; + entityHorse->xRot = -(float)atan(yd / 40.0f) * 20; + entityHorse->yHeadRot = entityHorse->yRot; + // entityHorse->glow = 1; + glTranslatef(0, entityHorse->heightOffset, 0); + EntityRenderDispatcher::instance->playerRotY = 180; + + // 4J Stu - Turning on hideGui while we do this stops the name rendering in + // split-screen + bool wasHidingGui = pMinecraft->options->hideGui; + pMinecraft->options->hideGui = true; + EntityRenderDispatcher::instance->render(entityHorse, 0, 0, 0, 0, 1, false, + false); + pMinecraft->options->hideGui = wasHidingGui; + // entityHorse->glow = 0; + + entityHorse->yBodyRot = oybr; + entityHorse->yRot = oyr; + entityHorse->xRot = oxr; + entityHorse->yHeadRot = oyhr; + glPopMatrix(); + Lighting::turnOff(); + glDisable(GL_RESCALE_NORMAL); +} diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftHorse.h b/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftHorse.h new file mode 100644 index 000000000..32ef7780c --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftHorse.h @@ -0,0 +1,14 @@ +#pragma once + +#include "UIControl.h" + +class UIControl_MinecraftHorse : public UIControl { +private: + float m_fScreenWidth, m_fScreenHeight; + float m_fRawWidth, m_fRawHeight; + +public: + UIControl_MinecraftHorse(); + + void render(IggyCustomDrawCallbackRegion* region); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftPlayer.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftPlayer.cpp index e2d47d2c6..5f51122c3 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftPlayer.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_MinecraftPlayer.cpp @@ -36,7 +36,8 @@ void UIControl_MinecraftPlayer::render(IggyCustomDrawCallbackRegion* region) { float xo = width / 2; float yo = height; - glTranslatef(xo, yo - 7.0f, 50.0f); + // dynamic y offset according to region height + glTranslatef(xo, yo - (height / 9.0f), 50.0f); float ss; diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp index 4ec59c2fd..5720ceafa 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp @@ -206,7 +206,7 @@ void UIControl_PlayerSkinPreview::render(IggyCustomDrawCallbackRegion* region) { // EntityRenderDispatcher::instance->render(pMinecraft->localplayers[0], 0, // 0, 0, 0, 1); EntityRenderer* renderer = - EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); + EntityRenderDispatcher::instance->getRenderer(eTYPE_LOCALPLAYER); if (renderer != NULL) { // 4J-PB - any additional parts to turn on for this player (skin // dependent) @@ -324,7 +324,13 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer* renderer, double x, float s = 15 / 16.0f; glScalef(s, s, s); + // 4J - TomK - pull up character a bit more to make sure extra geo around + // feet doesn't cause rendering problems on PSVita +#ifdef __PSVITA__ + glTranslatef(0, -24 * _scale - 1.0f / 16.0f, 0); +#else glTranslatef(0, -24 * _scale - 0.125f / 16.0f, 0); +#endif #ifdef SKIN_PREVIEW_WALKING_ANIM m_walkAnimSpeedO = m_walkAnimSpeed; diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Progress.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_Progress.cpp index 427ef72f5..0e44e7448 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Progress.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Progress.cpp @@ -22,8 +22,8 @@ bool UIControl_Progress::setupControl(UIScene* scene, IggyValuePath* parent, return success; } -void UIControl_Progress::init(const std::wstring& label, int id, int min, - int max, int current) { +void UIControl_Progress::init(UIString label, int id, int min, int max, + int current) { m_label = label; m_id = id; m_min = min; @@ -85,4 +85,4 @@ void UIControl_Progress::showBar(bool show) { IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_showBarFunc, 1, value); } -} +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Progress.h b/Minecraft.Client/Platform/Common/UI/UIControl_Progress.h index e4de454b3..14baa44ac 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Progress.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Progress.h @@ -17,7 +17,7 @@ public: virtual bool setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName); - void init(const std::wstring& label, int id, int min, int max, int current); + void init(UIString label, int id, int min, int max, int current); virtual void ReInit(); void setProgress(int current); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Slider.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_Slider.cpp index 2fca322e3..927ab921e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Slider.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Slider.cpp @@ -21,7 +21,7 @@ bool UIControl_Slider::setupControl(UIScene* scene, IggyValuePath* parent, return success; } -void UIControl_Slider::init(const std::wstring& label, int id, int min, int max, +void UIControl_Slider::init(UIString label, int id, int min, int max, int current) { m_label = label; m_id = id; @@ -104,6 +104,7 @@ S32 UIControl_Slider::GetRealWidth() { void UIControl_Slider::setAllPossibleLabels(int labelCount, wchar_t labels[][256]) { + m_allPossibleLabels.clear(); for (unsigned int i = 0; i < labelCount; ++i) { m_allPossibleLabels.push_back(labels[i]); } diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Slider.h b/Minecraft.Client/Platform/Common/UI/UIControl_Slider.h index 4a35edd3d..6bbc9f8d6 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Slider.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Slider.h @@ -22,7 +22,7 @@ public: virtual bool setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName); - void init(const std::wstring& label, int id, int min, int max, int current); + void init(UIString label, int id, int min, int max, int current); void handleSliderMove(int newValue); void SetSliderTouchPos(float fTouchPos); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_SlotList.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_SlotList.cpp index 993d068a5..a327ef17e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_SlotList.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_SlotList.cpp @@ -19,6 +19,12 @@ bool UIControl_SlotList::setupControl(UIScene* scene, IggyValuePath* parent, return success; } +void UIControl_SlotList::ReInit() { + UIControl_Base::ReInit(); + + m_lastHighlighted = -1; +} + void UIControl_SlotList::addSlot(int id) { IggyDataValue result; IggyDataValue value[3]; diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_SlotList.h b/Minecraft.Client/Platform/Common/UI/UIControl_SlotList.h index 009d6d4e5..b882e0b5d 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_SlotList.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_SlotList.h @@ -16,6 +16,8 @@ public: virtual bool setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName); + virtual void ReInit(); + void addSlot(int id); void addSlots(int iStartValue, int iCount); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_SpaceIndicatorBar.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_SpaceIndicatorBar.cpp index 04e36c1d8..27ce915fa 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_SpaceIndicatorBar.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_SpaceIndicatorBar.cpp @@ -24,22 +24,20 @@ bool UIControl_SpaceIndicatorBar::setupControl(UIScene* scene, return success; } -void UIControl_SpaceIndicatorBar::init(const std::wstring& label, int id, - __int64 min, __int64 max) { +void UIControl_SpaceIndicatorBar::init(UIString label, int id, int64_t min, + int64_t max) { m_label = label; m_id = id; m_min = min; m_max = max; - const std::u16string convLabel = convWstringToU16string(label); - IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_string_UTF16; IggyStringUTF16 stringVal; - stringVal.string = convLabel.c_str(); - stringVal.length = convLabel.length(); + stringVal.string = (IggyUTF16*)label.c_str(); + stringVal.length = label.length(); value[0].string16 = stringVal; IggyResult out = @@ -63,10 +61,10 @@ void UIControl_SpaceIndicatorBar::reset() { setSaveGameOffset(0.0f); } -void UIControl_SpaceIndicatorBar::addSave(__int64 size) { +void UIControl_SpaceIndicatorBar::addSave(int64_t size) { float startPercent = (float)((m_currentTotal - m_min)) / (m_max - m_min); - m_sizeAndOffsets.push_back(std::pair<__int64, float>(size, startPercent)); + m_sizeAndOffsets.push_back(std::pair(size, startPercent)); m_currentTotal += size; setTotalSize(m_currentTotal); @@ -74,7 +72,7 @@ void UIControl_SpaceIndicatorBar::addSave(__int64 size) { void UIControl_SpaceIndicatorBar::selectSave(int index) { if (index >= 0 && index < m_sizeAndOffsets.size()) { - std::pair<__int64, float> values = m_sizeAndOffsets[index]; + std::pair values = m_sizeAndOffsets[index]; setSaveSize(values.first); setSaveGameOffset(values.second); } else { @@ -83,7 +81,7 @@ void UIControl_SpaceIndicatorBar::selectSave(int index) { } } -void UIControl_SpaceIndicatorBar::setSaveSize(__int64 size) { +void UIControl_SpaceIndicatorBar::setSaveSize(int64_t size) { m_currentSave = size; float percent = (float)((m_currentSave - m_min)) / (m_max - m_min); @@ -97,7 +95,7 @@ void UIControl_SpaceIndicatorBar::setSaveSize(__int64 size) { getIggyValuePath(), m_setSaveSizeFunc, 1, value); } -void UIControl_SpaceIndicatorBar::setTotalSize(__int64 size) { +void UIControl_SpaceIndicatorBar::setTotalSize(int64_t size) { float percent = (float)((m_currentTotal - m_min)) / (m_max - m_min); IggyDataValue result; @@ -119,4 +117,4 @@ void UIControl_SpaceIndicatorBar::setSaveGameOffset(float offset) { IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_setSaveGameOffsetFunc, 1, value); -} +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_SpaceIndicatorBar.h b/Minecraft.Client/Platform/Common/UI/UIControl_SpaceIndicatorBar.h index 1fd10344f..f65c53c5e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_SpaceIndicatorBar.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_SpaceIndicatorBar.h @@ -5,12 +5,12 @@ class UIControl_SpaceIndicatorBar : public UIControl_Base { private: IggyName m_setSaveSizeFunc, m_setTotalSizeFunc, m_setSaveGameOffsetFunc; - __int64 m_min; - __int64 m_max; - __int64 m_currentSave, m_currentTotal; + int64_t m_min; + int64_t m_max; + int64_t m_currentSave, m_currentTotal; float m_currentOffset; - std::vector > m_sizeAndOffsets; + std::vector > m_sizeAndOffsets; public: UIControl_SpaceIndicatorBar(); @@ -18,15 +18,15 @@ public: virtual bool setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName); - void init(const std::wstring& label, int id, __int64 min, __int64 max); + void init(UIString label, int id, int64_t min, int64_t max); virtual void ReInit(); void reset(); - void addSave(__int64 size); + void addSave(int64_t size); void selectSave(int index); private: - void setSaveSize(__int64 size); - void setTotalSize(__int64 totalSize); + void setSaveSize(int64_t size); + void setTotalSize(int64_t totalSize); void setSaveGameOffset(float offset); }; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_TextInput.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_TextInput.cpp index aa990f8c2..72c7e0f14 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_TextInput.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_TextInput.cpp @@ -1,4 +1,4 @@ -#include "../../Minecraft.World/Platform/stdafx.h" +#include "../../stdafx.h" #include "UI.h" #include "UIControl_TextInput.h" @@ -17,7 +17,7 @@ bool UIControl_TextInput::setupControl(UIScene* scene, IggyValuePath* parent, return success; } -void UIControl_TextInput::init(const std::wstring& label, int id) { +void UIControl_TextInput::init(UIString label, int id) { m_label = label; m_id = id; diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_TextInput.h b/Minecraft.Client/Platform/Common/UI/UIControl_TextInput.h index 3ba16a1db..b8bc7a1bb 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_TextInput.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_TextInput.h @@ -13,7 +13,7 @@ public: virtual bool setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName); - void init(const std::wstring& label, int id); + void init(UIString label, int id); void ReInit(); virtual void setFocus(bool focus); diff --git a/Minecraft.Client/Platform/Common/UI/UIEnums.h b/Minecraft.Client/Platform/Common/UI/UIEnums.h index 6646e7572..f9a352e04 100644 --- a/Minecraft.Client/Platform/Common/UI/UIEnums.h +++ b/Minecraft.Client/Platform/Common/UI/UIEnums.h @@ -98,14 +98,23 @@ enum EUIScene { eUIScene_TradingMenu, eUIScene_AnvilMenu, eUIScene_TeleportMenu, + eUIScene_HopperMenu, + eUIScene_BeaconMenu, + eUIScene_HorseMenu, + eUIScene_FireworksMenu, #ifdef _XBOX // eUIScene_TransferToXboxOne, #endif +// **************************************** +// **************************************** +// ********** IMPORTANT ****************** +// **************************************** +// **************************************** // When adding new scenes here, you must also update the switches in // CConsoleMinecraftApp::NavigateToScene There are quite a few so you need to -// check them all +// check them all Also update UILayer::updateFocusState #ifndef _XBOX // Anything non-xbox should be added here. The ordering of scenes above is @@ -123,6 +132,7 @@ enum EUIScene { eUIScene_Timer, eUIScene_EULA, eUIScene_InGameSaveManagementMenu, + eUIScene_LanguageSelector, #endif // ndef _XBOX #ifdef _DEBUG_MENUS_ENABLED @@ -159,6 +169,8 @@ enum EToolTipButton { eToolTipButtonLB, eToolTipButtonRB, eToolTipButtonLS, + eToolTipButtonRS, + eToolTipButtonBack, eToolTipNumButtons }; @@ -212,6 +224,12 @@ enum EHowToPlayPage { eHowToPlay_Breeding, eHowToPlay_Trading, + eHowToPlay_Horses, + eHowToPlay_Beacons, + eHowToPlay_Fireworks, + eHowToPlay_Hoppers, + eHowToPlay_Droppers, + eHowToPlay_NetherPortal, eHowToPlay_TheEnd, #ifdef _XBOX @@ -231,7 +249,14 @@ enum ECreditTextTypes { eNumTextTypes }; +enum EUIMessage { + eUIMessage_InventoryUpdated, + + eUIMessage_COUNT, +}; + #define NO_TRANSLATED_STRING \ - (-1) // String ID used to indicate that we are using non localised string. + (-1) // String ID used to indicate that we are using non localised + // std::string. #define CONNECTING_PROGRESS_CHECK_TIME 500 diff --git a/Minecraft.Client/Platform/Common/UI/UIGroup.cpp b/Minecraft.Client/Platform/Common/UI/UIGroup.cpp index cec7e3e9f..c60a4b174 100644 --- a/Minecraft.Client/Platform/Common/UI/UIGroup.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIGroup.cpp @@ -283,6 +283,14 @@ void UIGroup::HandleDLCLicenseChange() { } #endif +void UIGroup::HandleMessage(EUIMessage message, void* data) { + // Ignore this group if the player isn't signed in + if (m_iPad >= 0 && !ProfileManager.IsSignedIn(m_iPad)) return; + for (unsigned int i = 0; i < eUILayer_COUNT; ++i) { + m_layers[i]->HandleMessage(message, data); + } +} + bool UIGroup::IsFullscreenGroup() { return m_group == eUIGroup_Fullscreen; } void UIGroup::handleUnlockFullVersion() { @@ -336,10 +344,10 @@ unsigned int UIGroup::GetLayerIndex(UILayer* layerPtr) { return 0; } -void UIGroup::PrintTotalMemoryUsage(__int64& totalStatic, - __int64& totalDynamic) { - __int64 groupStatic = 0; - __int64 groupDynamic = 0; +void UIGroup::PrintTotalMemoryUsage(int64_t& totalStatic, + int64_t& totalDynamic) { + int64_t groupStatic = 0; + int64_t groupDynamic = 0; app.DebugPrintf(app.USER_SR, "-- BEGIN GROUP %d\n", m_group); for (unsigned int i = 0; i < eUILayer_COUNT; ++i) { app.DebugPrintf(app.USER_SR, " \\- BEGIN LAYER %d\n", i); diff --git a/Minecraft.Client/Platform/Common/UI/UIGroup.h b/Minecraft.Client/Platform/Common/UI/UIGroup.h index 89cc5657a..587a4de51 100644 --- a/Minecraft.Client/Platform/Common/UI/UIGroup.h +++ b/Minecraft.Client/Platform/Common/UI/UIGroup.h @@ -107,11 +107,13 @@ public: #ifdef _XBOX_ONE virtual void HandleDLCLicenseChange(); #endif + virtual void HandleMessage(EUIMessage message, void* data); + bool IsFullscreenGroup(); void handleUnlockFullVersion(); - void PrintTotalMemoryUsage(__int64& totalStatic, __int64& totalDynamic); + void PrintTotalMemoryUsage(int64_t& totalStatic, int64_t& totalDynamic); unsigned int GetLayerIndex(UILayer* layerPtr); diff --git a/Minecraft.Client/Platform/Common/UI/UILayer.cpp b/Minecraft.Client/Platform/Common/UI/UILayer.cpp index 3d73df378..479e26aaa 100644 --- a/Minecraft.Client/Platform/Common/UI/UILayer.cpp +++ b/Minecraft.Client/Platform/Common/UI/UILayer.cpp @@ -162,7 +162,7 @@ void UILayer::ReloadAll(bool force) { if (!m_sceneStack.empty()) { int lowestRenderable = 0; for (; lowestRenderable < m_sceneStack.size(); ++lowestRenderable) { - m_sceneStack[lowestRenderable]->reloadMovie(); + m_sceneStack[lowestRenderable]->reloadMovie(force); } } } @@ -221,6 +221,18 @@ bool UILayer::NavigateToScene(int iPad, EUIScene scene, void* initData) { case eUIScene_AnvilMenu: newScene = new UIScene_AnvilMenu(iPad, initData, this); break; + case eUIScene_HopperMenu: + newScene = new UIScene_HopperMenu(iPad, initData, this); + break; + case eUIScene_BeaconMenu: + newScene = new UIScene_BeaconMenu(iPad, initData, this); + break; + case eUIScene_HorseMenu: + newScene = new UIScene_HorseInventoryMenu(iPad, initData, this); + break; + case eUIScene_FireworksMenu: + newScene = new UIScene_FireworksMenu(iPad, initData, this); + break; // Help and Options case eUIScene_HelpAndOptionsMenu: @@ -250,6 +262,9 @@ bool UILayer::NavigateToScene(int iPad, EUIScene scene, void* initData) { case eUIScene_HowToPlayMenu: newScene = new UIScene_HowToPlayMenu(iPad, initData, this); break; + case eUIScene_LanguageSelector: + newScene = new UIScene_LanguageSelector(iPad, initData, this); + break; case eUIScene_HowToPlay: newScene = new UIScene_HowToPlay(iPad, initData, this); break; @@ -307,9 +322,6 @@ bool UILayer::NavigateToScene(int iPad, EUIScene scene, void* initData) { // Frontend case eUIScene_TrialExitUpsell: newScene = new UIScene_TrialExitUpsell(iPad, initData, this); - app.DebugPrintf( - "UILayer::NavigateToScene AFTER UIScene_TrialExitUpsell " - "CALL\n"); break; case eUIScene_Intro: newScene = new UIScene_Intro(iPad, initData, this); @@ -350,6 +362,9 @@ bool UILayer::NavigateToScene(int iPad, EUIScene scene, void* initData) { case eUIScene_EULA: newScene = new UIScene_EULA(iPad, initData, this); break; + case eUIScene_NewUpdateMessage: + newScene = new UIScene_NewUpdateMessage(iPad, initData, this); + break; // Other case eUIScene_Keyboard: @@ -634,6 +649,11 @@ bool UILayer::updateFocusState(bool allowedFocus /* = false */) { m_scenesToDestroy.push_back(scene); #endif } + + if (scene->getSceneType() == eUIScene_SettingsOptionsMenu) { + scene->loseFocus(); + m_scenesToDestroy.push_back(scene); + } } /// UPDATE STACK STATES @@ -656,6 +676,12 @@ bool UILayer::updateFocusState(bool allowedFocus /* = false */) { case eUIScene_DispenserMenu: case eUIScene_BrewingStandMenu: case eUIScene_EnchantingMenu: + case eUIScene_TradingMenu: + case eUIScene_HopperMenu: + case eUIScene_HorseMenu: + case eUIScene_FireworksMenu: + case eUIScene_BeaconMenu: + case eUIScene_AnvilMenu: m_bContainerMenuDisplayed = true; // Intentional fall-through @@ -719,7 +745,7 @@ void UILayer::handleInput(int iPad, int key, bool repeat, bool pressed, // Fix for PS3 #444 - [IN GAME] If the user keeps pressing CROSS while // on the 'Save Game' screen the title will crash. - handled = handled || scene->hidesLowerScenes(); + handled = handled || scene->hidesLowerScenes() || scene->blocksInput(); if (handled) break; } @@ -750,6 +776,13 @@ void UILayer::HandleDLCLicenseChange() { } #endif +void UILayer::HandleMessage(EUIMessage message, void* data) { + for (AUTO_VAR(it, m_sceneStack.rbegin()); it != m_sceneStack.rend(); ++it) { + UIScene* topScene = *it; + topScene->HandleMessage(message, data); + } +} + bool UILayer::IsFullscreenGroup() { return m_parentGroup->IsFullscreenGroup(); } C4JRender::eViewportType UILayer::getViewport() { @@ -762,10 +795,10 @@ void UILayer::handleUnlockFullVersion() { } } -void UILayer::PrintTotalMemoryUsage(__int64& totalStatic, - __int64& totalDynamic) { - __int64 layerStatic = 0; - __int64 layerDynamic = 0; +void UILayer::PrintTotalMemoryUsage(int64_t& totalStatic, + int64_t& totalDynamic) { + int64_t layerStatic = 0; + int64_t layerDynamic = 0; for (AUTO_VAR(it, m_components.begin()); it != m_components.end(); ++it) { (*it)->PrintTotalMemoryUsage(layerStatic, layerDynamic); } @@ -787,4 +820,4 @@ UIScene* UILayer::FindScene(EUIScene sceneType) { } return NULL; -} +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UILayer.h b/Minecraft.Client/Platform/Common/UI/UILayer.h index fef973298..9c5c796ec 100644 --- a/Minecraft.Client/Platform/Common/UI/UILayer.h +++ b/Minecraft.Client/Platform/Common/UI/UILayer.h @@ -93,8 +93,10 @@ public: #ifdef _XBOX_ONE virtual void HandleDLCLicenseChange(); #endif + virtual void HandleMessage(EUIMessage message, void* data); + void handleUnlockFullVersion(); UIScene* FindScene(EUIScene sceneType); - void PrintTotalMemoryUsage(__int64& totalStatic, __int64& totalDynamic); + void PrintTotalMemoryUsage(int64_t& totalStatic, int64_t& totalDynamic); }; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene.cpp b/Minecraft.Client/Platform/Common/UI/UIScene.cpp index ca8e18d1b..ee1041974 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene.cpp @@ -91,6 +91,7 @@ void UIScene::reloadMovie(bool force) { (*it)->ReInit(); } + updateComponents(); handleReload(); IggyDataValue result; @@ -311,11 +312,11 @@ void UIScene::loadMovie() { } byteArray baFile = ui.getMovieData(moviePath.c_str()); - __int64 beforeLoad = ui.iggyAllocCount; + int64_t beforeLoad = ui.iggyAllocCount; swf = IggyPlayerCreateFromMemory(baFile.data, baFile.length, NULL); - __int64 afterLoad = ui.iggyAllocCount; + int64_t afterLoad = ui.iggyAllocCount; IggyPlayerInitializeAndTickRS(swf); - __int64 afterTick = ui.iggyAllocCount; + int64_t afterTick = ui.iggyAllocCount; if (!swf) { app.DebugPrintf("ERROR: Failed to load iggy scene!\n"); @@ -343,8 +344,8 @@ void UIScene::loadMovie() { IggyMemoryUseInfo memoryInfo; rrbool res; int iteration = 0; - __int64 totalStatic = 0; - __int64 totalDynamic = 0; + int64_t totalStatic = 0; + int64_t totalDynamic = 0; while(res = IggyDebugGetMemoryUseInfo ( swf , NULL , 0 , @@ -372,10 +373,10 @@ void UIScene::getDebugMemoryUseRecursive(const std::wstring& moviePath, rrbool res; IggyMemoryUseInfo internalMemoryInfo; int internalIteration = 0; - while ((res = IggyDebugGetMemoryUseInfo(swf, 0, memoryInfo.subcategory, - memoryInfo.subcategory_stringlen, - internalIteration, - &internalMemoryInfo))) { + while (res = IggyDebugGetMemoryUseInfo(swf, NULL, memoryInfo.subcategory, + memoryInfo.subcategory_stringlen, + internalIteration, + &internalMemoryInfo)) { app.DebugPrintf( app.USER_SR, "%ls - %.*s static: %d ( %d ) dynamic: %d ( %d )\n", moviePath.c_str(), internalMemoryInfo.subcategory_stringlen, @@ -391,17 +392,17 @@ void UIScene::getDebugMemoryUseRecursive(const std::wstring& moviePath, } } -void UIScene::PrintTotalMemoryUsage(__int64& totalStatic, - __int64& totalDynamic) { +void UIScene::PrintTotalMemoryUsage(int64_t& totalStatic, + int64_t& totalDynamic) { if (!swf) return; IggyMemoryUseInfo memoryInfo; rrbool res; int iteration = 0; - __int64 sceneStatic = 0; - __int64 sceneDynamic = 0; - while ((res = IggyDebugGetMemoryUseInfo(swf, 0, "", 0, iteration, - &memoryInfo))) { + int64_t sceneStatic = 0; + int64_t sceneDynamic = 0; + while (res = IggyDebugGetMemoryUseInfo(swf, NULL, "", 0, iteration, + &memoryInfo)) { sceneStatic += memoryInfo.static_allocation_bytes; sceneDynamic += memoryInfo.dynamic_allocation_bytes; totalStatic += memoryInfo.static_allocation_bytes; @@ -816,7 +817,7 @@ void UIScene::gainFocus() { app.DebugPrintf("Sent gain focus event to scene\n"); */ bHasFocus = true; - if (app.GetGameStarted() && needsReloaded()) { + if (needsReloaded()) { reloadMovie(); } @@ -864,7 +865,9 @@ void UIScene::handleGainFocus(bool navBack) { #endif } -void UIScene::updateTooltips() { ui.SetTooltips(m_iPad, -1); } +void UIScene::updateTooltips() { + if (!ui.IsReloadingSkin()) ui.SetTooltips(m_iPad, -1); +} void UIScene::sendInputToMovie(int key, bool repeat, bool pressed, bool released) { @@ -888,6 +891,7 @@ void UIScene::sendInputToMovie(int key, bool repeat, bool pressed, } int UIScene::convertGameActionToIggyKeycode(int action) { + // TODO: This action to key mapping should probably use the control mapping int keycode = -1; switch (action) { #ifdef __ORBIS__ @@ -927,7 +931,14 @@ int UIScene::convertGameActionToIggyKeycode(int action) { keycode = IGGY_KEYCODE_PAGE_UP; break; case ACTION_MENU_PAGEDOWN: - keycode = IGGY_KEYCODE_PAGE_DOWN; +#ifdef __PSVITA__ + if (!InputManager.IsVitaTV()) { + keycode = IGGY_KEYCODE_F6; + } else +#endif + { + keycode = IGGY_KEYCODE_PAGE_DOWN; + } break; case ACTION_MENU_RIGHT_SCROLL: keycode = IGGY_KEYCODE_F3; @@ -938,6 +949,7 @@ int UIScene::convertGameActionToIggyKeycode(int action) { case ACTION_MENU_STICK_PRESS: break; case ACTION_MENU_OTHER_STICK_PRESS: + keycode = IGGY_KEYCODE_F5; break; case ACTION_MENU_OTHER_STICK_UP: keycode = IGGY_KEYCODE_F11; @@ -1211,7 +1223,9 @@ void UIScene::UpdateSceneControls() { } #endif -size_t UIScene::GetCallbackUniqueId() { +void UIScene::HandleMessage(EUIMessage message, void* data) {} + +std::size_t UIScene::GetCallbackUniqueId() { if (m_callbackUniqueId == 0) { m_callbackUniqueId = ui.RegisterForCallbackId(this); } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene.h b/Minecraft.Client/Platform/Common/UI/UIScene.h index 74f0dc392..b4948bfce 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene.h @@ -179,6 +179,10 @@ public: // this scenes layers should be hidden virtual bool hidesLowerScenes() { return m_hasTickedOnce; } + // Returns true if this scene should block input to lower scenes (works like + // hidesLowerScenes but doesn't interfere with rendering) + virtual bool blocksInput() { return false; } + // returns main panel if controls are not living in the root virtual UIControl* GetMainPanel(); @@ -272,6 +276,9 @@ public: #ifdef _XBOX_ONE virtual void HandleDLCLicenseChange() {} #endif + + virtual void HandleMessage(EUIMessage message, void* data); + void registerSubstitutionTexture(const std::wstring& textureName, std::uint8_t* pbData, unsigned int dwLength, diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.cpp index 361c2ccd4..92d146005 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.cpp @@ -50,8 +50,11 @@ void UIScene_AbstractContainerMenu::handleDestroy() { // packet loss. We need to make sure that we call closeContainer() anytime // this menu is closed, even if it is forced to close by some other reason // (like the player dying) - if (pMinecraft->localplayers[m_iPad] != NULL) + if (pMinecraft->localplayers[m_iPad] != NULL && + pMinecraft->localplayers[m_iPad]->containerMenu->containerId == + m_menu->containerId) { pMinecraft->localplayers[m_iPad]->closeContainer(); + } ui.OverrideSFX(m_iPad, ACTION_MENU_A, false); ui.OverrideSFX(m_iPad, ACTION_MENU_OK, false); @@ -206,7 +209,7 @@ void UIScene_AbstractContainerMenu::render(S32 width, S32 height, m_needsCacheRendered = m_needsCacheRendered || m_menu->needsRendered(); if (m_needsCacheRendered) { - m_expectedCachedSlotCount = 0; + m_expectedCachedSlotCount = GetBaseSlotCount(); unsigned int count = m_menu->getSize(); for (unsigned int i = 0; i < count; ++i) { if (m_menu->getSlot(i)->hasItem()) { @@ -244,7 +247,10 @@ void UIScene_AbstractContainerMenu::customDraw( } if (item != NULL) - customDrawSlotControl(region, m_iPad, item, 1.0f, item->isFoil(), true); + customDrawSlotControl( + region, m_iPad, item, + m_menu->isValidIngredient(item, slotId) ? 1.0f : 0.5f, + item->isFoil(), true); } void UIScene_AbstractContainerMenu::handleInput(int iPad, int key, bool repeat, @@ -263,20 +269,24 @@ void UIScene_AbstractContainerMenu::handleInput(int iPad, int key, bool repeat, } void UIScene_AbstractContainerMenu::SetPointerText( - const std::wstring& description, - std::vector& unformattedStrings, bool newSlot) { - // app.DebugPrintf("Setting pointer text\n"); - m_cursorPath.setLabel(description, false, newSlot); + std::vector* description, bool newSlot) { + m_cursorPath.setLabel(HtmlString::Compose(description), false, newSlot); } void UIScene_AbstractContainerMenu::setSectionFocus(ESceneSection eSection, int iPad) { - if (m_focusSection != eSectionNone) { - UIControl* currentFocus = getSection(m_focusSection); - if (currentFocus) currentFocus->setFocus(false); - } UIControl* newFocus = getSection(eSection); if (newFocus) newFocus->setFocus(true); + + if (m_focusSection != eSectionNone) { + UIControl* currentFocus = getSection(m_focusSection); + // 4J-TomK only set current focus to false if it differs from last + // (previously this continuously fired iggy functions when they were + // identical! + if (currentFocus != newFocus) + if (currentFocus) currentFocus->setFocus(false); + } + m_focusSection = eSection; } @@ -297,6 +307,15 @@ std::shared_ptr UIScene_AbstractContainerMenu::getSlotItem( return nullptr; } +Slot* UIScene_AbstractContainerMenu::getSlot(ESceneSection eSection, + int iSlot) { + Slot* slot = m_menu->getSlot(getSectionStartOffset(eSection) + iSlot); + if (slot) + return slot; + else + return NULL; +} + bool UIScene_AbstractContainerMenu::isSlotEmpty(ESceneSection eSection, int iSlot) { Slot* slot = m_menu->getSlot(getSectionStartOffset(eSection) + iSlot); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.h index a0c449573..5dd27f54c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_AbstractContainerMenu.h @@ -49,19 +49,26 @@ protected: } virtual void setSectionFocus(ESceneSection eSection, int iPad); void setFocusToPointer(int iPad); - void SetPointerText(const std::wstring& description, - std::vector& unformattedStrings, - bool newSlot); + void SetPointerText(std::vector* description, bool newSlot); virtual std::shared_ptr getSlotItem(ESceneSection eSection, int iSlot); + virtual Slot* getSlot(ESceneSection eSection, int iSlot); virtual bool isSlotEmpty(ESceneSection eSection, int iSlot); virtual void adjustPointerForSafeZone(); virtual UIControl* getSection(ESceneSection eSection) { return NULL; } + virtual int GetBaseSlotCount() { return 0; } public: virtual void tick(); + // 4J - TomK If update tooltips is called then make sure the correct parent + // is invoked! (both UIScene AND IUIScene_AbstractContainerMenu have an + // instance of said function!) + virtual void updateTooltips() { + IUIScene_AbstractContainerMenu::UpdateTooltips(); + } + virtual void render(S32 width, S32 height, C4JRender::eViewportType viewpBort); virtual void customDraw(IggyCustomDrawCallbackRegion* region); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp index 47a32efe1..2b17117c4 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp @@ -29,17 +29,17 @@ UIScene_AnvilMenu::UIScene_AnvilMenu(int iPad, void* _initData, e_Tutorial_State_Anvil_Menu, this); } - m_repairMenu = new RepairMenu(initData->inventory, initData->level, - initData->x, initData->y, initData->z, - pMinecraft->localplayers[iPad]); + m_repairMenu = + new AnvilMenu(initData->inventory, initData->level, initData->x, + initData->y, initData->z, pMinecraft->localplayers[iPad]); m_repairMenu->addSlotListener(this); - Initialize(iPad, m_repairMenu, true, RepairMenu::INV_SLOT_START, + Initialize(iPad, m_repairMenu, true, AnvilMenu::INV_SLOT_START, eSectionAnvilUsing, eSectionAnvilMax); - m_slotListItem1.addSlots(RepairMenu::INPUT_SLOT, 1); - m_slotListItem2.addSlots(RepairMenu::ADDITIONAL_SLOT, 1); - m_slotListResult.addSlots(RepairMenu::RESULT_SLOT, 1); + m_slotListItem1.addSlots(AnvilMenu::INPUT_SLOT, 1); + m_slotListItem2.addSlots(AnvilMenu::ADDITIONAL_SLOT, 1); + m_slotListResult.addSlots(AnvilMenu::RESULT_SLOT, 1); bool expensive = false; std::wstring m_costString = L""; @@ -49,14 +49,14 @@ UIScene_AnvilMenu::UIScene_AnvilMenu(int iPad, void* _initData, !pMinecraft->localplayers[iPad]->abilities.instabuild) { m_costString = app.GetString(IDS_REPAIR_EXPENSIVE); expensive = true; - } else if (!m_repairMenu->getSlot(RepairMenu::RESULT_SLOT)->hasItem()) { + } else if (!m_repairMenu->getSlot(AnvilMenu::RESULT_SLOT)->hasItem()) { // Do nothing } else { const wchar_t* costString = app.GetString(IDS_REPAIR_COST); wchar_t temp[256]; swprintf(temp, 256, costString, m_repairMenu->cost); m_costString = temp; - if (!m_repairMenu->getSlot(RepairMenu::RESULT_SLOT) + if (!m_repairMenu->getSlot(AnvilMenu::RESULT_SLOT) ->mayPickup(std::dynamic_pointer_cast( m_inventory->player->shared_from_this()))) { expensive = true; @@ -81,12 +81,12 @@ std::wstring UIScene_AnvilMenu::getMoviePath() { } void UIScene_AnvilMenu::handleReload() { - Initialize(m_iPad, m_menu, true, RepairMenu::INV_SLOT_START, + Initialize(m_iPad, m_menu, true, AnvilMenu::INV_SLOT_START, eSectionAnvilUsing, eSectionAnvilMax); - m_slotListItem1.addSlots(RepairMenu::INPUT_SLOT, 1); - m_slotListItem2.addSlots(RepairMenu::ADDITIONAL_SLOT, 1); - m_slotListResult.addSlots(RepairMenu::RESULT_SLOT, 1); + m_slotListItem1.addSlots(AnvilMenu::INPUT_SLOT, 1); + m_slotListItem2.addSlots(AnvilMenu::ADDITIONAL_SLOT, 1); + m_slotListResult.addSlots(AnvilMenu::RESULT_SLOT, 1); } void UIScene_AnvilMenu::tick() { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp new file mode 100644 index 000000000..c1e1926a2 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp @@ -0,0 +1,497 @@ +#include "../../stdafx.h" +#include "UI.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" +#include "../../Minecraft.h" +#include "UIScene_BeaconMenu.h" + +UIScene_BeaconMenu::UIScene_BeaconMenu(int iPad, void* _initData, + UILayer* parentLayer) + : UIScene_AbstractContainerMenu(iPad, parentLayer) { + // Setup all the Iggy references we need for this scene + initialiseMovie(); + + m_labelPrimary.init(IDS_CONTAINER_BEACON_PRIMARY_POWER); + m_labelSecondary.init(IDS_CONTAINER_BEACON_SECONDARY_POWER); + + m_buttonsPowers[eControl_Primary1].setVisible(false); + m_buttonsPowers[eControl_Primary2].setVisible(false); + m_buttonsPowers[eControl_Primary3].setVisible(false); + m_buttonsPowers[eControl_Primary4].setVisible(false); + m_buttonsPowers[eControl_Primary5].setVisible(false); + m_buttonsPowers[eControl_Secondary1].setVisible(false); + m_buttonsPowers[eControl_Secondary2].setVisible(false); + + BeaconScreenInput* initData = (BeaconScreenInput*)_initData; + + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft->localgameModes[initData->iPad] != NULL) { + TutorialMode* gameMode = + (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; + m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); + gameMode->getTutorial()->changeTutorialState( + e_Tutorial_State_Beacon_Menu, this); + } + + m_beacon = initData->beacon; + + BeaconMenu* menu = new BeaconMenu(initData->inventory, initData->beacon); + + Initialize(initData->iPad, menu, true, BeaconMenu::INV_SLOT_START, + eSectionBeaconUsing, eSectionBeaconMax); + + m_slotListActivator.addSlots(BeaconMenu::PAYMENT_SLOT, 1); + + m_slotListActivatorIcons.addSlots(m_menu->getSize(), 4); + + // app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BEACON); + + delete initData; +} + +std::wstring UIScene_BeaconMenu::getMoviePath() { + if (app.GetLocalPlayerCount() > 1) { + return L"BeaconMenuSplit"; + } else { + return L"BeaconMenu"; + } +} + +void UIScene_BeaconMenu::handleReload() { + Initialize(m_iPad, m_menu, true, BeaconMenu::INV_SLOT_START, + eSectionBeaconUsing, eSectionBeaconMax); + + m_slotListActivator.addSlots(BeaconMenu::PAYMENT_SLOT, 1); + + m_slotListActivatorIcons.addSlots(m_menu->getSize(), 4); +} + +void UIScene_BeaconMenu::tick() { + UIScene_AbstractContainerMenu::tick(); + + handleTick(); +} + +int UIScene_BeaconMenu::getSectionColumns(ESceneSection eSection) { + int cols = 0; + switch (eSection) { + case eSectionBeaconItem: + cols = 1; + break; + case eSectionBeaconInventory: + cols = 9; + break; + case eSectionBeaconUsing: + cols = 9; + break; + default: + assert(false); + break; + }; + return cols; +} + +int UIScene_BeaconMenu::getSectionRows(ESceneSection eSection) { + int rows = 0; + switch (eSection) { + case eSectionBeaconItem: + rows = 1; + break; + case eSectionBeaconInventory: + rows = 3; + break; + case eSectionBeaconUsing: + rows = 1; + break; + default: + assert(false); + break; + }; + return rows; +} + +void UIScene_BeaconMenu::GetPositionOfSection(ESceneSection eSection, + UIVec2D* pPosition) { + switch (eSection) { + case eSectionBeaconItem: + pPosition->x = m_slotListActivator.getXPos(); + pPosition->y = m_slotListActivator.getYPos(); + break; + case eSectionBeaconInventory: + pPosition->x = m_slotListInventory.getXPos(); + pPosition->y = m_slotListInventory.getYPos(); + break; + case eSectionBeaconUsing: + pPosition->x = m_slotListHotbar.getXPos(); + pPosition->y = m_slotListHotbar.getYPos(); + break; + + case eSectionBeaconPrimaryTierOneOne: + pPosition->x = m_buttonsPowers[eControl_Primary1].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary1].getYPos(); + break; + case eSectionBeaconPrimaryTierOneTwo: + pPosition->x = m_buttonsPowers[eControl_Primary2].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary2].getYPos(); + break; + case eSectionBeaconPrimaryTierTwoOne: + pPosition->x = m_buttonsPowers[eControl_Primary3].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary3].getYPos(); + break; + case eSectionBeaconPrimaryTierTwoTwo: + pPosition->x = m_buttonsPowers[eControl_Primary4].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary4].getYPos(); + break; + case eSectionBeaconPrimaryTierThree: + pPosition->x = m_buttonsPowers[eControl_Primary5].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary5].getYPos(); + break; + case eSectionBeaconSecondaryOne: + pPosition->x = m_buttonsPowers[eControl_Secondary1].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Secondary1].getYPos(); + break; + case eSectionBeaconSecondaryTwo: + pPosition->x = m_buttonsPowers[eControl_Secondary2].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Secondary2].getYPos(); + break; + case eSectionBeaconConfirm: + pPosition->x = m_buttonConfirm.getXPos(); + pPosition->y = m_buttonConfirm.getYPos(); + break; + default: + assert(false); + break; + }; +} + +void UIScene_BeaconMenu::GetItemScreenData(ESceneSection eSection, + int iItemIndex, UIVec2D* pPosition, + UIVec2D* pSize) { + UIVec2D sectionSize; + switch (eSection) { + case eSectionBeaconItem: + sectionSize.x = m_slotListActivator.getWidth(); + sectionSize.y = m_slotListActivator.getHeight(); + break; + case eSectionBeaconInventory: + sectionSize.x = m_slotListInventory.getWidth(); + sectionSize.y = m_slotListInventory.getHeight(); + break; + case eSectionBeaconUsing: + sectionSize.x = m_slotListHotbar.getWidth(); + sectionSize.y = m_slotListHotbar.getHeight(); + break; + + case eSectionBeaconPrimaryTierOneOne: + sectionSize.x = m_buttonsPowers[eControl_Primary1].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary1].getHeight(); + break; + case eSectionBeaconPrimaryTierOneTwo: + sectionSize.x = m_buttonsPowers[eControl_Primary2].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary2].getHeight(); + break; + case eSectionBeaconPrimaryTierTwoOne: + sectionSize.x = m_buttonsPowers[eControl_Primary3].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary3].getHeight(); + break; + case eSectionBeaconPrimaryTierTwoTwo: + sectionSize.x = m_buttonsPowers[eControl_Primary4].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary4].getHeight(); + break; + case eSectionBeaconPrimaryTierThree: + sectionSize.x = m_buttonsPowers[eControl_Primary5].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary5].getHeight(); + break; + case eSectionBeaconSecondaryOne: + sectionSize.x = m_buttonsPowers[eControl_Secondary1].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Secondary1].getHeight(); + break; + case eSectionBeaconSecondaryTwo: + sectionSize.x = m_buttonsPowers[eControl_Secondary2].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Secondary2].getHeight(); + break; + case eSectionBeaconConfirm: + sectionSize.x = m_buttonConfirm.getWidth(); + sectionSize.y = m_buttonConfirm.getHeight(); + break; + default: + assert(false); + break; + }; + + if (IsSectionSlotList(eSection)) { + int rows = getSectionRows(eSection); + int cols = getSectionColumns(eSection); + + pSize->x = sectionSize.x / cols; + pSize->y = sectionSize.y / rows; + + int itemCol = iItemIndex % cols; + int itemRow = iItemIndex / cols; + + pPosition->x = itemCol * pSize->x; + pPosition->y = itemRow * pSize->y; + } else { + GetPositionOfSection(eSection, pPosition); + pSize->x = sectionSize.x; + pSize->y = sectionSize.y; + } +} + +void UIScene_BeaconMenu::setSectionSelectedSlot(ESceneSection eSection, int x, + int y) { + int cols = getSectionColumns(eSection); + + int index = (y * cols) + x; + + UIControl_SlotList* slotList = NULL; + switch (eSection) { + case eSectionBeaconItem: + slotList = &m_slotListActivator; + break; + case eSectionBeaconInventory: + slotList = &m_slotListInventory; + break; + case eSectionBeaconUsing: + slotList = &m_slotListHotbar; + break; + default: + assert(false); + break; + }; + + slotList->setHighlightSlot(index); +} + +UIControl* UIScene_BeaconMenu::getSection(ESceneSection eSection) { + UIControl* control = NULL; + switch (eSection) { + case eSectionBeaconItem: + control = &m_slotListActivator; + break; + case eSectionBeaconInventory: + control = &m_slotListInventory; + break; + case eSectionBeaconUsing: + control = &m_slotListHotbar; + break; + + case eSectionBeaconPrimaryTierOneOne: + control = &m_buttonsPowers[eControl_Primary1]; + break; + case eSectionBeaconPrimaryTierOneTwo: + control = &m_buttonsPowers[eControl_Primary2]; + break; + case eSectionBeaconPrimaryTierTwoOne: + control = &m_buttonsPowers[eControl_Primary3]; + break; + case eSectionBeaconPrimaryTierTwoTwo: + control = &m_buttonsPowers[eControl_Primary4]; + break; + case eSectionBeaconPrimaryTierThree: + control = &m_buttonsPowers[eControl_Primary5]; + break; + case eSectionBeaconSecondaryOne: + control = &m_buttonsPowers[eControl_Secondary1]; + break; + case eSectionBeaconSecondaryTwo: + control = &m_buttonsPowers[eControl_Secondary2]; + break; + case eSectionBeaconConfirm: + control = &m_buttonConfirm; + break; + + default: + assert(false); + break; + }; + return control; +} + +void UIScene_BeaconMenu::customDraw(IggyCustomDrawCallbackRegion* region) { + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft->localplayers[m_iPad] == NULL || + pMinecraft->localgameModes[m_iPad] == NULL) + return; + + std::shared_ptr item = nullptr; + int slotId = -1; + swscanf((wchar_t*)region->name, L"slot_%d", &slotId); + + if (slotId >= 0 && slotId >= m_menu->getSize()) { + int icon = slotId - m_menu->getSize(); + switch (icon) { + case 0: + item = std::shared_ptr( + new ItemInstance(Item::emerald)); + break; + case 1: + item = std::shared_ptr( + new ItemInstance(Item::diamond)); + break; + case 2: + item = std::shared_ptr( + new ItemInstance(Item::goldIngot)); + break; + case 3: + item = std::shared_ptr( + new ItemInstance(Item::ironIngot)); + break; + default: + assert(false); + break; + }; + if (item != NULL) + customDrawSlotControl(region, m_iPad, item, 1.0f, item->isFoil(), + true); + } else { + UIScene_AbstractContainerMenu::customDraw(region); + } +} + +void UIScene_BeaconMenu::SetConfirmButtonEnabled(bool enabled) { + m_buttonConfirm.SetButtonActive(enabled); +} + +void UIScene_BeaconMenu::AddPowerButton(int id, int icon, int tier, int count, + bool active, bool selected) { + switch (tier) { + case 0: + if (count == 0) { + m_buttonsPowers[eControl_Primary1].SetData(id, icon, active, + selected); + m_buttonsPowers[eControl_Primary1].setVisible(true); + } else { + m_buttonsPowers[eControl_Primary2].SetData(id, icon, active, + selected); + m_buttonsPowers[eControl_Primary2].setVisible(true); + } + break; + case 1: + if (count == 0) { + m_buttonsPowers[eControl_Primary3].SetData(id, icon, active, + selected); + m_buttonsPowers[eControl_Primary3].setVisible(true); + } else { + m_buttonsPowers[eControl_Primary4].SetData(id, icon, active, + selected); + m_buttonsPowers[eControl_Primary4].setVisible(true); + } + break; + case 2: + m_buttonsPowers[eControl_Primary5].SetData(id, icon, active, + selected); + m_buttonsPowers[eControl_Primary5].setVisible(true); + break; + case 3: + if (count == 0) { + m_buttonsPowers[eControl_Secondary1].SetData(id, icon, active, + selected); + m_buttonsPowers[eControl_Secondary1].setVisible(true); + } else { + m_buttonsPowers[eControl_Secondary2].SetData(id, icon, active, + selected); + m_buttonsPowers[eControl_Secondary2].setVisible(true); + } + break; + }; +} + +int UIScene_BeaconMenu::GetPowerButtonId(ESceneSection eSection) { + switch (eSection) { + case eSectionBeaconPrimaryTierOneOne: + return m_buttonsPowers[eControl_Primary1].GetData(); + break; + case eSectionBeaconPrimaryTierOneTwo: + return m_buttonsPowers[eControl_Primary2].GetData(); + break; + case eSectionBeaconPrimaryTierTwoOne: + return m_buttonsPowers[eControl_Primary3].GetData(); + break; + case eSectionBeaconPrimaryTierTwoTwo: + return m_buttonsPowers[eControl_Primary4].GetData(); + break; + case eSectionBeaconPrimaryTierThree: + return m_buttonsPowers[eControl_Primary5].GetData(); + break; + case eSectionBeaconSecondaryOne: + return m_buttonsPowers[eControl_Secondary1].GetData(); + break; + case eSectionBeaconSecondaryTwo: + return m_buttonsPowers[eControl_Secondary2].GetData(); + break; + }; + return 0; +} + +bool UIScene_BeaconMenu::IsPowerButtonSelected(ESceneSection eSection) { + switch (eSection) { + case eSectionBeaconPrimaryTierOneOne: + return m_buttonsPowers[eControl_Primary1].IsButtonSelected(); + break; + case eSectionBeaconPrimaryTierOneTwo: + return m_buttonsPowers[eControl_Primary2].IsButtonSelected(); + break; + case eSectionBeaconPrimaryTierTwoOne: + return m_buttonsPowers[eControl_Primary3].IsButtonSelected(); + break; + case eSectionBeaconPrimaryTierTwoTwo: + return m_buttonsPowers[eControl_Primary4].IsButtonSelected(); + break; + case eSectionBeaconPrimaryTierThree: + return m_buttonsPowers[eControl_Primary5].IsButtonSelected(); + break; + case eSectionBeaconSecondaryOne: + return m_buttonsPowers[eControl_Secondary1].IsButtonSelected(); + break; + case eSectionBeaconSecondaryTwo: + return m_buttonsPowers[eControl_Secondary2].IsButtonSelected(); + break; + }; + return false; +} + +void UIScene_BeaconMenu::SetPowerButtonSelected(ESceneSection eSection) { + switch (eSection) { + case eSectionBeaconPrimaryTierOneOne: + case eSectionBeaconPrimaryTierOneTwo: + case eSectionBeaconPrimaryTierTwoOne: + case eSectionBeaconPrimaryTierTwoTwo: + case eSectionBeaconPrimaryTierThree: + m_buttonsPowers[eControl_Primary1].SetButtonSelected(false); + m_buttonsPowers[eControl_Primary2].SetButtonSelected(false); + m_buttonsPowers[eControl_Primary3].SetButtonSelected(false); + m_buttonsPowers[eControl_Primary4].SetButtonSelected(false); + m_buttonsPowers[eControl_Primary5].SetButtonSelected(false); + break; + case eSectionBeaconSecondaryOne: + case eSectionBeaconSecondaryTwo: + m_buttonsPowers[eControl_Secondary1].SetButtonSelected(false); + m_buttonsPowers[eControl_Secondary2].SetButtonSelected(false); + break; + }; + + switch (eSection) { + case eSectionBeaconPrimaryTierOneOne: + return m_buttonsPowers[eControl_Primary1].SetButtonSelected(true); + break; + case eSectionBeaconPrimaryTierOneTwo: + return m_buttonsPowers[eControl_Primary2].SetButtonSelected(true); + break; + case eSectionBeaconPrimaryTierTwoOne: + return m_buttonsPowers[eControl_Primary3].SetButtonSelected(true); + break; + case eSectionBeaconPrimaryTierTwoTwo: + return m_buttonsPowers[eControl_Primary4].SetButtonSelected(true); + break; + case eSectionBeaconPrimaryTierThree: + return m_buttonsPowers[eControl_Primary5].SetButtonSelected(true); + break; + case eSectionBeaconSecondaryOne: + return m_buttonsPowers[eControl_Secondary1].SetButtonSelected(true); + break; + case eSectionBeaconSecondaryTwo: + return m_buttonsPowers[eControl_Secondary2].SetButtonSelected(true); + break; + }; +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.h new file mode 100644 index 000000000..6eed4eb70 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.h @@ -0,0 +1,74 @@ +#pragma once + +#include "UIScene_AbstractContainerMenu.h" +#include "UIControl_SlotList.h" +#include "IUIScene_BeaconMenu.h" + +class UIScene_BeaconMenu : public UIScene_AbstractContainerMenu, + public IUIScene_BeaconMenu { +private: + enum EControls { + eControl_Primary1, + eControl_Primary2, + eControl_Primary3, + eControl_Primary4, + eControl_Primary5, + eControl_Secondary1, + eControl_Secondary2, + + eControl_EFFECT_COUNT, + }; + +public: + UIScene_BeaconMenu(int iPad, void* initData, UILayer* parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_BeaconMenu; } + +protected: + UIControl_SlotList m_slotListActivator; + UIControl_SlotList m_slotListActivatorIcons; + UIControl_Label m_labelPrimary, m_labelSecondary; + UIControl_BeaconEffectButton m_buttonsPowers[eControl_EFFECT_COUNT]; + UIControl_BeaconEffectButton m_buttonConfirm; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene_AbstractContainerMenu) + UI_BEGIN_MAP_CHILD_ELEMENTS(m_controlMainPanel) + UI_MAP_ELEMENT(m_slotListActivator, "ActivatorSlot") + UI_MAP_ELEMENT(m_slotListActivatorIcons, "ActivatorList") + UI_MAP_ELEMENT(m_buttonsPowers[eControl_Primary1], "Primary_Slot_01") + UI_MAP_ELEMENT(m_buttonsPowers[eControl_Primary2], "Primary_Slot_02") + UI_MAP_ELEMENT(m_buttonsPowers[eControl_Primary3], "Primary_Slot_03") + UI_MAP_ELEMENT(m_buttonsPowers[eControl_Primary4], "Primary_Slot_04") + UI_MAP_ELEMENT(m_buttonsPowers[eControl_Primary5], "Primary_Slot_05") + UI_MAP_ELEMENT(m_buttonsPowers[eControl_Secondary1], "Secondary_Slot_01") + UI_MAP_ELEMENT(m_buttonsPowers[eControl_Secondary2], "Secondary_Slot_02") + UI_MAP_ELEMENT(m_buttonConfirm, "ConfirmButton") + UI_MAP_ELEMENT(m_labelPrimary, "PrimaryPowerLabel") + UI_MAP_ELEMENT(m_labelSecondary, "SecondaryPowerLabel") + UI_END_MAP_CHILD_ELEMENTS() + UI_END_MAP_ELEMENTS_AND_NAMES() + + virtual std::wstring getMoviePath(); + virtual void handleReload(); + virtual void tick(); + virtual int GetBaseSlotCount() { return 4; } + + virtual int getSectionColumns(ESceneSection eSection); + virtual int getSectionRows(ESceneSection eSection); + virtual void GetPositionOfSection(ESceneSection eSection, + UIVec2D* pPosition); + virtual void GetItemScreenData(ESceneSection eSection, int iItemIndex, + UIVec2D* pPosition, UIVec2D* pSize); + virtual void handleSectionClick(ESceneSection eSection) {} + virtual void setSectionSelectedSlot(ESceneSection eSection, int x, int y); + + virtual UIControl* getSection(ESceneSection eSection); + virtual void customDraw(IggyCustomDrawCallbackRegion* region); + + virtual void SetConfirmButtonEnabled(bool enabled); + virtual void AddPowerButton(int id, int icon, int tier, int count, + bool active, bool selected); + virtual int GetPowerButtonId(ESceneSection eSection); + virtual bool IsPowerButtonSelected(ESceneSection eSection); + virtual void SetPowerButtonSelected(ESceneSection eSection); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_BrewingStandMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_BrewingStandMenu.cpp index e33ddfb33..5e2f80728 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_BrewingStandMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_BrewingStandMenu.cpp @@ -18,11 +18,11 @@ UIScene_BrewingStandMenu::UIScene_BrewingStandMenu(int iPad, void* _initData, 0); m_progressBrewingBubbles.init(L"", 0, 0, 30, 0); - m_labelBrewingStand.init(app.GetString(IDS_BREWING_STAND)); - BrewingScreenInput* initData = (BrewingScreenInput*)_initData; m_brewingStand = initData->brewingStand; + m_labelBrewingStand.init(m_brewingStand->getName()); + Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft->localgameModes[initData->iPad] != NULL) { TutorialMode* gameMode = diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp index e1a5bc6ba..a1d03ba7e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp @@ -179,9 +179,8 @@ void UIScene_ConnectingProgress::handleTimerComplete(int id) { } else { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_CONNECTION_FAILED, exitReasonStringId, - uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, - NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_CONNECTION_FAILED, exitReasonStringId, + uiIDA, 1, ProfileManager.GetPrimaryPad()); exitReasonStringId = -1; // app.NavigateToHomeMenu(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_ContainerMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_ContainerMenu.cpp index 04ad16f25..ae5a7effb 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ContainerMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ContainerMenu.cpp @@ -21,7 +21,7 @@ UIScene_ContainerMenu::UIScene_ContainerMenu(int iPad, void* _initData, // Setup all the Iggy references we need for this scene initialiseMovie(); - m_labelChest.init(app.GetString(initData->container->getName())); + m_labelChest.init(initData->container->getName()); ContainerMenu* menu = new ContainerMenu(initData->inventory, initData->container); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp index a84ca9130..070c34e36 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp @@ -38,7 +38,7 @@ UIScene_ControlsMenu::UIScene_ControlsMenu(int iPad, void* initData, } // 4J-PB - stop the label showing in the in-game controls menu else { - m_labelVersion.init(" "); + m_labelVersion.init(L" "); } m_bCreativeMode = !bNotInGame && Minecraft::GetInstance()->localplayers[m_iPad] && diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp index b61d0ba34..3ad05f027 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp @@ -201,8 +201,12 @@ void UIScene_CraftingMenu::handleDestroy() { // We need to make sure that we call closeContainer() anytime this menu is // closed, even if it is forced to close by some other reason (like the // player dying) - if (Minecraft::GetInstance()->localplayers[m_iPad] != NULL) + if (Minecraft::GetInstance()->localplayers[m_iPad] != NULL && + Minecraft::GetInstance() + ->localplayers[m_iPad] + ->containerMenu->containerId == m_menu->containerId) { Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer(); + } ui.OverrideSFX(m_iPad, ACTION_MENU_A, false); ui.OverrideSFX(m_iPad, ACTION_MENU_OK, false); @@ -425,7 +429,7 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion* region) { float alpha = 1.0f; bool decorations = true; bool inventoryItem = false; - int slotId = parseSlotId(region->name); + swscanf((wchar_t*)region->name, L"slot_%d", &slotId); if (slotId == -1) { app.DebugPrintf("This is not the control we are looking for\n"); } else if (slotId >= CRAFTING_INVENTORY_SLOT_START && @@ -720,6 +724,18 @@ void UIScene_CraftingMenu::updateHighlightAndScrollPositions() { } } +void UIScene_CraftingMenu::HandleMessage(EUIMessage message, void* data) { + switch (message) { + case eUIMessage_InventoryUpdated: + handleInventoryUpdated(data); + break; + }; +} + +void UIScene_CraftingMenu::handleInventoryUpdated(LPVOID data) { + HandleInventoryUpdated(); +} + void UIScene_CraftingMenu::updateVSlotPositions(int iSlots, int i) { // Not needed } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.h index dae09cffc..4b304d064 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.h @@ -212,4 +212,12 @@ protected: virtual void updateVSlotPositions(int iSlots, int i); virtual void UpdateMultiPanel(); + + virtual void HandleMessage(EUIMessage message, void* data); + void handleInventoryUpdated(LPVOID data); + + // 4J - TomK If update tooltips is called then make sure the correct parent + // is invoked! (both UIScene AND IUIScene_CraftingMenu have an instance of + // said function!) + virtual void updateTooltips() { IUIScene_CraftingMenu::UpdateTooltips(); } }; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp index b89f37e7c..99b1bb876 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp @@ -42,11 +42,8 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void* initData, m_iPad = iPad; m_labelWorldName.init(app.GetString(IDS_WORLD_NAME)); - m_labelSeed.init(app.GetString(IDS_CREATE_NEW_WORLD_SEED)); - m_labelRandomSeed.init(app.GetString(IDS_CREATE_NEW_WORLD_RANDOM_SEED)); m_editWorldName.init(m_worldName, eControl_EditWorldName); - m_editSeed.init(L"", eControl_EditSeed); m_buttonGamemode.init(app.GetString(IDS_GAMEMODE_SURVIVAL), eControl_GameModeToggle); @@ -80,7 +77,16 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void* initData, m_MoreOptionsParams.bTNT = true; m_MoreOptionsParams.iPad = iPad; - m_bGameModeSurvival = true; + m_MoreOptionsParams.bMobGriefing = true; + m_MoreOptionsParams.bKeepInventory = false; + m_MoreOptionsParams.bDoMobSpawning = true; + m_MoreOptionsParams.bDoMobLoot = true; + m_MoreOptionsParams.bDoTileDrops = true; + m_MoreOptionsParams.bNaturalRegeneration = true; + m_MoreOptionsParams.bDoDaylightCycle = true; + + m_bGameModeCreative = false; + m_iGameModeId = GameType::SURVIVAL->getId(); m_pDLCPack = NULL; m_bRebuildTouchBoxes = false; @@ -126,26 +132,22 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void* initData, } } -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 - if (getSceneResolution() == eSceneResolution_1080) { - // Set up online game checkbox - bool bOnlineGame = m_MoreOptionsParams.bOnlineGame; - m_checkboxOnline.SetEnable(true); + // Set up online game checkbox + bool bOnlineGame = m_MoreOptionsParams.bOnlineGame; + m_checkboxOnline.SetEnable(true); - // 4J-PB - to stop an offline game being able to select the online flag - if (ProfileManager.IsSignedInLive(m_iPad) == false) { - m_checkboxOnline.SetEnable(false); - } - - if (m_MoreOptionsParams.bOnlineSettingChangedBySystem) { - m_checkboxOnline.SetEnable(false); - bOnlineGame = false; - } - - m_checkboxOnline.init(app.GetString(IDS_ONLINE_GAME), - eControl_OnlineGame, bOnlineGame); + // 4J-PB - to stop an offline game being able to select the online flag + if (ProfileManager.IsSignedInLive(m_iPad) == false) { + m_checkboxOnline.SetEnable(false); } -#endif + + if (m_MoreOptionsParams.bOnlineSettingChangedBySystem) { + m_checkboxOnline.SetEnable(false); + bOnlineGame = false; + } + + m_checkboxOnline.init(app.GetString(IDS_ONLINE_GAME), eControl_OnlineGame, + bOnlineGame); addTimer(GAME_CREATE_ONLINE_TIMER_ID, GAME_CREATE_ONLINE_TIMER_TIME); #if TO_BE_IMPLEMENTED @@ -176,6 +178,8 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void* initData, swprintf(imageName, 64, L"tpack%08x", tp->getId()); registerSubstitutionTexture(imageName, imageData, imageBytes); m_texturePackList.addPack(i, imageName); + app.DebugPrintf("Adding texture pack %ls at %d\n", imageName, + i); } } @@ -304,12 +308,11 @@ void UIScene_CreateWorldMenu::tick() { uiIDA[0] = IDS_PRO_NOTONLINE_DECLINE; // Give the player a warning about the texture pack missing - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PLAY_OFFLINE, IDS_NO_PLAYSTATIONPLUS, uiIDA, 1, ProfileManager.GetPrimaryPad(), &UIScene_CreateWorldMenu::ContinueOffline, - dynamic_cast(this), - app.GetStringTable(), 0, 0, false); + dynamic_cast(this)); } } break; default: @@ -357,9 +360,9 @@ void UIScene_CreateWorldMenu::handleInput(int iPad, int key, bool repeat, if (pressed && controlHasFocus(m_checkboxOnline.getId()) && !m_checkboxOnline.IsEnabled()) { unsigned int uiIDA[1] = {IDS_CONFIRM_OK}; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, - iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, + iPad); } #endif @@ -371,16 +374,13 @@ void UIScene_CreateWorldMenu::handleInput(int iPad, int key, bool repeat, case ACTION_MENU_OTHER_STICK_DOWN: sendInputToMovie(key, repeat, pressed, released); -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 - if (getSceneResolution() == eSceneResolution_1080) { - bool bOnlineGame = m_checkboxOnline.IsChecked(); - if (m_MoreOptionsParams.bOnlineGame != bOnlineGame) { - m_MoreOptionsParams.bOnlineGame = bOnlineGame; + bool bOnlineGame = m_checkboxOnline.IsChecked(); + if (m_MoreOptionsParams.bOnlineGame != bOnlineGame) { + m_MoreOptionsParams.bOnlineGame = bOnlineGame; - if (!m_MoreOptionsParams.bOnlineGame) { - m_MoreOptionsParams.bInviteOnly = false; - m_MoreOptionsParams.bAllowFriendsOfFriends = false; - } + if (!m_MoreOptionsParams.bOnlineGame) { + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } #endif @@ -405,45 +405,21 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId) { &UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback, this, C_4JInput::EKeyboardMode_Default); } break; - case eControl_EditSeed: { - m_bIgnoreInput = true; -#ifdef __PS3__ - int language = XGetLanguage(); - switch (language) { - case XC_LANGUAGE_JAPANESE: - case XC_LANGUAGE_KOREAN: - case XC_LANGUAGE_TCHINESE: - InputManager.RequestKeyboard( - app.GetString(IDS_CREATE_NEW_WORLD_SEED), - m_editSeed.getLabel(), 0, 60, - &UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback, - this, C_4JInput::EKeyboardMode_Default); - break; - default: - // 4J Stu - Use a different keyboard for non-asian languages - // so we don't have prediction on - InputManager.RequestKeyboard( - app.GetString(IDS_CREATE_NEW_WORLD_SEED), - m_editSeed.getLabel(), 0, 60, - &UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback, - this, C_4JInput::EKeyboardMode_Alphabet_Extended); - break; - } -#else - InputManager.RequestKeyboard( - app.GetString(IDS_CREATE_NEW_WORLD_SEED), m_editSeed.getLabel(), - 0, 60, &UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback, - this, C_4JInput::EKeyboardMode_Default); -#endif - } break; case eControl_GameModeToggle: - if (m_bGameModeSurvival) { - m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_CREATIVE)); - m_bGameModeSurvival = false; - } else { - m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_SURVIVAL)); - m_bGameModeSurvival = true; - } + switch (m_iGameModeId) { + case 0: // Survival + m_buttonGamemode.setLabel( + app.GetString(IDS_GAMEMODE_CREATIVE)); + m_iGameModeId = GameType::CREATIVE->getId(); + m_bGameModeCreative = true; + break; + case 1: // Creative + m_buttonGamemode.setLabel( + app.GetString(IDS_GAMEMODE_SURVIVAL)); + m_iGameModeId = GameType::SURVIVAL->getId(); + m_bGameModeCreative = false; + break; + }; break; case eControl_MoreOptions: ui.NavigateToScene(m_iPad, eUIScene_LaunchMoreOptionsMenu, @@ -517,11 +493,10 @@ void UIScene_CreateWorldMenu::StartSharedLaunchFlow() { uiIDA[1] = IDS_CONFIRM_CANCEL; // Give the player a warning about the texture pack missing - ui.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, - IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, - ProfileManager.GetPrimaryPad(), - &TexturePackDialogReturned, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, + IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &TexturePackDialogReturned, this); return; } } @@ -598,21 +573,19 @@ void UIScene_CreateWorldMenu::StartSharedLaunchFlow() { // trial pack warning unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, - IDS_USING_TRIAL_TEXUREPACK_WARNING, uiIDA, - 1, m_iPad, - &TrialTexturePackWarningReturned, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, + IDS_USING_TRIAL_TEXUREPACK_WARNING, + uiIDA, 1, m_iPad, + &TrialTexturePackWarningReturned, this); #elif defined __PS3__ || defined __ORBIS__ || defined(__PSVITA__) // trial pack warning unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - ui.RequestMessageBox(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, - IDS_USING_TRIAL_TEXUREPACK_WARNING, uiIDA, - 2, m_iPad, - &TrialTexturePackWarningReturned, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, + IDS_USING_TRIAL_TEXUREPACK_WARNING, + uiIDA, 2, m_iPad, + &TrialTexturePackWarningReturned, this); #endif #if defined _XBOX_ONE || defined __ORBIS__ @@ -685,13 +658,9 @@ void UIScene_CreateWorldMenu::handleTimerComplete(int id) { m_MoreOptionsParams.bAllowFriendsOfFriends = false; } -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 - if (getSceneResolution() == eSceneResolution_1080) { - m_checkboxOnline.SetEnable(bMultiplayerAllowed); - m_checkboxOnline.setChecked( - m_MoreOptionsParams.bOnlineGame); - } -#endif + m_checkboxOnline.SetEnable(bMultiplayerAllowed); + m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); + m_bMultiplayerAllowed = bMultiplayerAllowed; } } break; @@ -741,12 +710,7 @@ void UIScene_CreateWorldMenu::handleTimerComplete(int id) { void UIScene_CreateWorldMenu::handleGainFocus(bool navBack) { if (navBack) { -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 - if (getSceneResolution() == eSceneResolution_1080) { - m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); - } - m_editSeed.setLabel(m_MoreOptionsParams.seed); -#endif + m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); } } @@ -756,8 +720,8 @@ int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(void* lpParam, pClass->m_bIgnoreInput = false; // 4J HEG - No reason to set value if keyboard was cancelled if (bRes) { - std::uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(std::uint16_t)); + uint16_t pchText[128]; + ZeroMemory(pchText, 128 * sizeof(uint16_t)); InputManager.GetText(pchText); if (pchText[0] != 0) { @@ -826,19 +790,18 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() { // npAvailability isn't SCE_OK unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - iPadNotSignedInLive, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + iPadNotSignedInLive); } else { m_bIgnoreInput = true; unsigned int uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_CANCEL; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, iPadNotSignedInLive, - &UIScene_CreateWorldMenu::MustSignInReturnedPSN, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_CreateWorldMenu::MustSignInReturnedPSN, this); } return; /* 4J-PB - Add this after release @@ -849,27 +812,24 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() { (ProfileManager.IsSignedInPSN(ProfileManager.GetPrimaryPad())) { // Signed in to PSN but not connected (no internet -access) unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_PRO_CURRENTLY_NOT_ONLINE_TITLE, -IDS_PRO_PSNOFFLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL,NULL, -app.GetStringTable()); +access) UINT uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; + ui.RequestErrorMessage(IDS_PRO_CURRENTLY_NOT_ONLINE_TITLE, +IDS_PRO_PSNOFFLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad()); } else { // Not signed in to PSN unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, -IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL,NULL, -app.GetStringTable()); return; + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, +IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad()); return; }*/ #else m_bIgnoreInput = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, - uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, - NULL, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, + uiIDA, 1, ProfileManager.GetPrimaryPad()); return; #endif } @@ -893,6 +853,19 @@ app.GetStringTable()); return; if (bPlayStationPlus == false) { m_bIgnoreInput = false; + if (ProfileManager.RequestingPlaystationPlus( + iPadWithNoPlaystationPlus)) { + // MGH - added this so we don't try and upsell when we don't + // know if the player has PS Plus yet (if it can't connect to + // the PS Plus server). + UINT uiIDA[1]; + uiIDA[0] = IDS_OK; + ui.RequestAlertMessage( + IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, NULL); + return; + } + // 4J-PB - we're not allowed to show the text Playstation Plus - // have to call the upsell all the time! upsell psplus std::int32_t iResult = sceNpCommerceDialogInitialize(); @@ -917,20 +890,20 @@ app.GetStringTable()); return; } #endif - if (m_bGameModeSurvival != true || m_MoreOptionsParams.bHostPrivileges) { unsigned int uiIDA[2]; + if (m_bGameModeCreative == true || + m_MoreOptionsParams.bHostPrivileges == TRUE) { uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - if (m_bGameModeSurvival != true) { - ui.RequestMessageBox( + if (m_bGameModeCreative == true) { + ui.RequestAlertMessage( IDS_TITLE_START_GAME, IDS_CONFIRM_START_CREATIVE, uiIDA, 2, - m_iPad, &UIScene_CreateWorldMenu::ConfirmCreateReturned, this, - app.GetStringTable(), NULL, 0, false); + m_iPad, &UIScene_CreateWorldMenu::ConfirmCreateReturned, this); } else { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TITLE_START_GAME, IDS_CONFIRM_START_HOST_PRIVILEGES, uiIDA, 2, m_iPad, &UIScene_CreateWorldMenu::ConfirmCreateReturned, - this, app.GetStringTable(), NULL, 0, false); + this); } } else { // 4J Stu - If we only have one controller connected, then don't show @@ -980,6 +953,19 @@ app.GetStringTable()); return; else if (bPlayStationPlus == false) { m_bIgnoreInput = false; + if (ProfileManager.RequestingPlaystationPlus( + iPadWithNoPlaystationPlus)) { + // MGH - added this so we don't try and upsell when we + // don't know if the player has PS Plus yet (if it can't + // connect to the PS Plus server). + UINT uiIDA[1]; + uiIDA[0] = IDS_OK; + ui.RequestAlertMessage( + IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, NULL); + return; + } + // 4J-PB - we're not allowed to show the text Playstation Plus - // have to call the upsell all the time! upsell psplus std::int32_t iResult = sceNpCommerceDialogInitialize(); @@ -1026,6 +1012,19 @@ app.GetStringTable()); return; else if (isOnlineGame && isSignedInLive && (bPlayStationPlus == false)) { m_bIgnoreInput = false; + if (ProfileManager.RequestingPlaystationPlus( + iPadWithNoPlaystationPlus)) { + // MGH - added this so we don't try and upsell when we + // don't know if the player has PS Plus yet (if it can't + // connect to the PS Plus server). + UINT uiIDA[1]; + uiIDA[0] = IDS_OK; + ui.RequestAlertMessage( + IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, NULL); + return; + } + setVisible(true); // 4J-PB - we're not allowed to show the text Playstation Plus - @@ -1176,10 +1175,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, eGameHostOption_BedrockFog, app.GetGameSettings(pClass->m_iPad, eGameSetting_BedrockFog) ? 1 : 0); - app.SetGameHostOption(eGameHostOption_GameType, - pClass->m_bGameModeSurvival - ? GameType::SURVIVAL->getId() - : GameType::CREATIVE->getId()); + app.SetGameHostOption(eGameHostOption_GameType, pClass->m_iGameModeId); app.SetGameHostOption(eGameHostOption_LevelType, pClass->m_MoreOptionsParams.bFlatWorld); app.SetGameHostOption(eGameHostOption_Structures, @@ -1202,7 +1198,33 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, pClass->m_MoreOptionsParams.bHostPrivileges); - g_NetworkManager.HostGame(localUsersMask, isClientSide, isPrivate, + app.SetGameHostOption(eGameHostOption_MobGriefing, + pClass->m_MoreOptionsParams.bMobGriefing); + app.SetGameHostOption(eGameHostOption_KeepInventory, + pClass->m_MoreOptionsParams.bKeepInventory); + app.SetGameHostOption(eGameHostOption_DoMobSpawning, + pClass->m_MoreOptionsParams.bDoMobSpawning); + app.SetGameHostOption(eGameHostOption_DoMobLoot, + pClass->m_MoreOptionsParams.bDoMobLoot); + 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_WasntSaveOwner, false); +#ifdef _LARGE_WORLDS + app.SetGameHostOption(eGameHostOption_WorldSize, + pClass->m_MoreOptionsParams.worldSize + + 1); // 0 is GAME_HOST_OPTION_WORLDSIZE_UNKNOWN + pClass->m_MoreOptionsParams.currentWorldSize = + (EGameHostOptionWorldSize)(pClass->m_MoreOptionsParams.worldSize + 1); + pClass->m_MoreOptionsParams.newWorldSize = + (EGameHostOptionWorldSize)(pClass->m_MoreOptionsParams.worldSize + 1); +#endif + + g_NetworkManager.HostGame(dwLocalUsersMask, isClientSide, isPrivate, MINECRAFT_NET_MAX_PLAYERS, 0); param->settings = app.GetGameHostOption(eGameHostOption_All); @@ -1211,26 +1233,27 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, switch (pClass->m_MoreOptionsParams.worldSize) { case 0: // Classic - param->xzSize = 1 * 54; - param->hellScale = 3; + param->xzSize = LEVEL_WIDTH_CLASSIC; + param->hellScale = + HELL_LEVEL_SCALE_CLASSIC; // hellsize = 54/3 = 18 break; case 1: // Small - param->xzSize = 1 * 64; - param->hellScale = 3; + param->xzSize = LEVEL_WIDTH_SMALL; + param->hellScale = + HELL_LEVEL_SCALE_SMALL; // hellsize = ceil(64/3) = 22 break; case 2: // Medium - param->xzSize = 3 * 64; - param->hellScale = 6; + param->xzSize = LEVEL_WIDTH_MEDIUM; + param->hellScale = + HELL_LEVEL_SCALE_MEDIUM; // hellsize= ceil(3*64/6) = 32 break; case 3: - // param->xzSize = 5 * 64; - // param->hellScale = 8; - // Large - param->xzSize = LEVEL_MAX_WIDTH; - param->hellScale = HELL_LEVEL_MAX_SCALE; + param->xzSize = LEVEL_WIDTH_LARGE; + param->hellScale = + HELL_LEVEL_SCALE_LARGE; // hellsize = ceil(5*64/8) = 40 break; }; #else @@ -1314,30 +1337,28 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void* pParam, // npAvailability isn't SCE_OK unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, - iPadNotSignedInLive, NULL, NULL, - app.GetStringTable()); + ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + iPadNotSignedInLive); } else { pClass->m_bIgnoreInput = true; unsigned int uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_CANCEL; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, iPadNotSignedInLive, - &UIScene_CreateWorldMenu::MustSignInReturnedPSN, pClass, - app.GetStringTable(), NULL, 0, false); + &UIScene_CreateWorldMenu::MustSignInReturnedPSN, + pClass); } return 0; #else pClass->m_bIgnoreInput = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad()); return 0; #endif } @@ -1358,20 +1379,18 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void* pParam, pClass->m_bIgnoreInput = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ProfileManager.GetPrimaryPad()); } else { pClass->m_bIgnoreInput = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_HOST_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ProfileManager.GetPrimaryPad()); } } else { // This is NOT called from a storage manager thread, and is in @@ -1432,11 +1451,10 @@ int UIScene_CreateWorldMenu::ConfirmCreateReturned( pClass->m_bIgnoreInput = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ProfileManager.GetPrimaryPad()); } else { #if defined(__ORBIS__) || defined(__PSVITA__) bool isOnlineGame = ProfileManager.IsSignedInLive( diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.h index e50921aa2..a38d3e8ef 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.h @@ -6,7 +6,6 @@ class UIScene_CreateWorldMenu : public IUIScene_StartGame { private: enum EControls { eControl_EditWorldName, - eControl_EditSeed, eControl_TexturePackList, eControl_GameModeToggle, eControl_Difficulty, @@ -21,14 +20,11 @@ private: std::wstring m_seed; UIControl m_controlMainPanel; - UIControl_Label m_labelWorldName, m_labelSeed, m_labelRandomSeed; + UIControl_Label m_labelWorldName; UIControl_Button m_buttonGamemode, m_buttonMoreOptions, m_buttonCreateWorld; - UIControl_TextInput m_editWorldName, m_editSeed; + UIControl_TextInput m_editWorldName; UIControl_Slider m_sliderDifficulty; - -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 UIControl_CheckBox m_checkboxOnline; -#endif UIControl_BitmapIcon m_bitmapIcon, m_bitmapComparison; @@ -37,22 +33,17 @@ private: UI_BEGIN_MAP_CHILD_ELEMENTS(m_controlMainPanel) UI_MAP_ELEMENT(m_labelWorldName, "WorldName") UI_MAP_ELEMENT(m_editWorldName, "EditWorldName") - UI_MAP_ELEMENT(m_labelSeed, "Seed") - UI_MAP_ELEMENT(m_editSeed, "EditSeed") - UI_MAP_ELEMENT(m_labelRandomSeed, "RandomSeed") UI_MAP_ELEMENT(m_texturePackList, "TexturePackSelector") UI_MAP_ELEMENT(m_buttonGamemode, "GameModeToggle") - -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 UI_MAP_ELEMENT(m_checkboxOnline, "CheckboxOnline") -#endif UI_MAP_ELEMENT(m_buttonMoreOptions, "MoreOptions") UI_MAP_ELEMENT(m_buttonCreateWorld, "NewWorld") UI_MAP_ELEMENT(m_sliderDifficulty, "Difficulty") UI_END_MAP_CHILD_ELEMENTS() UI_END_MAP_ELEMENTS_AND_NAMES() - bool m_bGameModeSurvival; + bool m_bGameModeCreative; + int m_iGameModeId; bool m_bMultiplayerAllowed; DLCPack* m_pDLCPack; bool m_bRebuildTouchBoxes; @@ -97,11 +88,11 @@ private: protected: static int KeyboardCompleteWorldNameCallback(void* lpParam, const bool bRes); - static int KeyboardCompleteSeedCallback(void* lpParam, const bool bRes); void handlePress(F64 controlId, F64 childId); void handleSliderMove(F64 sliderId, F64 currentValue); - static void CreateGame(UIScene_CreateWorldMenu* pClass, int localUsersMask); + static void CreateGame(UIScene_CreateWorldMenu* pClass, + DWORD dwLocalUsersMask); static int ConfirmCreateReturned(void* pParam, int iPad, C4JStorage::EMessageResult result); static int StartGame_SignInReturned(void* pParam, bool bContinue, int iPad); @@ -116,4 +107,4 @@ protected: #endif virtual void checkStateAndStartGame(); -}; +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.cpp index 28f909df4..80ff2e379 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.cpp @@ -24,7 +24,7 @@ UIScene_CreativeMenu::UIScene_CreativeMenu(int iPad, void* _initData, std::shared_ptr creativeContainer = std::shared_ptr( - new SimpleContainer(0, TabSpec::MAX_SIZE)); + new SimpleContainer(0, L"", false, TabSpec::MAX_SIZE)); itemPickerMenu = new ItemPickerMenu(creativeContainer, initData->player->inventory); @@ -160,28 +160,6 @@ void UIScene_CreativeMenu::handleOtherClicked(int iPad, ESceneSection eSection, } } -void UIScene_CreativeMenu::ScrollBar(UIVec2D pointerPos) { - float fPosition = ((float)pointerPos.y - - (float)m_TouchInput[ETouchInput_TouchSlider].getYPos()) / - (float)m_TouchInput[ETouchInput_TouchSlider].getHeight(); - - // clamp - if (fPosition > 1) - fPosition = 1.0f; - else if (fPosition < 0) - fPosition = 0.0f; - - // calculate page position according to page count - int iCurrentPage = - Math::round(fPosition * (specs[m_curTab]->getPageCount() - 1)); - - // set tab page - m_tabPage[m_curTab] = iCurrentPage; - - // update tab - switchTab(m_curTab); -} - void UIScene_CreativeMenu::handleReload() { Initialize(m_iPad, m_menu, false, -1, eSectionInventoryCreativeUsing, eSectionInventoryCreativeMax, m_bNavigateBack); @@ -193,6 +171,10 @@ void UIScene_CreativeMenu::handleReload() { for (unsigned int i = TabSpec::MAX_SIZE; i < TabSpec::MAX_SIZE + 9; ++i) { m_slotListHotbar.addSlot(i); } + + ECreativeInventoryTabs lastTab = m_curTab; + m_curTab = eCreativeInventoryTab_COUNT; + switchTab(lastTab); } void UIScene_CreativeMenu::handleInput(int iPad, int key, bool repeat, @@ -491,4 +473,4 @@ void UIScene_CreativeMenu::updateScrollCurrentPage(int currentPage, IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetScrollBar, 2, value); -} +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.h index d637de209..91a60d133 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CreativeMenu.h @@ -84,7 +84,6 @@ public: virtual void handleTouchBoxRebuild(); virtual void handleTimerComplete(int id); #endif - virtual void ScrollBar(UIVec2D pointerPos); private: // IUIScene_CreativeMenu diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_Credits.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_Credits.cpp index 1084c0891..64ad951d5 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_Credits.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_Credits.cpp @@ -62,6 +62,18 @@ SCreditTextItemDef UIScene_Credits::gs_aCreditDefs[MAX_CREDIT_STRINGS] = { eSmallText}, {L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText}, // extra blank line + + // Added credit for horses + {L"Developers of Mo' Creatures:", NO_TRANSLATED_STRING, + NO_TRANSLATED_STRING, eExtraLargeText}, + {L"John Olarte (DrZhark)", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, + eSmallText}, + {L"Kent Christian Jensen", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, + eSmallText}, + {L"Dan Roque", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText}, + {L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, + eSmallText}, // extra blank line + {L"4J Studios", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eExtraLargeText}, {L"%ls", IDS_CREDITS_PROGRAMMING, NO_TRANSLATED_STRING, eLargeText}, @@ -758,19 +770,35 @@ void UIScene_Credits::tick() { { if (pDef->m_iStringID[0] == CREDIT_ICON) { addImage((ECreditIcons)pDef->m_iStringID[1]); - } else if (pDef->m_iStringID[0] == NO_TRANSLATED_STRING) { - setNextLabel(pDef->m_Text, pDef->m_eType); } else // using additional translated string. { + std::wstring sanitisedString = std::wstring(pDef->m_Text); + + // 4J-JEV: Some DLC credits contain copyright or registered + // symbols that are not rendered in some fonts. + if (!ui.UsingBitmapFont()) { + sanitisedString = + replaceAll(sanitisedString, L"\u00A9", L"(C)"); + sanitisedString = + replaceAll(sanitisedString, L"\u00AE", L"(R)"); + sanitisedString = + replaceAll(sanitisedString, L"\u2013", L"-"); + } + LPWSTR creditsString = new wchar_t[128]; - if (pDef->m_iStringID[1] != NO_TRANSLATED_STRING) { - swprintf(creditsString, 128, pDef->m_Text, + if (pDef->m_iStringID[0] == NO_TRANSLATED_STRING) { + ZeroMemory(creditsString, 128); + memcpy(creditsString, sanitisedString.c_str(), + sizeof(WCHAR) * sanitisedString.length()); + } else if (pDef->m_iStringID[1] != NO_TRANSLATED_STRING) { + swprintf(creditsString, 128, sanitisedString.c_str(), app.GetString(pDef->m_iStringID[0]), app.GetString(pDef->m_iStringID[1])); } else { - swprintf(creditsString, 128, pDef->m_Text, + swprintf(creditsString, 128, sanitisedString.c_str(), app.GetString(pDef->m_iStringID[0])); } + setNextLabel(creditsString, pDef->m_eType); delete[] creditsString; } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_Credits.h b/Minecraft.Client/Platform/Common/UI/UIScene_Credits.h index d809a71d9..1e5cefbd7 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_Credits.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_Credits.h @@ -2,10 +2,10 @@ #include "UIScene.h" -#define PS3_CREDITS_COUNT 75 -#define PSVITA_CREDITS_COUNT 77 -#define PS4_CREDITS_COUNT 75 -#define XBOXONE_CREDITS_COUNT (75 + 318) +#define PS3_CREDITS_COUNT 80 +#define PSVITA_CREDITS_COUNT 82 +#define PS4_CREDITS_COUNT 80 +#define XBOXONE_CREDITS_COUNT (80 + 318) #define MILES_AND_IGGY_CREDITS_COUNT 8 #define DYNAMODE_FONT_CREDITS_COUNT 2 #define PS3_DOLBY_CREDIT 4 @@ -18,10 +18,7 @@ #define MAX_CREDIT_STRINGS \ (PS4_CREDITS_COUNT + MILES_AND_IGGY_CREDITS_COUNT + \ DYNAMODE_FONT_CREDITS_COUNT) -#elif defined(_DURANGO) || defined _WIN64 -#define MAX_CREDIT_STRINGS \ - (XBOXONE_CREDITS_COUNT + MILES_AND_IGGY_CREDITS_COUNT) -#elif defined(__linux__) +#elif defined(_DURANGO) || defined _WINDOWS64 || defined __linux__ #define MAX_CREDIT_STRINGS \ (XBOXONE_CREDITS_COUNT + MILES_AND_IGGY_CREDITS_COUNT) #elif defined(__PSVITA__) diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DLCMainMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DLCMainMenu.cpp index 6151ced66..6ac19847d 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DLCMainMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DLCMainMenu.cpp @@ -16,7 +16,7 @@ UIScene_DLCMainMenu::UIScene_DLCMainMenu(int iPad, void* initData, // Alert the app the we want to be informed of ethernet connections app.SetLiveLinkRequired(true); - m_labelOffers.init(app.GetString(IDS_DOWNLOADABLE_CONTENT_OFFERS)); + m_labelOffers.init(IDS_DOWNLOADABLE_CONTENT_OFFERS); m_buttonListOffers.init(eControl_OffersList); #if defined _XBOX_ONE || defined __ORBIS__ @@ -33,7 +33,7 @@ UIScene_DLCMainMenu::UIScene_DLCMainMenu(int iPad, void* initData, if (m_loadedResolution == eSceneResolution_1080) { #ifdef _DURANGO - m_labelXboxStore.init(app.GetString(IDS_XBOX_STORE)); + m_labelXboxStore.init(IDS_XBOX_STORE); #else m_labelXboxStore.init(L""); #endif @@ -42,12 +42,9 @@ UIScene_DLCMainMenu::UIScene_DLCMainMenu(int iPad, void* initData, #if defined(_DURANGO) m_Timer.setVisible(false); - m_buttonListOffers.addItem(app.GetString(IDS_DLC_MENU_SKINPACKS), - e_DLC_SkinPack); - m_buttonListOffers.addItem(app.GetString(IDS_DLC_MENU_TEXTUREPACKS), - e_DLC_TexturePacks); - m_buttonListOffers.addItem(app.GetString(IDS_DLC_MENU_MASHUPPACKS), - e_DLC_MashupPacks); + m_buttonListOffers.addItem(IDS_DLC_MENU_SKINPACKS, e_DLC_SkinPack); + m_buttonListOffers.addItem(IDS_DLC_MENU_TEXTUREPACKS, e_DLC_TexturePacks); + m_buttonListOffers.addItem(IDS_DLC_MENU_MASHUPPACKS, e_DLC_MashupPacks); app.AddDLCRequest(e_Marketplace_Content); // content is skin packs, texture // packs and mash-up packs @@ -57,10 +54,8 @@ UIScene_DLCMainMenu::UIScene_DLCMainMenu(int iPad, void* initData, TelemetryManager->RecordMenuShown(iPad, eUIScene_DLCMainMenu, 0); -#ifdef __ORBIS__ - sceNpCommerceShowPsStoreIcon(SCE_NP_COMMERCE_PS_STORE_ICON_RIGHT); -#elif defined __PSVITA__ - sceNpCommerce2ShowPsStoreIcon(SCE_NP_COMMERCE2_ICON_DISP_RIGHT); +#if defined __ORBIS__ || defined __PSVITA__ + app.GetCommerce()->ShowPsStoreIcon(); #endif #if (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__) @@ -75,6 +70,11 @@ UIScene_DLCMainMenu::~UIScene_DLCMainMenu() { #if defined _XBOX_ONE || defined __ORBIS__ app.FreeLocalDLCImages(); #endif + +#ifdef _XBOX_ONE + // 4J-JEV: Have to switch back to user preferred languge now. + setLanguageOverride(true); +#endif } std::wstring UIScene_DLCMainMenu::getMoviePath() { return L"DLCMainMenu"; } @@ -94,10 +94,8 @@ void UIScene_DLCMainMenu::handleInput(int iPad, int key, bool repeat, switch (key) { case ACTION_MENU_CANCEL: if (pressed) { -#ifdef __ORBIS__ - sceNpCommerceHidePsStoreIcon(); -#elif defined __PSVITA__ - sceNpCommerce2HidePsStoreIcon(); +#if defined __ORBIS__ || defined __PSVITA__ + app.GetCommerce()->HidePsStoreIcon(); #endif navigateBack(); } @@ -153,13 +151,12 @@ void UIScene_DLCMainMenu::handleTimerComplete(int id) { // leaderboards unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - C4JStorage::EMessageResult result = ui.RequestMessageBox( + C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CONNECTION_LOST, g_NetworkManager.CorrectErrorIDS( IDS_CONNECTION_LOST_LIVE_NO_EXIT), uiIDA, 1, ProfileManager.GetPrimaryPad(), - UIScene_DLCMainMenu::ExitDLCMainMenu, this, - app.GetStringTable()); + UIScene_DLCMainMenu::ExitDLCMainMenu, this); } #endif break; @@ -171,10 +168,8 @@ int UIScene_DLCMainMenu::ExitDLCMainMenu(void* pParam, int iPad, C4JStorage::EMessageResult result) { UIScene_DLCMainMenu* pClass = (UIScene_DLCMainMenu*)pParam; -#ifdef __ORBIS__ - sceNpCommerceHidePsStoreIcon(); -#elif defined __PSVITA__ - sceNpCommerce2HidePsStoreIcon(); +#if defined __ORBIS__ || defined __PSVITA__ + app.GetCommerce()->HidePsStoreIcon(); #endif pClass->navigateBack(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DLCMainMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_DLCMainMenu.h index f7a435528..2c8ee1668 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DLCMainMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DLCMainMenu.h @@ -8,7 +8,7 @@ private: eControl_OffersList, }; - UIControl_ButtonList m_buttonListOffers; + UIControl_DynamicButtonList m_buttonListOffers; UIControl_Label m_labelOffers, m_labelXboxStore; UIControl m_Timer; UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp index a2db54649..078ad5b66 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp @@ -35,8 +35,8 @@ UIScene_DLCOffersMenu::UIScene_DLCOffersMenu(int iPad, void* initData, m_labelOffers.init(app.GetString(IDS_DOWNLOADABLE_CONTENT_OFFERS)); m_buttonListOffers.init(eControl_OffersList); - m_labelHTMLSellText.init(" "); - m_labelPriceTag.init(" "); + m_labelHTMLSellText.init(L" "); + m_labelPriceTag.init(L" "); TelemetryManager->RecordMenuShown(m_iPad, eUIScene_DLCOffersMenu, 0); m_bHasPurchased = false; @@ -92,13 +92,12 @@ void UIScene_DLCOffersMenu::handleTimerComplete(int id) { // menu unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - C4JStorage::EMessageResult result = ui.RequestMessageBox( + C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CONNECTION_LOST, g_NetworkManager.CorrectErrorIDS( IDS_CONNECTION_LOST_LIVE_NO_EXIT), uiIDA, 1, ProfileManager.GetPrimaryPad(), - UIScene_DLCOffersMenu::ExitDLCOffersMenu, this, - app.GetStringTable()); + UIScene_DLCOffersMenu::ExitDLCOffersMenu, this); } #endif break; @@ -110,10 +109,8 @@ int UIScene_DLCOffersMenu::ExitDLCOffersMenu( void* pParam, int iPad, C4JStorage::EMessageResult result) { UIScene_DLCOffersMenu* pClass = (UIScene_DLCOffersMenu*)pParam; -#ifdef __ORBIS__ - sceNpCommerceHidePsStoreIcon(); -#elif defined __PSVITA__ - sceNpCommerce2HidePsStoreIcon(); +#if defined __ORBIS__ || defined __PSVITA__ + app.GetCommerce()->HidePsStoreIcon(); #endif ui.NavigateToHomeMenu(); // iPad,eUIScene_MainMenu); @@ -284,7 +281,7 @@ void UIScene_DLCOffersMenu::handlePress(F64 controlId, F64 childId) { ULONGLONG ullIndexA[1]; ullIndexA[0] = StorageManager.GetOffer(iIndex).qwOfferID; - StorageManager.InstallOffer(1, (__uint64*)ullIndexA, NULL, NULL); + StorageManager.InstallOffer(1, ullIndexA, NULL, NULL); #endif } break; } @@ -439,7 +436,7 @@ void UIScene_DLCOffersMenu::tick() { if (hasRegisteredSubstitutionTexture(textureName) == false) { - std::uint8_t* pbImageData = NULL; + PBYTE pbImageData; int iImageDataBytes = 0; bool bDeleteData; #ifdef __ORBIS__ @@ -448,7 +445,7 @@ void UIScene_DLCOffersMenu::tick() { app.GetSONYDLCInfoFromKeyname(info.productId); // does the DLC info have an image? - if (pSONYDLCInfo->dwImageBytes != 0) { + if (pSONYDLCInfo && pSONYDLCInfo->dwImageBytes != 0) { pbImageData = pSONYDLCInfo->pbImageData; iImageDataBytes = pSONYDLCInfo->dwImageBytes; bDeleteData = @@ -560,7 +557,7 @@ void UIScene_DLCOffersMenu::tick() { std::wstring textureName = filenametostd::wstring(info.imageUrl); if (hasRegisteredSubstitutionTexture(textureName) == false) { - std::uint8_t* pbImageData = NULL; + PBYTE pbImageData; int iImageDataBytes = 0; bool bDeleteData; #ifdef __ORBIS__ @@ -628,6 +625,18 @@ void UIScene_DLCOffersMenu::tick() { MARKETPLACE_CONTENTOFFER_INFO xOffer = StorageManager.GetOffer(iIndex); + if (!ui.UsingBitmapFont()) // 4J-JEV: Replace characters we don't + // have. + { + for (int i = 0; xOffer.wszCurrencyPrice[i] != 0; i++) { + WCHAR* c = &xOffer.wszCurrencyPrice[i]; + if (*c == L'\u20A9') + *c = L'\uFFE6'; // Korean Won. + else if (*c == L'\u00A5') + *c = L'\uFFE5'; // Japanese Yen. + } + } + if (UpdateDisplay(xOffer)) { // image was available m_bSelectionChanged = false; @@ -710,7 +719,8 @@ void UIScene_DLCOffersMenu::GetDLCInfo(int iOfferC, bool bUpdateOnly) { if (wcsncmp(L"Minecraft ", wstrTemp.c_str(), 10) == 0) { app.DebugPrintf("Removing Minecraft from name\n"); - wstrTemp = wstrTemp.substr(10); + WCHAR* pwchNewName = (WCHAR*)wstrTemp.c_str(); + wstrTemp = &pwchNewName[10]; } #ifdef _XBOX_ONE @@ -792,7 +802,7 @@ bool UIScene_DLCOffersMenu::UpdateDisplay( #endif if (dlc != NULL) { - wchar_t* cString = dlc->wchBanner; + WCHAR* cString = dlc->wchBanner; // is the file in the local DLC images? // is the file in the TMS XZP? @@ -819,8 +829,8 @@ bool UIScene_DLCOffersMenu::UpdateDisplay( // m_bitmapIconOfferImage.setTextureName(L""); } else { if (hasRegisteredSubstitutionTexture(cString) == false) { - std::uint8_t* pData = NULL; - unsigned int dwSize = 0; + BYTE* pData = NULL; + DWORD dwSize = 0; app.GetMemFileDetails(cString, &pData, &dwSize); // set the image #ifdef _XBOX_ONE diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DeathMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DeathMenu.cpp index 796316501..88fca6502 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DeathMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DeathMenu.cpp @@ -108,49 +108,49 @@ void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) { uiIDA[1] = IDS_EXIT_GAME_SAVE; uiIDA[2] = IDS_EXIT_GAME_NO_SAVE; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, m_iPad, &IUIScene_PauseMenu::ExitGameSaveDialogReturned, - this, app.GetStringTable(), 0, 0, false); + (LPVOID)GetCallbackUniqueId()); } else { uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned, - this, app.GetStringTable(), 0, 0, false); + (LPVOID)GetCallbackUniqueId()); } #else if (StorageManager.GetSaveDisabled()) { uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, m_iPad, - &IUIScene_PauseMenu::ExitGameDialogReturned, this, - app.GetStringTable(), 0, 0, false); + &IUIScene_PauseMenu::ExitGameDialogReturned, + (LPVOID)GetCallbackUniqueId()); } else { if (g_NetworkManager.IsHost()) { uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_EXIT_GAME_SAVE; uiIDA[2] = IDS_EXIT_GAME_NO_SAVE; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, m_iPad, &IUIScene_PauseMenu::ExitGameSaveDialogReturned, - this, app.GetStringTable(), 0, 0, false); + (LPVOID)GetCallbackUniqueId()); } else { uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned, - this, app.GetStringTable(), 0, 0, false); + (LPVOID)GetCallbackUniqueId()); } } #endif @@ -174,11 +174,11 @@ void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) { unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, m_iPad, - &IUIScene_PauseMenu::ExitGameDialogReturned, this, - app.GetStringTable(), 0, 0, false); + &IUIScene_PauseMenu::ExitGameDialogReturned, + (LPVOID)GetCallbackUniqueId()); } else { TelemetryManager->RecordLevelExit( m_iPad, eSen_LevelExitStatus_Failed); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.cpp index 6f510cabc..b20c18e66 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.cpp @@ -14,15 +14,15 @@ const wchar_t* L"Craft Anything", L"Use DPad for debug", L"Mobs don't tick", - L"Instant Mine", + L"Art tools", // L"Instant Mine", L"Show UI Console", L"Distributable Save", L"Debug Leaderboards", - L"Height-Water-Biome Maps", + L"Height-Water Maps", L"Superflat Nether", // L"Light/Dark background", L"More lightning when thundering", - L"Go To Nether", + L"Biome override", // L"Go To End", L"Go To Overworld", L"Unlock All DLC", // L"Toggle Font", diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp index e3eb58160..3aa2d2619 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp @@ -29,8 +29,10 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void* initData, m_sliderFov.init(TempString, eControl_FOV, 0, 100, (int)pMinecraft->gameRenderer->GetFovVal()); - float currentTime = pMinecraft->level->getLevelData()->getTime() % 24000; - swprintf(TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime); + float currentTime = + pMinecraft->level->getLevelData()->getGameTime() % 24000; + swprintf((WCHAR*)TempString, 256, L"Set time (unsafe) (%d)", + (int)currentTime); m_sliderTime.init(TempString, eControl_Time, 0, 240, currentTime / 100); m_buttonRain.init(L"Toggle Rain", eControl_Rain); @@ -246,7 +248,7 @@ void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue) { // local level tries to predict the time Only works if we are on the // host machine, but shouldn't break if not MinecraftServer::SetTime(currentValue * 100); - pMinecraft->level->getLevelData()->setTime(currentValue * 100); + pMinecraft->level->getLevelData()->setGameTime(currentValue * 100); wchar_t TempString[256]; float currentTime = currentValue * 100; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DispenserMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DispenserMenu.cpp index e57cb00a8..b295d5cfe 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DispenserMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DispenserMenu.cpp @@ -11,10 +11,10 @@ UIScene_DispenserMenu::UIScene_DispenserMenu(int iPad, void* _initData, // Setup all the Iggy references we need for this scene initialiseMovie(); - m_labelDispenser.init(app.GetString(IDS_DISPENSER)); - TrapScreenInput* initData = (TrapScreenInput*)_initData; + m_labelDispenser.init(initData->trap->getName()); + Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft->localgameModes[initData->iPad] != NULL) { TutorialMode* gameMode = diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_EnchantingMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_EnchantingMenu.cpp index f5890c90f..55f171d5e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_EnchantingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_EnchantingMenu.cpp @@ -11,14 +11,15 @@ UIScene_EnchantingMenu::UIScene_EnchantingMenu(int iPad, void* _initData, // Setup all the Iggy references we need for this scene initialiseMovie(); - m_labelEnchant.init(app.GetString(IDS_ENCHANT)); - m_enchantButton[0].init(0); m_enchantButton[1].init(1); m_enchantButton[2].init(2); EnchantingScreenInput* initData = (EnchantingScreenInput*)_initData; + m_labelEnchant.init(initData->name.empty() ? app.GetString(IDS_ENCHANT) + : initData->name); + Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft->localgameModes[initData->iPad] != NULL) { TutorialMode* gameMode = diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_EndPoem.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_EndPoem.cpp index fc8456cb0..6db56e90c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_EndPoem.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_EndPoem.cpp @@ -214,8 +214,17 @@ void UIScene_EndPoem::updateNoise() { replaceString = L""; for (int i = 0; i < length; ++i) { - randomChar = SharedConstants::acceptableLetters[random->nextInt( - (int)SharedConstants::acceptableLetters.length())]; + if (ui.UsingBitmapFont()) { + randomChar = SharedConstants::acceptableLetters[random->nextInt( + (int)SharedConstants::acceptableLetters.length())]; + } else { + // 4J-JEV: It'd be nice to avoid null characters when using + // asian languages. + static std::wstring acceptableLetters = + L"!\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_'|}~"; + randomChar = acceptableLetters[random->nextInt( + (int)acceptableLetters.length())]; + } std::wstring randomCharStr = L""; randomCharStr.push_back(randomChar); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.cpp new file mode 100644 index 000000000..a1c8be3e6 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.cpp @@ -0,0 +1,229 @@ +#include "../../stdafx.h" +#include "UI.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" +#include "../../Minecraft.h" +#include "../../LocalPlayer.h" +#include "UIScene_FireworksMenu.h" + +UIScene_FireworksMenu::UIScene_FireworksMenu(int iPad, void* _initData, + UILayer* parentLayer) + : UIScene_AbstractContainerMenu(iPad, parentLayer) { + // Setup all the Iggy references we need for this scene + initialiseMovie(); + + FireworksScreenInput* initData = (FireworksScreenInput*)_initData; + + m_labelFireworks.init(app.GetString(IDS_HOW_TO_PLAY_MENU_FIREWORKS)); + + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft->localgameModes[initData->iPad] != NULL) { + TutorialMode* gameMode = + (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; + m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); + gameMode->getTutorial()->changeTutorialState( + e_Tutorial_State_Fireworks_Menu, this); + } + + FireworksMenu* menu = + new FireworksMenu(initData->player->inventory, initData->player->level, + initData->x, initData->y, initData->z); + + Initialize(initData->iPad, menu, true, FireworksMenu::INV_SLOT_START, + eSectionFireworksUsing, eSectionFireworksMax); + + m_slotListResult.addSlots(FireworksMenu::RESULT_SLOT, 1); + m_slotList3x3.addSlots(FireworksMenu::CRAFT_SLOT_START, 9); + ShowLargeCraftingGrid(true); + + delete initData; +} + +std::wstring UIScene_FireworksMenu::getMoviePath() { + if (app.GetLocalPlayerCount() > 1) { + return L"FireworksMenuSplit"; + } else { + return L"FireworksMenu"; + } +} + +void UIScene_FireworksMenu::handleReload() { + Initialize(m_iPad, m_menu, true, FireworksMenu::INV_SLOT_START, + eSectionFireworksUsing, eSectionFireworksMax); + + m_slotListResult.addSlots(FireworksMenu::RESULT_SLOT, 1); + m_slotList3x3.addSlots(FireworksMenu::CRAFT_SLOT_START, 9); + ShowLargeCraftingGrid(true); +} + +int UIScene_FireworksMenu::getSectionColumns(ESceneSection eSection) { + int cols = 0; + switch (eSection) { + case eSectionFireworksIngredients: + cols = 3; + break; + case eSectionFireworksResult: + cols = 1; + break; + case eSectionFireworksInventory: + cols = 9; + break; + case eSectionFireworksUsing: + cols = 9; + break; + default: + assert(false); + break; + } + return cols; +} + +int UIScene_FireworksMenu::getSectionRows(ESceneSection eSection) { + int rows = 0; + switch (eSection) { + case eSectionFireworksIngredients: + rows = 3; + break; + case eSectionFireworksResult: + rows = 1; + break; + case eSectionFireworksInventory: + rows = 3; + break; + case eSectionFireworksUsing: + rows = 1; + break; + default: + assert(false); + break; + } + return rows; +} + +void UIScene_FireworksMenu::GetPositionOfSection(ESceneSection eSection, + UIVec2D* pPosition) { + switch (eSection) { + case eSectionFireworksIngredients: + pPosition->x = m_slotList3x3.getXPos(); + pPosition->y = m_slotList3x3.getYPos(); + break; + case eSectionFireworksResult: + pPosition->x = m_slotListResult.getXPos(); + pPosition->y = m_slotListResult.getYPos(); + break; + case eSectionFireworksInventory: + pPosition->x = m_slotListInventory.getXPos(); + pPosition->y = m_slotListInventory.getYPos(); + break; + case eSectionFireworksUsing: + pPosition->x = m_slotListHotbar.getXPos(); + pPosition->y = m_slotListHotbar.getYPos(); + break; + default: + assert(false); + break; + } +} + +void UIScene_FireworksMenu::GetItemScreenData(ESceneSection eSection, + int iItemIndex, + UIVec2D* pPosition, + UIVec2D* pSize) { + UIVec2D sectionSize; + switch (eSection) { + case eSectionFireworksIngredients: + sectionSize.x = m_slotList3x3.getWidth(); + sectionSize.y = m_slotList3x3.getHeight(); + break; + case eSectionFireworksResult: + sectionSize.x = m_slotListResult.getWidth(); + sectionSize.y = m_slotListResult.getHeight(); + break; + case eSectionFireworksInventory: + sectionSize.x = m_slotListInventory.getWidth(); + sectionSize.y = m_slotListInventory.getHeight(); + break; + case eSectionFireworksUsing: + sectionSize.x = m_slotListHotbar.getWidth(); + sectionSize.y = m_slotListHotbar.getHeight(); + break; + default: + assert(false); + break; + } + + int rows = getSectionRows(eSection); + int cols = getSectionColumns(eSection); + + pSize->x = sectionSize.x / cols; + pSize->y = sectionSize.y / rows; + + int itemCol = iItemIndex % cols; + int itemRow = iItemIndex / cols; + + pPosition->x = itemCol * pSize->x; + pPosition->y = itemRow * pSize->y; +} + +void UIScene_FireworksMenu::setSectionSelectedSlot(ESceneSection eSection, + int x, int y) { + int cols = getSectionColumns(eSection); + + int index = (y * cols) + x; + + UIControl_SlotList* slotList = NULL; + switch (eSection) { + case eSectionFireworksIngredients: + slotList = &m_slotList3x3; + break; + case eSectionFireworksResult: + slotList = &m_slotListResult; + break; + case eSectionFireworksInventory: + slotList = &m_slotListInventory; + break; + case eSectionFireworksUsing: + slotList = &m_slotListHotbar; + break; + default: + assert(false); + break; + } + slotList->setHighlightSlot(index); +} + +UIControl* UIScene_FireworksMenu::getSection(ESceneSection eSection) { + UIControl* control = NULL; + switch (eSection) { + case eSectionFireworksIngredients: + control = &m_slotList3x3; + break; + case eSectionFireworksResult: + control = &m_slotListResult; + break; + case eSectionFireworksInventory: + control = &m_slotListInventory; + break; + case eSectionFireworksUsing: + control = &m_slotListHotbar; + break; + default: + assert(false); + break; + } + return control; +} + +// bShow == true removes the 2x2 crafting grid and bShow == false removes the +// 3x3 crafting grid +void UIScene_FireworksMenu::ShowLargeCraftingGrid(boolean bShow) { + app.DebugPrintf("ShowLargeCraftingGrid to %d\n", bShow); + + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_boolean; + value[0].boolval = bShow; + IggyResult out = IggyPlayerCallMethodRS( + getMovie(), &result, IggyPlayerRootPath(getMovie()), + m_funcShowLargeCraftingGrid, 1, value); +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.h new file mode 100644 index 000000000..6cc7c98d1 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_FireworksMenu.h @@ -0,0 +1,46 @@ +#pragma once + +#include "UIScene_AbstractContainerMenu.h" +#include "IUIScene_FireworksMenu.h" + +class InventoryMenu; + +class UIScene_FireworksMenu : public UIScene_AbstractContainerMenu, + public IUIScene_FireworksMenu { +public: + UIScene_FireworksMenu(int iPad, void* initData, UILayer* parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_FireworksMenu; } + +protected: + UIControl_SlotList m_slotListResult, m_slotList3x3, m_slotList2x2; + UIControl_Label m_labelFireworks; + IggyName m_funcShowLargeCraftingGrid; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene_AbstractContainerMenu) + UI_BEGIN_MAP_CHILD_ELEMENTS(m_controlMainPanel) + UI_MAP_ELEMENT(m_slotListResult, "Result") + UI_MAP_ELEMENT(m_slotList3x3, "Fireworks3x3") + UI_MAP_ELEMENT(m_slotList2x2, "Fireworks2x2") + UI_MAP_ELEMENT(m_labelFireworks, "FireworksLabel") + + UI_MAP_NAME(m_funcShowLargeCraftingGrid, L"ShowLargeCraftingGrid") + UI_END_MAP_CHILD_ELEMENTS() + UI_END_MAP_ELEMENTS_AND_NAMES() + + virtual std::wstring getMoviePath(); + virtual void handleReload(); + + virtual int getSectionColumns(ESceneSection eSection); + virtual int getSectionRows(ESceneSection eSection); + virtual void GetPositionOfSection(ESceneSection eSection, + UIVec2D* pPosition); + virtual void GetItemScreenData(ESceneSection eSection, int iItemIndex, + UIVec2D* pPosition, UIVec2D* pSize); + virtual void handleSectionClick(ESceneSection eSection) {} + virtual void setSectionSelectedSlot(ESceneSection eSection, int x, int y); + + virtual UIControl* getSection(ESceneSection eSection); + + void ShowLargeCraftingGrid(boolean bShow); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp index c2b9aeb18..3c33ac874 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp @@ -148,14 +148,7 @@ void UIScene_FullscreenProgress::tick() { } int code = thread->GetExitCode(); - const unsigned int exitcode = static_cast(code); - - static int s_FPTickCount = 0; - if (s_FPTickCount % 60 == 0) - app.DebugPrintf("[FP] tick #%d exitcode=%u STILL_ACTIVE=%u\n", - s_FPTickCount, exitcode, - static_cast(STILL_ACTIVE)); - s_FPTickCount++; + DWORD exitcode = *((DWORD*)&code); // app.DebugPrintf("CScene_FullscreenProgress Timer %d\n",pTimer->nId); @@ -189,12 +182,11 @@ void UIScene_FullscreenProgress::tick() { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestErrorMessage( g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_FAILED), g_NetworkManager.CorrectErrorIDS( IDS_CONNECTION_LOST_SERVER), - uiIDA, 1, XUSER_INDEX_ANY, NULL, NULL, - app.GetStringTable()); + uiIDA, 1, XUSER_INDEX_ANY); ui.NavigateToHomeMenu(); ui.UpdatePlayerBasePositions(); @@ -204,6 +196,11 @@ void UIScene_FullscreenProgress::tick() { (!m_bWasCancelled)) { m_threadCompleted = true; m_buttonConfirm.setVisible(true); + // 4J-TomK - rebuild touch after confirm button made visible + // again +#ifdef __PSVITA__ + ui.TouchBoxRebuild(this); +#endif updateTooltips(); } else { if (m_bWasCancelled) { @@ -380,4 +377,4 @@ bool UIScene_FullscreenProgress::isReadyToDelete() { } else { return true; } -} +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_FurnaceMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_FurnaceMenu.cpp index ce4642150..51b1a272c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_FurnaceMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_FurnaceMenu.cpp @@ -11,16 +11,16 @@ UIScene_FurnaceMenu::UIScene_FurnaceMenu(int iPad, void* _initData, // Setup all the Iggy references we need for this scene initialiseMovie(); - m_labelFurnace.init(app.GetString(IDS_FURNACE)); + FurnaceScreenInput* initData = (FurnaceScreenInput*)_initData; + m_furnace = initData->furnace; + + m_labelFurnace.init(m_furnace->getName()); m_labelIngredient.init(app.GetString(IDS_INGREDIENT)); m_labelFuel.init(app.GetString(IDS_FUEL)); m_progressFurnaceFire.init(L"", 0, 0, 12, 0); m_progressFurnaceArrow.init(L"", 0, 0, 24, 0); - FurnaceScreenInput* initData = (FurnaceScreenInput*)_initData; - m_furnace = initData->furnace; - Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft->localgameModes[initData->iPad] != NULL) { TutorialMode* gameMode = diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HUD.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HUD.cpp index 14f1b9717..89516254f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HUD.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HUD.cpp @@ -17,32 +17,6 @@ UIScene_HUD::UIScene_HUD(int iPad, void* initData, UILayer* parentLayer) // Setup all the Iggy references we need for this scene initialiseMovie(); - m_lastActiveSlot = 0; - m_lastScale = 1; - m_bToolTipsVisible = true; - m_lastExpProgress = 0.0f; - m_lastExpLevel = 0; - m_lastMaxHealth = 20; - m_lastHealthBlink = false; - m_lastHealthPoison = false; - m_lastMaxFood = 20; - m_lastFoodPoison = false; - m_lastAir = 10; - m_lastArmour = 0; - m_showHealth = true; - m_showFood = true; - m_showAir = true; - m_showArmour = true; - m_showExpBar = true; - m_lastRegenEffect = false; - m_lastSaturation = 0; - m_lastDragonHealth = 0.0f; - m_showDragonHealth = false; - m_ticksWithNoBoss = 0; - m_uiSelectedItemOpacityCountDown = 0; - m_displayName = L""; - m_lastShowDisplayName = true; - SetDragonLabel(app.GetString(IDS_BOSS_ENDERDRAGON_HEALTH)); SetSelectedLabel(L""); @@ -139,28 +113,28 @@ void UIScene_HUD::tick() { return; } - if (pMinecraft->localplayers[m_iPad]->dimension == 1) { - if (EnderDragonRenderer::bossInstance == NULL) { + // Is boss present? + bool noBoss = + BossMobGuiInfo::name.empty() || BossMobGuiInfo::displayTicks <= 0; + if (noBoss) { + if (m_showDragonHealth) { + // No boss and health is visible if (m_ticksWithNoBoss <= 20) { ++m_ticksWithNoBoss; - } - if (m_ticksWithNoBoss > 20) { + } else { ShowDragonHealth(false); } - } else { - std::shared_ptr boss = - EnderDragonRenderer::bossInstance; - // 4J Stu - Don't clear this here as it's wiped for other - // players - // EnderDragonRenderer::bossInstance = nullptr; - m_ticksWithNoBoss = 0; - - ShowDragonHealth(true); - SetDragonHealth((float)boss->getSynchedHealth() / - boss->getMaxHealth()); } } else { - ShowDragonHealth(false); + BossMobGuiInfo::displayTicks--; + + m_ticksWithNoBoss = 0; + SetDragonHealth(BossMobGuiInfo::healthProgress); + + if (!m_showDragonHealth) { + SetDragonLabel(BossMobGuiInfo::name); + ShowDragonHealth(true); + } } } } @@ -209,34 +183,48 @@ void UIScene_HUD::customDraw(IggyCustomDrawCallbackRegion* region) { } void UIScene_HUD::handleReload() { - m_lastActiveSlot = 0; - m_lastScale = 1; + m_lastActiveSlot = -1; + m_iGuiScale = -1; m_bToolTipsVisible = true; m_lastExpProgress = 0.0f; m_lastExpLevel = 0; + m_iCurrentHealth = 0; m_lastMaxHealth = 20; m_lastHealthBlink = false; m_lastHealthPoison = false; - m_lastMaxFood = 20; + m_iCurrentFood = -1; m_lastFoodPoison = false; m_lastAir = 10; + m_currentExtraAir = 0; m_lastArmour = 0; m_showHealth = true; + m_showHorseHealth = true; m_showFood = true; - m_showAir = true; + m_showAir = false; // get's initialised invisible anyways, by setting it to + // false we ensure it will remain visible when switching + // in and out of split screen! m_showArmour = true; m_showExpBar = true; - m_lastRegenEffect = false; - m_lastSaturation = 0; + m_bRegenEffectEnabled = false; + m_iFoodSaturation = 0; m_lastDragonHealth = 0.0f; m_showDragonHealth = false; m_ticksWithNoBoss = 0; m_uiSelectedItemOpacityCountDown = 0; m_displayName = L""; + m_lastShowDisplayName = true; + m_bRidingHorse = true; + m_horseHealth = 1; + m_lastHealthWither = true; + m_iCurrentHealthAbsorb = -1; + m_horseJumpProgress = 1.0f; + m_iHeartOffsetIndex = -1; + m_bHealthAbsorbActive = false; + m_iHorseMaxHealth = -1; m_labelDisplayName.setVisible(m_lastShowDisplayName); - SetDragonLabel(app.GetString(IDS_BOSS_ENDERDRAGON_HEALTH)); + SetDragonLabel(BossMobGuiInfo::name); SetSelectedLabel(L""); for (unsigned int i = 0; i < CHAT_LINES_COUNT; ++i) { @@ -264,9 +252,15 @@ void UIScene_HUD::handleReload() { eGameSetting_Tooltips) != 0))); } +int UIScene_HUD::getPad() { return m_iPad; } + +void UIScene_HUD::SetOpacity(float opacity) { setOpacity(opacity); } + +void UIScene_HUD::SetVisible(bool visible) { setVisible(visible); } + void UIScene_HUD::SetHudSize(int scale) { - if (scale != m_lastScale) { - m_lastScale = scale; + if (scale != m_iGuiScale) { + m_iGuiScale = scale; IggyDataValue result; IggyDataValue value[1]; @@ -278,7 +272,7 @@ void UIScene_HUD::SetHudSize(int scale) { } } -void UIScene_HUD::SetExpBarProgress(float progress) { +void UIScene_HUD::SetExpBarProgress(float progress, int xpNeededForNextLevel) { if (progress != m_lastExpProgress) { m_lastExpProgress = progress; @@ -321,33 +315,36 @@ void UIScene_HUD::SetActiveSlot(int slot) { } void UIScene_HUD::SetHealth(int iHealth, int iLastHealth, bool bBlink, - bool bPoison) { + bool bPoison, bool bWither) { int maxHealth = std::max(iHealth, iLastHealth); if (maxHealth != m_lastMaxHealth || bBlink != m_lastHealthBlink || - bPoison != m_lastHealthPoison) { + bPoison != m_lastHealthPoison || bWither != m_lastHealthWither) { m_lastMaxHealth = maxHealth; m_lastHealthBlink = bBlink; m_lastHealthPoison = bPoison; + m_lastHealthWither = bWither; IggyDataValue result; - IggyDataValue value[3]; + IggyDataValue value[4]; value[0].type = IGGY_DATATYPE_number; value[0].number = maxHealth; value[1].type = IGGY_DATATYPE_boolean; value[1].boolval = bBlink; value[2].type = IGGY_DATATYPE_boolean; value[2].boolval = bPoison; + value[3].type = IGGY_DATATYPE_boolean; + value[3].boolval = bWither; IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcSetHealth, 3, value); + m_funcSetHealth, 4, value); } } void UIScene_HUD::SetFood(int iFood, int iLastFood, bool bPoison) { // Ignore iLastFood as food doesn't flash int maxFood = iFood; //, iLastFood); - if (maxFood != m_lastMaxFood || bPoison != m_lastFoodPoison) { - m_lastMaxFood = maxFood; + if (maxFood != m_iCurrentFood || bPoison != m_lastFoodPoison) { + m_iCurrentFood = maxFood; m_lastFoodPoison = bPoison; IggyDataValue result; @@ -362,7 +359,7 @@ void UIScene_HUD::SetFood(int iFood, int iLastFood, bool bPoison) { } } -void UIScene_HUD::SetAir(int iAir) { +void UIScene_HUD::SetAir(int iAir, int extra) { if (iAir != m_lastAir) { app.DebugPrintf("SetAir to %d\n", iAir); m_lastAir = iAir; @@ -407,6 +404,21 @@ void UIScene_HUD::ShowHealth(bool show) { } } +void UIScene_HUD::ShowHorseHealth(bool show) { + if (show != m_showHorseHealth) { + app.DebugPrintf("ShowHorseHealth to %s\n", show ? "TRUE" : "FALSE"); + m_showHorseHealth = show; + + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_boolean; + value[0].boolval = show; + IggyResult out = IggyPlayerCallMethodRS( + getMovie(), &result, IggyPlayerRootPath(getMovie()), + m_funcShowHorseHealth, 1, value); + } +} + void UIScene_HUD::ShowFood(bool show) { if (show != m_showFood) { app.DebugPrintf("ShowFood to %s\n", show ? "TRUE" : "FALSE"); @@ -468,10 +480,10 @@ void UIScene_HUD::ShowExpBar(bool show) { } void UIScene_HUD::SetRegenerationEffect(bool bEnabled) { - if (bEnabled != m_lastRegenEffect) { + if (bEnabled != m_bRegenEffectEnabled) { app.DebugPrintf("SetRegenerationEffect to %s\n", bEnabled ? "TRUE" : "FALSE"); - m_lastRegenEffect = bEnabled; + m_bRegenEffectEnabled = bEnabled; IggyDataValue result; IggyDataValue value[1]; @@ -484,9 +496,9 @@ void UIScene_HUD::SetRegenerationEffect(bool bEnabled) { } void UIScene_HUD::SetFoodSaturationLevel(int iSaturation) { - if (iSaturation != m_lastSaturation) { + if (iSaturation != m_iFoodSaturation) { app.DebugPrintf("Set saturation to %d\n", iSaturation); - m_lastSaturation = iSaturation; + m_iFoodSaturation = iSaturation; IggyDataValue result; IggyDataValue value[1]; @@ -570,6 +582,78 @@ void UIScene_HUD::HideSelectedLabel() { m_funcHideSelectedLabel, 0, NULL); } +void UIScene_HUD::SetRidingHorse(bool ridingHorse, bool bIsJumpable, + int maxHorseHealth) { + if (m_bRidingHorse != ridingHorse || maxHorseHealth != m_iHorseMaxHealth) { + app.DebugPrintf("SetRidingHorse to %s\n", + ridingHorse ? "TRUE" : "FALSE"); + m_bRidingHorse = ridingHorse; + m_bIsJumpable = bIsJumpable; + m_iHorseMaxHealth = maxHorseHealth; + + IggyDataValue result; + IggyDataValue value[3]; + value[0].type = IGGY_DATATYPE_boolean; + value[0].boolval = ridingHorse; + value[1].type = IGGY_DATATYPE_boolean; + value[1].boolval = bIsJumpable; + value[2].type = IGGY_DATATYPE_number; + value[2].number = maxHorseHealth; + IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, + IggyPlayerRootPath(getMovie()), + m_funcSetRidingHorse, 3, value); + } +} + +void UIScene_HUD::SetHorseHealth(int health, bool blink /*= false*/) { + if (m_bRidingHorse && m_horseHealth != health) { + app.DebugPrintf("SetHorseHealth to %d\n", health); + m_horseHealth = health; + + IggyDataValue result; + IggyDataValue value[2]; + value[0].type = IGGY_DATATYPE_number; + value[0].number = health; + value[1].type = IGGY_DATATYPE_boolean; + value[1].boolval = blink; + IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, + IggyPlayerRootPath(getMovie()), + m_funcSetHorseHealth, 2, value); + } +} + +void UIScene_HUD::SetHorseJumpBarProgress(float progress) { + if (m_bRidingHorse && m_horseJumpProgress != progress) { + app.DebugPrintf("SetHorseJumpBarProgress to %f\n", progress); + m_horseJumpProgress = progress; + + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_number; + value[0].number = progress; + IggyResult out = IggyPlayerCallMethodRS( + getMovie(), &result, IggyPlayerRootPath(getMovie()), + m_funcSetHorseJumpBarProgress, 1, value); + } +} + +void UIScene_HUD::SetHealthAbsorb(int healthAbsorb) { + if (m_iCurrentHealthAbsorb != healthAbsorb) { + app.DebugPrintf("SetHealthAbsorb to %d\n", healthAbsorb); + m_iCurrentHealthAbsorb = healthAbsorb; + + IggyDataValue result; + IggyDataValue value[2]; + value[0].type = IGGY_DATATYPE_boolean; + value[0].boolval = healthAbsorb > 0; + value[1].type = IGGY_DATATYPE_number; + value[1].number = healthAbsorb; + IggyResult out = IggyPlayerCallMethodRS( + getMovie(), &result, IggyPlayerRootPath(getMovie()), + m_funcSetHealthAbsorb, 2, value); + } +} + void UIScene_HUD::render(S32 width, S32 height, C4JRender::eViewportType viewport) { if (m_bSplitscreen) { @@ -757,227 +841,6 @@ void UIScene_HUD::handleGameTick() { } m_parentLayer->showComponent(m_iPad, eUIScene_HUD, true); - int iGuiScale; - - if (pMinecraft->localplayers[m_iPad]->m_iScreenSection == - C4JRender::VIEWPORT_TYPE_FULLSCREEN) { - iGuiScale = app.GetGameSettings(m_iPad, eGameSetting_UISize); - } else { - iGuiScale = - app.GetGameSettings(m_iPad, eGameSetting_UISizeSplitscreen); - } - SetHudSize(iGuiScale); - - SetDisplayName(ProfileManager.GetDisplayName(m_iPad)); - - SetTooltipsEnabled( - ((ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad())) || - (app.GetGameSettings(ProfileManager.GetPrimaryPad(), - eGameSetting_Tooltips) != 0))); - -#if TO_BE_IMPLEMENTED - // Move the whole hud group if we are not in fullscreen - if (pMinecraft->localplayers[m_iPad]->m_iScreenSection != - C4JRender::VIEWPORT_TYPE_FULLSCREEN) { - int iTooltipsYOffset = 0; - // if tooltips are off, set the y offset to zero - if (app.GetGameSettings(m_iPad, eGameSetting_Tooltips) == 0) { - switch (iGuiScale) { - case 0: - iTooltipsYOffset = 28; // screenHeight/10; - break; - case 2: - iTooltipsYOffset = 28; // screenHeight/10; - break; - case 1: - default: - iTooltipsYOffset = 28; // screenHeight/10; - break; - } - } - - float fHeight, fWidth; - GetBounds(&fWidth, &fHeight); - - int iSafezoneYHalf = 0; - switch (pMinecraft->localplayers[m_iPad]->m_iScreenSection) { - case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - iSafezoneYHalf = - -fHeight / 10; // 5% (need to treat the whole screen - // is 2x this screen) - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: - iSafezoneYHalf = - (fHeight / 2) - - (fHeight / 10); // 5% (need to treat the whole screen - // is 2x this screen) - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - iSafezoneYHalf = - (fHeight / 2) - - (fHeight / 10); // 5% (need to treat the whole screen - // is 2x this screen) - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - iSafezoneYHalf = - -fHeight / - 10; // 5% (the whole screen is 2x this screen) - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - iSafezoneYHalf = - -fHeight / - 10; // 5% (the whole screen is 2x this screen) - break; - }; - - D3DXVECTOR3 pos; - m_hudGroup.GetPosition(&pos); - pos.y = iTooltipsYOffset + iSafezoneYHalf; - m_hudGroup.SetPosition(&pos); - } -#endif - SetActiveSlot(pMinecraft->localplayers[m_iPad]->inventory->selected); - - // Update xp progress - if (pMinecraft->localgameModes[m_iPad]->canHurtPlayer()) { - ShowExpBar(true); - int xpNeededForNextLevel = - pMinecraft->localplayers[m_iPad]->getXpNeededForNextLevel(); - int progress = - (int)(pMinecraft->localplayers[m_iPad]->experienceProgress * - xpNeededForNextLevel); - SetExpBarProgress((float)progress / xpNeededForNextLevel); - } else { - ShowExpBar(false); - } - - // Update xp level - if (pMinecraft->localgameModes[m_iPad]->hasExperience() && - pMinecraft->localplayers[m_iPad]->experienceLevel > 0) { - SetExpLevel(pMinecraft->localplayers[m_iPad]->experienceLevel); - } else { - SetExpLevel(0); - } - - if (pMinecraft->localgameModes[m_iPad]->canHurtPlayer()) { - ShowHealth(true); - ShowFood(true); - - SetRegenerationEffect(pMinecraft->localplayers[m_iPad]->hasEffect( - MobEffect::regeneration)); - - // Update health - bool blink = - pMinecraft->localplayers[m_iPad]->invulnerableTime / 3 % 2 == 1; - if (pMinecraft->localplayers[m_iPad]->invulnerableTime < 10) - blink = false; - int iHealth = pMinecraft->localplayers[m_iPad]->getHealth(); - int iLastHealth = pMinecraft->localplayers[m_iPad]->lastHealth; - bool bHasPoison = - pMinecraft->localplayers[m_iPad]->hasEffect(MobEffect::poison); - SetHealth(iHealth, iLastHealth, blink, bHasPoison); - - // Update food - // bool foodBlink = false; - FoodData* foodData = - pMinecraft->localplayers[m_iPad]->getFoodData(); - int food = foodData->getFoodLevel(); - int oldFood = foodData->getLastFoodLevel(); - bool hasHungerEffect = - pMinecraft->localplayers[m_iPad]->hasEffect(MobEffect::hunger); - int saturationLevel = pMinecraft->localplayers[m_iPad] - ->getFoodData() - ->getSaturationLevel(); - SetFood(food, oldFood, hasHungerEffect); - SetFoodSaturationLevel(saturationLevel); - - // Update armour - int armor = pMinecraft->localplayers[m_iPad]->getArmorValue(); - if (armor > 0) { - ShowArmour(true); - SetArmour(armor); - } else { - ShowArmour(false); - } - - // Update air - if (pMinecraft->localplayers[m_iPad]->isUnderLiquid( - Material::water)) { - ShowAir(true); - int count = (int)ceil( - (pMinecraft->localplayers[m_iPad]->getAirSupply() - 2) * - 10.0f / Player::TOTAL_AIR_SUPPLY); - SetAir(count); - } else { - ShowAir(false); - } - } else { - ShowHealth(false); - ShowFood(false); - ShowAir(false); - ShowArmour(false); - } - - if (m_uiSelectedItemOpacityCountDown > 0) { - --m_uiSelectedItemOpacityCountDown; - - // 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 (m_uiSelectedItemOpacityCountDown < - (SharedConstants::TICKS_PER_SECOND * 1)) { - HideSelectedLabel(); - m_uiSelectedItemOpacityCountDown = 0; - } - } - - unsigned char ucAlpha = app.GetGameSettings( - ProfileManager.GetPrimaryPad(), eGameSetting_InterfaceOpacity); - float fVal; - - if (ucAlpha < 80) { - // if we are in a menu, set the minimum opacity for tooltips to 15% - if (ui.GetMenuDisplayed(m_iPad) && (ucAlpha < 15)) { - ucAlpha = 15; - } - - // check if we have the timer running for the opacity - unsigned int uiOpacityTimer = app.GetOpacityTimer(m_iPad); - if (uiOpacityTimer != 0) { - if (uiOpacityTimer < 10) { - float fStep = (80.0f - (float)ucAlpha) / 10.0f; - fVal = 0.01f * - (80.0f - ((10.0f - (float)uiOpacityTimer) * fStep)); - } else { - fVal = 0.01f * 80.0f; - } - } else { - fVal = 0.01f * (float)ucAlpha; - } - } else { - // if we are in a menu, set the minimum opacity for tooltips to 15% - if (ui.GetMenuDisplayed(m_iPad) && (ucAlpha < 15)) { - ucAlpha = 15; - } - fVal = 0.01f * (float)ucAlpha; - } - setOpacity(fVal); - - bool bDisplayGui = - app.GetGameStarted() && !ui.GetMenuDisplayed(m_iPad) && - !(app.GetXuiAction(m_iPad) == - eAppAction_AutosaveSaveGameCapturedThumbnail) && - app.GetGameSettings(m_iPad, eGameSetting_DisplayHUD) != 0; - if (bDisplayGui && pMinecraft->localplayers[m_iPad] != NULL) { - setVisible(true); - } else { - setVisible(false); - } + updateFrameTick(); } -} +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HUD.h b/Minecraft.Client/Platform/Common/UI/UIScene_HUD.h index 563e88ab7..30fc32963 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HUD.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HUD.h @@ -1,37 +1,14 @@ #pragma once #include "UIScene.h" +#include "IUIScene_HUD.h" #define CHAT_LINES_COUNT 10 -class UIScene_HUD : public UIScene { +class UIScene_HUD : public UIScene, public IUIScene_HUD { private: bool m_bSplitscreen; - int m_lastActiveSlot; - int m_lastScale; - bool m_bToolTipsVisible; - float m_lastExpProgress; - int m_lastExpLevel; - int m_lastMaxHealth; - bool m_lastHealthBlink, m_lastHealthPoison; - int m_lastMaxFood; - bool m_lastFoodPoison; - int m_lastAir; - int m_lastArmour; - float m_lastDragonHealth; - bool m_showDragonHealth; - int m_ticksWithNoBoss; - bool m_lastShowDisplayName; - - bool m_showHealth, m_showFood, m_showAir, m_showArmour, m_showExpBar; - bool m_lastRegenEffect; - int m_lastSaturation; - - unsigned int m_uiSelectedItemOpacityCountDown; - - std::wstring m_displayName; - protected: UIControl_Label m_labelChatText[CHAT_LINES_COUNT]; UIControl_Label m_labelJukebox; @@ -41,14 +18,17 @@ protected: IggyName m_funcLoadHud, m_funcSetExpBarProgress, m_funcSetPlayerLevel, m_funcSetActiveSlot; IggyName m_funcSetHealth, m_funcSetFood, m_funcSetAir, m_funcSetArmour; - IggyName m_funcShowHealth, m_funcShowFood, m_funcShowAir, m_funcShowArmour, - m_funcShowExpbar; + IggyName m_funcShowHealth, m_funcShowHorseHealth, m_funcShowFood, + m_funcShowAir, m_funcShowArmour, m_funcShowExpbar; IggyName m_funcSetRegenerationEffect, m_funcSetFoodSaturationLevel; IggyName m_funcSetDragonHealth, m_funcSetDragonLabel, m_funcShowDragonHealth; IggyName m_funcSetSelectedLabel, m_funcHideSelectedLabel; IggyName m_funcRepositionHud, m_funcSetDisplayName, m_funcSetTooltipsEnabled; + IggyName m_funcSetRidingHorse, m_funcSetHorseHealth, + m_funcSetHorseJumpBarProgress; + IggyName m_funcSetHealthAbsorb; UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) UI_MAP_ELEMENT(m_labelChatText[0], "Label1") UI_MAP_ELEMENT(m_labelChatText[1], "Label2") @@ -87,6 +67,7 @@ protected: UI_MAP_NAME(m_funcSetArmour, L"SetArmour") UI_MAP_NAME(m_funcShowHealth, L"ShowHealth") + UI_MAP_NAME(m_funcShowHorseHealth, L"ShowHorseHealth") UI_MAP_NAME(m_funcShowFood, L"ShowFood") UI_MAP_NAME(m_funcShowAir, L"ShowAir") UI_MAP_NAME(m_funcShowArmour, L"ShowArmour") @@ -106,6 +87,12 @@ protected: UI_MAP_NAME(m_funcSetDisplayName, L"SetGamertag") UI_MAP_NAME(m_funcSetTooltipsEnabled, L"SetTooltipsEnabled") + + UI_MAP_NAME(m_funcSetRidingHorse, L"SetRidingHorse") + UI_MAP_NAME(m_funcSetHorseHealth, L"SetHorseHealth") + UI_MAP_NAME(m_funcSetHorseJumpBarProgress, L"SetHorseJumpBarProgress") + + UI_MAP_NAME(m_funcSetHealthAbsorb, L"SetHealthAbsorb") UI_END_MAP_ELEMENTS_AND_NAMES() public: @@ -137,17 +124,23 @@ public: virtual void handleReload(); private: + virtual int getPad(); + virtual void SetOpacity(float opacity); + virtual void SetVisible(bool visible); + void SetHudSize(int scale); - void SetExpBarProgress(float progress); + void SetExpBarProgress(float progress, int xpNeededForNextLevel); void SetExpLevel(int level); void SetActiveSlot(int slot); - void SetHealth(int iHealth, int iLastHealth, bool bBlink, bool bPoison); + void SetHealth(int iHealth, int iLastHealth, bool bBlink, bool bPoison, + bool bWither); void SetFood(int iFood, int iLastFood, bool bPoison); - void SetAir(int iAir); + void SetAir(int iAir, int extra); void SetArmour(int iArmour); void ShowHealth(bool show); + void ShowHorseHealth(bool show); void ShowFood(bool show); void ShowAir(bool show); void ShowArmour(bool show); @@ -166,6 +159,12 @@ private: void SetTooltipsEnabled(bool bEnabled); + void SetRidingHorse(bool ridingHorse, bool bIsJumpable, int maxHorseHealth); + void SetHorseHealth(int health, bool blink = false); + void SetHorseJumpBarProgress(float progress); + + void SetHealthAbsorb(int healthAbsorb); + public: void SetSelectedLabel(const std::wstring& label); void ShowDisplayName(bool show); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HelpAndOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HelpAndOptionsMenu.cpp index 6d26d9dfa..ad5cacd96 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HelpAndOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HelpAndOptionsMenu.cpp @@ -11,19 +11,14 @@ UIScene_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(int iPad, void* initData, m_bNotInGame = (Minecraft::GetInstance()->level == NULL); - m_buttons[BUTTON_HAO_CHANGESKIN].init(app.GetString(IDS_CHANGE_SKIN), + m_buttons[BUTTON_HAO_CHANGESKIN].init(IDS_CHANGE_SKIN, BUTTON_HAO_CHANGESKIN); - m_buttons[BUTTON_HAO_HOWTOPLAY].init(app.GetString(IDS_HOW_TO_PLAY), - BUTTON_HAO_HOWTOPLAY); - m_buttons[BUTTON_HAO_CONTROLS].init(app.GetString(IDS_CONTROLS), - BUTTON_HAO_CONTROLS); - m_buttons[BUTTON_HAO_SETTINGS].init(app.GetString(IDS_SETTINGS), - BUTTON_HAO_SETTINGS); - m_buttons[BUTTON_HAO_CREDITS].init(app.GetString(IDS_CREDITS), - BUTTON_HAO_CREDITS); + m_buttons[BUTTON_HAO_HOWTOPLAY].init(IDS_HOW_TO_PLAY, BUTTON_HAO_HOWTOPLAY); + m_buttons[BUTTON_HAO_CONTROLS].init(IDS_CONTROLS, BUTTON_HAO_CONTROLS); + m_buttons[BUTTON_HAO_SETTINGS].init(IDS_SETTINGS, BUTTON_HAO_SETTINGS); + m_buttons[BUTTON_HAO_CREDITS].init(IDS_CREDITS, BUTTON_HAO_CREDITS); // m_buttons[BUTTON_HAO_REINSTALL].init(app.GetString(IDS_REINSTALL_CONTENT),BUTTON_HAO_REINSTALL); - m_buttons[BUTTON_HAO_DEBUG].init(app.GetString(IDS_DEBUG_SETTINGS), - BUTTON_HAO_DEBUG); + m_buttons[BUTTON_HAO_DEBUG].init(IDS_DEBUG_SETTINGS, BUTTON_HAO_DEBUG); /* 4J-TomK - we should never remove a control before the other buttons controls are initialised! (because vita touchboxes are rebuilt on remove @@ -31,8 +26,6 @@ UIScene_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(int iPad, void* initData, // We don't have a reinstall content, so remove the button removeControl(&m_buttons[BUTTON_HAO_REINSTALL], false); - doHorizontalResizeCheck(); - #ifdef _FINAL_BUILD removeControl(&m_buttons[BUTTON_HAO_DEBUG], false); #else @@ -80,6 +73,11 @@ UIScene_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(int iPad, void* initData, removeControl(&m_buttons[BUTTON_HAO_CHANGESKIN], false); } + // 4J-TomK Moved horizontal resize check to the end to prevent horizontal + // scaling for buttons that might get removed anyways (debug options for + // example) + doHorizontalResizeCheck(); + // StorageManager.TMSPP_GetUserQuotaInfo(C4JStorage::eGlobalStorage_TitleUser,iPad); // StorageManager.WebServiceRequestGetFriends(iPad); } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HopperMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HopperMenu.cpp new file mode 100644 index 000000000..028162477 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HopperMenu.cpp @@ -0,0 +1,188 @@ +#include "../../stdafx.h" +#include "UI.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" +#include "../../Minecraft.h" +#include "UIScene_HopperMenu.h" + +UIScene_HopperMenu::UIScene_HopperMenu(int iPad, void* _initData, + UILayer* parentLayer) + : UIScene_AbstractContainerMenu(iPad, parentLayer) { + // Setup all the Iggy references we need for this scene + initialiseMovie(); + + HopperScreenInput* initData = (HopperScreenInput*)_initData; + + m_labelDispenser.init(initData->hopper->getName()); + + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft->localgameModes[initData->iPad] != NULL) { + TutorialMode* gameMode = + (TutorialMode*)pMinecraft->localgameModes[initData->iPad]; + m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); + gameMode->getTutorial()->changeTutorialState( + e_Tutorial_State_Hopper_Menu, this); + } + + HopperMenu* menu = new HopperMenu(initData->inventory, initData->hopper); + + m_containerSize = initData->hopper->getContainerSize(); + Initialize(initData->iPad, menu, true, m_containerSize, eSectionHopperUsing, + eSectionHopperMax); + + m_slotListTrap.addSlots(0, 9); + + delete initData; +} + +std::wstring UIScene_HopperMenu::getMoviePath() { + if (app.GetLocalPlayerCount() > 1) { + return L"HopperMenuSplit"; + } else { + return L"HopperMenu"; + } +} + +void UIScene_HopperMenu::handleReload() { + Initialize(m_iPad, m_menu, true, m_containerSize, eSectionHopperUsing, + eSectionHopperMax); + + m_slotListTrap.addSlots(0, 9); +} + +int UIScene_HopperMenu::getSectionColumns(ESceneSection eSection) { + int cols = 0; + switch (eSection) { + case eSectionHopperContents: + cols = 5; + break; + case eSectionHopperInventory: + cols = 9; + break; + case eSectionHopperUsing: + cols = 9; + break; + default: + assert(false); + break; + } + return cols; +} + +int UIScene_HopperMenu::getSectionRows(ESceneSection eSection) { + int rows = 0; + switch (eSection) { + case eSectionHopperContents: + rows = 1; + break; + case eSectionHopperInventory: + rows = 3; + break; + case eSectionHopperUsing: + rows = 1; + break; + default: + assert(false); + break; + } + return rows; +} + +void UIScene_HopperMenu::GetPositionOfSection(ESceneSection eSection, + UIVec2D* pPosition) { + switch (eSection) { + case eSectionHopperContents: + pPosition->x = m_slotListTrap.getXPos(); + pPosition->y = m_slotListTrap.getYPos(); + break; + case eSectionHopperInventory: + pPosition->x = m_slotListInventory.getXPos(); + pPosition->y = m_slotListInventory.getYPos(); + break; + case eSectionHopperUsing: + pPosition->x = m_slotListHotbar.getXPos(); + pPosition->y = m_slotListHotbar.getYPos(); + break; + default: + assert(false); + break; + } +} + +void UIScene_HopperMenu::GetItemScreenData(ESceneSection eSection, + int iItemIndex, UIVec2D* pPosition, + UIVec2D* pSize) { + UIVec2D sectionSize; + switch (eSection) { + case eSectionHopperContents: + sectionSize.x = m_slotListTrap.getWidth(); + sectionSize.y = m_slotListTrap.getHeight(); + break; + case eSectionHopperInventory: + sectionSize.x = m_slotListInventory.getWidth(); + sectionSize.y = m_slotListInventory.getHeight(); + break; + case eSectionHopperUsing: + sectionSize.x = m_slotListHotbar.getWidth(); + sectionSize.y = m_slotListHotbar.getHeight(); + break; + default: + assert(false); + break; + } + + int rows = getSectionRows(eSection); + int cols = getSectionColumns(eSection); + + pSize->x = sectionSize.x / cols; + pSize->y = sectionSize.y / rows; + + int itemCol = iItemIndex % cols; + int itemRow = iItemIndex / cols; + + pPosition->x = itemCol * pSize->x; + pPosition->y = itemRow * pSize->y; +} + +void UIScene_HopperMenu::setSectionSelectedSlot(ESceneSection eSection, int x, + int y) { + int cols = getSectionColumns(eSection); + + int index = (y * cols) + x; + + UIControl_SlotList* slotList = NULL; + switch (eSection) { + case eSectionHopperContents: + slotList = &m_slotListTrap; + break; + case eSectionHopperInventory: + slotList = &m_slotListInventory; + break; + case eSectionHopperUsing: + slotList = &m_slotListHotbar; + break; + default: + assert(false); + break; + } + slotList->setHighlightSlot(index); +} + +UIControl* UIScene_HopperMenu::getSection(ESceneSection eSection) { + UIControl* control = NULL; + switch (eSection) { + case eSectionHopperContents: + control = &m_slotListTrap; + break; + case eSectionHopperInventory: + control = &m_slotListInventory; + break; + case eSectionHopperUsing: + control = &m_slotListHotbar; + break; + default: + assert(false); + break; + } + return control; +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HopperMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_HopperMenu.h new file mode 100644 index 000000000..39b57109c --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HopperMenu.h @@ -0,0 +1,42 @@ +#pragma once + +#include "UIScene_AbstractContainerMenu.h" +#include "IUIScene_HopperMenu.h" + +class InventoryMenu; + +class UIScene_HopperMenu : public UIScene_AbstractContainerMenu, + public IUIScene_HopperMenu { +private: + int m_containerSize; + +public: + UIScene_HopperMenu(int iPad, void* initData, UILayer* parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_HopperMenu; } + +protected: + UIControl_SlotList m_slotListTrap; + UIControl_Label m_labelDispenser; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene_AbstractContainerMenu) + UI_BEGIN_MAP_CHILD_ELEMENTS(m_controlMainPanel) + UI_MAP_ELEMENT(m_slotListTrap, "Trap") + UI_MAP_ELEMENT(m_labelDispenser, "dispenserLabel") + UI_END_MAP_CHILD_ELEMENTS() + UI_END_MAP_ELEMENTS_AND_NAMES() + + virtual std::wstring getMoviePath(); + virtual void handleReload(); + + virtual int getSectionColumns(ESceneSection eSection); + virtual int getSectionRows(ESceneSection eSection); + virtual void GetPositionOfSection(ESceneSection eSection, + UIVec2D* pPosition); + virtual void GetItemScreenData(ESceneSection eSection, int iItemIndex, + UIVec2D* pPosition, UIVec2D* pSize); + virtual void handleSectionClick(ESceneSection eSection) {} + virtual void setSectionSelectedSlot(ESceneSection eSection, int x, int y); + + virtual UIControl* getSection(ESceneSection eSection); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.cpp new file mode 100644 index 000000000..d1f2c7c9b --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.cpp @@ -0,0 +1,324 @@ +#include "../../stdafx.h" +#include "UI.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" +#include "../../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h" +#include "../../../Player/MultiPlayerLocalPlayer.h" +#include "../../Minecraft.h" +#include "UIScene_HorseInventoryMenu.h" + +UIScene_HorseInventoryMenu::UIScene_HorseInventoryMenu(int iPad, + void* _initData, + UILayer* parentLayer) + : UIScene_AbstractContainerMenu(iPad, parentLayer) { + // Setup all the Iggy references we need for this scene + initialiseMovie(); + + HorseScreenInput* initData = (HorseScreenInput*)_initData; + + m_labelHorse.init(initData->container->getName()); + m_inventory = initData->inventory; + m_horse = initData->horse; + + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft->localgameModes[iPad] != NULL) { + TutorialMode* gameMode = + (TutorialMode*)pMinecraft->localgameModes[iPad]; + m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); + gameMode->getTutorial()->changeTutorialState( + e_Tutorial_State_Horse_Menu, this); + } + + HorseInventoryMenu* horseMenu = new HorseInventoryMenu( + initData->inventory, initData->container, initData->horse); + + int startSlot = EntityHorse::INV_BASE_COUNT; + if (m_horse->isChestedHorse()) { + startSlot += EntityHorse::INV_DONKEY_CHEST_COUNT; + } + Initialize(iPad, horseMenu, true, startSlot, eSectionHorseUsing, + eSectionHorseMax); + + m_slotSaddle.addSlots(EntityHorse::INV_SLOT_SADDLE, 1); + m_slotArmor.addSlots(EntityHorse::INV_SLOT_ARMOR, 1); + + if (m_horse->isChestedHorse()) { + // also starts at one, because a donkey can't wear armor! + m_slotListChest.addSlots(EntityHorse::INV_BASE_COUNT, + EntityHorse::INV_DONKEY_CHEST_COUNT); + } + + // remove horse inventory + if (!m_horse->isChestedHorse()) SetHasInventory(false); + + // cannot wear armor? remove armor slot! + if (!m_horse->canWearArmor()) SetIsDonkey(true); + + if (initData) delete initData; + + setIgnoreInput(false); + + // app.SetRichPresenceContext(iPad, CONTEXT_GAME_STATE_HORSE); +} + +std::wstring UIScene_HorseInventoryMenu::getMoviePath() { + if (app.GetLocalPlayerCount() > 1) { + return L"HorseInventoryMenuSplit"; + } else { + return L"HorseInventoryMenu"; + } +} + +void UIScene_HorseInventoryMenu::handleReload() { + int startSlot = EntityHorse::INV_BASE_COUNT; + if (m_horse->isChestedHorse()) { + startSlot += EntityHorse::INV_DONKEY_CHEST_COUNT; + } + Initialize(m_iPad, m_menu, true, startSlot, eSectionHorseUsing, + eSectionHorseMax); + + m_slotSaddle.addSlots(EntityHorse::INV_SLOT_SADDLE, 1); + m_slotArmor.addSlots(EntityHorse::INV_SLOT_ARMOR, 1); + + if (m_horse->isChestedHorse()) { + // also starts at one, because a donkey can't wear armor! + m_slotListChest.addSlots(EntityHorse::INV_BASE_COUNT, + EntityHorse::INV_DONKEY_CHEST_COUNT); + } + + // remove horse inventory + if (!m_horse->isChestedHorse()) SetHasInventory(false); + + // cannot wear armor? remove armor slot! + if (!m_horse->canWearArmor()) SetIsDonkey(true); +} + +int UIScene_HorseInventoryMenu::getSectionColumns(ESceneSection eSection) { + int cols = 0; + switch (eSection) { + case eSectionHorseArmor: + cols = 1; + break; + case eSectionHorseSaddle: + cols = 1; + break; + case eSectionHorseChest: + cols = 5; + break; + case eSectionHorseInventory: + cols = 9; + break; + case eSectionHorseUsing: + cols = 9; + break; + default: + assert(false); + break; + } + return cols; +} + +int UIScene_HorseInventoryMenu::getSectionRows(ESceneSection eSection) { + int rows = 0; + switch (eSection) { + case eSectionHorseArmor: + rows = 1; + break; + case eSectionHorseSaddle: + rows = 1; + break; + case eSectionHorseChest: + rows = 3; + break; + case eSectionHorseInventory: + rows = 3; + break; + case eSectionHorseUsing: + rows = 1; + break; + default: + assert(false); + break; + } + return rows; +} + +void UIScene_HorseInventoryMenu::GetPositionOfSection(ESceneSection eSection, + UIVec2D* pPosition) { + switch (eSection) { + case eSectionHorseArmor: + pPosition->x = m_slotArmor.getXPos(); + pPosition->y = m_slotArmor.getYPos(); + break; + case eSectionHorseSaddle: + pPosition->x = m_slotSaddle.getXPos(); + pPosition->y = m_slotSaddle.getYPos(); + break; + case eSectionHorseChest: + pPosition->x = m_slotListChest.getXPos(); + pPosition->y = m_slotListChest.getYPos(); + break; + case eSectionHorseInventory: + pPosition->x = m_slotListInventory.getXPos(); + pPosition->y = m_slotListInventory.getYPos(); + break; + case eSectionHorseUsing: + pPosition->x = m_slotListHotbar.getXPos(); + pPosition->y = m_slotListHotbar.getYPos(); + break; + default: + assert(false); + break; + } +} + +void UIScene_HorseInventoryMenu::GetItemScreenData(ESceneSection eSection, + int iItemIndex, + UIVec2D* pPosition, + UIVec2D* pSize) { + UIVec2D sectionSize; + + switch (eSection) { + case eSectionHorseArmor: + sectionSize.x = m_slotArmor.getWidth(); + sectionSize.y = m_slotArmor.getHeight(); + break; + case eSectionHorseSaddle: + sectionSize.x = m_slotSaddle.getWidth(); + sectionSize.y = m_slotSaddle.getHeight(); + break; + case eSectionHorseChest: + sectionSize.x = m_slotListChest.getWidth(); + sectionSize.y = m_slotListChest.getHeight(); + break; + case eSectionHorseInventory: + sectionSize.x = m_slotListInventory.getWidth(); + sectionSize.y = m_slotListInventory.getHeight(); + break; + case eSectionHorseUsing: + sectionSize.x = m_slotListHotbar.getWidth(); + sectionSize.y = m_slotListHotbar.getHeight(); + break; + default: + assert(false); + break; + } + + if (IsSectionSlotList(eSection)) { + int rows = getSectionRows(eSection); + int cols = getSectionColumns(eSection); + + pSize->x = sectionSize.x / cols; + pSize->y = sectionSize.y / rows; + + int itemCol = iItemIndex % cols; + int itemRow = iItemIndex / cols; + + pPosition->x = itemCol * pSize->x; + pPosition->y = itemRow * pSize->y; + } else { + GetPositionOfSection(eSection, pPosition); + pSize->x = sectionSize.x; + pSize->y = sectionSize.y; + } +} + +void UIScene_HorseInventoryMenu::setSectionSelectedSlot(ESceneSection eSection, + int x, int y) { + int cols = getSectionColumns(eSection); + + int index = (y * cols) + x; + + UIControl_SlotList* slotList = NULL; + switch (eSection) { + case eSectionHorseArmor: + slotList = &m_slotArmor; + break; + case eSectionHorseSaddle: + slotList = &m_slotSaddle; + break; + case eSectionHorseChest: + slotList = &m_slotListChest; + break; + case eSectionHorseInventory: + slotList = &m_slotListInventory; + break; + case eSectionHorseUsing: + slotList = &m_slotListHotbar; + break; + default: + assert(false); + break; + } + + slotList->setHighlightSlot(index); +} + +UIControl* UIScene_HorseInventoryMenu::getSection(ESceneSection eSection) { + UIControl* control = NULL; + switch (eSection) { + case eSectionHorseArmor: + control = &m_slotArmor; + break; + case eSectionHorseSaddle: + control = &m_slotSaddle; + break; + case eSectionHorseChest: + control = &m_slotListChest; + break; + case eSectionHorseInventory: + control = &m_slotListInventory; + break; + case eSectionHorseUsing: + control = &m_slotListHotbar; + break; + default: + assert(false); + break; + } + return control; +} + +void UIScene_HorseInventoryMenu::customDraw( + IggyCustomDrawCallbackRegion* region) { + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft->localplayers[m_iPad] == NULL || + pMinecraft->localgameModes[m_iPad] == NULL) + return; + + if (wcscmp((wchar_t*)region->name, L"horse") == 0) { + // Setup GDraw, normal game render states and matrices + CustomDrawData* customDrawRegion = ui.setupCustomDraw(this, region); + delete customDrawRegion; + + m_horsePreview.render(region); + + // Finish GDraw and anything else that needs to be finalised + ui.endCustomDraw(region); + } else { + UIScene_AbstractContainerMenu::customDraw(region); + } +} + +void UIScene_HorseInventoryMenu::SetHasInventory(bool bHasInventory) { + app.DebugPrintf("SetHasInventory to %d\n", bHasInventory); + + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_boolean; + value[0].boolval = bHasInventory; + IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, + IggyPlayerRootPath(getMovie()), + m_funcSetHasInventory, 1, value); +} + +void UIScene_HorseInventoryMenu::SetIsDonkey(bool bSetIsDonkey) { + app.DebugPrintf("SetIsDonkey to %d\n", bSetIsDonkey); + + IggyDataValue result; + IggyDataValue value[1]; + value[0].type = IGGY_DATATYPE_boolean; + value[0].boolval = bSetIsDonkey; + IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, + IggyPlayerRootPath(getMovie()), + m_funcSetIsDonkey, 1, value); +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.h new file mode 100644 index 000000000..ef22502db --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HorseInventoryMenu.h @@ -0,0 +1,57 @@ +#pragma once + +#include "UIScene_AbstractContainerMenu.h" +#include "IUIScene_HorseInventoryMenu.h" + +class InventoryMenu; + +class UIScene_HorseInventoryMenu : public UIScene_AbstractContainerMenu, + public IUIScene_HorseInventoryMenu { + friend class UIControl_MinecraftHorse; + +public: + UIScene_HorseInventoryMenu(int iPad, void* initData, UILayer* parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_HorseMenu; } + +protected: + UIControl_SlotList m_slotSaddle, m_slotArmor, m_slotListChest; + UIControl_Label m_labelHorse; + + IggyName m_funcSetIsDonkey, m_funcSetHasInventory; + + UIControl_MinecraftHorse m_horsePreview; + + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene_AbstractContainerMenu) + UI_BEGIN_MAP_CHILD_ELEMENTS(m_controlMainPanel) + UI_MAP_ELEMENT(m_slotSaddle, "SlotSaddle") + UI_MAP_ELEMENT(m_slotArmor, "SlotArmor") + UI_MAP_ELEMENT(m_slotListChest, "DonkeyInventoryList") + UI_MAP_ELEMENT(m_labelHorse, "horseinventoryText") + + UI_MAP_ELEMENT(m_horsePreview, "iggy_horse") + UI_END_MAP_CHILD_ELEMENTS() + + UI_MAP_NAME(m_funcSetIsDonkey, L"SetIsDonkey") + UI_MAP_NAME(m_funcSetHasInventory, L"SetHasInventory") + UI_END_MAP_ELEMENTS_AND_NAMES() + + virtual std::wstring getMoviePath(); + virtual void handleReload(); + + virtual int getSectionColumns(ESceneSection eSection); + virtual int getSectionRows(ESceneSection eSection); + virtual void GetPositionOfSection(ESceneSection eSection, + UIVec2D* pPosition); + virtual void GetItemScreenData(ESceneSection eSection, int iItemIndex, + UIVec2D* pPosition, UIVec2D* pSize); + virtual void handleSectionClick(ESceneSection eSection) {} + virtual void setSectionSelectedSlot(ESceneSection eSection, int x, int y); + + virtual UIControl* getSection(ESceneSection eSection); + + virtual void customDraw(IggyCustomDrawCallbackRegion* region); + + void SetHasInventory(bool bHasInventory); + void SetIsDonkey(bool bSetIsDonkey); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.cpp index ed775fdfe..12464dcf0 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.cpp @@ -42,6 +42,11 @@ static UIScene_HowToPlay::SHowToPlayPageDef gs_aPageDefs[eHowToPlay_NumPages] = {IDS_HOW_TO_PLAY_TRADING, UIScene_HowToPlay::eHowToPlay_LabelTrading_Inventory, 5}, // eHowToPlay_Trading + {IDS_HOW_TO_PLAY_HORSES, 0, 0}, // eHowToPlay_Horses + {IDS_HOW_TO_PLAY_BEACONS, 0, 0}, // eHowToPlay_Beacons + {IDS_HOW_TO_PLAY_FIREWORKS, 0, 0}, // eHowToPlay_Fireworks + {IDS_HOW_TO_PLAY_HOPPERS, 0, 0}, // eHowToPlay_Hoppers + {IDS_HOW_TO_PLAY_DROPPERS, 0, 0}, // eHowToPlay_Droppers {IDS_HOW_TO_PLAY_NETHERPORTAL, 0, 0}, // eHowToPlay_NetherPortal {IDS_HOW_TO_PLAY_THEEND, 0, 0}, // eHowToPlay_NetherPortal #ifdef _XBOX @@ -73,6 +78,12 @@ int gs_pageToFlashMapping[eHowToPlay_NumPages] = { 15, // eHowToPlay_Breeding, 22, // eHowToPlay_Trading, + 24, // eHowToPlay_Horses + 25, // eHowToPlay_Beacons + 26, // eHowToPlay_Fireworks + 27, // eHowToPlay_Hoppers + 28, // eHowToPlay_Droppers + 16, // eHowToPlay_NetherPortal, 17, // eHowToPlay_TheEnd, #ifdef _XBOX @@ -103,7 +114,7 @@ UIScene_HowToPlay::UIScene_HowToPlay(int iPad, void* initData, m_labels[eHowToPlay_LabelLCInventory].init(inventoryString); m_labels[eHowToPlay_LabelCreativeInventory].init( app.GetString(IDS_GROUPNAME_BUILDING_BLOCKS)); - m_labels[eHowToPlay_LabelLCChest].init(app.GetString(IDS_CHEST)); + m_labels[eHowToPlay_LabelLCChest].init(app.GetString(IDS_CHEST_LARGE)); m_labels[eHowToPlay_LabelSCInventory].init(inventoryString); m_labels[eHowToPlay_LabelSCChest].init(app.GetString(IDS_CHEST)); m_labels[eHowToPlay_LabelIInventory].init(inventoryString); @@ -129,6 +140,21 @@ UIScene_HowToPlay::UIScene_HowToPlay(int iPad, void* initData, m_labels[eHowToPlay_LabelTrading_NeededForTrade].init( app.GetString(IDS_REQUIRED_ITEMS_FOR_TRADE)); + m_labels[eHowToPlay_LabelBeacon_PrimaryPower].init( + app.GetString(IDS_CONTAINER_BEACON_PRIMARY_POWER)); + m_labels[eHowToPlay_LabelBeacon_SecondaryPower].init( + app.GetString(IDS_CONTAINER_BEACON_SECONDARY_POWER)); + + m_labels[eHowToPlay_LabelFireworksText].init( + app.GetString(IDS_HOW_TO_PLAY_MENU_FIREWORKS)); + m_labels[eHowToPlay_LabelFireworksInventory].init(inventoryString.c_str()); + + m_labels[eHowToPlay_LabelHopperText].init(app.GetString(IDS_TILE_HOPPER)); + m_labels[eHowToPlay_LabelHopperInventory].init(inventoryString.c_str()); + + m_labels[eHowToPlay_LabelDropperText].init(app.GetString(IDS_TILE_DROPPER)); + m_labels[eHowToPlay_LabelDropperInventory].init(inventoryString.c_str()); + wsTemp = app.GetString(IDS_VILLAGER_OFFERS_ITEM); wsTemp = replaceAll(wsTemp, L"{*VILLAGER_TYPE*}", app.GetString(IDS_VILLAGER_PRIEST)); @@ -162,18 +188,14 @@ void UIScene_HowToPlay::updateTooltips() { int iPage = (int)(m_eCurrPage); int firstPage = eHowToPlay_WhatsNew; -#ifdef __PS3__ - // If it's the blu ray, or the first Japanese digital game, there's no - // What's New until the first patch, which will take this line out - if (StorageManager.GetBootTypeDisc() || - (app.GetProductSKU() == e_sku_SCEJ)) { - ++firstPage; - } -#elif defined(__ORBIS__) || defined(_DURANGO) || defined(__PSVITA__) - // No What's New for the first PS4 and Xbox One builds - if (true) { - ++firstPage; - } + + // 4J Stu - Add back for future platforms +#if 0 + // No What's New for the first PS4 and Xbox One builds + if(true) + { + ++firstPage; + } #endif int iA = -1; @@ -224,27 +246,18 @@ void UIScene_HowToPlay::handleInput(int iPad, int key, bool repeat, // Previous page int iPrevPage = (int)(m_eCurrPage)-1; -#ifdef __PS3__ - // If it's the blu ray, or the first Japanese digital game, - // there's no What's New until the first patch, which will take - // this line out - if (StorageManager.GetBootTypeDisc() || - (app.GetProductSKU() == e_sku_SCEJ)) { - if (iPrevPage >= 0 && - !((iPrevPage == eHowToPlay_WhatsNew))) { - StartPage((EHowToPlayPage)(iPrevPage)); - ui.PlayUISFX(eSFX_Press); - } - } else -#elif defined(__ORBIS__) || defined(_DURANGO) || defined(__PSVITA__) - // No What's New for the first PS4 and Xbox One builds - if (true) { - if (iPrevPage >= 0 && - !((iPrevPage == eHowToPlay_WhatsNew))) { - StartPage((EHowToPlayPage)(iPrevPage)); - ui.PlayUISFX(eSFX_Press); - } - } else + // 4J Stu - Add back for future platforms +#if 0 + // No What's New for the first PS4 and Xbox One builds + if(true) + { + if ( iPrevPage >= 0 && !((iPrevPage==eHowToPlay_WhatsNew))) + { + StartPage( ( EHowToPlayPage )( iPrevPage ) ); + ui.PlayUISFX(eSFX_Press); + } + } + else #endif { if (iPrevPage >= 0) { @@ -275,12 +288,10 @@ void UIScene_HowToPlay::StartPage(EHowToPlayPage ePage) { app.FormatHTMLString(m_iPad, app.GetString(pDef->m_iTextStringID)); // 4J-PB - replace the title with the platform specific title, and the // platform name -// replacedText = -//replaceAll(replacedText,L"{*TITLE_UPDATE_NAME*}",app.GetString(IDS_TITLE_UPDATE_NAME)); -#ifndef _WINDOWS64 + // replacedText = + // replaceAll(replacedText,L"{*TITLE_UPDATE_NAME*}",app.GetString(IDS_TITLE_UPDATE_NAME)); replacedText = replaceAll(replacedText, L"{*KICK_PLAYER_DESCRIPTION*}", app.GetString(IDS_KICK_PLAYER_DESCRIPTION)); -#endif #ifdef _XBOX_ONE replacedText = replaceAll(replacedText, L"{*PLATFORM_NAME*}", app.GetString(IDS_PLATFORM_NAME)); @@ -291,6 +302,14 @@ void UIScene_HowToPlay::StartPage(EHowToPlayPage ePage) { replaceAll(replacedText, L"{*DISABLES_ACHIEVEMENTS*}", app.GetString(IDS_HOST_OPTION_DISABLES_ACHIEVEMENTS)); + // 4J-JEV: Temporary fix: LOC: Minecraft: XB1: KO: Font: Uncategorized: + // Squares appear instead of hyphens in FIREWORKS description + if (!ui.UsingBitmapFont()) { + replacedText = replaceAll(replacedText, L"\u00A9", L"(C)"); + replacedText = replaceAll(replacedText, L"\u00AE", L"(R)"); + replacedText = replaceAll(replacedText, L"\u2013", L"-"); + } + // strip out any tab characters and repeated spaces stripWhitespaceForHtml(replacedText, true); @@ -304,7 +323,7 @@ void UIScene_HowToPlay::StartPage(EHowToPlayPage ePage) { std::vector paragraphs; int lastIndex = 0; for (int index = finalText.find(L"\r\n", lastIndex, 2); - index != std::wstring::npos; + index != wstring::npos; index = finalText.find(L"\r\n", lastIndex, 2)) { paragraphs.push_back(finalText.substr(lastIndex, index - lastIndex) + L" "); @@ -322,14 +341,9 @@ void UIScene_HowToPlay::StartPage(EHowToPlayPage ePage) { value[0].type = IGGY_DATATYPE_number; value[0].number = gs_pageToFlashMapping[(int)ePage]; - std::vector conv; - conv.reserve(paragraphs.size()); - for (unsigned int i = 0; i < paragraphs.size(); ++i) { - conv.push_back(convWstringToU16string(paragraphs[i])); - - stringVal[i].string = conv[i].c_str(); - stringVal[i].length = conv[i].length(); + stringVal[i].string = (IggyUTF16*)paragraphs[i].c_str(); + stringVal[i].length = paragraphs[i].length(); value[i + 1].type = IGGY_DATATYPE_string_UTF16; value[i + 1].string16 = stringVal[i]; } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.h b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.h index 55d6887c5..c65c4a450 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.h @@ -36,6 +36,14 @@ public: eHowToPlay_LabelTrading_Offer1, eHowToPlay_LabelTrading_NeededForTrade, eHowToPlay_LabelTrading_VillagerOffers, + eHowToPlay_LabelBeacon_PrimaryPower, + eHowToPlay_LabelBeacon_SecondaryPower, + eHowToPlay_LabelFireworksText, + eHowToPlay_LabelFireworksInventory, + eHowToPlay_LabelHopperText, + eHowToPlay_LabelHopperInventory, + eHowToPlay_LabelDropperText, + eHowToPlay_LabelDropperInventory, eHowToPlay_NumLabels }; @@ -99,6 +107,18 @@ private: UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelAnvil_Cost], "Label2_21") UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelAnvil_Inventory], "Label3_21") + UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelBeacon_PrimaryPower], "Label1_25") + UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelBeacon_SecondaryPower], "Label2_25") + + UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelFireworksText], "Label1_26") + UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelFireworksInventory], "Label2_26") + + UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelHopperText], "Label1_27") + UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelHopperInventory], "Label2_27") + + UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelDropperText], "Label1_28") + UI_MAP_ELEMENT(m_labels[eHowToPlay_LabelDropperInventory], "Label2_28") + UI_MAP_NAME(m_funcLoadPage, L"LoadHowToPlayPage") UI_END_MAP_ELEMENTS_AND_NAMES() public: diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp index 6a1c5d6c4..a10427f3a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp @@ -22,6 +22,10 @@ unsigned int UIScene_HowToPlayMenu::m_uiHTPButtonNameA[] = { IDS_HOW_TO_PLAY_MENU_BREEDANIMALS, // eHTPButton_Breeding, IDS_HOW_TO_PLAY_MENU_TRADING, + IDS_HOW_TO_PLAY_MENU_HORSES, IDS_HOW_TO_PLAY_MENU_BEACONS, + IDS_HOW_TO_PLAY_MENU_FIREWORKS, IDS_HOW_TO_PLAY_MENU_HOPPERS, + IDS_HOW_TO_PLAY_MENU_DROPPERS, + IDS_HOW_TO_PLAY_MENU_NETHERPORTAL, // eHTPButton_NetherPortal, IDS_HOW_TO_PLAY_MENU_THEEND, // eHTPButton_TheEnd, #ifdef _XBOX @@ -43,6 +47,10 @@ unsigned int UIScene_HowToPlayMenu::m_uiHTPSceneA[] = { eHowToPlay_Anvil, eHowToPlay_FarmingAnimals, eHowToPlay_Breeding, eHowToPlay_Trading, + eHowToPlay_Horses, eHowToPlay_Beacons, + eHowToPlay_Fireworks, eHowToPlay_Hoppers, + eHowToPlay_Droppers, + eHowToPlay_NetherPortal, eHowToPlay_TheEnd, #ifdef _XBOX eHowToPlay_SocialMedia, eHowToPlay_BanList, @@ -59,30 +67,25 @@ UIScene_HowToPlayMenu::UIScene_HowToPlayMenu(int iPad, void* initData, m_buttonListHowTo.init(eControl_Buttons); for (unsigned int i = 0; i < eHTPButton_Max; ++i) { -#ifdef __PS3__ - // If it's the blu ray, or the first Japanese digital game, there's no - // What's New until the first patch, which will take this line out - if (StorageManager.GetBootTypeDisc() || - (app.GetProductSKU() == e_sku_SCEJ)) { - if (!(i == eHTPButton_WhatsNew)) { - m_buttonListHowTo.addItem(app.GetString(m_uiHTPButtonNameA[i]), - i); // iCount++); - } - } else -#elif defined(__ORBIS__) || defined(_DURANGO) || defined(__PSVITA__) - // No What's New for the first PS4 and Xbox One builds - if (true) { - if (!(i == eHTPButton_WhatsNew)) { - m_buttonListHowTo.addItem(app.GetString(m_uiHTPButtonNameA[i]), - i); // iCount++); - } - } else + // 4J Stu - Re-add for future platforms +#if 0 + // No What's New + if(true) + { + if(!(i==eHTPButton_WhatsNew) ) + { + m_buttonListHowTo.addItem( app.GetString(m_uiHTPButtonNameA[i]) , i);//iCount++); + } + } + else #endif { m_buttonListHowTo.addItem(app.GetString(m_uiHTPButtonNameA[i]), i); // iCount++); } } + + doHorizontalResizeCheck(); } std::wstring UIScene_HowToPlayMenu::getMoviePath() { @@ -114,29 +117,24 @@ void UIScene_HowToPlayMenu::updateComponents() { void UIScene_HowToPlayMenu::handleReload() { for (unsigned int i = 0; i < eHTPButton_Max; ++i) { -#ifdef __PS3__ - // If it's the blu ray, or the first Japanese digital game, there's no - // What's New until the first patch, which will take this line out - if (StorageManager.GetBootTypeDisc() || - (app.GetProductSKU() == e_sku_SCEJ)) { - if (!(i == eHTPButton_WhatsNew)) { - m_buttonListHowTo.addItem(app.GetString(m_uiHTPButtonNameA[i]), - i); - } - } else -#elif defined(__ORBIS__) || defined(_DURANGO) || defined(__PSVITA__) - // No What's New for the first PS4 and Xbox One builds - if (true) { - if (!(i == eHTPButton_WhatsNew)) { - m_buttonListHowTo.addItem(app.GetString(m_uiHTPButtonNameA[i]), - i); - } - } else + // 4J Stu - Re-add for future platforms +#if 0 + // No What's New + if(true) + { + if(!(i==eHTPButton_WhatsNew) ) + { + m_buttonListHowTo.addItem( app.GetString(m_uiHTPButtonNameA[i]) , i); + } + } + else #endif { m_buttonListHowTo.addItem(app.GetString(m_uiHTPButtonNameA[i]), i); } } + + doHorizontalResizeCheck(); } void UIScene_HowToPlayMenu::handleInput(int iPad, int key, bool repeat, @@ -176,7 +174,6 @@ void UIScene_HowToPlayMenu::handlePress(F64 controlId, F64 childId) { unsigned int uiInitData; uiInitData = ((1 << 31) | (m_uiHTPSceneA[(int)childId] << 16) | (short)(m_iPad)); - ui.NavigateToScene(m_iPad, eUIScene_HowToPlay, - (void*)(intptr_t)(uiInitData)); + ui.NavigateToScene(m_iPad, eUIScene_HowToPlay, (void*)(uiInitData)); } } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.h index 07da5dcfd..b25d5ff79 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.h @@ -25,6 +25,11 @@ private: eHTPButton_FarmingAnimals, eHTPButton_Breeding, eHTPButton_Trading, + eHTPButton_Horses, + eHTPButton_Beacons, + eHTPButton_Fireworks, + eHTPButton_Hoppers, + eHTPButton_Droppers, eHTPButton_NetherPortal, eHTPButton_TheEnd, #ifdef _XBOX diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameHostOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGameHostOptionsMenu.cpp index ba51befdf..a37dddc18 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameHostOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameHostOptionsMenu.cpp @@ -19,6 +19,36 @@ UIScene_InGameHostOptionsMenu::UIScene_InGameHostOptionsMenu( m_checkboxTNT.init(app.GetString(IDS_TNT_EXPLODES), eControl_TNT, app.GetGameHostOption(eGameHostOption_TNT) != 0); + 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)); + + // If cheats are disabled, remove checkboxes + if (!app.GetGameHostOption(eGameHostOption_CheatsEnabled)) { + removeControl(&m_checkboxMobGriefing, true); + removeControl(&m_checkboxKeepInventory, true); + removeControl(&m_checkboxDoMobSpawning, true); + removeControl(&m_checkboxDoDaylightCycle, true); + } + + 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)); + INetworkPlayer* localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(m_iPad); unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId()); @@ -48,6 +78,30 @@ void UIScene_InGameHostOptionsMenu::updateTooltips() { ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK); } +void UIScene_InGameHostOptionsMenu::handleReload() { + UIScene::handleReload(); + + // If cheats are disabled, remove checkboxes + if (!app.GetGameHostOption(eGameHostOption_CheatsEnabled)) { + removeControl(&m_checkboxMobGriefing, true); + removeControl(&m_checkboxKeepInventory, true); + removeControl(&m_checkboxDoMobSpawning, true); + removeControl(&m_checkboxDoDaylightCycle, true); + } + + 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) { + } else { + removeControl(&m_buttonTeleportToPlayer, true); + removeControl(&m_buttonTeleportToMe, true); + } +} + void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool& handled) { @@ -65,6 +119,29 @@ void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat, 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)) { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameHostOptionsMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_InGameHostOptionsMenu.h index 67d576242..9ba522936 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameHostOptionsMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameHostOptionsMenu.h @@ -7,15 +7,32 @@ private: enum EControls { eControl_FireSpreads, eControl_TNT, + eControl_MobGriefing, + eControl_KeepInventory, + eControl_DoMobSpawning, + eControl_DoMobLoot, + eControl_DoTileDrops, + eControl_NaturalRegeneration, + eControl_DoDaylightCycle, eControl_TeleportToPlayer, eControl_TeleportToMe, }; - UIControl_CheckBox m_checkboxFireSpreads, m_checkboxTNT; + 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; 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() @@ -26,6 +43,8 @@ public: virtual EUIScene getSceneType() { return eUIScene_InGameHostOptionsMenu; } virtual void updateTooltips(); + virtual void handleReload(); + protected: // TODO: This should be pure virtual in this class virtual std::wstring getMoviePath(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp index 05b36d945..3ed39d34f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp @@ -17,51 +17,19 @@ UIScene_InGameInfoMenu::UIScene_InGameInfoMenu(int iPad, void* initData, m_labelTitle.init(app.GetString(IDS_PLAYERS_INVITE)); m_playerList.init(eControl_GamePlayers); - for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { - m_playerNames[i] = L""; - } + m_players = std::vector(); int playerCount = g_NetworkManager.GetPlayerCount(); - m_playersCount = 0; for (int i = 0; i < playerCount; ++i) { INetworkPlayer* player = g_NetworkManager.GetPlayerByIndex(i); if (player != NULL) { - m_players[i] = player->GetSmallId(); - ++m_playersCount; + PlayerInfo* info = BuildPlayerInfo(player); - std::wstring playerName = L""; -#ifndef _CONTENT_PACKAGE - if (app.DebugSettingsOn() && - (app.GetGameSettingsDebugMask() & - (1L << eDebugSetting_DebugLeaderboards))) { - playerName = L"WWWWWWWWWWWWWWWW"; - } else -#endif - { - playerName = player->GetDisplayName(); - } - - int voiceStatus = 0; - if (player != NULL && player->HasVoice()) { - if (player->IsMutedByLocalUser(m_iPad)) { - // Muted image - voiceStatus = 3; - } else if (player->IsTalking()) { - // Talking image - voiceStatus = 2; - } else { - // Not talking image - voiceStatus = 1; - } - } - - m_playersVoiceState[i] = voiceStatus; - m_playersColourState[i] = app.GetPlayerColour(m_players[i]); - m_playerNames[i] = playerName; - m_playerList.addItem(playerName, app.GetPlayerColour(m_players[i]), - voiceStatus); + m_players.push_back(info); + m_playerList.addItem(info->m_name, info->m_colorState, + info->m_voiceStatus); } } @@ -94,6 +62,13 @@ UIScene_InGameInfoMenu::UIScene_InGameInfoMenu(int iPad, void* initData, #endif } +UIScene_InGameInfoMenu::~UIScene_InGameInfoMenu() { + // Delete player infos + for (int i = 0; i < m_players.size(); i++) { + delete m_players[i]; + } +} + std::wstring UIScene_InGameInfoMenu::getMoviePath() { if (app.GetLocalPlayerCount() > 1) { return L"InGameInfoMenuSplit"; @@ -118,7 +93,7 @@ void UIScene_InGameInfoMenu::updateTooltips() { #endif INetworkPlayer* selectedPlayer = g_NetworkManager.GetPlayerBySmallId( - m_players[m_playerList.getCurrentSelection()]); + m_players[m_playerList.getCurrentSelection()]->m_smallId); int keyA = -1; Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -186,8 +161,13 @@ void UIScene_InGameInfoMenu::handleGainFocus(bool navBack) { void UIScene_InGameInfoMenu::handleReload() { int playerCount = g_NetworkManager.GetPlayerCount(); - m_playersCount = 0; - for (int i = 0; i < playerCount; ++i) { + // Remove all player info + for (int i = 0; i < m_players.size(); i++) { + delete m_players[i]; + } + m_players.clear(); + + for (DWORD i = 0; i < playerCount; ++i) { INetworkPlayer* player = g_NetworkManager.GetPlayerByIndex(i); if (player != NULL) { @@ -195,36 +175,11 @@ void UIScene_InGameInfoMenu::handleReload() { ++m_playersCount; std::wstring playerName = L""; -#ifndef _CONTENT_PACKAGE if (app.DebugSettingsOn() && - (app.GetGameSettingsDebugMask() & (1L << eDebugSetting_DebugLeaderboards))) { - playerName = L"WWWWWWWWWWWWWWWW"; - } else -#endif - { - playerName = player->GetDisplayName(); - } - - int voiceStatus = 0; - if (player != NULL && player->HasVoice()) { - if (player->IsMutedByLocalUser(m_iPad)) { - // Muted image - voiceStatus = 3; - } else if (player->IsTalking()) { - // Talking image - voiceStatus = 2; - } else { - // Not talking image - voiceStatus = 1; - } - } - - m_playersVoiceState[i] = voiceStatus; - m_playersColourState[i] = app.GetPlayerColour(m_players[i]); - m_playerNames[i] = playerName; - m_playerList.addItem(playerName, app.GetPlayerColour(m_players[i]), - voiceStatus); + m_players.push_back(info); + m_playerList.addItem(info->m_name, info->m_colorState, + info->m_voiceStatus); } } @@ -259,44 +214,32 @@ void UIScene_InGameInfoMenu::tick() { if (player != NULL && player->HasVoice()) { if (player->IsMutedByLocalUser(m_iPad)) { // Muted image - voiceStatus = 3; - } else if (player->IsTalking()) { - // Talking image - voiceStatus = 2; - } else { - // Not talking image - voiceStatus = 1; - } - } + PlayerInfo* info = BuildPlayerInfo(player); - if (voiceStatus != m_playersVoiceState[i]) { - m_playersVoiceState[i] = voiceStatus; m_playerList.setVOIPIcon(i, voiceStatus); - } + m_players[i]->m_smallId = info->m_smallId; - short icon = app.GetPlayerColour(m_players[i]); - - if (icon != m_playersColourState[i]) { m_playersColourState[i] = icon; m_playerList.setPlayerIcon( - i, (int)app.GetPlayerColour(m_players[i])); + m_players[i]->m_voiceStatus = info->m_voiceStatus; + m_playerList.setVOIPIcon(i, info->m_voiceStatus); } - std::wstring playerName = L""; #ifndef _CONTENT_PACKAGE if (app.DebugSettingsOn() && (app.GetGameSettingsDebugMask() & (1L << eDebugSetting_DebugLeaderboards))) { - playerName = L"WWWWWWWWWWWWWWWW"; - } else -#endif - { - playerName = player->GetDisplayName(); + if (info->m_colorState != m_players[i]->m_colorState) { + m_players[i]->m_colorState = info->m_colorState; + m_playerList.setPlayerIcon(i, info->m_colorState); } - if (playerName.compare(m_playerNames[i]) != 0) { - m_playerList.setButtonLabel(i, playerName); m_playerNames[i] = playerName; + + m_playerList.setButtonLabel(i, info->m_name); + m_players[i]->m_name = info->m_name; } + + delete info; } } } @@ -430,6 +373,8 @@ void UIScene_InGameInfoMenu::handlePress(F64 controlId, F64 childId) { pInitData->networkSmallId = m_players[currentSelection]; pInitData->playerPrivileges = app.GetPlayerPrivileges(m_players[currentSelection]); + pInitData->playerPrivileges = app.GetPlayerPrivileges( + m_players[currentSelection]->m_smallId); ui.NavigateToScene(m_iPad, eUIScene_InGamePlayerOptionsMenu, pInitData); } else if (selectedPlayer->IsLocal() != TRUE && @@ -481,49 +426,45 @@ void UIScene_InGameInfoMenu::OnPlayerChanged(void* callbackParam, } } + + // If the player was found remove them (even if they're joining, they'll be + // added again later) if (playerFound) { - --scene->m_playersCount; - scene->m_playersVoiceState[scene->m_playersCount] = 0; scene->m_playersColourState[scene->m_playersCount] = 0; - scene->m_playerNames[scene->m_playersCount] = L""; scene->m_playerList.removeItem(scene->m_playersCount); - } + app.DebugPrintf( + " Player \"%ls\" found, " + "removing\n", - if (!playerFound) { - // Player added scene->m_players[scene->m_playersCount] = pPlayer->GetSmallId(); - ++scene->m_playersCount; + delete scene->m_players[foundIndex]; + scene->m_players.erase(scene->m_players.begin() + foundIndex); - std::wstring playerName = L""; #ifndef _CONTENT_PACKAGE if (app.DebugSettingsOn() && - (app.GetGameSettingsDebugMask() & (1L << eDebugSetting_DebugLeaderboards))) { - playerName = L"WWWWWWWWWWWWWWWW"; - } else -#endif - { playerName = pPlayer->GetDisplayName(); - } + // Remove player from list + scene->m_playerList.removeItem(foundIndex); + } - int voiceStatus = 0; - if (pPlayer != NULL && pPlayer->HasVoice()) { if (pPlayer->IsMutedByLocalUser(scene->m_iPad)) { - // Muted image voiceStatus = 3; - } else if (pPlayer->IsTalking()) { - // Talking image - voiceStatus = 2; - } else { // Not talking image - voiceStatus = 1; - } - } + // If the player is joining + if (!leaving) { + app.DebugPrintf( + " Player \"%ls\" not " + "found, adding\n", + pPlayer->GetOnlineName()); + + PlayerInfo* info = scene->BuildPlayerInfo(pPlayer); + scene->m_players.push_back(info); - scene->m_playerList.addItem( - playerName, app.GetPlayerColour(scene->m_players[scene->m_playersCount - 1]), - voiceStatus); + // important that we add the button (not the order or content) + scene->m_playerList.addItem(info->m_name, info->m_colorState, + info->m_voiceStatus); } } @@ -545,6 +486,33 @@ int UIScene_InGameInfoMenu::KickPlayerReturned( return 0; } + } else +#endif + { + playerName = player->GetDisplayName(); + } + + int voiceStatus = 0; + if (player != NULL && player->HasVoice()) { + if (player->IsMutedByLocalUser(m_iPad)) { + // Muted image + voiceStatus = 3; + } else if (player->IsTalking()) { + // Talking image + voiceStatus = 2; + } else { + // Not talking image + voiceStatus = 1; + } + } + + info->m_voiceStatus = voiceStatus; + info->m_colorState = app.GetPlayerColour(info->m_smallId); + info->m_name = playerName; + + return info; +} + #if defined __PS3__ || defined __PSVITA__ int UIScene_InGameInfoMenu::MustSignInReturnedPSN( void* pParam, int iPad, C4JStorage::EMessageResult result) { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.h index c5aff1190..cbabbf5ed 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.h @@ -11,13 +11,20 @@ private: eControl_GamePlayers, }; + typedef struct _PlayerInfo { + uint8_t m_smallId; + char m_voiceStatus; + short m_colorState; + std::wstring m_name; + + } PlayerInfo; + bool m_isHostPlayer; - int m_playersCount; - std::uint8_t - m_players[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's - char m_playersVoiceState[MINECRAFT_NET_MAX_PLAYERS]; - short m_playersColourState[MINECRAFT_NET_MAX_PLAYERS]; - std::wstring m_playerNames[MINECRAFT_NET_MAX_PLAYERS]; + // int m_playersCount; + std::vector m_players; // A std::vector of player info structs + // char m_playersVoiceState[MINECRAFT_NET_MAX_PLAYERS]; + // short m_playersColourState[MINECRAFT_NET_MAX_PLAYERS]; + // std::wstring m_playerNames[MINECRAFT_NET_MAX_PLAYERS]; UIControl_Button m_buttonGameOptions; UIControl_PlayerList m_playerList; @@ -29,6 +36,7 @@ private: UI_END_MAP_ELEMENTS_AND_NAMES() public: UIScene_InGameInfoMenu(int iPad, void* initData, UILayer* parentLayer); + virtual ~UIScene_InGameInfoMenu(); virtual EUIScene getSceneType() { return eUIScene_InGameInfoMenu; } virtual void updateTooltips(); @@ -59,6 +67,8 @@ public: bool leaving); private: + PlayerInfo* BuildPlayerInfo(INetworkPlayer* player); + #if defined(__PS3__) || defined(__PSVITA__) || defined(__ORBIS__) static int MustSignInReturnedPSN(void* pParam, int iPad, C4JStorage::EMessageResult result); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp index ff533f82c..b8cd7d5b3 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp @@ -297,6 +297,89 @@ void UIScene_InGamePlayerOptionsMenu::updateTooltips() { ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK); } +void UIScene_InGamePlayerOptionsMenu::handleReload() { + UIScene::handleReload(); + + 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 != NULL && localPlayer == editingPlayer); + + if (m_editingSelf || trustPlayers || editingPlayer->IsHost()) { + 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); + } + + if (m_editingSelf) { +#if (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) { + 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 { + removeControl(&m_checkboxes[eControl_HostInvisible], true); + removeControl(&m_checkboxes[eControl_HostFly], true); + removeControl(&m_checkboxes[eControl_HostHunger], true); + } + } else { + if (!localPlayer->IsHost()) { + removeControl(&m_checkboxes[eControl_Op], true); + } + + if (localPlayer->IsHost() && cheats) { + 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 { + 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) { + 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); +} + void UIScene_InGamePlayerOptionsMenu::tick() { UIScene::tick(); @@ -486,10 +569,10 @@ void UIScene_InGamePlayerOptionsMenu::handlePress(F64 controlId, F64 childId) { uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_UNLOCK_KICK_PLAYER_TITLE, IDS_UNLOCK_KICK_PLAYER, uiIDA, 2, m_iPad, &UIScene_InGamePlayerOptionsMenu::KickPlayerReturned, - smallId, app.GetStringTable(), NULL, 0, false); + smallId); } break; }; } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.h index a57d846a1..07a10c730 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.h @@ -67,6 +67,8 @@ public: virtual EUIScene getSceneType() { return eUIScene_InGamePlayerOptionsMenu; } virtual void updateTooltips(); + virtual void handleReload(); + protected: // TODO: This should be pure virtual in this class virtual std::wstring getMoviePath(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp index dcc9b500d..20d776152 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp @@ -190,9 +190,7 @@ void UIScene_InGameSaveManagementMenu::tick() { // Stop loading thumbnails if we navigate forwards if (hasFocus(m_iPad)) { if (m_bUpdateSaveSize) { -#if defined(_XBOX_ONE) || defined(__ORBIS__) m_spaceIndicatorSaves.selectSave(m_iSaveListIndex); -#endif m_bUpdateSaveSize = false; } @@ -200,9 +198,7 @@ void UIScene_InGameSaveManagementMenu::tick() { if (!m_bSavesDisplayed) { m_pSaveDetails = StorageManager.ReturnSavesInfo(); if (m_pSaveDetails != NULL) { -#if defined(_XBOX_ONE) || defined(__ORBIS__) m_spaceIndicatorSaves.reset(); -#endif m_bSavesDisplayed = true; @@ -297,11 +293,6 @@ void UIScene_InGameSaveManagementMenu::tick() { MAX_SAVEFILENAME_LENGTH // size of destination buffer, in // WCHAR's ); -#elif defined(__linux__) - mbstowcs( - (wchar_t*)u16Message, - m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename, - MAX_SAVEFILENAME_LENGTH); #else #ifdef __PS3 size_t srcmax, dstmax; @@ -471,10 +462,10 @@ void UIScene_InGameSaveManagementMenu::handlePress(F64 controlId, F64 childId) { unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestErrorMessage( IDS_TOOLTIPS_DELETESAVE, IDS_TEXT_DELETE_SAVE, uiIDA, 2, m_iPad, &UIScene_InGameSaveManagementMenu::DeleteSaveDialogReturned, - this, app.GetStringTable(), NULL, 0, true); + this); ui.PlayUISFX(eSFX_Press); break; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_Intro.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_Intro.cpp index 59f2bf7b0..3cd6b1296 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_Intro.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_Intro.cpp @@ -17,12 +17,16 @@ UIScene_Intro::UIScene_Intro(int iPad, void* initData, UILayer* parentLayer) #endif bool bSkipESRB = false; + bool bChina = false; #if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) bSkipESRB = app.GetProductSKU() != e_sku_SCEA; #elif defined(_XBOX) || defined(_DURANGO) bSkipESRB = !ProfileManager.LocaleIsUSorCanada(); #endif +#ifdef _DURANGO + bChina = ProfileManager.LocaleIsChina(); +#endif // 4J Stu - These map to values in the Actionscript #if defined(_WINDOWS64) || defined(__linux__) int platformIdx = 0; @@ -39,15 +43,19 @@ UIScene_Intro::UIScene_Intro(int iPad, void* initData, UILayer* parentLayer) #endif IggyDataValue result; - IggyDataValue value[2]; + IggyDataValue value[3]; value[0].type = IGGY_DATATYPE_number; value[0].number = platformIdx; value[1].type = IGGY_DATATYPE_boolean; - value[1].boolval = bSkipESRB; + value[1].boolval = bChina ? true : bSkipESRB; + + value[2].type = IGGY_DATATYPE_boolean; + value[2].boolval = bChina; + IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), - m_funcSetIntroPlatform, 2, value); + m_funcSetIntroPlatform, 3, value); #ifdef __PSVITA__ // initialise vita touch controls with ids diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp index 1e4f0cbde..dbbc3cbc6 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp @@ -141,6 +141,8 @@ void UIScene_JoinMenu::tick() { app.GetGameHostOption(uiGameHostSettings, eGameHostOption_GameType); if (option == GameType::CREATIVE->getId()) { m_labelValues[eLabel_GameType].init(app.GetString(IDS_CREATIVE)); + } else if (option == GameType::ADVENTURE->getId()) { + m_labelValues[eLabel_GameType].init(app.GetString(IDS_ADVENTURE)); } else { m_labelValues[eLabel_GameType].init(app.GetString(IDS_SURVIVAL)); } @@ -240,10 +242,10 @@ void UIScene_JoinMenu::tick() { ui.RequestMessageBox(IDS_CONNECTION_FAILED, IDS_DISCONNECTED_SERVER_QUIT, uiIDA, 1, m_iPad, ErrorDialogReturned, this, app.GetStringTable()); + IDS_DISCONNECTED_SERVER_QUIT, uiIDA, 1, m_iPad, + ErrorDialogReturned, this); #else - ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, - 1, m_iPad, ErrorDialogReturned, this, - app.GetStringTable()); + uiIDA, 1, m_iPad, ErrorDialogReturned, this); #endif } @@ -353,10 +355,13 @@ void UIScene_JoinMenu::checkPrivilegeCallback(void* lpParam, bool hasPrivilege, int iPad) { UIScene_JoinMenu* pClass = (UIScene_JoinMenu*)lpParam; - if (hasPrivilege) { - pClass->StartSharedLaunchFlow(); - } else { pClass->m_bIgnoreInput = false; + if (pClass) { + if (hasPrivilege) { + pClass->StartSharedLaunchFlow(); + } else { + pClass->m_bIgnoreInput = false; + } } } #endif @@ -383,12 +388,21 @@ int UIScene_JoinMenu::StartGame_SignInReturned(void* pParam, bool bContinue, if (bContinue == true) { // It's possible that the player has not signed in - they can back out - if (ProfileManager.IsSignedIn(iPad)) { - JoinGame(pClass); + UIScene_JoinMenu* pClass = + (UIScene_JoinMenu*)ui.GetSceneFromCallbackId((size_t)pParam); + + if (pClass) { + if (bContinue == true) { + // It's possible that the player has not signed in - they can back + // out + if (ProfileManager.IsSignedIn(iPad)) { + JoinGame(pClass); + } else { + pClass->m_bIgnoreInput = false; + } } else { pClass->m_bIgnoreInput = false; } - } else { pClass->m_bIgnoreInput = false; } return 0; @@ -400,6 +414,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { bool noPrivileges = false; int signedInUsers = 0; int localUsersMask = 0; + DWORD dwLocalUsersMask = 0; bool isSignedInLive = true; int iPadNotSignedInLive = -1; @@ -409,7 +424,6 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { if (app.IsLocalMultiplayerAvailable()) { for (unsigned int index = 0; index < XUSER_MAX_COUNT; ++index) { if (ProfileManager.IsSignedIn(index)) { - ++signedInUsers; if (isSignedInLive && !ProfileManager.IsSignedInLive(index)) { // Record the first non signed in live pad iPadNotSignedInLive = index; @@ -417,7 +431,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { if (!ProfileManager.AllowedToPlayMultiplayer(index)) noPrivileges = true; - localUsersMask |= + dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index); isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(index); @@ -425,11 +439,9 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { } } else { if (ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) { - ++signedInUsers; if (!ProfileManager.AllowedToPlayMultiplayer( ProfileManager.GetPrimaryPad())) noPrivileges = true; - localUsersMask |= CGameNetworkManager::GetLocalPlayerMask( ProfileManager.GetPrimaryPad()); isSignedInLive = @@ -456,19 +468,18 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { // npAvailability isn't SCE_OK unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - iPadNotSignedInLive, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + iPadNotSignedInLive); } else #endif { pClass->m_bIgnoreInput = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad()); } return; } @@ -502,7 +513,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { pClass->m_bIgnoreInput = false; int messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; - if (signedInUsers > 1) + if (dwSignedInUsers > 1) messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; ui.RequestUGCMessageBox(IDS_CONNECTION_FAILED, messageText); @@ -511,10 +522,9 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { pClass->m_bIgnoreInput = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, - IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, + IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad()); } else { #if defined(__ORBIS__) || defined(__PSVITA__) bool chatRestricted = false; @@ -527,7 +537,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { } #endif CGameNetworkManager::eJoinGameResult result = g_NetworkManager.JoinGame( - pClass->m_selectedSession, localUsersMask); + pClass->m_selectedSession, dwLocalUsersMask); // Alert the app the we no longer want to be informed of ethernet // connections @@ -548,9 +558,9 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { } else { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_CONNECTION_FAILED, exitReasonStringId, - uiIDA, 1, ProfileManager.GetPrimaryPad(), - NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_CONNECTION_FAILED, + exitReasonStringId, uiIDA, 1, + ProfileManager.GetPrimaryPad()); exitReasonStringId = -1; ui.NavigateToHomeMenu(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.cpp new file mode 100644 index 000000000..14242072c --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.cpp @@ -0,0 +1,120 @@ +#include "../../stdafx.h" +#include "UI.h" +#include "UIScene_LanguageSelector.h" + +// strings for buttons in the list +const unsigned int UIScene_LanguageSelector::m_uiHTPButtonNameA[] = { + HAS_LANGUAGE_SYSTEM(IDS_LANG_SYSTEM) HAS_LANGUAGE_EN_US( + IDS_LANG_ENGLISH) HAS_LANGUAGE_DE_DE(IDS_LANG_GERMAN) + HAS_LANGUAGE_ES_ES(IDS_LANG_SPANISH_SPAIN) HAS_LANGUAGE_ES_MX( + IDS_LANG_SPANISH_LATIN_AMERICA) HAS_LANGUAGE_FR_FR(IDS_LANG_FRENCH) + HAS_LANGUAGE_IT_IT(IDS_LANG_ITALIAN) HAS_LANGUAGE_PT_PT( + IDS_LANG_PORTUGUESE_PORTUGAL) + HAS_LANGUAGE_PT_BR(IDS_LANG_PORTUGUESE_BRAZIL) HAS_LANGUAGE_JA_JP( + IDS_LANG_JAPANESE) HAS_LANGUAGE_KO_KR(IDS_LANG_KOREAN) + HAS_LANGUAGE_CN_TW(IDS_LANG_CHINESE_TRADITIONAL) HAS_LANGUAGE_CN_CN( + IDS_LANG_CHINESE_SIMPLIFIED) + HAS_LANGUAGE_DA_DK(IDS_LANG_DANISH) HAS_LANGUAGE_FI_FI( + IDS_LANG_FINISH) HAS_LANGUAGE_NL_NL(IDS_LANG_DUTCH) + HAS_LANGUAGE_PL_PL(IDS_LANG_POLISH) + HAS_LANGUAGE_RU_RU(IDS_LANG_RUSSIAN) + HAS_LANGUAGE_SV_SE(IDS_LANG_SWEDISH) + HAS_LANGUAGE_NB_NO(IDS_LANG_NORWEGIAN) + HAS_LANGUAGE_SK_SK(IDS_LANG_SLOVAK) + HAS_LANGUAGE_CZ_CZ( + IDS_LANG_CZECH) + HAS_LANGUAGE_EL_GR( + IDS_LANG_GREEK) + HAS_LANGUAGE_TR_TR( + IDS_LANG_TURKISH)}; + +UIScene_LanguageSelector::UIScene_LanguageSelector(int iPad, void* initData, + UILayer* parentLayer) + : UIScene(iPad, parentLayer) { + // Setup all the Iggy references we need for this scene + initialiseMovie(); + + m_buttonListHowTo.init(eControl_Buttons); + + for (unsigned int i = 0; i < eLanguageSelector_MAX; ++i) { + m_buttonListHowTo.addItem(m_uiHTPButtonNameA[i], i); + } +} + +std::wstring UIScene_LanguageSelector::getMoviePath() { + if (app.GetLocalPlayerCount() > 1) + return L"LanguagesMenuSplit"; + else + return L"LanguagesMenu"; +} + +void UIScene_LanguageSelector::updateTooltips() { + ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK); +} + +void UIScene_LanguageSelector::updateComponents() { + bool bNotInGame = (Minecraft::GetInstance()->level == NULL); + 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); + + if (app.GetLocalPlayerCount() == 1) + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); + else + m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false); + } +} + +void UIScene_LanguageSelector::handleReload() { + for (unsigned int i = 0; i < eLanguageSelector_MAX; ++i) { + m_buttonListHowTo.addItem(m_uiHTPButtonNameA[i], i); + } +} + +void UIScene_LanguageSelector::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(m_iPad, key, repeat, pressed, released); + + switch (key) { + case ACTION_MENU_CANCEL: + if (pressed) { + navigateBack(); + // ui.NavigateToScene(m_iPad, eUIScene_SettingsOptionsMenu); + } + break; + case ACTION_MENU_OK: +#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_PAGEUP: + case ACTION_MENU_PAGEDOWN: + sendInputToMovie(key, repeat, pressed, released); + break; + } +} + +void UIScene_LanguageSelector::handlePress(F64 controlId, F64 childId) { + if ((int)controlId == eControl_Buttons) { + // CD - Added for audio + ui.PlayUISFX(eSFX_Press); + + int newLanguage, newLocale; + newLanguage = uiLangMap[(int)childId]; + newLocale = uiLocaleMap[(int)childId]; + + app.SetMinecraftLanguage(m_iPad, newLanguage); + app.SetMinecraftLocale(m_iPad, newLocale); + + app.CheckGameSettingsChanged(true, m_iPad); + } +} diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.h b/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.h new file mode 100644 index 000000000..4fd1a8097 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LanguageSelector.h @@ -0,0 +1,162 @@ +#pragma once + +#include "UIScene.h" + +#define HAS_LANGUAGE_SYSTEM(exp) exp, + +#define HAS_LANGUAGE_EN_US(exp) exp, +#define HAS_LANGUAGE_DE_DE(exp) exp, +#define HAS_LANGUAGE_ES_ES(exp) exp, +#define HAS_LANGUAGE_ES_MX(exp) exp, +#define HAS_LANGUAGE_FR_FR(exp) exp, +#define HAS_LANGUAGE_IT_IT(exp) exp, +#define HAS_LANGUAGE_PT_PT(exp) exp, +#define HAS_LANGUAGE_PT_BR(exp) exp, +#define HAS_LANGUAGE_JA_JP(exp) exp, +#define HAS_LANGUAGE_KO_KR(exp) exp, +#define HAS_LANGUAGE_CN_TW(exp) exp, + +#ifdef _DURANGO +#define HAS_LANGUAGE_CN_CN(exp) exp, +#define HAS_LANGUAGE_SK_SK(exp) exp, +#define HAS_LANGUAGE_CZ_CZ(exp) exp, +#else +#define HAS_LANGUAGE_CN_CN(exp) +#define HAS_LANGUAGE_SK_SK(exp) +#define HAS_LANGUAGE_CZ_CZ(exp) +#endif + +#define HAS_LANGUAGE_DA_DK(exp) exp, +#define HAS_LANGUAGE_FI_FI(exp) exp, +#define HAS_LANGUAGE_NL_NL(exp) exp, +#define HAS_LANGUAGE_PL_PL(exp) exp, +#define HAS_LANGUAGE_RU_RU(exp) exp, +#define HAS_LANGUAGE_SV_SE(exp) exp, +#define HAS_LANGUAGE_NB_NO(exp) exp, +#define HAS_LANGUAGE_EL_GR(exp) exp, + +#if defined(__ORBIS__) || defined(__PS3__) || defined(__PSVITA__) +#define HAS_LANGUAGE_TR_TR(exp) exp, +#else +#define HAS_LANGUAGE_TR_TR(exp) +#endif + +class UIScene_LanguageSelector : public UIScene { +public: + enum ELangButtons { + eLanguageSelector_LabelNone = -1, + HAS_LANGUAGE_SYSTEM(eLanguageSelector_system) HAS_LANGUAGE_EN_US( + eLanguageSelector_EN_US) HAS_LANGUAGE_DE_DE(eLanguageSelector_DE_DE) + HAS_LANGUAGE_ES_ES(eLanguageSelector_ES_ES) HAS_LANGUAGE_ES_MX( + eLanguageSelector_ES_MX) HAS_LANGUAGE_FR_FR(eLanguageSelector_FR_FR) + HAS_LANGUAGE_IT_IT(eLanguageSelector_IT_IT) HAS_LANGUAGE_PT_PT( + eLanguageSelector_PT_PT) HAS_LANGUAGE_PT_BR(eLanguageSelector_PT_BR) + HAS_LANGUAGE_JA_JP(eLanguageSelector_JA_JP) HAS_LANGUAGE_KO_KR( + eLanguageSelector_KO_KR) HAS_LANGUAGE_CN_TW(eLanguageSelector_CN_TW) + HAS_LANGUAGE_CN_CN(eLanguageSelector_CN_CN) HAS_LANGUAGE_DA_DK( + eLanguageSelector_DA_DK) + HAS_LANGUAGE_FI_FI(eLanguageSelector_FI_FI) HAS_LANGUAGE_NL_NL( + eLanguageSelector_NL_NL) + HAS_LANGUAGE_PL_PL(eLanguageSelector_PL_PL) + HAS_LANGUAGE_RU_RU(eLanguageSelector_RU_RU) + HAS_LANGUAGE_SV_SE( + eLanguageSelector_SV_SE) + HAS_LANGUAGE_NB_NO( + eLanguageSelector_NB_NO) + HAS_LANGUAGE_SK_SK( + eLanguageSelector_SK_SK) + HAS_LANGUAGE_CZ_CZ( + eLanguageSelector_CZ_CZ) + HAS_LANGUAGE_EL_GR( + eLanguageSelector_EL_GR) + HAS_LANGUAGE_TR_TR( + eLanguageSelector_TR_TR) + eLanguageSelector_MAX + }; + +private: + enum EControls { + eControl_Buttons, + }; + + static const unsigned int m_uiHTPButtonNameA[eLanguageSelector_MAX]; + + UIControl_DynamicButtonList m_buttonListHowTo; + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) + UI_MAP_ELEMENT(m_buttonListHowTo, "HowToList") + UI_END_MAP_ELEMENTS_AND_NAMES() + +public: + UIScene_LanguageSelector(int iPad, void* initData, UILayer* parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_LanguageSelector; } + + virtual void updateTooltips(); + virtual void updateComponents(); + + virtual void handleReload(); + +protected: + // TODO: This should be pure virtual in this class + virtual std::wstring getMoviePath(); + +public: + // INPUT + virtual void handleInput(int iPad, int key, bool repeat, bool pressed, + bool released, bool& handled); + +protected: + void handlePress(F64 controlId, F64 childId); +}; + +const int uiLangMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = { + HAS_LANGUAGE_SYSTEM(MINECRAFT_LANGUAGE_DEFAULT) HAS_LANGUAGE_EN_US( + XC_LANGUAGE_ENGLISH) HAS_LANGUAGE_DE_DE(XC_LANGUAGE_GERMAN) + HAS_LANGUAGE_ES_ES(XC_LANGUAGE_SPANISH) HAS_LANGUAGE_ES_MX( + XC_LANGUAGE_SPANISH) HAS_LANGUAGE_FR_FR(XC_LANGUAGE_FRENCH) + HAS_LANGUAGE_IT_IT(XC_LANGUAGE_ITALIAN) HAS_LANGUAGE_PT_PT( + XC_LANGUAGE_PORTUGUESE) HAS_LANGUAGE_PT_BR(XC_LANGUAGE_PORTUGUESE) + HAS_LANGUAGE_JA_JP(XC_LANGUAGE_JAPANESE) HAS_LANGUAGE_KO_KR( + XC_LANGUAGE_KOREAN) HAS_LANGUAGE_CN_TW(XC_LANGUAGE_TCHINESE) + HAS_LANGUAGE_CN_CN(XC_LANGUAGE_SCHINESE) HAS_LANGUAGE_DA_DK( + XC_LANGUAGE_DANISH) HAS_LANGUAGE_FI_FI(XC_LANGUAGE_FINISH) + HAS_LANGUAGE_NL_NL(XC_LANGUAGE_DUTCH) HAS_LANGUAGE_PL_PL( + XC_LANGUAGE_POLISH) + HAS_LANGUAGE_RU_RU(XC_LANGUAGE_RUSSIAN) + HAS_LANGUAGE_SV_SE(XC_LANGUAGE_SWEDISH) + HAS_LANGUAGE_NB_NO(XC_LANGUAGE_BNORWEGIAN) + HAS_LANGUAGE_SK_SK(XC_LANGUAGE_SLOVAK) + HAS_LANGUAGE_CZ_CZ( + XC_LANGUAGE_CZECH) + HAS_LANGUAGE_EL_GR( + XC_LANGUAGE_GREEK) + HAS_LANGUAGE_TR_TR( + XC_LANGUAGE_TURKISH)}; + +const int uiLocaleMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = { + HAS_LANGUAGE_SYSTEM(MINECRAFT_LANGUAGE_DEFAULT) HAS_LANGUAGE_EN_US( + MINECRAFT_LANGUAGE_DEFAULT) HAS_LANGUAGE_DE_DE(MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_ES_ES(XC_LOCALE_SPAIN) HAS_LANGUAGE_ES_MX( + XC_LOCALE_LATIN_AMERICA) HAS_LANGUAGE_FR_FR(MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_IT_IT(MINECRAFT_LANGUAGE_DEFAULT) HAS_LANGUAGE_PT_PT( + XC_LOCALE_PORTUGAL) HAS_LANGUAGE_PT_BR(XC_LOCALE_BRAZIL) + HAS_LANGUAGE_JA_JP(MINECRAFT_LANGUAGE_DEFAULT) HAS_LANGUAGE_KO_KR( + MINECRAFT_LANGUAGE_DEFAULT) HAS_LANGUAGE_CN_TW(MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_CN_CN(MINECRAFT_LANGUAGE_DEFAULT) HAS_LANGUAGE_DA_DK( + MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_FI_FI(MINECRAFT_LANGUAGE_DEFAULT) HAS_LANGUAGE_NL_NL( + MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_PL_PL(MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_RU_RU(MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_SV_SE( + MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_NB_NO( + MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_SK_SK( + MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_CZ_CZ( + MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_EL_GR( + MINECRAFT_LANGUAGE_DEFAULT) + HAS_LANGUAGE_TR_TR( + MINECRAFT_LANGUAGE_DEFAULT)}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index cb3fe6621..448acff95 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -25,12 +25,32 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu( m_labelWorldOptions.init(app.GetString(IDS_WORLD_OPTIONS)); IggyDataValue result; + +#ifdef _LARGE_WORLDS + IggyDataValue value[2]; + value[0].type = IGGY_DATATYPE_number; + value[0].number = m_params->bGenerateOptions ? 0 : 1; + value[1].type = IGGY_DATATYPE_boolean; + value[1].boolval = false; + if (m_params->currentWorldSize == e_worldSize_Classic || + m_params->currentWorldSize == e_worldSize_Small || + m_params->currentWorldSize == e_worldSize_Medium) { + // don't show the increase world size stuff if we're already large, or + // the size is unknown. + value[1].boolval = true; + } + + IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, + IggyPlayerRootPath(getMovie()), + m_funcSetMenuType, 2, value); +#else IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; value[0].number = m_params->bGenerateOptions ? 0 : 1; IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetMenuType, 1, value); +#endif m_bMultiplayerAllowed = ProfileManager.IsSignedInLive(m_params->iPad) && @@ -59,6 +79,11 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu( m_checkboxes[eLaunchCheckbox_AllowFoF].SetEnable(false); } + // Init cheats + m_bUpdateCheats = false; + // Update cheat checkboxes + UpdateCheats(); + m_checkboxes[eLaunchCheckbox_Online].init( app.GetString(IDS_ONLINE_GAME), eLaunchCheckbox_Online, bOnlineGame); m_checkboxes[eLaunchCheckbox_InviteOnly].init( @@ -93,22 +118,56 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu( app.GetString(IDS_BONUS_CHEST), eLaunchCheckbox_BonusChest, m_params->bBonusChest); - if (m_loadedResolution == eSceneResolution_1080) { -#ifdef _LARGE_WORLDS - m_labelGameOptions.init(app.GetString(IDS_GAME_OPTIONS)); - m_labelSeed.init(app.GetString(IDS_CREATE_NEW_WORLD_SEED)); - m_labelRandomSeed.init(app.GetString(IDS_CREATE_NEW_WORLD_RANDOM_SEED)); - m_editSeed.init(m_params->seed, eControl_EditSeed); - m_labelWorldSize.init(app.GetString(IDS_WORLD_SIZE)); - m_sliderWorldSize.init( - app.GetString(m_iWorldSizeTitleA[m_params->worldSize]), - eControl_WorldSize, 0, 3, m_params->worldSize); + 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); + m_checkboxes[eLaunchCheckbox_MobLoot].init(app.GetString(IDS_MOB_LOOT), + eLaunchCheckbox_MobLoot, + m_params->bDoMobLoot); + m_checkboxes[eLaunchCheckbox_MobGriefing].init( + app.GetString(IDS_MOB_GRIEFING), eLaunchCheckbox_MobGriefing, + m_params->bMobGriefing); + m_checkboxes[eLaunchCheckbox_TileDrops].init(app.GetString(IDS_TILE_DROPS), + eLaunchCheckbox_TileDrops, + m_params->bDoTileDrops); + m_checkboxes[eLaunchCheckbox_NaturalRegeneration].init( + app.GetString(IDS_NATURAL_REGEN), eLaunchCheckbox_NaturalRegeneration, + m_params->bNaturalRegeneration); + m_checkboxes[eLaunchCheckbox_DayLightCycle].init( + app.GetString(IDS_DAYLIGHT_CYCLE), eLaunchCheckbox_DayLightCycle, + m_params->bDoDaylightCycle); - m_checkboxes[eLaunchCheckbox_DisableSaving].init( - app.GetString(IDS_DISABLE_SAVING), eLaunchCheckbox_DisableSaving, - m_params->bDisableSaving); -#endif + m_labelGameOptions.init(app.GetString(IDS_GAME_OPTIONS)); + m_labelSeed.init(app.GetString(IDS_CREATE_NEW_WORLD_SEED)); + m_labelRandomSeed.init(app.GetString(IDS_CREATE_NEW_WORLD_RANDOM_SEED)); + m_editSeed.init(m_params->seed, eControl_EditSeed); + +#ifdef _LARGE_WORLDS + m_labelWorldSize.init(app.GetString(IDS_WORLD_SIZE)); + m_sliderWorldSize.init( + app.GetString(m_iWorldSizeTitleA[m_params->worldSize]), + eControl_WorldSize, 0, 3, m_params->worldSize); + + m_checkboxes[eLaunchCheckbox_DisableSaving].init( + app.GetString(IDS_DISABLE_SAVING), eLaunchCheckbox_DisableSaving, + m_params->bDisableSaving); + + if (m_params->currentWorldSize != e_worldSize_Unknown) { + m_labelWorldResize.init(app.GetString(IDS_INCREASE_WORLD_SIZE)); + int min = int(m_params->currentWorldSize) - 1; + int max = 3; + int curr = int(m_params->newWorldSize) - 1; + m_sliderWorldResize.init(app.GetString(m_iWorldSizeTitleA[curr]), + eControl_WorldResize, min, max, curr); + m_checkboxes[eLaunchCheckbox_WorldResizeType].init( + app.GetString(IDS_INCREASE_WORLD_SIZE_OVERWRITE_EDGES), + eLaunchCheckbox_WorldResizeType, + m_params->newWorldSizeOverwriteEdges); } +#endif // Only the Xbox 360 needs a reset nether // 4J-PB - PS3 needs it now @@ -116,6 +175,9 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu( // if(!m_params->bGenerateOptions) removeControl( // &m_checkboxes[eLaunchCheckbox_ResetNether], false ); #endif + m_tabIndex = + m_params->bGenerateOptions ? TAB_WORLD_OPTIONS : TAB_GAME_OPTIONS; + // set the default text #ifdef _LARGE_WORLDS std::wstring wsText = L""; @@ -135,32 +197,33 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu( swprintf(startTags, 64, L"", app.GetHTMLColour(eHTMLColor_White)); wsText = startTags + wsText; - m_labelDescription.init(wsText); + if (m_tabIndex == TAB_WORLD_OPTIONS) + m_labelDescription_WorldOptions.setLabel(wsText); + else + m_labelDescription_GameOptions.setLabel(wsText); addTimer(GAME_CREATE_ONLINE_TIMER_ID, GAME_CREATE_ONLINE_TIMER_TIME); #ifdef __PSVITA__ + // initialise vita tab controls with ids + m_TouchTabWorld.init(ETouchInput_TabWorld); + m_TouchTabGame.init(ETouchInput_TabGame); + ui.TouchBoxRebuild(this); #endif m_bIgnoreInput = false; - m_tabIndex = 0; } void UIScene_LaunchMoreOptionsMenu::updateTooltips() { int changeTabTooltip = -1; -#ifdef _LARGE_WORLDS - if (m_loadedResolution == eSceneResolution_1080 && - m_params->bGenerateOptions) { - // Set tooltip for change tab (only two tabs) - if (m_tabIndex == 0) { - changeTabTooltip = IDS_GAME_OPTIONS; - } else { - changeTabTooltip = IDS_WORLD_OPTIONS; - } + // Set tooltip for change tab (only two tabs) + if (m_tabIndex == TAB_GAME_OPTIONS) { + changeTabTooltip = IDS_WORLD_OPTIONS; + } else { + changeTabTooltip = IDS_GAME_OPTIONS; } -#endif // If there's a change tab tooltip, left bumper symbol should show but not // the text (-2) @@ -172,11 +235,11 @@ void UIScene_LaunchMoreOptionsMenu::updateTooltips() { void UIScene_LaunchMoreOptionsMenu::updateComponents() { m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true); -#ifdef _LARGE_WORLDS - m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true); -#else + // #ifdef _LARGE_WORLDS + // m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,true); + // #else m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false); -#endif + // #endif } std::wstring UIScene_LaunchMoreOptionsMenu::getMoviePath() { @@ -202,6 +265,17 @@ void UIScene_LaunchMoreOptionsMenu::tick() { m_bMultiplayerAllowed = bMultiplayerAllowed; } + + // Check cheats + if (m_bUpdateCheats) { + UpdateCheats(); + m_bUpdateCheats = false; + } + // check online + if (m_bUpdateOnline) { + UpdateOnline(); + m_bUpdateOnline = false; + } } void UIScene_LaunchMoreOptionsMenu::handleDestroy() { @@ -244,9 +318,9 @@ void UIScene_LaunchMoreOptionsMenu::handleInput(int iPad, int key, bool repeat, if (pressed && controlHasFocus(checkboxOnline->getId()) && !checkboxOnline->IsEnabled()) { unsigned int uiIDA[1] = {IDS_CONFIRM_OK}; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, - iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, + iPad); } } #endif @@ -264,7 +338,7 @@ void UIScene_LaunchMoreOptionsMenu::handleInput(int iPad, int key, bool repeat, break; case ACTION_MENU_LEFT_SCROLL: case ACTION_MENU_RIGHT_SCROLL: - if (pressed && m_loadedResolution == eSceneResolution_1080) { + if (pressed) { // Toggle tab index m_tabIndex = m_tabIndex == 0 ? 1 : 0; updateTooltips(); @@ -277,6 +351,40 @@ void UIScene_LaunchMoreOptionsMenu::handleInput(int iPad, int key, bool repeat, } } +#ifdef __PSVITA__ +void UIScene_LaunchMoreOptionsMenu::handleTouchInput(unsigned int iPad, S32 x, + S32 y, int iId, + bool bPressed, + bool bRepeat, + bool bReleased) { + if (bPressed) { + switch (iId) { + case ETouchInput_TabWorld: + case ETouchInput_TabGame: + // Toggle tab index + int iNewTabIndex = (iId == ETouchInput_TabWorld) ? 0 : 1; + if (m_tabIndex != iNewTabIndex) { + m_tabIndex = iNewTabIndex; + updateTooltips(); + IggyDataValue result; + IggyResult out = IggyPlayerCallMethodRS( + getMovie(), &result, IggyPlayerRootPath(getMovie()), + m_funcChangeTab, 0, NULL); + } + ui.TouchBoxRebuild(this); + break; + } + } +} + +UIControl* UIScene_LaunchMoreOptionsMenu::GetMainPanel() { + if (m_tabIndex == 0) + return &m_worldOptions; + else + return &m_gameOptions; +} +#endif + void UIScene_LaunchMoreOptionsMenu::handleCheckboxToggled(F64 controlId, bool selected) { // CD - Added for audio @@ -285,6 +393,7 @@ void UIScene_LaunchMoreOptionsMenu::handleCheckboxToggled(F64 controlId, switch ((EControls)((int)controlId)) { case eLaunchCheckbox_Online: m_params->bOnlineGame = selected; + m_bUpdateOnline = true; break; case eLaunchCheckbox_InviteOnly: m_params->bInviteOnly = selected; @@ -306,6 +415,7 @@ void UIScene_LaunchMoreOptionsMenu::handleCheckboxToggled(F64 controlId, break; case eLaunchCheckbox_HostPrivileges: m_params->bHostPrivileges = selected; + m_bUpdateCheats = true; break; case eLaunchCheckbox_ResetNether: m_params->bResetNether = selected; @@ -319,9 +429,34 @@ void UIScene_LaunchMoreOptionsMenu::handleCheckboxToggled(F64 controlId, case eLaunchCheckbox_BonusChest: m_params->bBonusChest = selected; break; +#ifdef _LARGE_WORLDS case eLaunchCheckbox_DisableSaving: m_params->bDisableSaving = selected; break; + case eLaunchCheckbox_WorldResizeType: + m_params->newWorldSizeOverwriteEdges = selected; + break; +#endif + case eLaunchCheckbox_KeepInventory: + m_params->bKeepInventory = selected; + break; + case eLaunchCheckbox_MobSpawning: + m_params->bDoMobSpawning = selected; + break; + case eLaunchCheckbox_MobLoot: + m_params->bDoMobLoot = selected; + case eLaunchCheckbox_MobGriefing: + m_params->bMobGriefing = selected; + break; + case eLaunchCheckbox_TileDrops: + m_params->bDoTileDrops = selected; + break; + case eLaunchCheckbox_NaturalRegeneration: + m_params->bNaturalRegeneration = selected; + break; + case eLaunchCheckbox_DayLightCycle: + m_params->bDoDaylightCycle = selected; + break; default: break; }; @@ -367,16 +502,43 @@ void UIScene_LaunchMoreOptionsMenu::handleFocusChange(F64 controlId, case eLaunchCheckbox_BonusChest: stringId = IDS_GAMEOPTION_BONUS_CHEST; break; -#ifdef _LARGE_WORLDS + case eLaunchCheckbox_KeepInventory: + stringId = IDS_GAMEOPTION_KEEP_INVENTORY; + break; + case eLaunchCheckbox_MobSpawning: + stringId = IDS_GAMEOPTION_MOB_SPAWNING; + break; + case eLaunchCheckbox_MobLoot: + stringId = IDS_GAMEOPTION_MOB_LOOT; // PLACEHOLDER + break; + case eLaunchCheckbox_MobGriefing: + stringId = IDS_GAMEOPTION_MOB_GRIEFING; // PLACEHOLDER + break; + case eLaunchCheckbox_TileDrops: + stringId = IDS_GAMEOPTION_TILE_DROPS; + break; + case eLaunchCheckbox_NaturalRegeneration: + stringId = IDS_GAMEOPTION_NATURAL_REGEN; + break; + case eLaunchCheckbox_DayLightCycle: + stringId = IDS_GAMEOPTION_DAYLIGHT_CYCLE; + break; case eControl_EditSeed: stringId = IDS_GAMEOPTION_SEED; break; +#ifdef _LARGE_WORLDS case eControl_WorldSize: stringId = IDS_GAMEOPTION_WORLD_SIZE; break; + case eControl_WorldResize: + stringId = IDS_GAMEOPTION_INCREASE_WORLD_SIZE; + break; case eLaunchCheckbox_DisableSaving: stringId = IDS_GAMEOPTION_DISABLE_SAVING; break; + case eLaunchCheckbox_WorldResizeType: + stringId = IDS_GAMEOPTION_INCREASE_WORLD_SIZE_OVERWRITE_EDGES; + break; #endif }; @@ -390,7 +552,10 @@ void UIScene_LaunchMoreOptionsMenu::handleFocusChange(F64 controlId, app.GetHTMLColour(eHTMLColor_White)); wsText = startTags + wsText; - m_labelDescription.setLabel(wsText); + if (m_tabIndex == TAB_WORLD_OPTIONS) + m_labelDescription_WorldOptions.setLabel(wsText); + else + m_labelDescription_GameOptions.setLabel(wsText); } void UIScene_LaunchMoreOptionsMenu::handleTimerComplete(int id) { @@ -427,8 +592,14 @@ int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(void* lpParam, pClass->m_bIgnoreInput = false; // 4J HEG - No reason to set value if keyboard was cancelled if (bRes) { +#ifdef __PSVITA__ + // CD - Changed to 2048 [SCE_IME_MAX_TEXT_LENGTH] + uint16_t pchText[2048]; + ZeroMemory(pchText, 2048 * sizeof(uint16_t)); +#else uint16_t pchText[128]; ZeroMemory(pchText, 128 * sizeof(uint16_t)); +#endif InputManager.GetText(pchText); pClass->m_editSeed.setLabel((wchar_t*)pchText); pClass->m_params->seed = (wchar_t*)pchText; @@ -487,7 +658,52 @@ void UIScene_LaunchMoreOptionsMenu::handleSliderMove(F64 sliderId, m_params->worldSize = value; m_sliderWorldSize.setLabel( app.GetString(m_iWorldSizeTitleA[value])); +#endif + break; + case eControl_WorldResize: +#ifdef _LARGE_WORLDS + EGameHostOptionWorldSize changedSize = + EGameHostOptionWorldSize(value + 1); + if (changedSize >= m_params->currentWorldSize) { + m_sliderWorldResize.handleSliderMove(value); + m_params->newWorldSize = EGameHostOptionWorldSize(value + 1); + m_sliderWorldResize.setLabel( + app.GetString(m_iWorldSizeTitleA[value])); + } #endif break; } } + +void UIScene_LaunchMoreOptionsMenu::UpdateCheats() { + bool cheatsOn = m_params->bHostPrivileges; + + m_checkboxes[eLaunchCheckbox_KeepInventory].SetEnable(cheatsOn); + m_checkboxes[eLaunchCheckbox_MobSpawning].SetEnable(cheatsOn); + m_checkboxes[eLaunchCheckbox_MobGriefing].SetEnable(cheatsOn); + m_checkboxes[eLaunchCheckbox_DayLightCycle].SetEnable(cheatsOn); + + if (!cheatsOn) { + // Set defaults + m_params->bMobGriefing = true; + m_params->bKeepInventory = false; + m_params->bDoMobSpawning = true; + m_params->bDoDaylightCycle = true; + + m_checkboxes[eLaunchCheckbox_KeepInventory].setChecked( + m_params->bKeepInventory); + m_checkboxes[eLaunchCheckbox_MobSpawning].setChecked( + m_params->bDoMobSpawning); + m_checkboxes[eLaunchCheckbox_MobGriefing].setChecked( + m_params->bMobGriefing); + m_checkboxes[eLaunchCheckbox_DayLightCycle].setChecked( + m_params->bDoDaylightCycle); + } +} + +void UIScene_LaunchMoreOptionsMenu::UpdateOnline() { + bool bOnline = m_params->bOnlineGame; + + m_checkboxes[eLaunchCheckbox_InviteOnly].SetEnable(bOnline); + m_checkboxes[eLaunchCheckbox_AllowFoF].SetEnable(bOnline); +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.h index 476776503..ca6ec1526 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.h @@ -4,6 +4,9 @@ class UIScene_LaunchMoreOptionsMenu : public UIScene { private: + static const int TAB_WORLD_OPTIONS = 0; + static const int TAB_GAME_OPTIONS = 1; + enum EControls { // Add all checkboxes at the start as they also index into a checkboxes // array @@ -20,97 +23,121 @@ private: eLaunchCheckbox_FlatWorld, eLaunchCheckbox_BonusChest, eLaunchCheckbox_DisableSaving, + eLaunchCheckbox_WorldResizeType, + eLaunchCheckbox_KeepInventory, + eLaunchCheckbox_MobSpawning, + eLaunchCheckbox_MobLoot, + eLaunchCheckbox_MobGriefing, + eLaunchCheckbox_TileDrops, + eLaunchCheckbox_NaturalRegeneration, + eLaunchCheckbox_DayLightCycle, eLaunchCheckboxes_Count, eControl_EditSeed, eControl_WorldSize, + eControl_WorldResize, + + eControl_Count }; +#ifdef __PSVITA__ + enum ETouchInput { + ETouchInput_TabWorld = eControl_Count, + ETouchInput_TabGame, + + ETouchInput_Count + }; + UIControl_Touch m_TouchTabWorld, m_TouchTabGame; + UIControl m_controlWorldPanel, m_controlGamePanel; +#endif UIControl m_gameOptions, m_worldOptions; UIControl_CheckBox m_checkboxes[eLaunchCheckboxes_Count]; UIControl_Label m_labelWorldOptions, m_labelGameOptions, m_labelDescription; - UIControl_Label m_labelSeed, m_labelRandomSeed, m_labelWorldSize; + UIControl_HTMLLabel m_labelDescription_GameOptions, + m_labelDescription_WorldOptions; + UIControl_Label m_labelSeed, m_labelRandomSeed, m_labelWorldSize, + m_labelWorldResize; UIControl_TextInput m_editSeed; UIControl_Slider m_sliderWorldSize; - IggyName m_funcSetMenuType, m_funcChangeTab; + UIControl_Slider m_sliderWorldResize; + IggyName m_funcSetMenuType, m_funcChangeTab, m_funcSetDescription; UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) - if (m_loadedResolution == eSceneResolution_1080) { - UI_MAP_ELEMENT(m_labelGameOptions, "LabelGame") - UI_MAP_ELEMENT(m_labelWorldOptions, "LabelWorld") + UI_MAP_ELEMENT(m_labelGameOptions, "LabelGame") + UI_MAP_ELEMENT(m_labelWorldOptions, "LabelWorld") - UI_MAP_ELEMENT(m_gameOptions, "GameOptions") - UI_BEGIN_MAP_CHILD_ELEMENTS(m_gameOptions) - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_Online], "CheckboxOnline") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_InviteOnly], - "CheckboxInviteOnly") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_AllowFoF], - "CheckboxAllowFoF") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_PVP], "CheckboxPVP") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_TrustSystem], - "CheckboxTrustSystem") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_FireSpreads], - "CheckboxFireSpreads") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_TNT], "CheckboxTNT") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_HostPrivileges], - "CheckboxHostPrivileges") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_ResetNether], - "CheckboxResetNether") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_DisableSaving], - "CheckboxDisableSaving") - UI_END_MAP_CHILD_ELEMENTS() + UI_MAP_ELEMENT(m_gameOptions, "GameOptions") + UI_BEGIN_MAP_CHILD_ELEMENTS(m_gameOptions) +#ifdef __PSVITA__ + UI_MAP_ELEMENT(m_TouchTabGame, "TouchTabGame") +#endif + UI_MAP_ELEMENT(m_labelDescription_GameOptions, "Description_GameOptions") - UI_MAP_ELEMENT(m_worldOptions, "WorldOptions") - UI_BEGIN_MAP_CHILD_ELEMENTS(m_worldOptions) - UI_MAP_ELEMENT(m_labelSeed, "Seed") - UI_MAP_ELEMENT(m_editSeed, "EditSeed") - UI_MAP_ELEMENT(m_labelRandomSeed, "RandomSeed") - UI_MAP_ELEMENT(m_labelWorldSize, "WorldSize") - UI_MAP_ELEMENT(m_sliderWorldSize, "WorldSizeSlider") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_Structures], - "CheckboxStructures") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_BonusChest], - "CheckboxBonusChest") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_FlatWorld], - "CheckboxFlatWorld") - UI_END_MAP_CHILD_ELEMENTS() + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_Online], "CheckboxOnline") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_InviteOnly], + "CheckboxInviteOnly") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_AllowFoF], "CheckboxAllowFoF") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_PVP], "CheckboxPVP") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_HostPrivileges], + "CheckboxHostPrivileges") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_DayLightCycle], + "CheckboxDayLightCycle") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_KeepInventory], + "CheckboxKeepInventory") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_MobSpawning], + "CheckboxMobSpawning") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_MobGriefing], + "CheckboxMobGriefing") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_MobLoot], "CheckboxMobLoot") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_TileDrops], "CheckboxTileDrops") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_NaturalRegeneration], + "CheckboxNaturalRegeneration") + UI_END_MAP_CHILD_ELEMENTS() - UI_MAP_NAME(m_funcChangeTab, L"ChangeTab") - } else { - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_Online], "CheckboxOnline") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_InviteOnly], - "CheckboxInviteOnly") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_AllowFoF], - "CheckboxAllowFoF") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_PVP], "CheckboxPVP") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_TrustSystem], - "CheckboxTrustSystem") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_FireSpreads], - "CheckboxFireSpreads") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_TNT], "CheckboxTNT") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_HostPrivileges], - "CheckboxHostPrivileges") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_ResetNether], - "CheckboxResetNether") + UI_MAP_ELEMENT(m_worldOptions, "WorldOptions") + UI_BEGIN_MAP_CHILD_ELEMENTS(m_worldOptions) +#ifdef __PSVITA__ + UI_MAP_ELEMENT(m_TouchTabWorld, "TouchTabWorld") +#endif + UI_MAP_ELEMENT(m_labelDescription_WorldOptions, "Description_WorldOptions") - UI_MAP_ELEMENT(m_labelWorldOptions, "WorldOptions") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_Structures], - "CheckboxStructures") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_FlatWorld], - "CheckboxFlatWorld") - UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_BonusChest], - "CheckboxBonusChest") - } + UI_MAP_ELEMENT(m_labelSeed, "Seed") + UI_MAP_ELEMENT(m_editSeed, "EditSeed") + UI_MAP_ELEMENT(m_labelRandomSeed, "RandomSeed") + UI_MAP_ELEMENT(m_labelWorldSize, "WorldSize") + UI_MAP_ELEMENT(m_sliderWorldSize, "WorldSizeSlider") - UI_MAP_ELEMENT(m_labelDescription, "Description") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_Structures], + "CheckboxStructures") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_BonusChest], + "CheckboxBonusChest") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_FlatWorld], "CheckboxFlatWorld") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_ResetNether], + "CheckboxResetNether") + + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_DisableSaving], + "CheckboxDisableSaving") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_TrustSystem], + "CheckboxTrustSystem") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_FireSpreads], + "CheckboxFireSpreads") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_TNT], "CheckboxTNT") + + UI_MAP_ELEMENT(m_labelWorldResize, "ResizeLabel") + UI_MAP_ELEMENT(m_sliderWorldResize, "ChangeWorldSizeSlider") + UI_MAP_ELEMENT(m_checkboxes[eLaunchCheckbox_WorldResizeType], + "CheckboxResizeType") + UI_END_MAP_CHILD_ELEMENTS() + + UI_MAP_NAME(m_funcChangeTab, L"ChangeTab") UI_MAP_NAME(m_funcSetMenuType, L"SetMenuType") UI_END_MAP_ELEMENTS_AND_NAMES() LaunchMoreOptionsMenuInitData* m_params; bool m_bMultiplayerAllowed; bool m_bIgnoreInput; - bool m_tabIndex; + int m_tabIndex; public: UIScene_LaunchMoreOptionsMenu(int iPad, void* initData, @@ -139,4 +166,17 @@ public: protected: void handleCheckboxToggled(F64 controlId, bool selected); + +private: + bool m_bUpdateCheats; // If true, update cheats on next tick + void UpdateCheats(); + + bool m_bUpdateOnline; // If true, update online settings on next tick + void UpdateOnline(); + +#ifdef __PSVITA__ + virtual void handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, + bool bPressed, bool bRepeat, bool bReleased); + virtual UIControl* GetMainPanel(); +#endif //__PSVITA__ }; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp index e61398151..9deae896d 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp @@ -14,11 +14,11 @@ const int UIScene_LeaderboardsMenu::TitleIcons [UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][7] = { {UIControl_LeaderboardList::e_ICON_TYPE_WALKED, UIControl_LeaderboardList::e_ICON_TYPE_FALLEN, Item::minecart_Id, - Item::boat_Id, 0}, - {Tile::dirt_Id, Tile::stoneBrick_Id, Tile::sand_Id, Tile::rock_Id, + Item::boat_Id, NULL}, + {Tile::dirt_Id, Tile::cobblestone_Id, Tile::sand_Id, Tile::stone_Id, Tile::gravel_Id, Tile::clay_Id, Tile::obsidian_Id}, - {Item::egg_Id, Item::wheat_Id, Tile::mushroom1_Id, Tile::reeds_Id, - Item::milk_Id, Tile::pumpkin_Id, 0}, + {Item::egg_Id, Item::wheat_Id, Tile::mushroom_brown_Id, Tile::reeds_Id, + Item::bucket_milk_Id, Tile::pumpkin_Id, NULL}, {UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIE, UIControl_LeaderboardList::e_ICON_TYPE_SKELETON, UIControl_LeaderboardList::e_ICON_TYPE_CREEPER, @@ -77,7 +77,7 @@ const UIScene_LeaderboardsMenu::LeaderboardDescriptor UIScene_LeaderboardsMenu:: UIScene_LeaderboardsMenu::UIScene_LeaderboardsMenu(int iPad, void* initData, UILayer* parentLayer) - : UIScene(iPad, parentLayer) { + : UIScene(iPad, parentLayer), m_interface(LeaderboardManager::Instance()) { // Setup all the Iggy references we need for this scene initialiseMovie(); @@ -94,8 +94,6 @@ UIScene_LeaderboardsMenu::UIScene_LeaderboardsMenu(int iPad, void* initData, // Alert the app the we want to be informed of ethernet connections app.SetLiveLinkRequired(true); - LeaderboardManager::Instance()->OpenSession(); - // GetFriends(); m_currentLeaderboard = 0; @@ -121,9 +119,6 @@ UIScene_LeaderboardsMenu::UIScene_LeaderboardsMenu(int iPad, void* initData, } UIScene_LeaderboardsMenu::~UIScene_LeaderboardsMenu() { - LeaderboardManager::Instance()->CancelOperation(); - LeaderboardManager::Instance()->CloseSession(); - // Alert the app the we no longer want to be informed of ethernet // connections app.SetLiveLinkRequired(false); @@ -200,6 +195,11 @@ std::wstring UIScene_LeaderboardsMenu::getMoviePath() { return L"LeaderboardMenu"; } +void UIScene_LeaderboardsMenu::tick() { + UIScene::tick(); + m_interface.tick(); +} + void UIScene_LeaderboardsMenu::handleReload() { // We don't allow this in splitscreen, so just go back navigateBack(); @@ -493,16 +493,16 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) { } switch (filtermode) { - case LeaderboardManager::eFM_TopRank: - LeaderboardManager::Instance()->ReadStats_TopRank( + case LeaderboardManager::eFM_TopRank: { + m_interface.ReadStats_TopRank( this, m_currentDifficulty, (LeaderboardManager::EStatsType)m_currentLeaderboard, m_newEntryIndex, m_newReadSize); - break; + } break; case LeaderboardManager::eFM_MyScore: { PlayerUID uid; ProfileManager.GetXUID(ProfileManager.GetPrimaryPad(), &uid, true); - LeaderboardManager::Instance()->ReadStats_MyScore( + m_interface.ReadStats_MyScore( this, m_currentDifficulty, (LeaderboardManager::EStatsType)m_currentLeaderboard, uid /*ignored on PS3*/, m_newReadSize); @@ -510,7 +510,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) { case LeaderboardManager::eFM_Friends: { PlayerUID uid; ProfileManager.GetXUID(ProfileManager.GetPrimaryPad(), &uid, true); - LeaderboardManager::Instance()->ReadStats_Friends( + m_interface.ReadStats_Friends( this, m_currentDifficulty, (LeaderboardManager::EStatsType)m_currentLeaderboard, uid /*ignored on PS3*/, m_newEntryIndex, m_newReadSize); @@ -537,12 +537,10 @@ bool UIScene_LeaderboardsMenu::OnStatsReadComplete( bool ret; // app.DebugPrintf("Leaderboards read %d stats\n", numResults); - if (retIn == LeaderboardManager::eStatsReturn_Success) { - m_numStats = numResults; - m_stats = results; - ret = RetrieveStats(); - } else - ret = true; + + m_numStats = numResults; + m_stats = results; + ret = RetrieveStats(); // else LeaderboardManager::Instance()->SetStatsRetrieved(false); @@ -1062,13 +1060,12 @@ void UIScene_LeaderboardsMenu::handleTimerComplete(int id) { // leaderboards unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - C4JStorage::EMessageResult result = ui.RequestMessageBox( + C4JStorage::EMessageResult result = ui.RequestErrorMessage( IDS_CONNECTION_LOST, g_NetworkManager.CorrectErrorIDS( IDS_CONNECTION_LOST_LIVE_NO_EXIT), uiIDA, 1, ProfileManager.GetPrimaryPad(), - UIScene_LeaderboardsMenu::ExitLeaderboards, this, - app.GetStringTable()); + UIScene_LeaderboardsMenu::ExitLeaderboards, this); } #endif break; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.h index a60565359..e5f72ba50 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.h @@ -82,6 +82,8 @@ private: bool m_bPopulatedOnce; bool m_bReady; + LeaderboardInterface m_interface; + UIControl_LeaderboardList m_listEntries; UIControl_Label m_labelFilter, m_labelLeaderboard, m_labelEntries, m_labelInfo; @@ -117,7 +119,8 @@ protected: virtual std::wstring getMoviePath(); public: - void handleReload(); + virtual void tick(); + virtual void handleReload(); // INPUT virtual void handleInput(int iPad, int key, bool repeat, bool pressed, diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp index 8ab9ee372..d84330c84 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp @@ -100,8 +100,10 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void* initData, m_iSaveGameInfoIndex = params->iSaveGameInfoIndex; m_levelGen = params->levelGen; - m_bGameModeSurvival = true; + m_bGameModeCreative = false; + m_iGameModeId = GameType::SURVIVAL->getId(); m_bHasBeenInCreative = false; + m_bIsSaveOwner = true; m_bSaveThumbnailReady = false; m_bRetrievingSaveThumbnail = true; @@ -113,6 +115,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void* initData, m_bRebuildTouchBoxes = false; m_bThumbnailGetFailed = false; m_seed = 0; + m_bIsCorrupt = false; m_bMultiplayerAllowed = ProfileManager.IsSignedInLive(m_iPad) && ProfileManager.AllowedToPlayMultiplayer(m_iPad); @@ -145,26 +148,22 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void* initData, } } -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 - if (getSceneResolution() == eSceneResolution_1080) { - // Set up online game checkbox - bool bOnlineGame = m_MoreOptionsParams.bOnlineGame; - m_checkboxOnline.SetEnable(true); + // Set up online game checkbox + bool bOnlineGame = m_MoreOptionsParams.bOnlineGame; + m_checkboxOnline.SetEnable(true); - // 4J-PB - to stop an offline game being able to select the online flag - if (ProfileManager.IsSignedInLive(m_iPad) == false) { - m_checkboxOnline.SetEnable(false); - } - - if (m_MoreOptionsParams.bOnlineSettingChangedBySystem) { - m_checkboxOnline.SetEnable(false); - bOnlineGame = false; - } - - m_checkboxOnline.init(app.GetString(IDS_ONLINE_GAME), - eControl_OnlineGame, bOnlineGame); + // 4J-PB - to stop an offline game being able to select the online flag + if (ProfileManager.IsSignedInLive(m_iPad) == false) { + m_checkboxOnline.SetEnable(false); } -#endif + + if (m_MoreOptionsParams.bOnlineSettingChangedBySystem) { + m_checkboxOnline.SetEnable(false); + bOnlineGame = false; + } + + m_checkboxOnline.init(app.GetString(IDS_ONLINE_GAME), eControl_OnlineGame, + bOnlineGame); // Level gen if (m_levelGen) { @@ -191,19 +190,23 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void* initData, } // Set this level as created in creative mode, so that people can't use // the themed worlds as an easy way to get achievements - m_bHasBeenInCreative = true; - m_labelCreatedMode.setLabel(app.GetString(IDS_CREATED_IN_CREATIVE)); + m_bHasBeenInCreative = m_levelGen->getLevelHasBeenInCreative(); + if (m_bHasBeenInCreative) { + m_labelCreatedMode.setLabel(app.GetString(IDS_CREATED_IN_CREATIVE)); + } else { + m_labelCreatedMode.setLabel(app.GetString(IDS_CREATED_IN_SURVIVAL)); + } } else { #if defined(__PS3__) || defined(__ORBIS__) || defined(_DURANGO) || \ defined(__PSVITA__) // convert to utf16 - std::uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; + uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; size_t srclen, dstlen; srclen = MAX_SAVEFILENAME_LENGTH; dstlen = MAX_SAVEFILENAME_LENGTH; #ifdef __PS3__ L10nResult lres = - UTF8stoUTF16s((std::uint8_t*)params->saveDetails->UTF8SaveFilename, + UTF8stoUTF16s((uint8_t*)params->saveDetails->UTF8SaveFilename, &srclen, u16Message, &dstlen); #elif defined(_DURANGO) // Already utf16 on durango @@ -213,9 +216,9 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void* initData, { SceCesUcsContext Context; sceCesUcsContextInit(&Context); - std::uint32_t utf8Len, utf16Len; + uint32_t utf8Len, utf16Len; sceCesUtf8StrToUtf16Str( - &Context, (std::uint8_t*)params->saveDetails->UTF8SaveFilename, + &Context, (uint8_t*)params->saveDetails->UTF8SaveFilename, srclen, &utf8Len, u16Message, dstlen, &utf16Len); } #endif @@ -237,20 +240,25 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void* initData, C4JStorage::ESaveGameState eLoadStatus = StorageManager.LoadSaveDataThumbnail( &pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex], - &LoadMenuThumbnailReturnedThunk, this, true); + &LoadSaveDataThumbnailReturned, + (void*)GetCallbackUniqueId(), true); #else C4JStorage::ESaveGameState eLoadStatus = StorageManager.LoadSaveDataThumbnail( &pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex], - &LoadMenuThumbnailReturnedThunk, this); + &LoadSaveDataThumbnailReturned, + (void*)GetCallbackUniqueId()); #endif m_bShowTimer = true; } #if defined(_DURANGO) m_labelGameName.init(params->saveDetails->UTF16SaveName); #else - - m_labelGameName.init(params->saveDetails->UTF8SaveName); + wchar_t wSaveName[128]; + ZeroMemory(wSaveName, 128 * sizeof(wchar_t)); + mbstowcs(wSaveName, params->saveDetails->UTF8SaveName, + strlen(params->saveDetails->UTF8SaveName) + 1); // plus null + m_labelGameName.init(wSaveName); #endif #endif } @@ -438,7 +446,8 @@ void UIScene_LoadMenu::tick() { // // dump out the thumbnail // HANDLE hThumbnail = // CreateFile("GAME:\\thumbnail.png", GENERIC_WRITE, 0, NULL, - // OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); DWORD dwBytes; + // OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); + // DWORD dwBytes; // WriteFile(hThumbnail,pbImageData,dwImageBytes,&dwBytes,NULL); // XCloseHandle(hThumbnail); // #endif @@ -471,6 +480,35 @@ void UIScene_LoadMenu::tick() { m_MoreOptionsParams.bDisableSaving = app.GetGameHostOption(uiHostOptions, eGameHostOption_DisableSaving) > 0; + m_MoreOptionsParams.currentWorldSize = + (EGameHostOptionWorldSize)app.GetGameHostOption( + uiHostOptions, eGameHostOption_WorldSize); + m_MoreOptionsParams.newWorldSize = + m_MoreOptionsParams.currentWorldSize; + + m_MoreOptionsParams.bMobGriefing = app.GetGameHostOption( + uiHostOptions, eGameHostOption_MobGriefing); + m_MoreOptionsParams.bKeepInventory = app.GetGameHostOption( + uiHostOptions, eGameHostOption_KeepInventory); + m_MoreOptionsParams.bDoMobSpawning = app.GetGameHostOption( + uiHostOptions, eGameHostOption_DoMobSpawning); + m_MoreOptionsParams.bDoMobLoot = + app.GetGameHostOption(uiHostOptions, eGameHostOption_DoMobLoot); + m_MoreOptionsParams.bDoTileDrops = app.GetGameHostOption( + uiHostOptions, eGameHostOption_DoTileDrops); + m_MoreOptionsParams.bNaturalRegeneration = app.GetGameHostOption( + uiHostOptions, eGameHostOption_NaturalRegeneration); + m_MoreOptionsParams.bDoDaylightCycle = app.GetGameHostOption( + uiHostOptions, eGameHostOption_DoDaylightCycle); + + bool cheatsOn = m_MoreOptionsParams.bHostPrivileges; + if (!cheatsOn) { + // Set defaults + m_MoreOptionsParams.bMobGriefing = true; + m_MoreOptionsParams.bKeepInventory = false; + m_MoreOptionsParams.bDoMobSpawning = true; + m_MoreOptionsParams.bDoDaylightCycle = true; + } // turn off creative mode on the save // #ifdef _DEBUG @@ -479,6 +517,11 @@ void UIScene_LoadMenu::tick() { // 0); // #endif + if (app.GetGameHostOption(uiHostOptions, + eGameHostOption_WasntSaveOwner) > 0) { + m_bIsSaveOwner = false; + } + m_bHasBeenInCreative = app.GetGameHostOption(uiHostOptions, eGameHostOption_HasBeenInCreative) > 0; @@ -491,11 +534,30 @@ void UIScene_LoadMenu::tick() { app.GetString(IDS_CREATED_IN_SURVIVAL)); } - if (app.GetGameHostOption(uiHostOptions, eGameHostOption_GameType) > - 0) { - m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_CREATIVE)); - m_bGameModeSurvival = false; - } + switch (app.GetGameHostOption(uiHostOptions, + eGameHostOption_GameType)) { + case 1: // Creative + m_buttonGamemode.setLabel( + app.GetString(IDS_GAMEMODE_CREATIVE)); + m_bGameModeCreative = true; + m_iGameModeId = GameType::CREATIVE->getId(); + break; +#ifdef _ADVENTURE_MODE_ENABLED + case 2: // Adventure + m_buttonGamemode.setLabel( + app.GetString(IDS_GAMEMODE_ADVENTURE)); + m_bGameModeCreative = false; + m_iGameModeId = GameType::ADVENTURE->getId(); + break; +#endif + case 0: // Survival + default: + m_buttonGamemode.setLabel( + app.GetString(IDS_GAMEMODE_SURVIVAL)); + m_bGameModeCreative = false; + m_iGameModeId = GameType::SURVIVAL->getId(); + break; + }; bool bGameSetting_Online = (app.GetGameSettings(m_iPad, eGameSetting_Online) != 0); @@ -559,10 +621,10 @@ void UIScene_LoadMenu::tick() { uiIDA[0] = IDS_PRO_NOTONLINE_DECLINE; // Give the player a warning about the texture pack missing - ui.RequestMessageBox(IDS_PLAY_OFFLINE, IDS_NO_PLAYSTATIONPLUS, - uiIDA, 1, ProfileManager.GetPrimaryPad(), - &UIScene_LoadMenu::ContinueOffline, this, - app.GetStringTable(), 0, 0, false); + ui.RequestAlertMessage(IDS_PLAY_OFFLINE, IDS_NO_PLAYSTATIONPLUS, + uiIDA, 1, ProfileManager.GetPrimaryPad(), + &UIScene_LoadMenu::ContinueOffline, + this); } } break; default: @@ -612,9 +674,9 @@ void UIScene_LoadMenu::handleInput(int iPad, int key, bool repeat, bool pressed, if (pressed && controlHasFocus(m_checkboxOnline.getId()) && !m_checkboxOnline.IsEnabled()) { unsigned int uiIDA[1] = {IDS_CONFIRM_OK}; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, - iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, + iPad); } #endif @@ -626,19 +688,16 @@ void UIScene_LoadMenu::handleInput(int iPad, int key, bool repeat, bool pressed, case ACTION_MENU_OTHER_STICK_DOWN: sendInputToMovie(key, repeat, pressed, released); -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 - if (getSceneResolution() == eSceneResolution_1080) { - bool bOnlineGame = m_checkboxOnline.IsChecked(); - if (m_MoreOptionsParams.bOnlineGame != bOnlineGame) { - m_MoreOptionsParams.bOnlineGame = bOnlineGame; + bool bOnlineGame = m_checkboxOnline.IsChecked(); + if (m_MoreOptionsParams.bOnlineGame != bOnlineGame) { + m_MoreOptionsParams.bOnlineGame = bOnlineGame; - if (!m_MoreOptionsParams.bOnlineGame) { - m_MoreOptionsParams.bInviteOnly = false; - m_MoreOptionsParams.bAllowFriendsOfFriends = false; - } + if (!m_MoreOptionsParams.bOnlineGame) { + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } -#endif + handled = true; break; } @@ -652,13 +711,28 @@ void UIScene_LoadMenu::handlePress(F64 controlId, F64 childId) { switch ((int)controlId) { case eControl_GameMode: - if (m_bGameModeSurvival) { - m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_CREATIVE)); - m_bGameModeSurvival = false; - } else { - m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_SURVIVAL)); - m_bGameModeSurvival = true; - } + switch (m_iGameModeId) { + case 0: // Survival + m_buttonGamemode.setLabel( + app.GetString(IDS_GAMEMODE_CREATIVE)); + m_iGameModeId = GameType::CREATIVE->getId(); + m_bGameModeCreative = true; + break; + case 1: // Creative +#ifdef _ADVENTURE_MODE_ENABLED + m_buttonGamemode.setLabel( + app.GetString(IDS_GAMEMODE_ADVENTURE)); + m_iGameModeId = GameType::ADVENTURE->getId(); + m_bGameModeCreative = false; + break; + case 2: // Adventure +#endif + m_buttonGamemode.setLabel( + app.GetString(IDS_GAMEMODE_SURVIVAL)); + m_iGameModeId = GameType::SURVIVAL->getId(); + m_bGameModeCreative = false; + break; + }; break; case eControl_MoreOptions: ui.NavigateToScene(m_iPad, eUIScene_LaunchMoreOptionsMenu, @@ -730,11 +804,10 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() { uiIDA[1] = IDS_CONFIRM_CANCEL; // Give the player a warning about the texture pack missing - ui.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, - IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, - ProfileManager.GetPrimaryPad(), - &TexturePackDialogReturned, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, + IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &TexturePackDialogReturned, this); return; } } @@ -811,21 +884,19 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() { // trial pack warning unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, - IDS_USING_TRIAL_TEXUREPACK_WARNING, uiIDA, - 1, m_iPad, - &TrialTexturePackWarningReturned, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, + IDS_USING_TRIAL_TEXUREPACK_WARNING, + uiIDA, 1, m_iPad, + &TrialTexturePackWarningReturned, this); #elif defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) // trial pack warning unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - ui.RequestMessageBox(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, - IDS_USING_TRIAL_TEXUREPACK_WARNING, uiIDA, - 2, m_iPad, - &TrialTexturePackWarningReturned, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, + IDS_USING_TRIAL_TEXUREPACK_WARNING, + uiIDA, 2, m_iPad, + &TrialTexturePackWarningReturned, this); #endif #if defined _XBOX_ONE || defined __ORBIS__ @@ -835,12 +906,46 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() { } } } + app.SetGameHostOption(eGameHostOption_WasntSaveOwner, (!m_bIsSaveOwner)); #if defined _XBOX_ONE || defined __ORBIS__ app.SetGameHostOption(eGameHostOption_DisableSaving, m_MoreOptionsParams.bDisableSaving ? 1 : 0); - StorageManager.SetSaveDisabled(m_MoreOptionsParams.bDisableSaving); + + int newWorldSize = 0; + int newHellScale = 0; + switch (m_MoreOptionsParams.newWorldSize) { + case e_worldSize_Unknown: + newWorldSize = 0; + newHellScale = 0; + break; + case e_worldSize_Classic: + newWorldSize = LEVEL_WIDTH_CLASSIC; + newHellScale = HELL_LEVEL_SCALE_CLASSIC; + break; + case e_worldSize_Small: + newWorldSize = LEVEL_WIDTH_SMALL; + newHellScale = HELL_LEVEL_SCALE_SMALL; + break; + case e_worldSize_Medium: + newWorldSize = LEVEL_WIDTH_MEDIUM; + newHellScale = HELL_LEVEL_SCALE_MEDIUM; + break; + case e_worldSize_Large: + newWorldSize = LEVEL_WIDTH_LARGE; + newHellScale = HELL_LEVEL_SCALE_LARGE; + break; + default: + assert(0); + break; + } + bool bUseMoat = !m_MoreOptionsParams.newWorldSizeOverwriteEdges; + app.SetGameNewWorldSize(newWorldSize, bUseMoat); + app.SetGameNewHellScale(newHellScale); + app.SetGameHostOption(eGameHostOption_WorldSize, + m_MoreOptionsParams.newWorldSize); + #endif #if TO_BE_IMPLEMENTED @@ -856,10 +961,9 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() { uiIDA[0] = IDS_DONT_RESET_NETHER; uiIDA[1] = IDS_RESET_NETHER; - ui.RequestMessageBox(IDS_RESETNETHER_TITLE, IDS_RESETNETHER_TEXT, uiIDA, - 2, m_iPad, - &UIScene_LoadMenu::CheckResetNetherReturned, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage( + IDS_RESETNETHER_TITLE, IDS_RESETNETHER_TEXT, uiIDA, 2, m_iPad, + &UIScene_LoadMenu::CheckResetNetherReturned, this); } else { LaunchGame(); } @@ -904,14 +1008,19 @@ void UIScene_LoadMenu::handleTimerComplete(int id) { if (bMultiplayerAllowed) { bool bGameSetting_Online = (app.GetGameSettings(m_iPad, eGameSetting_Online) != 0); - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online; + m_MoreOptionsParams.bOnlineGame = + bGameSetting_Online ? true : false; if (bGameSetting_Online) { m_MoreOptionsParams.bInviteOnly = - app.GetGameSettings(m_iPad, - eGameSetting_InviteOnly) != 0; + (app.GetGameSettings(m_iPad, + eGameSetting_InviteOnly) != 0) + ? true + : false; m_MoreOptionsParams.bAllowFriendsOfFriends = - app.GetGameSettings( - m_iPad, eGameSetting_FriendsOfFriends) != 0; + (app.GetGameSettings( + m_iPad, eGameSetting_FriendsOfFriends) != 0) + ? true + : false; } else { m_MoreOptionsParams.bInviteOnly = false; m_MoreOptionsParams.bAllowFriendsOfFriends = false; @@ -921,13 +1030,9 @@ void UIScene_LoadMenu::handleTimerComplete(int id) { m_MoreOptionsParams.bInviteOnly = false; m_MoreOptionsParams.bAllowFriendsOfFriends = false; } -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 - if (getSceneResolution() == eSceneResolution_1080) { - m_checkboxOnline.SetEnable(bMultiplayerAllowed); - m_checkboxOnline.setChecked( - m_MoreOptionsParams.bOnlineGame); - } -#endif + + m_checkboxOnline.SetEnable(bMultiplayerAllowed); + m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); m_bMultiplayerAllowed = bMultiplayerAllowed; } @@ -944,7 +1049,7 @@ void UIScene_LoadMenu::handleTimerComplete(int id) { if (pDLCInfo) { // retrieve the image - if we haven't already std::wstring textureName = - filenametostd::wstring(pDLCInfo->chImageURL); + filenametowstring(pDLCInfo->chImageURL); if (hasRegisteredSubstitutionTexture(textureName) == false) { @@ -1000,19 +1105,19 @@ void UIScene_LoadMenu::LaunchGame(void) { killTimer(CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID); #endif - if ((m_bGameModeSurvival != true || m_bHasBeenInCreative) || - m_MoreOptionsParams.bHostPrivileges) { + if ((m_bGameModeCreative == true || m_bHasBeenInCreative) || + m_MoreOptionsParams.bHostPrivileges == true) { unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - if (m_bGameModeSurvival != true || m_bHasBeenInCreative) { + if (m_bGameModeCreative == true || m_bHasBeenInCreative) { // 4J-PB - Need different text for Survival mode with a level that // has been saved in Creative - if (m_bGameModeSurvival) { - ui.RequestMessageBox( + if (!m_bGameModeCreative) { + ui.RequestAlertMessage( IDS_TITLE_START_GAME, IDS_CONFIRM_START_SAVEDINCREATIVE, uiIDA, 2, m_iPad, &UIScene_LoadMenu::ConfirmLoadReturned, - this, app.GetStringTable(), NULL, 0, false); + this); } else // it's creative mode { // has it previously been saved in creative? @@ -1026,7 +1131,8 @@ void UIScene_LoadMenu::LaunchGame(void) { // m_iPad,&CScene_LoadGameSettings::ConfirmLoadReturned,this,app.GetStringTable()); if (m_levelGen != NULL) { - LoadLevelGen(m_levelGen); + m_bIsCorrupt = false; + LoadDataComplete(this); } else { // set the save to load PSAVE_DETAILS pSaveDetails = @@ -1053,7 +1159,7 @@ void UIScene_LoadMenu::LaunchGame(void) { StorageManager.SetSaveDeviceSelected(m_iPad, false); unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( + ui.RequestErrorMessage( IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, m_iPad, &CScene_LoadGameSettings:: @@ -1065,21 +1171,21 @@ void UIScene_LoadMenu::LaunchGame(void) { } else { // ask if they're sure they want to turn this into a // creative map - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TITLE_START_GAME, IDS_CONFIRM_START_CREATIVE, uiIDA, - 2, m_iPad, &UIScene_LoadMenu::ConfirmLoadReturned, this, - app.GetStringTable(), NULL, 0, false); + 2, m_iPad, &UIScene_LoadMenu::ConfirmLoadReturned, + this); } } } else { - ui.RequestMessageBox(IDS_TITLE_START_GAME, - IDS_CONFIRM_START_HOST_PRIVILEGES, uiIDA, 2, - m_iPad, &UIScene_LoadMenu::ConfirmLoadReturned, - this, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage( + IDS_TITLE_START_GAME, IDS_CONFIRM_START_HOST_PRIVILEGES, uiIDA, + 2, m_iPad, &UIScene_LoadMenu::ConfirmLoadReturned, this); } } else { if (m_levelGen != NULL) { - LoadLevelGen(m_levelGen); + m_bIsCorrupt = false; + LoadDataComplete(this); } else { // set the save to load PSAVE_DETAILS pSaveDetails = StorageManager.ReturnSavesInfo(); @@ -1102,7 +1208,7 @@ void UIScene_LoadMenu::LaunchGame(void) { StorageManager.SetSaveDeviceSelected(m_iPad, false); unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( + ui.RequestErrorMessage( IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, m_iPad, &CScene_LoadGameSettings::DeviceRemovedDialogReturned, @@ -1124,7 +1230,7 @@ int UIScene_LoadMenu::CheckResetNetherReturned( pClass->LaunchGame(); } else if (result == C4JStorage::EMessage_ResultAccept) { // turn off the reset nether and continue - pClass->m_MoreOptionsParams.bResetNether = FALSE; + pClass->m_MoreOptionsParams.bResetNether = false; pClass->LaunchGame(); } else { // else they chose cancel @@ -1139,7 +1245,8 @@ int UIScene_LoadMenu::ConfirmLoadReturned(void* pParam, int iPad, if (result == C4JStorage::EMessage_ResultAccept) { if (pClass->m_levelGen != NULL) { - pClass->LoadLevelGen(pClass->m_levelGen); + pClass->m_bIsCorrupt = false; + pClass->LoadDataComplete(pClass); } else { // set the save to load PSAVE_DETAILS pSaveDetails = StorageManager.ReturnSavesInfo(); @@ -1163,7 +1270,7 @@ int UIScene_LoadMenu::ConfirmLoadReturned(void* pParam, int iPad, StorageManager.SetSaveDeviceSelected(m_iPad, false); unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( + ui.RequestErrorMessage( IDS_STORAGEDEVICEPROBLEM_TITLE, IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 1, m_iPad, &CScene_LoadGameSettings::DeviceRemovedDialogReturned, @@ -1215,29 +1322,27 @@ int UIScene_LoadMenu::LoadDataComplete(void* pParam) { // npAvailability isn't SCE_OK unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - iPadNotSignedInLive, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + iPadNotSignedInLive); } else { pClass->m_bIgnoreInput = true; unsigned int uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_CANCEL; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, iPadNotSignedInLive, - &UIScene_LoadMenu::MustSignInReturnedPSN, pClass, - app.GetStringTable(), NULL, 0, false); + &UIScene_LoadMenu::MustSignInReturnedPSN, pClass); } return 0; #else pClass->m_bIgnoreInput = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad()); return 0; #endif } @@ -1293,9 +1398,22 @@ int UIScene_LoadMenu::LoadDataComplete(void* pParam) { pClass->setVisible(true); pClass->m_bIgnoreInput = false; + if (ProfileManager.RequestingPlaystationPlus( + iPadWithNoPlaystationPlus)) { + // MGH - added this so we don't try and upsell when we + // don't know if the player has PS Plus yet (if it can't + // connect to the PS Plus server). + unsigned int uiIDA[1]; + uiIDA[0] = IDS_OK; + ui.RequestAlertMessage( + IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, NULL); + return 0; + } + // 4J-PB - we're not allowed to show the text Playstation Plus - // have to call the upsell all the time! upsell psplus - std::int32_t iResult = sceNpCommerceDialogInitialize(); + int32_t iResult = sceNpCommerceDialogInitialize(); SceNpCommerceDialogParam param; sceNpCommerceDialogParamInitialize(¶m); @@ -1355,9 +1473,22 @@ int UIScene_LoadMenu::LoadDataComplete(void* pParam) { pClass->setVisible(true); pClass->m_bIgnoreInput = false; + if (ProfileManager.RequestingPlaystationPlus( + iPadWithNoPlaystationPlus)) { + // MGH - added this so we don't try and upsell when we + // don't know if the player has PS Plus yet (if it can't + // connect to the PS Plus server). + unsigned int uiIDA[1]; + uiIDA[0] = IDS_OK; + ui.RequestAlertMessage( + IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, NULL); + return 0; + } + // 4J-PB - we're not allowed to show the text Playstation Plus - // have to call the upsell all the time! upsell psplus - std::int32_t iResult = sceNpCommerceDialogInitialize(); + int32_t iResult = sceNpCommerceDialogInitialize(); SceNpCommerceDialogParam param; sceNpCommerceDialogParamInitialize(¶m); @@ -1389,11 +1520,10 @@ int UIScene_LoadMenu::LoadDataComplete(void* pParam) { unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_CORRUPT_OR_DAMAGED_SAVE_TITLE, - IDS_CORRUPT_OR_DAMAGED_SAVE_TEXT, uiIDA, 2, - pClass->m_iPad, - &UIScene_LoadMenu::DeleteSaveDialogReturned, - pClass, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage( + IDS_CORRUPT_OR_DAMAGED_SAVE_TITLE, IDS_CORRUPT_OR_DAMAGED_SAVE_TEXT, + uiIDA, 2, pClass->m_iPad, + &UIScene_LoadMenu::DeleteSaveDialogReturned, pClass); } return 0; @@ -1404,6 +1534,13 @@ int UIScene_LoadMenu::LoadSaveDataReturned(void* pParam, bool bIsCorrupt, UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; pClass->m_bIsCorrupt = bIsCorrupt; + +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) + if (app.GetGameHostOption(eGameHostOption_WasntSaveOwner)) { + bIsOwner = false; + } +#endif + if (bIsOwner) { LoadDataComplete(pClass); } else { @@ -1414,10 +1551,10 @@ int UIScene_LoadMenu::LoadSaveDataReturned(void* pParam, bool bIsCorrupt, // show the message that trophies are disabled unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_SAVEDATA_COPIED_TITLE, - IDS_SAVEDATA_COPIED_TEXT, uiIDA, 1, pClass->m_iPad, - &UIScene_LoadMenu::TrophyDialogReturned, pClass, - app.GetStringTable()); + ui.RequestErrorMessage( + IDS_SAVEDATA_COPIED_TITLE, IDS_SAVEDATA_COPIED_TEXT, uiIDA, 1, + pClass->m_iPad, &UIScene_LoadMenu::TrophyDialogReturned, pClass); + app.SetGameHostOption(eGameHostOption_WasntSaveOwner, true); #endif } @@ -1459,14 +1596,22 @@ int UIScene_LoadMenu::DeleteSaveDataReturned(void* pParam, bool bSuccess) { // sign-in or not void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, int localUsersMask) { - int saveOrCheckpointId = 0; - bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); - TelemetryManager->RecordLevelResume( - pClass->m_iPad, eSen_FriendOrMatch_Playing_With_Invited_Friends, - eSen_CompeteOrCoop_Coop_and_Competitive, - app.GetGameSettings(pClass->m_iPad, eGameSetting_Difficulty), - app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount(), - saveOrCheckpointId); + if (pClass->m_levelGen == NULL) { + INT saveOrCheckpointId = 0; + bool validSave = + StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); + TelemetryManager->RecordLevelResume( + pClass->m_iPad, eSen_FriendOrMatch_Playing_With_Invited_Friends, + eSen_CompeteOrCoop_Coop_and_Competitive, + app.GetGameSettings(pClass->m_iPad, eGameSetting_Difficulty), + app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount(), + saveOrCheckpointId); + } else { + StorageManager.ResetSaveData(); + // Make our next save default to the name of the level + StorageManager.SetSaveTitle( + pClass->m_levelGen->getDefaultSaveName().c_str()); + } bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && @@ -1490,6 +1635,7 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, NetworkGameInitData* param = new NetworkGameInitData(); param->seed = pClass->m_seed; param->saveData = NULL; + param->levelGen = pClass->m_levelGen; param->texturePackId = pClass->m_MoreOptionsParams.dwTexturePack; Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -1525,16 +1671,37 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, pClass->m_MoreOptionsParams.bHostPrivileges); + app.SetGameHostOption(eGameHostOption_MobGriefing, + pClass->m_MoreOptionsParams.bMobGriefing); + app.SetGameHostOption(eGameHostOption_KeepInventory, + pClass->m_MoreOptionsParams.bKeepInventory); + app.SetGameHostOption(eGameHostOption_DoMobSpawning, + pClass->m_MoreOptionsParams.bDoMobSpawning); + app.SetGameHostOption(eGameHostOption_DoMobLoot, + pClass->m_MoreOptionsParams.bDoMobLoot); + app.SetGameHostOption(eGameHostOption_DoTileDrops, + pClass->m_MoreOptionsParams.bDoTileDrops); + app.SetGameHostOption(eGameHostOption_NaturalRegeneration, + pClass->m_MoreOptionsParams.bNaturalRegeneration); + app.SetGameHostOption(eGameHostOption_DoDaylightCycle, + pClass->m_MoreOptionsParams.bDoDaylightCycle); + +#ifdef _LARGE_WORLDS + app.SetGameHostOption(eGameHostOption_WorldSize, + pClass->m_MoreOptionsParams.worldSize + + 1); // 0 is GAME_HOST_OPTION_WORLDSIZE_UNKNOWN +#endif + // app.SetGameNewWorldSize(64, true ); + // app.SetGameNewWorldSize(0, false ); + // flag if the user wants to reset the Nether to force a Fortress with // netherwart etc. - app.SetResetNether(pClass->m_MoreOptionsParams.bResetNether); + app.SetResetNether( + (pClass->m_MoreOptionsParams.bResetNether == true) ? true : false); // clear out the app's terrain features list app.ClearTerrainFeaturePosition(); - app.SetGameHostOption(eGameHostOption_GameType, - pClass->m_bGameModeSurvival - ? GameType::SURVIVAL->getId() - : GameType::CREATIVE->getId()); + app.SetGameHostOption(eGameHostOption_GameType, pClass->m_iGameModeId); g_NetworkManager.HostGame(localUsersMask, isClientSide, isPrivate, MINECRAFT_NET_MAX_PLAYERS, 0); @@ -1554,8 +1721,8 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, UIFullscreenProgressCompletionData* completionData = new UIFullscreenProgressCompletionData(); - completionData->bShowBackground = TRUE; - completionData->bShowLogo = TRUE; + completionData->bShowBackground = true; + completionData->bShowLogo = true; completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes; completionData->iPad = DEFAULT_XUI_MENU_USER; loadingParams->completionData = completionData; @@ -1572,146 +1739,14 @@ void UIScene_LoadMenu::checkStateAndStartGame() { uiIDA[0] = IDS_DONT_RESET_NETHER; uiIDA[1] = IDS_RESET_NETHER; - ui.RequestMessageBox(IDS_RESETNETHER_TITLE, IDS_RESETNETHER_TEXT, uiIDA, - 2, m_iPad, - &UIScene_LoadMenu::CheckResetNetherReturned, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage( + IDS_RESETNETHER_TITLE, IDS_RESETNETHER_TEXT, uiIDA, 2, m_iPad, + &UIScene_LoadMenu::CheckResetNetherReturned, this); } else { LaunchGame(); } } -void UIScene_LoadMenu::LoadLevelGen(LevelGenerationOptions* levelGen) { - bool isClientSide = - ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && - m_MoreOptionsParams.bOnlineGame; - - // 4J Stu - If we only have one controller connected, then don't show the - // sign-in UI again - int connectedControllers = 0; - for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if (InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i)) - ++connectedControllers; - } - - if (!isClientSide || connectedControllers == 1 || - !RenderManager.IsHiDef()) { - // Check if user-created content is allowed, as we cannot play - // multiplayer if it's not - bool noUGC = false; - bool pccAllowed = true; - bool pccFriendsAllowed = true; - - ProfileManager.AllowedPlayerCreatedContent( - ProfileManager.GetPrimaryPad(), false, &pccAllowed, - &pccFriendsAllowed); - if (!pccAllowed && !pccFriendsAllowed) noUGC = true; - - if (isClientSide && noUGC) { - m_bIgnoreInput = false; - unsigned int uiIDA[1]; - uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_FAILED_TO_CREATE_GAME_TITLE, - IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, - uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, - NULL, app.GetStringTable(), NULL, 0, false); - return; - } - } - - int localUsersMask = 0; - - localUsersMask |= - CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad()); - // Load data from disc - // File saveFile( L"Tutorial\\Tutorial" ); - // LoadSaveFromDisk(&saveFile); - - StorageManager.ResetSaveData(); - // Make our next save default to the name of the level - StorageManager.SetSaveTitle(levelGen->getDefaultSaveName().c_str()); - - bool isPrivate = (app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) > 0) - ? true - : false; - - g_NetworkManager.HostGame(localUsersMask, isClientSide, isPrivate, - MINECRAFT_NET_MAX_PLAYERS, 0); - - NetworkGameInitData* param = new NetworkGameInitData(); - param->seed = 0; - param->saveData = NULL; - param->levelGen = levelGen; - - if (levelGen->requiresTexturePack()) { - param->texturePackId = levelGen->getRequiredTexturePackId(); - - Minecraft* pMinecraft = Minecraft::GetInstance(); - pMinecraft->skins->selectTexturePackById(param->texturePackId); - // pMinecraft->skins->updateUI(); - } - - app.SetGameHostOption(eGameHostOption_Difficulty, - Minecraft::GetInstance()->options->difficulty); - app.SetGameHostOption( - eGameHostOption_FriendsOfFriends, - app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends)); - app.SetGameHostOption( - eGameHostOption_Gamertags, - app.GetGameSettings(m_iPad, eGameSetting_GamertagsVisible)); - - app.SetGameHostOption( - eGameHostOption_BedrockFog, - app.GetGameSettings(m_iPad, eGameSetting_BedrockFog) ? 1 : 0); - - app.SetGameHostOption(eGameHostOption_PvP, m_MoreOptionsParams.bPVP); - app.SetGameHostOption(eGameHostOption_TrustPlayers, - m_MoreOptionsParams.bTrust); - app.SetGameHostOption(eGameHostOption_FireSpreads, - m_MoreOptionsParams.bFireSpreads); - app.SetGameHostOption(eGameHostOption_TNT, m_MoreOptionsParams.bTNT); - app.SetGameHostOption(eGameHostOption_HostCanFly, - m_MoreOptionsParams.bHostPrivileges); - app.SetGameHostOption(eGameHostOption_HostCanChangeHunger, - m_MoreOptionsParams.bHostPrivileges); - app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, - m_MoreOptionsParams.bHostPrivileges); - - // flag if the user wants to reset the Nether to force a Fortress with - // netherwart etc. - app.SetResetNether(m_MoreOptionsParams.bResetNether); - // clear out the app's terrain features list - app.ClearTerrainFeaturePosition(); - - app.SetGameHostOption(eGameHostOption_GameType, - m_bGameModeSurvival ? GameType::SURVIVAL->getId() - : GameType::CREATIVE->getId()); - - param->settings = app.GetGameHostOption(eGameHostOption_All); - -#ifndef _XBOX - g_NetworkManager.FakeLocalPlayerJoined(); -#endif - - LoadingInputParams* loadingParams = new LoadingInputParams(); - loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = param; - - // Reset the autosave time - app.SetAutosaveTimerTime(); - - UIFullscreenProgressCompletionData* completionData = - new UIFullscreenProgressCompletionData(); - completionData->bShowBackground = TRUE; - completionData->bShowLogo = TRUE; - completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes; - completionData->iPad = DEFAULT_XUI_MENU_USER; - loadingParams->completionData = completionData; - - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_FullscreenProgress, loadingParams); -} - int UIScene_LoadMenu::StartGame_SignInReturned(void* pParam, bool bContinue, int iPad) { UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)pParam; @@ -1761,30 +1796,27 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void* pParam, bool bContinue, // npAvailability isn't SCE_OK unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, - iPadNotSignedInLive, NULL, NULL, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + iPadNotSignedInLive); } else { pClass->m_bIgnoreInput = true; unsigned int uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_CANCEL; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, iPadNotSignedInLive, - &UIScene_LoadMenu::MustSignInReturnedPSN, pClass, - app.GetStringTable(), NULL, 0, false); + &UIScene_LoadMenu::MustSignInReturnedPSN, pClass); } return 0; #else pClass->m_bIgnoreInput = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad()); return 0; #endif } @@ -1806,21 +1838,19 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void* pParam, bool bContinue, pClass->setVisible(true); unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_FAILED_TO_CREATE_GAME_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ProfileManager.GetPrimaryPad()); } else { pClass->m_bIgnoreInput = false; pClass->setVisible(true); unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_HOST_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ProfileManager.GetPrimaryPad()); } } else { #if defined(__ORBIS__) || defined(__PSVITA__) @@ -1856,11 +1886,7 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void* pParam, bool bContinue, void UIScene_LoadMenu::handleGainFocus(bool navBack) { if (navBack) { -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 - if (getSceneResolution() == eSceneResolution_1080) { - m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); - } -#endif + m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame == true); } } @@ -1909,4 +1935,4 @@ int UIScene_LoadMenu::MustSignInReturnedPSN(void* pParam, int iPad, // pClass->m_bIgnoreInput=false; // return 0; // } -#endif +#endif \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.h index de3f68045..deb5d31b3 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.h @@ -23,9 +23,7 @@ private: UIControl_Slider m_sliderDifficulty; UIControl_BitmapIcon m_bitmapIcon; -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 UIControl_CheckBox m_checkboxOnline; -#endif UI_BEGIN_MAP_ELEMENTS_AND_NAMES(IUIScene_StartGame) UI_MAP_ELEMENT(m_controlMainPanel, "MainPanel") @@ -35,10 +33,7 @@ private: UI_MAP_ELEMENT(m_labelSeed, "Seed") UI_MAP_ELEMENT(m_texturePackList, "TexturePackSelector") UI_MAP_ELEMENT(m_buttonGamemode, "GameModeToggle") - -#if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 UI_MAP_ELEMENT(m_checkboxOnline, "CheckboxOnline") -#endif UI_MAP_ELEMENT(m_buttonMoreOptions, "MoreOptions") UI_MAP_ELEMENT(m_buttonLoadWorld, "LoadSettings") UI_MAP_ELEMENT(m_sliderDifficulty, "Difficulty") @@ -51,8 +46,10 @@ private: int m_iSaveGameInfoIndex; int m_CurrentDifficulty; - bool m_bGameModeSurvival; + bool m_bGameModeCreative; + int m_iGameModeId; bool m_bHasBeenInCreative; + bool m_bIsSaveOwner; bool m_bRetrievingSaveThumbnail; bool m_bSaveThumbnailReady; bool m_bMultiplayerAllowed; @@ -61,7 +58,7 @@ private: bool m_bRequestQuadrantSignin; bool m_bIsCorrupt; bool m_bThumbnailGetFailed; - __int64 m_seed; + int64_t m_seed; #ifdef __PS3__ std::vector* m_pvProductInfo; @@ -106,7 +103,6 @@ protected: private: void StartSharedLaunchFlow(); virtual void checkStateAndStartGame(); - void LoadLevelGen(LevelGenerationOptions* levelGen); void LaunchGame(void); #ifdef _DURANGO @@ -122,6 +118,9 @@ private: static int TrophyDialogReturned(void* pParam, int iPad, C4JStorage::EMessageResult result); static int LoadDataComplete(void* pParam); + static int LoadSaveDataThumbnailReturned(void* lpParam, + std::uint8_t* pbThumbnail, + unsigned int thumbnailBytes); static int CheckResetNetherReturned(void* pParam, int iPad, C4JStorage::EMessageResult result); static int DeleteSaveDialogReturned(void* pParam, int iPad, @@ -137,8 +136,5 @@ private: #endif public: - static int LoadSaveDataThumbnailReturned(void* lpParam, - std::uint8_t* pbThumbnail, - unsigned int thumbnailBytes); static int StartGame_SignInReturned(void* pParam, bool, int); }; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp index 94a1efa50..563124002 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp @@ -29,6 +29,7 @@ #ifdef SONY_REMOTE_STORAGE_DOWNLOAD unsigned long UIScene_LoadOrJoinMenu::m_ulFileSize = 0L; std::wstring UIScene_LoadOrJoinMenu::m_wstrStageText = L""; +bool UIScene_LoadOrJoinMenu::m_bSaveTransferRunning = false; #endif #define JOIN_LOAD_ONLINE_TIMER_ID 0 @@ -114,9 +115,9 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void* initData, m_buttonListSaves.init(eControl_SavesList); m_buttonListGames.init(eControl_GamesList); - m_labelSavesListTitle.init(app.GetString(IDS_START_GAME)); - m_labelJoinListTitle.init(app.GetString(IDS_JOIN_GAME)); - m_labelNoGames.init(app.GetString(IDS_NO_GAMES_FOUND)); + m_labelSavesListTitle.init(IDS_START_GAME); + m_labelJoinListTitle.init(IDS_JOIN_GAME); + m_labelNoGames.init(IDS_NO_GAMES_FOUND); m_labelNoGames.setVisible(false); m_controlSavesTimer.setVisible(true); m_controlJoinTimer.setVisible(true); @@ -312,6 +313,14 @@ UIScene_LoadOrJoinMenu::~UIScene_LoadOrJoinMenu() { } void UIScene_LoadOrJoinMenu::updateTooltips() { +#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ + if (m_eSaveTransferState != eSaveTransfer_Idle) { + // we're in a full screen progress for the save download here, so don't + // change the tooltips + return; + } +#endif + // update the tooltips // if the saves list has focus, then we should show the Delete Save tooltip // if the games list has focus, then we should the the View Gamercard @@ -533,6 +542,13 @@ void UIScene_LoadOrJoinMenu::tick() { } // Stop loading thumbnails if we navigate forwards if (hasFocus(m_iPad)) { +#ifdef SONY_REMOTE_STORAGE_DOWNLOAD + // if the loadOrJoin menu has focus again, we can clear the saveTransfer + // flag now. Added so we can delay the ehternet disconnect till it's + // cleaned up + if (m_eSaveTransferState == eSaveTransfer_Idle) + m_bSaveTransferRunning = false; +#endif #if defined(_XBOX_ONE) || defined(__ORBIS__) if (m_bUpdateSaveSize) { if ((m_iDefaultButtonsC > 0) && @@ -763,9 +779,8 @@ void UIScene_LoadOrJoinMenu::tick() { if (g_NetworkManager.ShouldMessageForFullSession()) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_CONNECTION_FAILED, IDS_IN_PARTY_SESSION_FULL, - uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, - NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_CONNECTION_FAILED, IDS_IN_PARTY_SESSION_FULL, + uiIDA, 1, ProfileManager.GetPrimaryPad()); } #endif @@ -897,8 +912,10 @@ void UIScene_LoadOrJoinMenu::AddDefaultButtons() { } } + // 4J-JEV: For debug. Ignore worlds with no name. + LPCWSTR wstr = levelGen->getWorldName(); + m_buttonListSaves.addItem(wstr); m_generators.push_back(levelGen); - m_buttonListSaves.addItem(levelGen->getWorldName()); if (uiTexturePackID != 0) { // increment the count of the mash-up pack worlds in the save list @@ -982,9 +999,9 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) { unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, - uiIDA, 1, iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + iPad); break; } @@ -996,11 +1013,10 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, unsigned int uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(), - &UIScene_LoadOrJoinMenu::MustSignInReturnedPSN, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_LoadOrJoinMenu::MustSignInReturnedPSN, this); } else { #ifdef __ORBIS__ SQRNetworkManager_Orbis::RecvInviteGUI(); @@ -1048,11 +1064,11 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TOOLTIPS_DELETESAVE, IDS_TEXT_DELETE_SAVE, uiIDA, 2, iPad, &UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + this); } else { if (StorageManager.EnoughSpaceForAMinSaveGame()) { unsigned int uiIDA[4]; @@ -1071,12 +1087,12 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, numOptions = 4; uiIDA[3] = IDS_COPYSAVE; #endif - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TOOLTIPS_SAVEOPTIONS, IDS_TEXT_SAVEOPTIONS, uiIDA, numOptions, iPad, &UIScene_LoadOrJoinMenu:: SaveOptionsDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + this); } else { // delete the save game // Have to ask the player if they are sure they want @@ -1084,12 +1100,12 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( - IDS_TOOLTIPS_DELETESAVE, IDS_TEXT_DELETE_SAVE, - uiIDA, 2, iPad, - &UIScene_LoadOrJoinMenu:: - DeleteSaveDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_TOOLTIPS_DELETESAVE, + IDS_TEXT_DELETE_SAVE, uiIDA, + 2, iPad, + &UIScene_LoadOrJoinMenu:: + DeleteSaveDialogReturned, + this); } } ui.PlayUISFX(eSFX_Press); @@ -1274,12 +1290,12 @@ void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId) { unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_CORRUPT_OR_DAMAGED_SAVE_TITLE, IDS_CORRUPT_OR_DAMAGED_SAVE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(), - &UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned, + this); } else #endif @@ -1315,11 +1331,10 @@ void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId) { uiIDA[1] = IDS_CONFIRM_CANCEL; m_loadMenuInitData = params; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_LOAD_SAVED_WORLD, IDS_CONFIRM_SYNC_REQUIRED, uiIDA, 2, ProfileManager.GetPrimaryPad(), - &NeedSyncMessageReturned, this, - app.GetStringTable(), NULL, 0, false); + &NeedSyncMessageReturned, this); } else #endif { @@ -1401,9 +1416,8 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; // Not allowed to play online - ui.RequestMessageBox(IDS_ONLINE_GAME, IDS_CHAT_RESTRICTION_UGC, - uiIDA, 1, m_iPad, NULL, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_ONLINE_GAME, IDS_CHAT_RESTRICTION_UGC, + uiIDA, 1, m_iPad, NULL, this); #else // Not allowed to play online ProfileManager.ShowSystemMessage( @@ -1433,18 +1447,30 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex) { // 4J Stu - This is a bit messy and is due to the library // incorrectly returning false for IsSignedInLive if the // npAvailability isn't SCE_OK - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - iPadNotSignedInLive, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + iPadNotSignedInLive); } else { - ui.RequestMessageBox( + ui.RequestErrorMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPadNotSignedInLive, - &UIScene_LoadOrJoinMenu::MustSignInReturnedPSN, this, - app.GetStringTable()); + &UIScene_LoadOrJoinMenu::MustSignInReturnedPSN, this); } return; } else if (bPlayStationPlus == false) { + if (ProfileManager.RequestingPlaystationPlus( + iPadWithNoPlaystationPlus)) { + // MGH - added this so we don't try and upsell when we don't + // know if the player has PS Plus yet (if it can't connect to + // the PS Plus server). + unsigned int uiIDA[1]; + uiIDA[0] = IDS_OK; + ui.RequestAlertMessage( + IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, NULL); + return; + } + // PS Plus upsell // 4J-PB - we're not allowed to show the text Playstation Plus - // have to call the upsell all the time! upsell psplus @@ -1518,14 +1544,24 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex) { uiIDA[1] = IDS_CONFIRM_CANCEL; // Give the player a warning about the texture pack missing - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, m_iPad, - &UIScene_LoadOrJoinMenu::TexturePackDialogReturned, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_LoadOrJoinMenu::TexturePackDialogReturned, this); return; } + +#ifdef __PSVITA__ + if (CGameNetworkManager::usingAdhocMode() && + !SQRNetworkManager_AdHoc_Vita::GetAdhocStatus()) { + // not connected to adhoc anymore, must have connected back to + // PSN to buy texture pack so sign in again + SQRNetworkManager_AdHoc_Vita::AttemptAdhocSignIn( + &UIScene_LoadOrJoinMenu::SignInAdhocReturned, this); + return; + } +#endif } m_controlJoinTimer.setVisible(false); @@ -1830,7 +1866,7 @@ void UIScene_LoadOrJoinMenu::handleTimerComplete(int id) { if (pDLCInfo) { // retrieve the image - if we haven't already std::wstring textureName = - filenametostd::wstring(pDLCInfo->chImageURL); + filenametowstring(pDLCInfo->chImageURL); if (hasRegisteredSubstitutionTexture(textureName) == false) { @@ -1879,7 +1915,7 @@ void UIScene_LoadOrJoinMenu::LoadSaveFromDisk( // Make our next save default to the name of the level StorageManager.SetSaveTitle(saveFile->getName().c_str()); - __int64 fileSize = saveFile->length(); + int64_t fileSize = saveFile->length(); FileInputStream fis(*saveFile); byteArray ba(fileSize); fis.read(ba); @@ -1945,7 +1981,7 @@ void UIScene_LoadOrJoinMenu::LoadSaveFromCloud() { strlen(app.getRemoteStorage()->getSaveNameUTF8()) + 1); // plus null StorageManager.SetSaveTitle(wSaveName); - __int64 fileSize = cloudFile.length(); + int64_t fileSize = cloudFile.length(); FileInputStream fis(cloudFile); byteArray ba(fileSize); fis.read(ba); @@ -2120,10 +2156,9 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned( unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TOOLTIPS_DELETESAVE, IDS_TEXT_DELETE_SAVE, uiIDA, 2, iPad, - &UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned, pClass, - app.GetStringTable(), NULL, 0, false); + &UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned, pClass); } break; #ifdef SONY_REMOTE_STORAGE_UPLOAD @@ -2133,10 +2168,10 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned( uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TOOLTIPS_SAVETRANSFER_UPLOAD, IDS_SAVE_TRANSFER_TEXT, uiIDA, 2, iPad, &UIScene_LoadOrJoinMenu::SaveTransferDialogReturned, - pClass, app.GetStringTable(), NULL, 0, false); + pClass); } break; #endif // SONY_REMOTE_STORAGE_UPLOAD #if defined _XBOX_ONE || defined __ORBIS__ @@ -2146,10 +2181,9 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned( uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_COPYSAVE, IDS_TEXT_COPY_SAVE, uiIDA, 2, iPad, - &UIScene_LoadOrJoinMenu::CopySaveDialogReturned, pClass, - app.GetStringTable(), NULL, 0, false); + &UIScene_LoadOrJoinMenu::CopySaveDialogReturned, pClass); } break; #endif @@ -2163,6 +2197,81 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned( return 0; } +#if defined(__PSVITA__) + +int UIScene_LoadOrJoinMenu::SignInAdhocReturned(void* pParam, bool bContinue, + int iPad) { + UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)pParam; + pClass->m_bIgnoreInput = false; + return 0; +} + +int UIScene_LoadOrJoinMenu::MustSignInTexturePack( + void* pParam, int iPad, C4JStorage::EMessageResult result) { + UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)pParam; + + if (result == C4JStorage::EMessage_ResultAccept) { + SQRNetworkManager_Vita::AttemptPSNSignIn( + &UIScene_LoadOrJoinMenu::MustSignInReturnedTexturePack, pClass); + } else { + pClass->m_bIgnoreInput = false; + } + + return 0; +} + +int UIScene_LoadOrJoinMenu::MustSignInReturnedTexturePack(void* pParam, + bool bContinue, + int iPad) { + UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)pParam; + + int commerceState = app.GetCommerceState(); + while (commerceState != CConsoleMinecraftApp::eCommerce_State_Offline && + commerceState != CConsoleMinecraftApp::eCommerce_State_Online && + commerceState != CConsoleMinecraftApp::eCommerce_State_Error) { + Sleep(10); + commerceState = app.GetCommerceState(); + } + + if (bContinue == true) { + SONYDLC* pSONYDLCInfo = app.GetSONYDLCInfo( + pClass->m_initData->selectedSession->data.texturePackParentId); + if (pSONYDLCInfo != NULL) { + char chName[42]; + char chKeyName[20]; + char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN]; + + memset(chSkuID, 0, SCE_NP_COMMERCE2_SKU_ID_LEN); + // we have to retrieve the skuid from the store info, it can't be + // hardcoded since Sony may change it. So we assume the first sku + // for the product is the one we want MGH - keyname in the DLC file + // is 16 chars long, but there's no space for a NULL terminating + // char + memset(chKeyName, 0, sizeof(chKeyName)); + strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); + +#ifdef __ORBIS__ + strcpy(chName, chKeyName); +#else + sprintf(chName, "%s-%s", app.GetCommerceCategory(), chKeyName); +#endif + app.GetDLCSkuIDFromProductList(chName, chSkuID); + // 4J-PB - need to check for an empty store + if (app.CheckForEmptyStore(iPad) == false) { + if (app.DLCAlreadyPurchased(chSkuID)) { + app.DownloadAlreadyPurchased(chSkuID); + } else { + app.Checkout(chSkuID); + } + } + } + } + pClass->m_bIgnoreInput = false; + return 0; +} + +#endif + int UIScene_LoadOrJoinMenu::TexturePackDialogReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)pParam; @@ -2171,23 +2280,53 @@ int UIScene_LoadOrJoinMenu::TexturePackDialogReturned( if (result == C4JStorage::EMessage_ResultAccept) { // we need to enable background downloading for the DLC XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); -#if TO_BE_IMPLEMENTED - ULONGLONG ullOfferID_Full; - ULONGLONG ullIndexA[1]; - app.GetDLCFullOfferIDForPackID( - pClass->m_initData->selectedSession->data.texturePackParentId, - &ullOfferID_Full); +#if defined __PSVITA__ || defined __PS3__ || defined __ORBIS__ - if (result == C4JStorage::EMessage_ResultAccept) // Full version - { - ullIndexA[0] = ullOfferID_Full; - StorageManager.InstallOffer(1, ullIndexA, NULL, NULL); +#ifdef __PSVITA__ + if (!ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && + CGameNetworkManager::usingAdhocMode()) { + // get them to sign in to online + unsigned int uiIDA[2]; + uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; + uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; + ui.RequestAlertMessage( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, + 2, ProfileManager.GetPrimaryPad(), + &UIScene_LoadOrJoinMenu::MustSignInTexturePack, pClass); + return; + } +#endif - } else // trial version - { - DLC_INFO* pDLCInfo = app.GetDLCInfoForFullOfferID(ullOfferID_Full); - ullIndexA[0] = pDLCInfo->ullOfferID_Trial; - StorageManager.InstallOffer(1, ullIndexA, NULL, NULL); + SONYDLC* pSONYDLCInfo = app.GetSONYDLCInfo( + pClass->m_initData->selectedSession->data.texturePackParentId); + if (pSONYDLCInfo != NULL) { + char chName[42]; + char chKeyName[20]; + char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN]; + + memset(chSkuID, 0, SCE_NP_COMMERCE2_SKU_ID_LEN); + // we have to retrieve the skuid from the store info, it can't be + // hardcoded since Sony may change it. So we assume the first sku + // for the product is the one we want MGH - keyname in the DLC file + // is 16 chars long, but there's no space for a NULL terminating + // char + memset(chKeyName, 0, sizeof(chKeyName)); + strncpy(chKeyName, pSONYDLCInfo->chDLCKeyname, 16); + +#ifdef __ORBIS__ + strcpy(chName, chKeyName); +#else + sprintf(chName, "%s-%s", app.GetCommerceCategory(), chKeyName); +#endif + app.GetDLCSkuIDFromProductList(chName, chSkuID); + // 4J-PB - need to check for an empty store + if (app.CheckForEmptyStore(iPad) == false) { + if (app.DLCAlreadyPurchased(chSkuID)) { + app.DownloadAlreadyPurchased(chSkuID); + } else { + app.Checkout(chSkuID); + } + } } #endif @@ -2200,16 +2339,16 @@ int UIScene_LoadOrJoinMenu::TexturePackDialogReturned( .texturePackParentId, ProductId); - StorageManager.InstallOffer( - 1, const_cast(ProductId.c_str()), NULL, NULL); + StorageManager.InstallOffer(1, (WCHAR*)ProductId.c_str(), NULL, + NULL); } else { // 4J-JEV: Fix for XB1: #165863 - XR-074: Compliance: With no // active network connection user is unable to convert from // Trial to Full texture pack and is not messaged why. unsigned int uiIDA[1] = {IDS_CONFIRM_OK}; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, - iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, + iPad); } } #endif @@ -2258,8 +2397,7 @@ int UIScene_LoadOrJoinMenu::PSN_SignInReturned(void* pParam, bool bContinue, "sceNpBasicRecvMessageCustom return %d ( %08x )\n", ret, ret); #elif defined __PSVITA__ - // TO BE IMPLEMENTED FOR VITA - PSVITA_STUBBED; + SQRNetworkManager_Vita::RecvInviteGUI(); #else SQRNetworkManager_Orbis::RecvInviteGUI(); #endif @@ -2364,9 +2502,14 @@ int UIScene_LoadOrJoinMenu::RemoteSaveNotFoundCallback( bool g_bForceVitaSaveWipe = false; int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { + m_bSaveTransferRunning = true; +#ifdef __PS3__ + StorageManager.SetSaveTransferInProgress(true); +#endif Compression::UseDefaultThreadStorage(); UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)lpParameter; pClass->m_saveTransferDownloadCancelled = false; + m_bSaveTransferRunning = true; bool bAbortCalled = false; Minecraft* pMinecraft = Minecraft::GetInstance(); bool bSaveFileCreated = false; @@ -2400,19 +2543,30 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { } if (app.getRemoteStorage()->waitingForSaveInfo() == false) { if (app.getRemoteStorage()->saveIsAvailable()) { - pClass->m_eSaveTransferState = - eSaveTransfer_CreateDummyFile; + if (app.getRemoteStorage()->saveVersionSupported()) { + pClass->m_eSaveTransferState = + eSaveTransfer_CreateDummyFile; + } else { + // must be a newer version of the save in the cloud + // that we don't support yet + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + ui.RequestAlertMessage( + IDS_TOOLTIPS_SAVETRANSFER_DOWNLOAD, + IDS_SAVE_TRANSFER_WRONG_VERSION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + RemoteSaveNotFoundCallback, pClass); + } } else { // no save available, inform the user about the // functionality unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TOOLTIPS_SAVETRANSFER_DOWNLOAD, IDS_SAVE_TRANSFER_NOT_AVAILABLE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), - RemoteSaveNotFoundCallback, pClass, - app.GetStringTable(), NULL, 0, false); + RemoteSaveNotFoundCallback, pClass); } } break; @@ -2445,10 +2599,18 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { std::uint8_t bTextMetadata[88]; ZeroMemory(bTextMetadata, 88); + unsigned int hostOptions = + app.getRemoteStorage()->getSaveHostOptions(); +#ifdef __ORBIS__ + app.SetGameHostOption( + hostOptions, eGameHostOption_WorldSize, + e_worldSize_Classic); // force the classic world size on, + // otherwise it's unknown and we + // can't expand +#endif int iTextMetadataBytes = app.CreateImageTextData( bTextMetadata, app.getRemoteStorage()->getSaveSeed(), true, - app.getRemoteStorage()->getSaveHostOptions(), - app.getRemoteStorage()->getSaveTexturePack()); + hostOptions, app.getRemoteStorage()->getSaveTexturePack()); // set the icon and save image StorageManager.SetSaveImages( @@ -2628,9 +2790,13 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { std::uint8_t bTextMetadata[88]; ZeroMemory(bTextMetadata, 88); + unsigned int remoteHostOptions = + app.getRemoteStorage()->getSaveHostOptions(); + app.SetGameHostOption(eGameHostOption_All, + remoteHostOptions); int iTextMetadataBytes = app.CreateImageTextData( bTextMetadata, app.getRemoteStorage()->getSaveSeed(), - true, app.getRemoteStorage()->getSaveHostOptions(), + true, remoteHostOptions, app.getRemoteStorage()->getSaveTexturePack()); // set the icon and save image @@ -2709,11 +2875,10 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { // complete before we hand // control back to the // player - ui.RequestMessageBox(IDS_TOOLTIPS_SAVETRANSFER_DOWNLOAD, - IDS_SAVE_TRANSFER_DOWNLOADCOMPLETE, uiIDA, - 1, ProfileManager.GetPrimaryPad(), - CrossSaveFinishedCallback, pClass, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_TOOLTIPS_SAVETRANSFER_DOWNLOAD, + IDS_SAVE_TRANSFER_DOWNLOADCOMPLETE, + uiIDA, 1, ProfileManager.GetPrimaryPad(), + CrossSaveFinishedCallback, pClass); pClass->m_eSaveTransferState = eSaveTransfer_Finished; } break; @@ -2793,12 +2958,33 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { } else { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_TOOLTIPS_SAVETRANSFER_DOWNLOAD, - IDS_SAVE_TRANSFER_DOWNLOADFAILED, - uiIDA, 1, - ProfileManager.GetPrimaryPad(), - CrossSaveFinishedCallback, pClass, - app.GetStringTable()); + UINT errorMessage = IDS_SAVE_TRANSFER_DOWNLOADFAILED; + if (!ProfileManager.IsSignedInLive( + ProfileManager.GetPrimaryPad())) { + errorMessage = + IDS_ERROR_NETWORK; // show "A network error has + // occurred." +#ifdef __ORBIS__ + if (!ProfileManager.isSignedInPSN( + ProfileManager.GetPrimaryPad())) { + errorMessage = + IDS_PRO_NOTONLINE_TEXT; // show "not signed + // into PSN" + } +#endif +#ifdef __VITA__ + if (!ProfileManager.IsSignedInPSN( + ProfileManager.GetPrimaryPad())) { + errorMessage = + IDS_PRO_NOTONLINE_TEXT; // show "not signed + // into PSN" + } +#endif + } + ui.RequestErrorMessage(IDS_TOOLTIPS_SAVETRANSFER_DOWNLOAD, + errorMessage, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + CrossSaveFinishedCallback, pClass); pClass->m_eSaveTransferState = eSaveTransfer_Finished; } if (bSaveFileCreated) // save file has been created, then @@ -2815,7 +3001,10 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { } Sleep(50); } - + m_bSaveTransferRunning = false; +#ifdef __PS3__ + StorageManager.SetSaveTransferInProgress(false); +#endif return 0; } @@ -2934,16 +3123,15 @@ int UIScene_LoadOrJoinMenu::UploadSonyCrossSaveThreadProc(void* lpParameter) { case eSaveUpload_FileDataUploaded: { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_TOOLTIPS_SAVETRANSFER_UPLOAD, - IDS_SAVE_TRANSFER_UPLOADCOMPLETE, uiIDA, 1, - ProfileManager.GetPrimaryPad(), - CrossSaveUploadFinishedCallback, pClass, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_TOOLTIPS_SAVETRANSFER_UPLOAD, + IDS_SAVE_TRANSFER_UPLOADCOMPLETE, uiIDA, + 1, ProfileManager.GetPrimaryPad(), + CrossSaveUploadFinishedCallback, pClass); pClass->m_eSaveUploadState = esaveUpload_Finished; } break; case eSaveUpload_Cancelled: // this is no longer used assert(0); // pClass->m_eSaveUploadState = - //eSaveUpload_Idle; + // eSaveUpload_Idle; break; case eSaveUpload_Error: { if (pClass->m_saveTransferUploadCancelled) { @@ -2951,11 +3139,11 @@ int UIScene_LoadOrJoinMenu::UploadSonyCrossSaveThreadProc(void* lpParameter) { } else { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_TOOLTIPS_SAVETRANSFER_UPLOAD, - IDS_SAVE_TRANSFER_UPLOADFAILED, uiIDA, - 1, ProfileManager.GetPrimaryPad(), - CrossSaveUploadFinishedCallback, - pClass, app.GetStringTable()); + ui.RequestErrorMessage( + IDS_TOOLTIPS_SAVETRANSFER_UPLOAD, + IDS_SAVE_TRANSFER_UPLOADFAILED, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + CrossSaveUploadFinishedCallback, pClass); pClass->m_eSaveUploadState = esaveUpload_Finished; } } break; @@ -2976,10 +3164,9 @@ void UIScene_LoadOrJoinMenu::SaveUploadReturned(void* lpParam, if (pClass->m_saveTransferUploadCancelled) { unsigned int uiIDA[1] = {IDS_CONFIRM_OK}; - ui.RequestMessageBox(IDS_CANCEL_UPLOAD_TITLE, IDS_CANCEL_UPLOAD_TEXT, - uiIDA, 1, ProfileManager.GetPrimaryPad(), - CrossSaveUploadFinishedCallback, pClass, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_CANCEL_UPLOAD_TITLE, IDS_CANCEL_UPLOAD_TEXT, + uiIDA, 1, ProfileManager.GetPrimaryPad(), + CrossSaveUploadFinishedCallback, pClass); pClass->m_eSaveUploadState = esaveUpload_Finished; } else { if (s == SonyRemoteStorage::e_setDataSucceeded) @@ -3101,9 +3288,20 @@ int UIScene_LoadOrJoinMenu::DownloadXbox360SaveThreadProc(void* lpParameter) { case C4JStorage::eSaveTransfer_FileDataRetrieved: switch (UIScene_LoadOrJoinMenu::s_eSaveTransferFile) { case eSaveTransferFile_Marker: - UIScene_LoadOrJoinMenu::s_eSaveTransferFile = - eSaveTransferFile_Metadata; - RequestFileSize(pStateContainer, L"metadata"); + // MGH - the marker file now contains the save file + // version number if the version is higher than we + // handle, cancel the download. + if (UIScene_LoadOrJoinMenu::s_transferData[0] > + SAVE_FILE_VERSION_NUMBER) { + pMinecraft->progressRenderer->progressStage( + IDS_SAVETRANSFER_NONE_FOUND); + pStateContainer->m_eSaveTransferState = + C4JStorage::eSaveTransfer_Idle; + } else { + UIScene_LoadOrJoinMenu::s_eSaveTransferFile = + eSaveTransferFile_Metadata; + RequestFileSize(pStateContainer, L"metadata"); + } break; case eSaveTransferFile_Metadata: { ByteArrayInputStream bais( @@ -3129,8 +3327,38 @@ int UIScene_LoadOrJoinMenu::DownloadXbox360SaveThreadProc(void* lpParameter) { byteArray ba(thumbnailSize); dis.readFully(ba); + // retrieve the seed value from the image metadata, + // we need to change to host options, then set it + // back again + bool bHostOptionsRead = false; + unsigned int uiHostOptions = 0; + DWORD dwTexturePack; + int64_t seedVal; + + char szSeed[50]; + ZeroMemory(szSeed, 50); + app.GetImageTextData( + ba.data, ba.length, (unsigned char*)&szSeed, + uiHostOptions, bHostOptionsRead, dwTexturePack); + sscanf_s(szSeed, "%I64d", &seedVal); + + app.SetGameHostOption( + uiHostOptions, eGameHostOption_WorldSize, + e_worldSize_Classic); // force the classic + // world size on, + // otherwise it's unknown + // and we can't expand + + BYTE bTextMetadata[88]; + ZeroMemory(bTextMetadata, 88); + + int iTextMetadataBytes = app.CreateImageTextData( + bTextMetadata, seedVal, true, uiHostOptions, + dwTexturePack); + // set the icon and save image StorageManager.SetSaveImages(ba.data, ba.length, - NULL, 0, NULL, 0); + NULL, 0, bTextMetadata, + iTextMetadataBytes); delete ba.data; } @@ -3234,7 +3462,7 @@ int UIScene_LoadOrJoinMenu::DownloadXbox360SaveThreadProc(void* lpParameter) { // pClass->m_iProgress=0; // pClass->m_eSaveTransferState=C4JStorage::eSaveTransfer_Idle; // pMinecraft->progressRenderer->progressStage( - //IDS_SAVE_TRANSFER_DOWNLOAD_AND_CONVERT_COMPLETE ); + // IDS_SAVE_TRANSFER_DOWNLOAD_AND_CONVERT_COMPLETE ); // break; //} @@ -3551,18 +3779,16 @@ int UIScene_LoadOrJoinMenu::CopySaveDataReturned( if (stat == C4JStorage::ESaveGame_CopyCompleteFailLocalStorage) { ui.LeaveCallbackIdCriticalSection(); - ui.RequestMessageBox(IDS_COPYSAVE_FAILED_TITLE, - IDS_COPYSAVE_FAILED_LOCAL, uiIDA, 1, - ProfileManager.GetPrimaryPad(), - CopySaveErrorDialogFinishedCallback, - lpParam, app.GetStringTable()); + ui.RequestErrorMessage( + IDS_COPYSAVE_FAILED_TITLE, IDS_COPYSAVE_FAILED_LOCAL, uiIDA, + 1, ProfileManager.GetPrimaryPad(), + CopySaveErrorDialogFinishedCallback, lpParam); } else if (stat == C4JStorage::ESaveGame_CopyCompleteFailQuota) { ui.LeaveCallbackIdCriticalSection(); - ui.RequestMessageBox(IDS_COPYSAVE_FAILED_TITLE, - IDS_COPYSAVE_FAILED_QUOTA, uiIDA, 1, - ProfileManager.GetPrimaryPad(), - CopySaveErrorDialogFinishedCallback, - lpParam, app.GetStringTable()); + ui.RequestErrorMessage( + IDS_COPYSAVE_FAILED_TITLE, IDS_COPYSAVE_FAILED_QUOTA, uiIDA, + 1, ProfileManager.GetPrimaryPad(), + CopySaveErrorDialogFinishedCallback, lpParam); } else { pClass->m_bCopying = false; ui.LeaveCallbackIdCriticalSection(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.h index 0ee57328e..740907387 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.h @@ -1,7 +1,5 @@ #pragma once -#include - #include "UIScene.h" class LevelGenerationOptions; @@ -154,6 +152,13 @@ public: static int DeleteSaveDataReturned(void* lpParam, bool bRes); static int RenameSaveDataReturned(void* lpParam, bool bRes); static int KeyboardCompleteWorldNameCallback(void* lpParam, bool bRes); +#ifdef __PSVITA__ + static int MustSignInTexturePack(void* pParam, int iPad, + C4JStorage::EMessageResult result); + static int MustSignInReturnedTexturePack(void* pParam, bool bContinue, + int iPad); + static int SignInAdhocReturned(void* pParam, bool bContinue, int iPad); +#endif protected: void handlePress(F64 controlId, F64 childId); @@ -258,8 +263,10 @@ private: eSaveTransferState m_eSaveTransferState; static unsigned long m_ulFileSize; static std::wstring m_wstrStageText; + static bool m_bSaveTransferRunning; int m_iProgress; - char m_downloadedUniqueFilename[64]; // SCE_SAVE_DATA_DIRNAME_DATA_MAXSIZE]; + char + m_downloadedUniqueFilename[64]; // SCE_SAVE_DATA_DIRNAME_DATA_MAXSIZE]; bool m_saveTransferDownloadCancelled; void LaunchSaveTransfer(); static int CreateDummySaveDataCallback(void* lpParam, bool bRes); @@ -279,6 +286,11 @@ private: static ConsoleSaveFile* SonyCrossSaveConvert(); static void CancelSaveTransferCallback(void* lpParam); + +public: + static bool isSaveTransferRunning() { return m_bSaveTransferRunning; } + +private: #endif #ifdef SONY_REMOTE_STORAGE_UPLOAD diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp index b198c2805..4a6da3114 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp @@ -12,6 +12,8 @@ Random* UIScene_MainMenu::random = new Random(); +EUIScene UIScene_MainMenu::eNavigateWhenReady = (EUIScene)-1; + UIScene_MainMenu::UIScene_MainMenu(int iPad, void* initData, UILayer* parentLayer) : UIScene(iPad, parentLayer) { @@ -30,37 +32,35 @@ UIScene_MainMenu::UIScene_MainMenu(int iPad, void* initData, m_eAction = eAction_None; m_bIgnorePress = false; - m_buttons[(int)eControl_PlayGame].init(app.GetString(IDS_PLAY_GAME), - eControl_PlayGame); + m_buttons[(int)eControl_PlayGame].init(IDS_PLAY_GAME, eControl_PlayGame); #ifdef _XBOX_ONE if (!ProfileManager.IsFullVersion()) - m_buttons[(int)eControl_PlayGame].setLabel( - app.GetString(IDS_PLAY_TRIAL_GAME)); + m_buttons[(int)eControl_PlayGame].setLabel(IDS_PLAY_TRIAL_GAME); app.SetReachedMainMenu(); #endif - m_buttons[(int)eControl_Leaderboards].init(app.GetString(IDS_LEADERBOARDS), + m_buttons[(int)eControl_Leaderboards].init(IDS_LEADERBOARDS, eControl_Leaderboards); - m_buttons[(int)eControl_Achievements].init(app.GetString(IDS_ACHIEVEMENTS), + m_buttons[(int)eControl_Achievements].init((UIString)IDS_ACHIEVEMENTS, eControl_Achievements); - m_buttons[(int)eControl_HelpAndOptions].init( - app.GetString(IDS_HELP_AND_OPTIONS), eControl_HelpAndOptions); + m_buttons[(int)eControl_HelpAndOptions].init(IDS_HELP_AND_OPTIONS, + eControl_HelpAndOptions); if (ProfileManager.IsFullVersion()) { m_bTrialVersion = false; - m_buttons[(int)eControl_UnlockOrDLC].init( - app.GetString(IDS_DOWNLOADABLECONTENT), eControl_UnlockOrDLC); + m_buttons[(int)eControl_UnlockOrDLC].init(IDS_DOWNLOADABLECONTENT, + eControl_UnlockOrDLC); } else { m_bTrialVersion = true; - m_buttons[(int)eControl_UnlockOrDLC].init( - app.GetString(IDS_UNLOCK_FULL_GAME), eControl_UnlockOrDLC); + m_buttons[(int)eControl_UnlockOrDLC].init(IDS_UNLOCK_FULL_GAME, + eControl_UnlockOrDLC); } #ifndef _DURANGO m_buttons[(int)eControl_Exit].init(app.GetString(IDS_EXIT_GAME), eControl_Exit); #else - m_buttons[(int)eControl_XboxHelp].init(app.GetString(IDS_XBOX_HELP_APP), + m_buttons[(int)eControl_XboxHelp].init(IDS_XBOX_HELP_APP, eControl_XboxHelp); #endif @@ -153,6 +153,10 @@ void UIScene_MainMenu::handleGainFocus(bool navBack) { ui.ShowPlayerDisplayname(false); m_bIgnorePress = false; + if (eNavigateWhenReady >= 0) { + return; + } + // 4J-JEV: This needs to come before SetLockedProfile(-1) as it wipes the // XbLive contexts. if (!navBack) { @@ -175,8 +179,7 @@ void UIScene_MainMenu::handleGainFocus(bool navBack) { if (navBack && ProfileManager.IsFullVersion()) { // Replace the Unlock Full Game with Downloadable Content - m_buttons[(int)eControl_UnlockOrDLC].setLabel( - app.GetString(IDS_DOWNLOADABLECONTENT)); + m_buttons[(int)eControl_UnlockOrDLC].setLabel(IDS_DOWNLOADABLECONTENT); } #if TO_BE_IMPLEMENTED @@ -223,13 +226,28 @@ void UIScene_MainMenu::handleGainFocus(bool navBack) { std::wstring UIScene_MainMenu::getMoviePath() { return L"MainMenu"; } +void UIScene_MainMenu::handleReload() { +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) + // Not allowed to exit from a PS3 game from the game - have to use the PS + // button + removeControl(&m_buttons[(int)eControl_Exit], false); + // We don't have a way to display trophies/achievements, so remove the + // button + removeControl(&m_buttons[(int)eControl_Achievements], false); +#endif +#ifdef _DURANGO + // Allowed to not have achievements in the menu + removeControl(&m_buttons[(int)eControl_Achievements], false); +#endif +} + void UIScene_MainMenu::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"); - if (m_bIgnorePress) return; + if (m_bIgnorePress || (eNavigateWhenReady >= 0)) return; #if defined(__ORBIS__) || defined(__PSVITA__) // ignore all players except player 0 - it's their profile that is currently @@ -266,7 +284,7 @@ void UIScene_MainMenu::handleInput(int iPad, int key, bool repeat, bool pressed, unsigned int uiIDA[2]; uiIDA[0] = IDS__NETWORK_PSN; uiIDA[1] = IDS_NETWORK_ADHOC; - ui.RequestMessageBox( + ui.RequestErrorMessage( IDS_SELECT_NETWORK_MODE_TITLE, IDS_SELECT_NETWORK_MODE_TEXT, uiIDA, 2, XUSER_INDEX_ANY, &UIScene_MainMenu::SelectNetworkModeReturned, this); @@ -284,7 +302,12 @@ void UIScene_MainMenu::handleInput(int iPad, int key, bool repeat, bool pressed, void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) { int primaryPad = ProfileManager.GetPrimaryPad(); +#ifdef _XBOX_ONE + int (*signInReturnedFunc)(void*, const bool, const int iPad, + const int iController) = NULL; +#else int (*signInReturnedFunc)(void*, const bool, const int iPad) = NULL; +#endif switch ((int)controlId) { case eControl_PlayGame: @@ -304,13 +327,8 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) { ui.PlayUISFX(eSFX_Press); signInReturnedFunc = &UIScene_MainMenu::CreateLoad_SignInReturned; - app.DebugPrintf( - "UIScene_MainMenu::handlePress AFTER " - "&UIScene_MainMenu::CreateLoad_SignInReturned\n"); #endif - app.DebugPrintf( - "UIScene_MainMenu::handlePress FINISH eControl_PlayGame \n"); - break; + break; case eControl_Leaderboards: // CD - Added for audio ui.PlayUISFX(eSFX_Press); @@ -345,34 +363,23 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) { signInReturnedFunc = &UIScene_MainMenu::UnlockFullGame_SignInReturned; break; +#if defined _XBOX case eControl_Exit: if (ProfileManager.IsFullVersion()) { unsigned int uiIDA[2]; uiIDA[0] = IDS_CANCEL; uiIDA[1] = IDS_OK; - ui.RequestMessageBox( + ui.RequestErrorMessage( IDS_WARNING_ARCADE_TITLE, IDS_WARNING_ARCADE_TEXT, uiIDA, 2, XUSER_INDEX_ANY, &UIScene_MainMenu::ExitGameReturned, this); - app.DebugPrintf( - "UIScene_MainMenu::handlePress AFTER " - "ui.RequestMessageBox(IDS_WARNING_ARCADE_TITLE, " - "IDS_WARNING_ARCADE_TEXT, uiIDA, 2, " - "XUSER_INDEX_ANY,&UIScene_MainMenu::ExitGameReturned,this) " - "CALL\n"); - } -#if defined _XBOX //|| _ENABLEIGGY - else { + } else { #ifdef _XBOX_ONE ui.ShowPlayerDisplayname(true); #endif ui.NavigateToScene(primaryPad, eUIScene_TrialExitUpsell); - app.DebugPrintf( - "UIScene_MainMenu::handlePress AFTER " - "ui.NavigateToScene(primaryPad,eUIScene_TrialExitUpsell) " - "CALL\n"); } -#endif break; +#endif #ifdef _DURANGO case eControl_XboxHelp: @@ -404,10 +411,9 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) { unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - ui.RequestMessageBox(IDS_MUST_SIGN_IN_TITLE, IDS_MUST_SIGN_IN_TEXT, - uiIDA, 2, primaryPad, - &UIScene_MainMenu::MustSignInReturned, this, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_MUST_SIGN_IN_TITLE, + IDS_MUST_SIGN_IN_TEXT, uiIDA, 2, primaryPad, + &UIScene_MainMenu::MustSignInReturned, this); } } } @@ -601,8 +607,13 @@ int UIScene_MainMenu::MustSignInReturnedPSN(void* pParam, int iPad, &UIScene_MainMenu::Leaderboards_SignInReturned, pClass); break; case eAction_RunGamePSN: - SQRNetworkManager_Vita::AttemptPSNSignIn( - &UIScene_MainMenu::CreateLoad_SignInReturned, pClass); + if (CGameNetworkManager::usingAdhocMode()) { + SQRNetworkManager_AdHoc_Vita::AttemptAdhocSignIn( + &UIScene_MainMenu::CreateLoad_SignInReturned, pClass); + } else { + SQRNetworkManager_Vita::AttemptPSNSignIn( + &UIScene_MainMenu::CreateLoad_SignInReturned, pClass); + } break; case eAction_RunUnlockOrDLCPSN: // CD - Must force Ad-Hoc off if they want commerce PSN sign-in @@ -650,8 +661,15 @@ int UIScene_MainMenu::MustSignInReturnedPSN(void* pParam, int iPad, } #endif +#ifdef _XBOX_ONE int UIScene_MainMenu::HelpAndOptions_SignInReturned(void* pParam, - bool bContinue, int iPad) { + bool bContinue, int iPad, + int iController) +#else +int UIScene_MainMenu::HelpAndOptions_SignInReturned(void* pParam, + bool bContinue, int iPad) +#endif +{ UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; if (bContinue) { @@ -668,7 +686,7 @@ int UIScene_MainMenu::HelpAndOptions_SignInReturned(void* pParam, #ifdef _XBOX_ONE ui.ShowPlayerDisplayname(true); #endif - ui.NavigateToScene(iPad, eUIScene_HelpAndOptionsMenu); + proceedToScene(iPad, eUIScene_HelpAndOptionsMenu); } #if TO_BE_IMPLEMENTED else { @@ -707,16 +725,22 @@ int UIScene_MainMenu::HelpAndOptions_SignInReturned(void* pParam, #ifdef _XBOX_ONE int UIScene_MainMenu::ChooseUser_SignInReturned(void* pParam, bool bContinue, - int iPad) { + int iPad, int iController) { UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; pClass->m_bIgnorePress = false; - + pClass->updateTooltips(); return 0; } #endif +#ifdef _XBOX_ONE int UIScene_MainMenu::CreateLoad_SignInReturned(void* pParam, bool bContinue, - int iPad) { + int iPad, int iController) +#else +int UIScene_MainMenu::CreateLoad_SignInReturned(void* pParam, bool bContinue, + int iPad) +#endif +{ UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; if (bContinue) { @@ -729,8 +753,8 @@ int UIScene_MainMenu::CreateLoad_SignInReturned(void* pParam, bool bContinue, if (ProfileManager.IsGuest(ProfileManager.GetPrimaryPad())) { pClass->m_bIgnorePress = false; - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); } else { ProfileManager.SetLockedProfile(ProfileManager.GetPrimaryPad()); @@ -762,9 +786,9 @@ int UIScene_MainMenu::CreateLoad_SignInReturned(void* pParam, bool bContinue, if (ProfileManager.IsGuest(iPad)) { pClass->m_bIgnorePress = false; - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, - 1); + ui.RequestErrorMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, + 1); } else { // 4J Stu - Not relevant to PS3 #ifdef _XBOX_ONE @@ -782,8 +806,8 @@ int UIScene_MainMenu::CreateLoad_SignInReturned(void* pParam, bool bContinue, #ifdef _XBOX_ONE ui.ShowPlayerDisplayname(true); #endif - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_LoadOrJoinMenu); + proceedToScene(ProfileManager.GetPrimaryPad(), + eUIScene_LoadOrJoinMenu); } else { app.SetTMSAction( iPad, @@ -793,7 +817,8 @@ int UIScene_MainMenu::CreateLoad_SignInReturned(void* pParam, bool bContinue, pClass->m_bIgnorePress = true; // We want to hide everything in this scene and // display a timer until we get a completion for the - // TMS files for(int i=0;im_bIgnorePress = false; - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); } else if (!ProfileManager.IsSignedInLive( ProfileManager.GetPrimaryPad())) { pClass->m_bIgnorePress = false; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); } else { bool bContentRestricted = false; #if defined(__PS3__) || defined(__PSVITA__) @@ -947,24 +978,23 @@ int UIScene_MainMenu::Leaderboards_SignInReturned(void* pParam, bool bContinue, #endif if (bContentRestricted) { pClass->m_bIgnorePress = false; -#if !(defined(_XBOX) || \ - defined(_WIN64)) // 4J Stu - Temp to get the win build running, but so we - // check this for other platforms +#if !(defined(_XBOX) || defined(_WINDOWS64) || \ + defined(_XBOX_ONE)) // 4J Stu - Temp to get the win build running, but so + // we check this for other platforms // you can't see leaderboards unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad()); #endif } else { ProfileManager.SetLockedProfile(ProfileManager.GetPrimaryPad()); #ifdef _XBOX_ONE ui.ShowPlayerDisplayname(true); #endif - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_LeaderboardsMenu); + proceedToScene(ProfileManager.GetPrimaryPad(), + eUIScene_LeaderboardsMenu); } } } else { @@ -982,8 +1012,14 @@ int UIScene_MainMenu::Leaderboards_SignInReturned(void* pParam, bool bContinue, return 0; } +#ifdef _XBOX_ONE int UIScene_MainMenu::Achievements_SignInReturned(void* pParam, bool bContinue, - int iPad) { + int iPad, int iController) +#else +int UIScene_MainMenu::Achievements_SignInReturned(void* pParam, bool bContinue, + int iPad) +#endif +{ UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; if (bContinue) { @@ -1009,8 +1045,15 @@ int UIScene_MainMenu::Achievements_SignInReturned(void* pParam, bool bContinue, return 0; } +#ifdef _XBOX_ONE int UIScene_MainMenu::UnlockFullGame_SignInReturned(void* pParam, - bool bContinue, int iPad) { + bool bContinue, int iPad, + int iController) +#else +int UIScene_MainMenu::UnlockFullGame_SignInReturned(void* pParam, + bool bContinue, int iPad) +#endif +{ UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; if (bContinue) { @@ -1036,9 +1079,9 @@ int UIScene_MainMenu::UnlockFullGame_SignInReturned(void* pParam, return 0; } -#ifdef _DURANGO +#ifdef _XBOX_ONE int UIScene_MainMenu::XboxHelp_SignInReturned(void* pParam, bool bContinue, - int iPad) { + int iPad, int iController) { UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; if (bContinue) { @@ -1070,8 +1113,6 @@ int UIScene_MainMenu::ExitGameReturned(void* pParam, int iPad, if (result == C4JStorage::EMessage_ResultDecline) { // XLaunchNewImage(XLAUNCH_KEYWORD_DASH_ARCADE, 0); app.ExitGame(); - app.DebugPrintf( - "UIScene_MainMenu::ExitGameReturned AFTER app.ExitGame() CALL\n"); } return 0; @@ -1131,10 +1172,10 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_PlayGame( if (pClass->m_errorCode == SCE_NP_ERROR_AGE_RESTRICTION) { unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, - uiIDA, 1, ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::PlayOfflineReturned, pClass, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + &UIScene_MainMenu::PlayOfflineReturned, pClass); return; } @@ -1156,10 +1197,9 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_PlayGame( unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - ui.RequestMessageBox(IDS_MUST_SIGN_IN_TITLE, IDS_MUST_SIGN_IN_TEXT, - uiIDA, 2, primaryPad, - &UIScene_MainMenu::MustSignInReturned, pClass, - app.GetStringTable()); + ui.RequestErrorMessage( + IDS_MUST_SIGN_IN_TITLE, IDS_MUST_SIGN_IN_TEXT, uiIDA, 2, + primaryPad, &UIScene_MainMenu::MustSignInReturned, pClass); } } } @@ -1221,9 +1261,9 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_Leaderboards( if (pClass->m_errorCode == SCE_NP_ERROR_AGE_RESTRICTION) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, - uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, - pClass, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), nullptr, pClass); return; } @@ -1243,10 +1283,9 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_Leaderboards( unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - ui.RequestMessageBox(IDS_MUST_SIGN_IN_TITLE, IDS_MUST_SIGN_IN_TEXT, - uiIDA, 2, primaryPad, - &UIScene_MainMenu::MustSignInReturned, pClass, - app.GetStringTable()); + ui.RequestErrorMessage( + IDS_MUST_SIGN_IN_TITLE, IDS_MUST_SIGN_IN_TEXT, uiIDA, 2, + primaryPad, &UIScene_MainMenu::MustSignInReturned, pClass); } } } @@ -1282,8 +1321,8 @@ void UIScene_MainMenu::RunPlayGame(int iPad) { uiIDA[0] = IDS_OK; m_bIgnorePress = false; - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); } else { ProfileManager.SetLockedProfile(iPad); @@ -1336,12 +1375,11 @@ void UIScene_MainMenu::RunPlayGame(int iPad) { if (CGameNetworkManager::usingAdhocMode()) { uiIDA[0] = IDS_NETWORK_ADHOC; // this should be "Connect to adhoc network" - ui.RequestMessageBox( + ui.RequestErrorMessage( IDS_PRO_NOTADHOCONLINE_TITLE, IDS_PRO_NOTADHOCONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::MustSignInReturnedPSN, this, - app.GetStringTable()); + &UIScene_MainMenu::MustSignInReturnedPSN, this); } else { /* 4J-PB - Add this after release // Determine why they're not "signed in live" @@ -1367,18 +1405,16 @@ void UIScene_MainMenu::RunPlayGame(int iPad) { &UIScene_MainMenu::MustSignInReturnedPSN, this, app.GetStringTable()); return; } */ - ui.RequestMessageBox( + ui.RequestErrorMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::MustSignInReturnedPSN, this, - app.GetStringTable()); + &UIScene_MainMenu::MustSignInReturnedPSN, this); } #else - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, iPad, - &UIScene_MainMenu::MustSignInReturnedPSN, - this, app.GetStringTable()); + ui.RequestErrorMessage( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, + iPad, &UIScene_MainMenu::MustSignInReturnedPSN, this); #endif #elif defined __ORBIS__ @@ -1391,20 +1427,19 @@ void UIScene_MainMenu::RunPlayGame(int iPad) { unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, - IDS_ERROR_NETWORK, uiIDA, 1, iPad, - UIScene_MainMenu::PlayOfflineReturned, - this, app.GetStringTable()); + ui.RequestErrorMessage( + IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, + iPad, UIScene_MainMenu::PlayOfflineReturned, this); } else { m_eAction = eAction_RunGamePSN; // Not signed in to PSN unsigned int uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, - 2, iPad, &UIScene_MainMenu::MustSignInReturnedPSN, this, - app.GetStringTable(), NULL, 0, false); + 2, iPad, &UIScene_MainMenu::MustSignInReturnedPSN, + this); return; } #else @@ -1412,8 +1447,8 @@ void UIScene_MainMenu::RunPlayGame(int iPad) { #ifdef _XBOX_ONE ui.ShowPlayerDisplayname(true); #endif - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_LoadOrJoinMenu); + proceedToScene(ProfileManager.GetPrimaryPad(), + eUIScene_LoadOrJoinMenu); #endif } else { #ifdef _XBOX_ONE @@ -1488,8 +1523,8 @@ void UIScene_MainMenu::RunPlayGame(int iPad) { #ifdef _XBOX_ONE ui.ShowPlayerDisplayname(true); #endif - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_LoadOrJoinMenu); + proceedToScene(ProfileManager.GetPrimaryPad(), + eUIScene_LoadOrJoinMenu); #endif } } else { @@ -1530,18 +1565,17 @@ void UIScene_MainMenu::RunLeaderboards(int iPad) { // guests can't look at leaderboards if (ProfileManager.IsGuest(iPad)) { - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); } else if (!ProfileManager.IsSignedInLive(iPad)) { #if defined __PS3__ || defined __PSVITA__ m_eAction = eAction_RunLeaderboardsPSN; // get them to sign in to online unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, - uiIDA, 1, ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::MustSignInReturnedPSN, this, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, + uiIDA, 1, ProfileManager.GetPrimaryPad(), + &UIScene_MainMenu::MustSignInReturnedPSN, this); /* 4J-PB - Add this after release #elif defined __PSVITA__ @@ -1573,23 +1607,21 @@ IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, - uiIDA, 1, iPad, NULL, NULL, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, + uiIDA, 1, iPad); } else { // Not signed in to PSN unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::MustSignInReturnedPSN, this, - app.GetStringTable()); + ui.RequestErrorMessage( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + &UIScene_MainMenu::MustSignInReturnedPSN, this); return; } #else - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); #endif } else { // we're supposed to check for parental control restrictions before @@ -1608,16 +1640,15 @@ IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), &bContentRestricted, NULL); #endif if (bContentRestricted) { -#if !(defined(_XBOX) || \ - defined(_WIN64)) // 4J Stu - Temp to get the win build running, but so we - // check this for other platforms +#if !(defined(_XBOX) || defined(_WINDOWS64) || \ + defined(_XBOX_ONE)) // 4J Stu - Temp to get the win build running, but so + // we check this for other platforms // you can't see leaderboards unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, this, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, this); #endif } else { ProfileManager.SetLockedProfile(iPad); @@ -1629,7 +1660,7 @@ IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), #ifdef _XBOX_ONE ui.ShowPlayerDisplayname(true); #endif - ui.NavigateToScene(iPad, eUIScene_LeaderboardsMenu); + proceedToScene(iPad, eUIScene_LeaderboardsMenu); } } } @@ -1684,10 +1715,9 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { m_bIgnorePress = false; unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, - ProfileManager.GetPrimaryPad(), nullptr, this, - app.GetStringTable()); + ui.RequestErrorMessage( + IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), nullptr, this); return; } @@ -1696,8 +1726,8 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { if (ProfileManager.IsSignedInLive(iPad)) { if (ProfileManager.IsGuest(iPad)) { m_bIgnorePress = false; - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); } else { // If the player was signed in before selecting play, we'll not // have read the profile yet, so query the sign-in status to get @@ -1715,24 +1745,24 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { #endif if (bContentRestricted) { m_bIgnorePress = false; -#if !(defined(_XBOX) || \ - defined( \ - _WIN64)) // 4J Stu - Temp to get the win build running, but so we - // check this for other platforms you can't see the store +#if !(defined(_XBOX) || defined(_WINDOWS64) || \ + defined(_XBOX_ONE)) // 4J Stu - Temp to get the win build running, but so + // we check this for other platforms + // you can't see the store unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, - ProfileManager.GetPrimaryPad(), - NULL, this, app.GetStringTable()); + ui.RequestErrorMessage( + IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, + uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, + this); #endif } else { ProfileManager.SetLockedProfile(iPad); #ifdef _XBOX_ONE ui.ShowPlayerDisplayname(true); #endif - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_DLCMainMenu); + proceedToScene(ProfileManager.GetPrimaryPad(), + eUIScene_DLCMainMenu); } } #if defined _XBOX_ONE @@ -1773,11 +1803,10 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; // uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::MustSignInReturnedPSN, this, - app.GetStringTable()); + ui.RequestErrorMessage( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + &UIScene_MainMenu::MustSignInReturnedPSN, this); #elif defined __ORBIS__ m_eAction = eAction_RunUnlockOrDLCPSN; // Determine why they're not "signed in live" @@ -1788,44 +1817,41 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, - uiIDA, 1, iPad, NULL, NULL, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_ERROR_NETWORK_TITLE, + IDS_ERROR_NETWORK, uiIDA, 1, iPad); } else { // Not signed in to PSN unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::MustSignInReturnedPSN, - this, app.GetStringTable()); + ui.RequestErrorMessage( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + &UIScene_MainMenu::MustSignInReturnedPSN, this); return; } #else unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); #endif } } else { // guests can't buy the game if (ProfileManager.IsGuest(iPad)) { m_bIgnorePress = false; - ui.RequestMessageBox(IDS_UNLOCK_TITLE, IDS_UNLOCK_GUEST_TEXT, uiIDA, - 1, iPad); + ui.RequestErrorMessage(IDS_UNLOCK_TITLE, IDS_UNLOCK_GUEST_TEXT, + uiIDA, 1, iPad); } else if (!ProfileManager.IsSignedInLive(iPad)) { #if defined(__PS3__) || defined(__PSVITA__) m_eAction = eAction_RunUnlockOrDLCPSN; // get them to sign in to online unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::MustSignInReturnedPSN, this, - app.GetStringTable()); + ui.RequestErrorMessage( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + &UIScene_MainMenu::MustSignInReturnedPSN, this); #elif defined __ORBIS__ m_eAction = eAction_RunUnlockOrDLCPSN; // Determine why they're not "signed in live" @@ -1836,25 +1862,23 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, - uiIDA, 1, iPad, NULL, NULL, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_ERROR_NETWORK_TITLE, + IDS_ERROR_NETWORK, uiIDA, 1, iPad); } else { // Not signed in to PSN unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::MustSignInReturnedPSN, - this, app.GetStringTable()); + ui.RequestErrorMessage( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + &UIScene_MainMenu::MustSignInReturnedPSN, this); return; } #else unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1); #endif } else { @@ -1884,6 +1908,7 @@ void UIScene_MainMenu::tick() { UIScene::tick(); #if !defined(_ENABLEIGGY) && !defined(ENABLE_JAVA_GUIS) + // 4jcraft { static int s_mainMenuTickCount = 0; s_mainMenuTickCount++; @@ -1891,8 +1916,8 @@ void UIScene_MainMenu::tick() { fprintf(stderr, "[MM] tick %d\n", s_mainMenuTickCount); fflush(stderr); } - if (s_mainMenuTickCount == 90) // ~3 seconds at 30fps - { + // ~3 seconds at 30fps + if (s_mainMenuTickCount == 90) { fprintf(stderr, "[Linux] Auto-starting trial world from MainMenu after %d " "ticks\n", @@ -1903,6 +1928,59 @@ void UIScene_MainMenu::tick() { } #endif + if ((eNavigateWhenReady >= 0)) { + int lockedProfile = ProfileManager.GetLockedProfile(); + +#ifdef _DURANGO + // 4J-JEV: DLC menu contains text localised to system language + // which we can't change. We need to switch to + // this language in-case it uses a different font. + if (eNavigateWhenReady == eUIScene_DLCMainMenu) + setLanguageOverride(false); + + bool isSignedIn; + C4JStorage::eOptionsCallback status; + bool pendingFontChange; + if (lockedProfile >= 0) { + isSignedIn = ProfileManager.IsSignedIn(lockedProfile); + status = app.GetOptionsCallbackStatus(lockedProfile); + pendingFontChange = ui.PendingFontChange(); + + if (status == C4JStorage::eOptions_Callback_Idle) { + // make sure the TMS banned list data is ditched - the player + // may have gone in to help & options, backed out, and signed + // out + app.InvalidateBannedList(lockedProfile); + + // need to ditch any DLCOffers info + StorageManager.ClearDLCOffers(); + app.ClearAndResetDLCDownloadQueue(); + app.ClearDLCInstalled(); + } + } + + if ((lockedProfile >= 0) && isSignedIn && + ((status == C4JStorage::eOptions_Callback_Read) || + (status == C4JStorage::eOptions_Callback_Write)) && + !pendingFontChange) +#endif + { + app.DebugPrintf("[MainMenu] Navigating away from MainMenu.\n"); + ui.NavigateToScene(lockedProfile, eNavigateWhenReady); + eNavigateWhenReady = (EUIScene)-1; + } +#ifdef _DURANGO + else { + app.DebugPrintf( + "[MainMenu] Delaying navigation: lockedProfile=%i, %s, " + "status=%ls, %s.\n", + lockedProfile, isSignedIn ? "SignedIn" : "SignedOut", + app.toStringOptionsStatus(status).c_str(), + pendingFontChange ? "Pending font change" : "font OK"); + } +#endif + } + #if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) if (m_bLaunchFullVersionPurchase) { int iCommerceState = app.GetCommerceState(); @@ -1922,10 +2000,9 @@ void UIScene_MainMenu::tick() { if (bContentRestricted) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, this, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad()); } else { TelemetryManager->RecordUpsellPresented( ProfileManager.GetPrimaryPad(), @@ -1952,17 +2029,16 @@ void UIScene_MainMenu::tick() { if (app.GetTMSDLCInfoRead()) { m_bWaitingForDLCInfo = false; ProfileManager.SetLockedProfile(m_iPad); - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_DLCMainMenu); + proceedToScene(ProfileManager.GetPrimaryPad(), + eUIScene_DLCMainMenu); } } if (g_NetworkManager.ShouldMessageForFullSession()) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_CONNECTION_FAILED, IDS_IN_PARTY_SESSION_FULL, - uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, - NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_CONNECTION_FAILED, IDS_IN_PARTY_SESSION_FULL, + uiIDA, 1, ProfileManager.GetPrimaryPad()); } #endif @@ -1984,11 +2060,11 @@ void UIScene_MainMenu::tick() { // give the option of continuing offline unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION_PATCH_AVAILABLE, - uiIDA, 1, ProfileManager.GetPrimaryPad(), - &UIScene_MainMenu::PlayOfflineReturned, - this, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION_PATCH_AVAILABLE, + uiIDA, 1, ProfileManager.GetPrimaryPad(), + &UIScene_MainMenu::PlayOfflineReturned, + this); } m_bErrorDialogRunning = false; } @@ -2010,8 +2086,8 @@ void UIScene_MainMenu::RunAchievements(int iPad) { // guests can't look at achievements if (ProfileManager.IsGuest(iPad)) { - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); } else { XShowAchievementsUI(iPad); } @@ -2022,8 +2098,8 @@ void UIScene_MainMenu::RunHelpAndOptions(int iPad) { if (ProfileManager.IsGuest(iPad)) { unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1); } else { // If the player was signed in before selecting play, we'll not have // read the profile yet, so query the sign-in status to get this to @@ -2039,7 +2115,7 @@ void UIScene_MainMenu::RunHelpAndOptions(int iPad) { #ifdef _XBOX_ONE ui.ShowPlayerDisplayname(true); #endif - ui.NavigateToScene(iPad, eUIScene_HelpAndOptionsMenu); + proceedToScene(iPad, eUIScene_HelpAndOptionsMenu); } #if TO_BE_IMPLEMENTED else { @@ -2076,6 +2152,7 @@ void UIScene_MainMenu::LoadTrial(void) { // No saving in the trial StorageManager.SetSaveDisabled(true); + app.SetGameHostOption(eGameHostOption_WasntSaveOwner, false); // Set the global flag, so that we don't disable saving again once the save // is complete @@ -2100,18 +2177,11 @@ void UIScene_MainMenu::LoadTrial(void) { app.GetGameHostOption(eGameHostOption_DisableSaving); std::vector* generators = app.getLevelGenerators(); - if (generators->empty()) { - app.DebugPrintf( - "LoadTrial: no level generators available, cannot start " - "tutorial\n"); - delete param; - return; - } param->levelGen = generators->at(0); LoadingInputParams* loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = param; + loadingParams->lpParam = (void*)param; UIFullscreenProgressCompletionData* completionData = new UIFullscreenProgressCompletionData(); @@ -2131,8 +2201,8 @@ void UIScene_MainMenu::LoadTrial(void) { } void UIScene_MainMenu::handleUnlockFullVersion() { - m_buttons[(int)eControl_UnlockOrDLC].setLabel( - app.GetString(IDS_DOWNLOADABLECONTENT), true); + m_buttons[(int)eControl_UnlockOrDLC].setLabel(IDS_DOWNLOADABLECONTENT, + true); } #ifdef __PSVITA__ diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.h index 1d2a14c90..143797f46 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.h @@ -88,6 +88,14 @@ private: }; eActions m_eAction; +private: + // 4J-JEV: Delay navigation until font changes. + static EUIScene eNavigateWhenReady; + + static void proceedToScene(int iPad, EUIScene eScene) { + eNavigateWhenReady = eScene; + } + public: UIScene_MainMenu(int iPad, void* initData, UILayer* parentLayer); virtual ~UIScene_MainMenu(); @@ -111,6 +119,7 @@ protected: public: virtual void tick(); + virtual void handleReload(); // INPUT virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool& handled); @@ -136,9 +145,28 @@ private: static void LoadTrial(); #ifdef _XBOX_ONE - static int ChooseUser_SignInReturned(void* pParam, bool bContinue, - int iPad); -#endif + static int ChooseUser_SignInReturned(void* pParam, bool bContinue, int iPad, + int iController); + static int CreateLoad_SignInReturned(void* pParam, bool bContinue, int iPad, + int iController); + static int HelpAndOptions_SignInReturned(void* pParam, bool bContinue, + int iPad, int iController); + static int Achievements_SignInReturned(void* pParam, bool bContinue, + int iPad, int iController); + static int MustSignInReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result); + + static int Leaderboards_SignInReturned(void* pParam, bool bContinue, + int iPad, int iController); + static int UnlockFullGame_SignInReturned(void* pParam, bool bContinue, + int iPad, int iController); + static int ExitGameReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result); + + static int XboxHelp_SignInReturned(void* pParam, bool bContinue, int iPad, + int iController); +#else + static int CreateLoad_SignInReturned(void* pParam, bool bContinue, int iPad); static int HelpAndOptions_SignInReturned(void* pParam, bool bContinue, @@ -168,9 +196,6 @@ private: static int PlayOfflineReturned(void* pParam, int iPad, C4JStorage::EMessageResult result); #endif - -#ifdef _DURANGO - static int XboxHelp_SignInReturned(void* pParam, bool bContinue, int iPad); #endif #ifdef __PSVITA__ diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.h b/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.h index 434a67f3a..e2c978561 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.h @@ -41,6 +41,7 @@ public: // Returns true if lower scenes in this scenes layer, or in any layer below // this scenes layers should be hidden virtual bool hidesLowerScenes() { return false; } + virtual bool blocksInput() { return true; } protected: // TODO: This should be pure virtual in this class diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_PauseMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_PauseMenu.cpp index a618277c4..d29a90e21 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_PauseMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_PauseMenu.cpp @@ -440,9 +440,9 @@ void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, // IsSignedInLive is the npAvailability isn't SCE_OK unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, - uiIDA, 1, iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, + 1, iPad); } else // Determine why they're not "signed in live" if (ProfileManager.isSignedInPSN(iPad)) { @@ -452,28 +452,27 @@ void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, - IDS_ERROR_NETWORK, uiIDA, 1, - iPad, NULL, NULL, - app.GetStringTable()); + ui.RequestErrorMessage(IDS_ERROR_NETWORK_TITLE, + IDS_ERROR_NETWORK, uiIDA, 1, + iPad); } else { // Not signed in to PSN unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, - &UIScene_PauseMenu::MustSignInReturnedPSN, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_PauseMenu::MustSignInReturnedPSN, + (LPVOID)GetCallbackUniqueId()); } #else // __PS3__ // get them to sign in to online unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, &UIScene_PauseMenu::MustSignInReturnedPSN, - this, app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); #endif } else { #ifdef __ORBIS__ @@ -515,11 +514,11 @@ void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_ACTION_BAN_LEVEL_TITLE, IDS_ACTION_BAN_LEVEL_DESCRIPTION, uiIDA, 2, iPad, - &UIScene_PauseMenu::BanGameDialogReturned, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_PauseMenu::BanGameDialogReturned, + (LPVOID)GetCallbackUniqueId()); // rfHandled = TRUE; } @@ -552,10 +551,9 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { // 4J Gordon: Being used for the leaderboards proper now // guests can't look at leaderboards if (ProfileManager.IsGuest(m_iPad)) { - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad()); } else if (!ProfileManager.IsSignedInLive(m_iPad)) { #ifdef __ORBIS__ // If a patch is available, can't show leaderboard @@ -569,9 +567,9 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { if (errorCode == SCE_NP_ERROR_AGE_RESTRICTION) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, - uiIDA, 1, m_iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + m_iPad); break; ; @@ -584,11 +582,11 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { m_eAction = eAction_ViewLeaderboardsPSN; unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, ProfileManager.GetPrimaryPad(), - &UIScene_PauseMenu::MustSignInReturnedPSN, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_PauseMenu::MustSignInReturnedPSN, + (LPVOID)GetCallbackUniqueId()); #elif defined(__ORBIS__) m_eAction = eAction_ViewLeaderboardsPSN; int npAvailability = ProfileManager.getNPAvailability(m_iPad); @@ -598,9 +596,9 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { // npAvailability isn't SCE_OK unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, - uiIDA, 1, m_iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + m_iPad); } else // Determine why they're not "signed in live" if (ProfileManager.isSignedInPSN(m_iPad)) { @@ -612,24 +610,24 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox( - IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, - 1, m_iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ERROR_NETWORK_TITLE, + IDS_ERROR_NETWORK, uiIDA, 1, + m_iPad); } else { // Not signed in to PSN unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, m_iPad, - &UIScene_PauseMenu::MustSignInReturnedPSN, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_PauseMenu::MustSignInReturnedPSN, + (LPVOID)GetCallbackUniqueId()); } #else unsigned int uiIDA[1] = {IDS_OK}; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, - m_iPad); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, + m_iPad); #endif } else { bool bContentRestricted = false; @@ -638,16 +636,15 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { m_iPad, true, NULL, &bContentRestricted, NULL); #endif if (bContentRestricted) { -#if !(defined(_XBOX) || \ - defined(_WIN64)) // 4J Stu - Temp to get the win build running, but so we - // check this for other platforms +#if !(defined(_XBOX) || defined(_WINDOWS64) || \ + defined(_XBOX_ONE)) // 4J Stu - Temp to get the win build running, but so + // we check this for other platforms // you can't see leaderboards unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, - m_iPad, NULL, this, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + m_iPad); #endif } else { ui.NavigateToScene(m_iPad, eUIScene_LeaderboardsMenu); @@ -667,10 +664,9 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { if (ProfileManager.IsGuest(pNotifyPressData->UserIndex)) { unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad()); } else { XShowAchievementsUI(pNotifyPressData->UserIndex); } @@ -708,43 +704,41 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { uiIDA[2] = IDS_EXIT_GAME_NO_SAVE; if (g_NetworkManager.GetPlayerCount() > 1) { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, m_iPad, &UIScene_PauseMenu::ExitGameSaveDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } else { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, m_iPad, &UIScene_PauseMenu::ExitGameSaveDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } } else if (g_NetworkManager.IsHost() && g_NetworkManager.GetPlayerCount() > 1) { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT, uiIDA, 2, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned, - dynamic_cast(this), - app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } else { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned, - dynamic_cast(this), - app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } #else if (StorageManager.GetSaveDisabled()) { uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, m_iPad, - &IUIScene_PauseMenu::ExitGameDialogReturned, this, - app.GetStringTable(), NULL, 0, false); + &IUIScene_PauseMenu::ExitGameDialogReturned, + (LPVOID)GetCallbackUniqueId()); } else { if (g_NetworkManager.IsHost()) { uiIDA[0] = IDS_CONFIRM_CANCEL; @@ -752,30 +746,30 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { uiIDA[2] = IDS_EXIT_GAME_NO_SAVE; if (g_NetworkManager.GetPlayerCount() > 1) { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, m_iPad, &UIScene_PauseMenu:: ExitGameSaveDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } else { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, m_iPad, &UIScene_PauseMenu:: ExitGameSaveDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } } else { uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } } #endif @@ -808,12 +802,11 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned, - dynamic_cast(this), - app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } else { int playTime = -1; @@ -843,16 +836,16 @@ void UIScene_PauseMenu::PerformActionSaveGame() { // Unlock the full version? if (!ProfileManager.IsSignedInLive(m_iPad)) { -#if defined(__PS3__) +#if defined(__PS3__) || defined(__PSVITA__) m_eAction = eAction_SaveGamePSN; unsigned int uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 2, - ProfileManager.GetPrimaryPad(), - &UIScene_PauseMenu::MustSignInReturnedPSN, - this, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &UIScene_PauseMenu::MustSignInReturnedPSN, + (LPVOID)GetCallbackUniqueId()); #elif defined(__ORBIS__) m_eAction = eAction_SaveGamePSN; int npAvailability = ProfileManager.getNPAvailability(m_iPad); @@ -862,9 +855,9 @@ void UIScene_PauseMenu::PerformActionSaveGame() { // npAvailability isn't SCE_OK unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, m_iPad, - NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + m_iPad); } else // Determine why they're not "signed in live" if (ProfileManager.isSignedInPSN(m_iPad)) { @@ -873,27 +866,26 @@ void UIScene_PauseMenu::PerformActionSaveGame() { unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, - IDS_ERROR_NETWORK, uiIDA, 1, m_iPad, - NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ERROR_NETWORK_TITLE, + IDS_ERROR_NETWORK, uiIDA, 1, m_iPad); } else { // Not signed in to PSN unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, m_iPad, &UIScene_PauseMenu::MustSignInReturnedPSN, - this, app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } #endif } else { unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_CANCEL; - ui.RequestMessageBox(IDS_UNLOCK_TITLE, IDS_UNLOCK_TOSAVE_TEXT, - uiIDA, 2, m_iPad, - &UIScene_PauseMenu::UnlockFullSaveReturned, - this, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_UNLOCK_TITLE, IDS_UNLOCK_TOSAVE_TEXT, + uiIDA, 2, m_iPad, + &UIScene_PauseMenu::UnlockFullSaveReturned, + (LPVOID)GetCallbackUniqueId()); } return; @@ -940,11 +932,11 @@ void UIScene_PauseMenu::PerformActionSaveGame() { // end up asking to purchase again #endif { - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, m_iPad, - &UIScene_PauseMenu::WarningTrialTexturePackReturned, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_PauseMenu::WarningTrialTexturePackReturned, + (LPVOID)GetCallbackUniqueId()); } return; @@ -965,10 +957,10 @@ void UIScene_PauseMenu::PerformActionSaveGame() { uiIDA[0] = IDS_SELECTANEWDEVICE; uiIDA[1] = IDS_NODEVICE_DECLINE; - ui.RequestMessageBox(IDS_STORAGEDEVICEPROBLEM_TITLE, - IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 2, m_iPad, - &IUIScene_PauseMenu::DeviceRemovedDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_STORAGEDEVICEPROBLEM_TITLE, + IDS_FAILED_TO_LOADSAVE_TEXT, uiIDA, 2, m_iPad, + &IUIScene_PauseMenu::DeviceRemovedDialogReturned, + (LPVOID)GetCallbackUniqueId()); } else #endif { @@ -977,10 +969,10 @@ void UIScene_PauseMenu::PerformActionSaveGame() { unsigned int uiIDA[2]; uiIDA[0] = IDS_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TITLE_DISABLE_AUTOSAVE, IDS_CONFIRM_DISABLE_AUTOSAVE, uiIDA, 2, m_iPad, &IUIScene_PauseMenu::DisableAutosaveDialogReturned, - this, app.GetStringTable(), NULL, 0, false); + (LPVOID)GetCallbackUniqueId()); } else #endif // we need to ask if they are sure they want to overwrite the @@ -989,20 +981,20 @@ void UIScene_PauseMenu::PerformActionSaveGame() { unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, - m_iPad, &IUIScene_PauseMenu::SaveGameDialogReturned, this, - app.GetStringTable(), NULL, 0, false); + m_iPad, &IUIScene_PauseMenu::SaveGameDialogReturned, + (LPVOID)GetCallbackUniqueId()); } else { #if defined(_XBOX_ONE) || defined(__ORBIS__) unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TITLE_ENABLE_AUTOSAVE, IDS_CONFIRM_ENABLE_AUTOSAVE, uiIDA, 2, m_iPad, - &IUIScene_PauseMenu::EnableAutosaveDialogReturned, this, - app.GetStringTable(), NULL, 0, false); + &IUIScene_PauseMenu::EnableAutosaveDialogReturned, + (LPVOID)GetCallbackUniqueId()); #else // flag a app action of save game app.SetAction(m_iPad, eAppAction_SaveGame); @@ -1054,7 +1046,6 @@ void UIScene_PauseMenu::HandleDLCMountingComplete() { int UIScene_PauseMenu::UnlockFullSaveReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; Minecraft* pMinecraft = Minecraft::GetInstance(); if (result == C4JStorage::EMessage_ResultAccept) { @@ -1068,10 +1059,9 @@ int UIScene_PauseMenu::UnlockFullSaveReturned( if (bContentRestricted) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, pClass, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad()); } else #endif { @@ -1091,10 +1081,12 @@ int UIScene_PauseMenu::UnlockFullSaveReturned( int UIScene_PauseMenu::SaveGame_SignInReturned(void* pParam, bool bContinue, int iPad) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; + UIScene_PauseMenu* pClass = + (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam); + if (pClass) pClass->SetIgnoreInput(false); if (bContinue == true) { - pClass->PerformActionSaveGame(); + if (pClass) pClass->PerformActionSaveGame(); } return 0; @@ -1114,27 +1106,27 @@ int UIScene_PauseMenu::BanGameDialogReturned( #if defined(__PS3__) || defined(__PSVITA__) || defined(__ORBIS__) int UIScene_PauseMenu::MustSignInReturnedPSN( void* pParam, int iPad, C4JStorage::EMessageResult result) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; - - if (result == C4JStorage::EMessage_ResultAccept) { + UIScene_PauseMenu* pClass = + (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam); + if (result == C4JStorage::EMessage_ResultAccept && pClass) { #ifdef __PS3__ switch (pClass->m_eAction) { case eAction_ViewLeaderboardsPSN: SQRNetworkManager_PS3::AttemptPSNSignIn( &UIScene_PauseMenu::ViewLeaderboards_SignInReturned, - pClass); + pParam); break; case eAction_ViewInvitesPSN: SQRNetworkManager_PS3::AttemptPSNSignIn( - &UIScene_PauseMenu::ViewInvites_SignInReturned, pClass); + &UIScene_PauseMenu::ViewInvites_SignInReturned, pParam); break; case eAction_SaveGamePSN: SQRNetworkManager_PS3::AttemptPSNSignIn( - &UIScene_PauseMenu::SaveGame_SignInReturned, pClass); + &UIScene_PauseMenu::SaveGame_SignInReturned, pParam); break; case eAction_BuyTexturePackPSN: SQRNetworkManager_PS3::AttemptPSNSignIn( - &UIScene_PauseMenu::BuyTexturePack_SignInReturned, pClass); + &UIScene_PauseMenu::BuyTexturePack_SignInReturned, pParam); break; } #elif defined __PSVITA__ @@ -1148,19 +1140,19 @@ int UIScene_PauseMenu::MustSignInReturnedPSN( // Now Sign-in SQRNetworkManager_Vita::AttemptPSNSignIn( &UIScene_PauseMenu::ViewLeaderboards_SignInReturned, - pClass); + pParam); break; case eAction_ViewInvitesPSN: SQRNetworkManager_Vita::AttemptPSNSignIn( - &UIScene_PauseMenu::ViewInvites_SignInReturned, pClass); + &UIScene_PauseMenu::ViewInvites_SignInReturned, pParam); break; case eAction_SaveGamePSN: SQRNetworkManager_Vita::AttemptPSNSignIn( - &UIScene_PauseMenu::SaveGame_SignInReturned, pClass); + &UIScene_PauseMenu::SaveGame_SignInReturned, pParam, true); break; case eAction_BuyTexturePackPSN: SQRNetworkManager_Vita::AttemptPSNSignIn( - &UIScene_PauseMenu::BuyTexturePack_SignInReturned, pClass); + &UIScene_PauseMenu::BuyTexturePack_SignInReturned, pParam); break; } #else @@ -1195,7 +1187,9 @@ int UIScene_PauseMenu::MustSignInReturnedPSN( int UIScene_PauseMenu::ViewLeaderboards_SignInReturned(void* pParam, bool bContinue, int iPad) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; + UIScene_PauseMenu* pClass = + (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam); + if (!pClass) return 0; if (bContinue == true) { unsigned int uiIDA[1]; @@ -1203,10 +1197,9 @@ int UIScene_PauseMenu::ViewLeaderboards_SignInReturned(void* pParam, // guests can't look at leaderboards if (ProfileManager.IsGuest(pClass->m_iPad)) { - ui.RequestMessageBox(IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, NULL, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad()); } else if (ProfileManager.IsSignedInLive(iPad)) { #ifndef __ORBIS__ bool bContentRestricted = false; @@ -1214,10 +1207,9 @@ int UIScene_PauseMenu::ViewLeaderboards_SignInReturned(void* pParam, pClass->m_iPad, true, NULL, &bContentRestricted, NULL); if (bContentRestricted) { // you can't see leaderboards - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, pClass, - app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad()); } else #endif { @@ -1231,17 +1223,18 @@ int UIScene_PauseMenu::ViewLeaderboards_SignInReturned(void* pParam, int UIScene_PauseMenu::WarningTrialTexturePackReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; + UIScene_PauseMenu* pClass = + (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam); #ifdef __ORBIS__ // If a patch is available, can't proceed - if (pClass->CheckForPatch()) return 0; + if (!pClass || pClass->CheckForPatch()) return 0; #endif #if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) if (result == C4JStorage::EMessage_ResultAccept) { if (!ProfileManager.IsSignedInLive(iPad)) { - pClass->m_eAction = eAction_SaveGamePSN; + if (pClass) pClass->m_eAction = eAction_SaveGamePSN; #ifdef __ORBIS__ // Check if PSN is unavailable because of age restriction int npAvailability = ProfileManager.getNPAvailability(iPad); if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) { @@ -1250,9 +1243,8 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned( // npAvailability isn't SCE_OK unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad, - NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad); } else // Determine why they're not "signed in live" if (ProfileManager.isSignedInPSN(iPad)) { @@ -1261,26 +1253,24 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned( unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, - IDS_ERROR_NETWORK, uiIDA, 1, iPad, - NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ERROR_NETWORK_TITLE, + IDS_ERROR_NETWORK, uiIDA, 1, iPad); } else { unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, &UIScene_PauseMenu::MustSignInReturnedPSN, - pClass, app.GetStringTable(), NULL, 0, false); + pParam); } #else // __PS3__ // You're not signed in to PSN! unsigned int uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 2, iPad, - &UIScene_PauseMenu::MustSignInReturnedPSN, - pClass, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, + 2, iPad, &UIScene_PauseMenu::MustSignInReturnedPSN, pParam); #endif } else { #ifndef __ORBIS__ @@ -1292,9 +1282,8 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned( if (bContentRestricted) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - iPad, NULL, pClass, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad); } else #endif { @@ -1359,8 +1348,6 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned( int UIScene_PauseMenu::BuyTexturePack_SignInReturned(void* pParam, bool bContinue, int iPad) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; - if (bContinue == true) { // Check if we're signed in to LIVE if (ProfileManager.IsSignedInLive(iPad)) { @@ -1374,9 +1361,8 @@ int UIScene_PauseMenu::BuyTexturePack_SignInReturned(void* pParam, if (bContentRestricted) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, - iPad, NULL, pClass, app.GetStringTable(), NULL, 0, false); + ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad); } else #endif { @@ -1464,7 +1450,6 @@ int UIScene_PauseMenu::ViewInvites_SignInReturned(void* pParam, bool bContinue, int UIScene_PauseMenu::ExitGameSaveDialogReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { - UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)pParam; // Exit with or without saving // Decline means save in this dialog if (result == C4JStorage::EMessage_ResultDecline || @@ -1505,13 +1490,12 @@ int UIScene_PauseMenu::ExitGameSaveDialogReturned( // Give the player a warning about the trial version of the // texture pack - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(), &UIScene_PauseMenu::WarningTrialTexturePackReturned, - dynamic_cast(pClass), - app.GetStringTable(), NULL, 0, false); + pParam); return S_OK; } @@ -1527,12 +1511,10 @@ int UIScene_PauseMenu::ExitGameSaveDialogReturned( unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(), - &IUIScene_PauseMenu::ExitGameAndSaveReturned, - dynamic_cast(pClass), - app.GetStringTable(), NULL, 0, false); + &IUIScene_PauseMenu::ExitGameAndSaveReturned, pParam); return 0; } else { #if defined(_XBOX_ONE) || defined(__ORBIS__) @@ -1545,12 +1527,10 @@ int UIScene_PauseMenu::ExitGameSaveDialogReturned( unsigned int uiIDA[2]; uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(), - &IUIScene_PauseMenu::ExitGameDeclineSaveReturned, - dynamic_cast(pClass), app.GetStringTable(), - NULL, 0, false); + &IUIScene_PauseMenu::ExitGameDeclineSaveReturned, pParam); return 0; } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp index 936c25ae4..267435344 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp @@ -6,11 +6,6 @@ #include "../Network/Sony/SonyHttp.h" #endif -namespace { -int AvatarReturnedThunk(void* lpParam, std::uint8_t* thumbnailData, - unsigned int thumbnailBytes); -} - UIScene_QuadrantSignin::UIScene_QuadrantSignin(int iPad, void* _initData, UILayer* parentLayer) : UIScene(iPad, parentLayer) { @@ -22,35 +17,8 @@ UIScene_QuadrantSignin::UIScene_QuadrantSignin(int iPad, void* _initData, m_bIgnoreInput = false; m_lastRequestedAvatar = -1; - for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - m_iconRequested[i] = false; - m_labelPressToJoin[i].init(app.GetString(IDS_MUST_SIGN_IN_TITLE)); - m_labelConnectController[i].init(L""); - m_labelAccountType[i].init(L""); - - // wchar_t num[2]; - // swprintf(num,2,L"%d",i+1); - // m_labelPlayerNumber[i].init(num); - - m_controllerStatus[i] = eControllerStatus_ConnectController; - - if (ProfileManager.IsSignedIn(i)) { - app.DebugPrintf("Index %d is signed in\n", i); - - setControllerState(i, eControllerStatus_PlayerDetails); - m_labelDisplayName[i].init(ProfileManager.GetDisplayName(i)); - } else if (InputManager.IsPadConnected(i)) { - app.DebugPrintf("Index %d is not signed in\n", i); - - setControllerState(i, eControllerStatus_PressToJoin); - m_labelDisplayName[i].init(L""); - } else { - app.DebugPrintf("Index %d is not connected\n", i); - - setControllerState(i, eControllerStatus_ConnectController); - } - } + _initQuadrants(); #if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) if (InputManager.IsCircleCrossSwapped()) { @@ -91,6 +59,8 @@ bool UIScene_QuadrantSignin::hidesLowerScenes() { } void UIScene_QuadrantSignin::tick() { + if (!getMovie()) return; + UIScene::tick(); updateState(); @@ -111,7 +81,7 @@ void UIScene_QuadrantSignin::handleInput(int iPad, int key, bool repeat, switch (key) { case ACTION_MENU_CANCEL: { if (pressed) { -#ifdef _DURANGO +#ifdef _XBOX_ONE if (InputManager.IsPadLocked(iPad)) { if (iPad != ProfileManager.GetPrimaryPad()) { ProfileManager.RemoveGamepadFromGame(iPad); @@ -126,7 +96,7 @@ void UIScene_QuadrantSignin::handleInput(int iPad, int key, bool repeat, navigateBack(); } } -#ifdef _DURANGO +#ifdef _XBOX_ONE } #endif } break; @@ -136,11 +106,17 @@ void UIScene_QuadrantSignin::handleInput(int iPad, int key, bool repeat, #endif if (pressed) { m_bIgnoreInput = true; - if (ProfileManager.IsSignedIn(iPad)) { +#ifdef _XBOX_ONE + if (ProfileManager.IsSignedIn(iPad) && + InputManager.IsPadLocked(iPad)) +#else + if (ProfileManager.IsSignedIn(iPad)) +#endif + { app.DebugPrintf("Signed in pad pressed\n"); ProfileManager.CancelProfileAvatarRequest(); -#ifdef _DURANGO +#ifdef _XBOX_ONE // On Durango, if we don't navigate forward here, then // when we are on the main menu, it (re)gains focus & // that causes our users to get cleared @@ -149,11 +125,25 @@ void UIScene_QuadrantSignin::handleInput(int iPad, int key, bool repeat, navigateBack(); m_signInInfo.Func(m_signInInfo.lpParam, true, m_iPad); } else { - app.DebugPrintf("Non-signed in pad pressed\n"); - ProfileManager.RequestSignInUI( - false, false, false, true, true, - &UIScene_QuadrantSignin::SignInReturned, this, - iPad); +#ifdef _XBOX_ONE + if (ProfileManager.IsSignedIn(0) && + !InputManager.IsPadLocked(0)) { + app.DebugPrintf( + "Signed in pad with no controller bound " + "pressed\n"); + ProfileManager.RequestSignInUI( + false, false, false, true, false, + &UIScene_QuadrantSignin::SignInReturned, this, + iPad); + } else +#endif + { + app.DebugPrintf("Non-signed in pad pressed\n"); + ProfileManager.RequestSignInUI( + false, false, false, true, true, + &UIScene_QuadrantSignin::SignInReturned, this, + iPad); + } } } break; @@ -169,15 +159,24 @@ void UIScene_QuadrantSignin::handleInput(int iPad, int key, bool repeat, handled = true; } +#ifdef _XBOX_ONE int UIScene_QuadrantSignin::SignInReturned(void* pParam, bool bContinue, - int iPad) { + int iPad, int iController) +#else +int UIScene_QuadrantSignin::SignInReturned(void* pParam, bool bContinue, + int iPad) +#endif +{ app.DebugPrintf("SignInReturned for pad %d\n", iPad); UIScene_QuadrantSignin* pClass = (UIScene_QuadrantSignin*)pParam; -#ifdef _DURANGO +#ifdef _XBOX_ONE if (bContinue && pClass->m_signInInfo.requireOnline && ProfileManager.IsSignedIn(iPad)) { + if (!InputManager.IsPadLocked(iPad)) { + ProfileManager.ForcePrimaryPadController(iController); + } ProfileManager.CheckMultiplayerPrivileges( iPad, true, &checkAllPrivilegesCallback, pClass); } else @@ -190,8 +189,8 @@ int UIScene_QuadrantSignin::SignInReturned(void* pParam, bool bContinue, return 0; } -#ifdef _DURANGO -void UIScene_QuadrantSignin::checkAllPrivilegesCallback(void* lpParam, +#ifdef _XBOX_ONE +void UIScene_QuadrantSignin::checkAllPrivilegesCallback(LPVOID lpParam, bool hasPrivileges, int iPad) { UIScene_QuadrantSignin* pClass = (UIScene_QuadrantSignin*)lpParam; @@ -210,7 +209,15 @@ void UIScene_QuadrantSignin::updateState() { // app.DebugPrintf("Index %d is signed in, display name - '%s'\n", // i, ProfileManager.GetDisplayName(i).data()); - setControllerState(i, eControllerStatus_PlayerDetails); +#ifdef _XBOX_ONE + if (!InputManager.IsPadLocked(i)) { + setControllerState(i, eControllerStatus_PressToJoin_LoggedIn); + } else +#endif + { + setControllerState(i, eControllerStatus_PlayerDetails); + } + m_labelDisplayName[i].setLabel(ProfileManager.GetDisplayName(i)); // m_buttonControllers[i].setLabel(app.GetString(IDS_TOOLTIPS_CONTINUE),i); @@ -286,3 +293,41 @@ int UIScene_QuadrantSignin::AvatarReturned(void* lpParam, return 0; } + +void UIScene_QuadrantSignin::_initQuadrants() { + for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { + m_iconRequested[i] = false; + + m_labelPressToJoin[i].init(IDS_MUST_SIGN_IN_TITLE); + m_labelConnectController[i].init(L""); + m_labelAccountType[i].init(L""); + + m_controllerStatus[i] = eControllerStatus_ConnectController; + + if (ProfileManager.IsSignedIn(i)) { + app.DebugPrintf("Index %d is signed in\n", i); + +#ifdef _XBOX_ONE + if (!InputManager.IsPadLocked(i)) { + setControllerState(i, eControllerStatus_PressToJoin_LoggedIn); + } else +#endif + { + setControllerState(i, eControllerStatus_PlayerDetails); + } + + m_labelDisplayName[i].init(ProfileManager.GetDisplayName(i)); + } else if (InputManager.IsPadConnected(i)) { + app.DebugPrintf("Index %d is not signed in\n", i); + + setControllerState(i, eControllerStatus_PressToJoin); + m_labelDisplayName[i].init(L""); + } else { + app.DebugPrintf("Index %d is not connected\n", i); + + setControllerState(i, eControllerStatus_ConnectController); + } + } +} + +void UIScene_QuadrantSignin::handleReload() { _initQuadrants(); } \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.h b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.h index 5e0992fa8..fda86781f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.h @@ -9,7 +9,9 @@ private: enum EControllerStatus { eControllerStatus_ConnectController, eControllerStatus_PressToJoin, - eControllerStatus_PlayerDetails + eControllerStatus_PlayerDetails, + eControllerStatus_PressToJoin_LoggedIn, + eControllerStatus_PressToJoin_NoController, }; bool m_bIgnoreInput; @@ -102,7 +104,14 @@ public: bool released, bool& handled); private: +#ifdef _XBOX_ONE + static int SignInReturned(void* pParam, bool bContinue, int iPad, + int iController); +#else static int SignInReturned(void* pParam, bool bContinue, int iPad); +#endif + static int AvatarReturned(LPVOID lpParam, PBYTE pbThumbnail, + DWORD dwThumbnailBytes); void updateState(); void setControllerState(int iPad, EControllerStatus state); @@ -112,7 +121,8 @@ private: int iPad); #endif -public: - static int AvatarReturned(void* lpParam, std::uint8_t* pbThumbnail, - unsigned int thumbnailBytes); +protected: + void _initQuadrants(); + + virtual void handleReload(); }; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp index cbd6ce130..e8b45d4d8 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp @@ -153,11 +153,12 @@ void UIScene_SaveMessage::handleTimerComplete(int id) { m_bIgnoreInput = false; // give the option to delete the save unsigned int uiIDA[1]; - uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox( - IDS_CORRUPT_FILE, IDS_CORRUPT_OPTIONS, uiIDA, 1, 0, - &UIScene_SaveMessage::DeleteOptionsDialogReturned, this, - app.GetStringTable()); + uiIDA[0] = IDS_CORRUPT_OPTIONS_RETRY; + uiIDA[1] = IDS_CORRUPT_OPTIONS_DELETE; + ui.RequestErrorMessage( + IDS_CORRUPT_FILE, IDS_CORRUPT_OPTIONS, uiIDA, 2, 0, + &UIScene_SaveMessage::DeleteOptionsDialogReturned, + this); break; } #endif @@ -171,10 +172,14 @@ void UIScene_SaveMessage::handleTimerComplete(int id) { int UIScene_SaveMessage::DeleteOptionsDialogReturned( void* pParam, int iPad, C4JStorage::EMessageResult result) { // UIScene_SaveMessage* pClass = (UIScene_SaveMessage*)pParam; - - // kick off the delete - StorageManager.DeleteOptionsData(iPad); - + if (result == C4JStorage::EMessage_ResultAccept) { + // retry loading the options file + StorageManager.ReadFromProfile(iPad); + } else // result == EMessage_ResultDecline + { + // kick off the delete + StorageManager.DeleteOptionsData(iPad); + } return 0; } #endif diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp index 75f891fb2..d79951807 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp @@ -11,22 +11,17 @@ UIScene_SettingsMenu::UIScene_SettingsMenu(int iPad, void* initData, bool bNotInGame = (Minecraft::GetInstance()->level == NULL); - m_buttons[BUTTON_ALL_OPTIONS].init(app.GetString(IDS_OPTIONS), - BUTTON_ALL_OPTIONS); - m_buttons[BUTTON_ALL_AUDIO].init(app.GetString(IDS_AUDIO), - BUTTON_ALL_AUDIO); - m_buttons[BUTTON_ALL_CONTROL].init(app.GetString(IDS_CONTROL), - BUTTON_ALL_CONTROL); - m_buttons[BUTTON_ALL_GRAPHICS].init(app.GetString(IDS_GRAPHICS), - BUTTON_ALL_GRAPHICS); - m_buttons[BUTTON_ALL_UI].init(app.GetString(IDS_USER_INTERFACE), - BUTTON_ALL_UI); - m_buttons[BUTTON_ALL_RESETTODEFAULTS].init( - app.GetString(IDS_RESET_TO_DEFAULTS), BUTTON_ALL_RESETTODEFAULTS); + m_buttons[BUTTON_ALL_OPTIONS].init(IDS_OPTIONS, BUTTON_ALL_OPTIONS); + m_buttons[BUTTON_ALL_AUDIO].init(IDS_AUDIO, BUTTON_ALL_AUDIO); + m_buttons[BUTTON_ALL_CONTROL].init(IDS_CONTROL, BUTTON_ALL_CONTROL); + m_buttons[BUTTON_ALL_GRAPHICS].init(IDS_GRAPHICS, BUTTON_ALL_GRAPHICS); + m_buttons[BUTTON_ALL_UI].init(IDS_USER_INTERFACE, BUTTON_ALL_UI); + m_buttons[BUTTON_ALL_RESETTODEFAULTS].init(IDS_RESET_TO_DEFAULTS, + BUTTON_ALL_RESETTODEFAULTS); if (ProfileManager.GetPrimaryPad() != m_iPad) { - removeControl(&m_buttons[BUTTON_ALL_AUDIO], true); - removeControl(&m_buttons[BUTTON_ALL_GRAPHICS], true); + removeControl(&m_buttons[BUTTON_ALL_AUDIO], bNotInGame); + removeControl(&m_buttons[BUTTON_ALL_GRAPHICS], bNotInGame); } doHorizontalResizeCheck(); @@ -50,8 +45,8 @@ std::wstring UIScene_SettingsMenu::getMoviePath() { void UIScene_SettingsMenu::handleReload() { if (ProfileManager.GetPrimaryPad() != m_iPad) { - removeControl(&m_buttons[BUTTON_ALL_AUDIO], true); - removeControl(&m_buttons[BUTTON_ALL_GRAPHICS], true); + removeControl(&m_buttons[BUTTON_ALL_AUDIO], bNotInGame); + removeControl(&m_buttons[BUTTON_ALL_GRAPHICS], bNotInGame); } doHorizontalResizeCheck(); @@ -134,10 +129,9 @@ void UIScene_SettingsMenu::handlePress(F64 controlId, F64 childId) { uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestMessageBox( + ui.RequestAlertMessage( IDS_DEFAULTS_TITLE, IDS_DEFAULTS_TEXT, uiIDA, 2, m_iPad, - &UIScene_SettingsMenu::ResetDefaultsDialogReturned, this, - app.GetStringTable(), NULL, 0, false); + &UIScene_SettingsMenu::ResetDefaultsDialogReturned, this); } break; } } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp index 1a690e983..1eb2f9509 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp @@ -2,6 +2,10 @@ #include "UI.h" #include "UIScene_SettingsOptionsMenu.h" +#if defined(_XBOX_ONE) +#define _ENABLE_LANGUAGE_SELECT +#endif + int UIScene_SettingsOptionsMenu::m_iDifficultySettingA[4] = { IDS_DIFFICULTY_PEACEFUL, IDS_DIFFICULTY_EASY, IDS_DIFFICULTY_NORMAL, IDS_DIFFICULTY_HARD}; @@ -14,29 +18,31 @@ UIScene_SettingsOptionsMenu::UIScene_SettingsOptionsMenu(int iPad, void* initData, UILayer* parentLayer) : UIScene(iPad, parentLayer) { + m_bNavigateToLanguageSelector = false; + // Setup all the Iggy references we need for this scene initialiseMovie(); m_bNotInGame = (Minecraft::GetInstance()->level == NULL); m_checkboxViewBob.init( - app.GetString(IDS_VIEW_BOBBING), eControl_ViewBob, + IDS_VIEW_BOBBING, eControl_ViewBob, (app.GetGameSettings(m_iPad, eGameSetting_ViewBob) != 0)); m_checkboxShowHints.init( - app.GetString(IDS_HINTS), eControl_ShowHints, + IDS_HINTS, eControl_ShowHints, (app.GetGameSettings(m_iPad, eGameSetting_Hints) != 0)); m_checkboxShowTooltips.init( - app.GetString(IDS_IN_GAME_TOOLTIPS), eControl_ShowTooltips, + IDS_IN_GAME_TOOLTIPS, eControl_ShowTooltips, (app.GetGameSettings(m_iPad, eGameSetting_Tooltips) != 0)); m_checkboxInGameGamertags.init( - app.GetString(IDS_IN_GAME_GAMERTAGS), eControl_InGameGamertags, + IDS_IN_GAME_GAMERTAGS, eControl_InGameGamertags, (app.GetGameSettings(m_iPad, eGameSetting_GamertagsVisible) != 0)); // check if we should display the mash-up option if (m_bNotInGame && app.GetMashupPackWorlds(m_iPad) != 0xFFFFFFFF) { // the mash-up option is needed m_bMashUpWorldsUnhideOption = true; - m_checkboxMashupWorlds.init(app.GetString(IDS_UNHIDE_MASHUP_WORLDS), + m_checkboxMashupWorlds.init(IDS_UNHIDE_MASHUP_WORLDS, eControl_ShowMashUpWorlds, false); } else { // m_checkboxMashupWorlds.init(L"",eControl_ShowMashUpWorlds,false); @@ -96,7 +102,6 @@ UIScene_SettingsOptionsMenu::UIScene_SettingsOptionsMenu(int iPad, bool bRemoveDifficulty = false; bool bRemoveAutosave = false; bool bRemoveInGameGamertags = false; - float fRemoveHeight = 0.0f, fWidth, fHeight; bool bNotInGame = (Minecraft::GetInstance()->level == NULL); bool bPrimaryPlayer = ProfileManager.GetPrimaryPad() == m_iPad; @@ -127,6 +132,20 @@ UIScene_SettingsOptionsMenu::UIScene_SettingsOptionsMenu(int iPad, removeControl(&m_checkboxInGameGamertags, true); } + // 4J-JEV: Changing languages in-game will produce many a bug. + // MGH - disabled the language select for the patch build, we'll re-enable + // afterwards 4J Stu - Removed it with a preprocessor def as we turn this + // off in various places +#ifdef _ENABLE_LANGUAGE_SELECT + if (app.GetGameStarted()) { + removeControl(&m_buttonLanguageSelect, false); + } else { + m_buttonLanguageSelect.init(IDS_LANGUAGE_SELECTOR, eControl_Languages); + } +#else + removeControl(&m_buttonLanguageSelect, false); +#endif + doHorizontalResizeCheck(); if (app.GetLocalPlayerCount() > 1) { @@ -134,10 +153,22 @@ UIScene_SettingsOptionsMenu::UIScene_SettingsOptionsMenu(int iPad, app.AdjustSplitscreenScene(m_hObj, &m_OriginalPosition, m_iPad); #endif } + + m_labelDifficultyText.disableReinitialisation(); } UIScene_SettingsOptionsMenu::~UIScene_SettingsOptionsMenu() {} +void UIScene_SettingsOptionsMenu::tick() { + UIScene::tick(); + + if (m_bNavigateToLanguageSelector) { + m_bNavigateToLanguageSelector = false; + setGameSettings(); + ui.NavigateToScene(m_iPad, eUIScene_LanguageSelector); + } +} + std::wstring UIScene_SettingsOptionsMenu::getMoviePath() { if (app.GetLocalPlayerCount() > 1) { return L"SettingsOptionsMenuSplit"; @@ -173,30 +204,7 @@ void UIScene_SettingsOptionsMenu::handleInput(int iPad, int key, bool repeat, switch (key) { case ACTION_MENU_CANCEL: if (pressed) { - // check the checkboxes - app.SetGameSettings(m_iPad, eGameSetting_ViewBob, - m_checkboxViewBob.IsChecked() ? 1 : 0); - app.SetGameSettings( - m_iPad, eGameSetting_GamertagsVisible, - m_checkboxInGameGamertags.IsChecked() ? 1 : 0); - app.SetGameSettings(m_iPad, eGameSetting_Hints, - m_checkboxShowHints.IsChecked() ? 1 : 0); - app.SetGameSettings(m_iPad, eGameSetting_Tooltips, - m_checkboxShowTooltips.IsChecked() ? 1 : 0); - - // the mashup option will only be shown if some worlds have been - // previously hidden - if (m_bMashUpWorldsUnhideOption && - m_checkboxMashupWorlds.IsChecked()) { - // unhide all worlds - app.EnableMashupPackWorlds(m_iPad); - } - - // 4J-PB - don't action changes here or we might write to the - // profile on backing out here and then get a change in the - // settings all, and write again on backing out there - // app.CheckGameSettingsChanged(true,pInputData->UserIndex); - + setGameSettings(); navigateBack(); } break; @@ -215,6 +223,142 @@ void UIScene_SettingsOptionsMenu::handleInput(int iPad, int key, bool repeat, } } +void UIScene_SettingsOptionsMenu::handlePress(F64 controlId, F64 childId) { + // CD - Added for audio + ui.PlayUISFX(eSFX_Press); + + switch ((int)controlId) { + case eControl_Languages: + m_bNavigateToLanguageSelector = true; + break; + } +} + +void UIScene_SettingsOptionsMenu::handleReload() { + m_bNavigateToLanguageSelector = false; + + m_checkboxViewBob.init( + IDS_VIEW_BOBBING, eControl_ViewBob, + (app.GetGameSettings(m_iPad, eGameSetting_ViewBob) != 0)); + m_checkboxShowHints.init( + IDS_HINTS, eControl_ShowHints, + (app.GetGameSettings(m_iPad, eGameSetting_Hints) != 0)); + m_checkboxShowTooltips.init( + IDS_IN_GAME_TOOLTIPS, eControl_ShowTooltips, + (app.GetGameSettings(m_iPad, eGameSetting_Tooltips) != 0)); + m_checkboxInGameGamertags.init( + IDS_IN_GAME_GAMERTAGS, eControl_InGameGamertags, + (app.GetGameSettings(m_iPad, eGameSetting_GamertagsVisible) != 0)); + + // check if we should display the mash-up option + if (m_bNotInGame && app.GetMashupPackWorlds(m_iPad) != 0xFFFFFFFF) { + // the mash-up option is needed + m_bMashUpWorldsUnhideOption = true; + } else { + // m_checkboxMashupWorlds.init(L"",eControl_ShowMashUpWorlds,false); + removeControl(&m_checkboxMashupWorlds, true); + m_bMashUpWorldsUnhideOption = false; + } + + unsigned char ucValue = app.GetGameSettings(m_iPad, eGameSetting_Autosave); + + wchar_t autosaveLabels[9][256]; + for (unsigned int i = 0; i < 9; ++i) { + if (i == 0) { + swprintf(autosaveLabels[i], 256, L"%ls", + app.GetString(IDS_SLIDER_AUTOSAVE_OFF)); + } else { + swprintf(autosaveLabels[i], 256, L"%ls: %d %ls", + app.GetString(IDS_SLIDER_AUTOSAVE), i * 15, + app.GetString(IDS_MINUTES)); + } + } + m_sliderAutosave.setAllPossibleLabels(9, autosaveLabels); + m_sliderAutosave.init(autosaveLabels[ucValue], eControl_Autosave, 0, 8, + ucValue); + +#if defined(_XBOX_ONE) || defined(__ORBIS__) + removeControl(&m_sliderAutosave, true); +#endif + + ucValue = app.GetGameSettings(m_iPad, eGameSetting_Difficulty); + + wchar_t difficultyLabels[4][256]; + for (unsigned int i = 0; i < 4; ++i) { + swprintf(difficultyLabels[i], 256, L"%ls: %ls", + app.GetString(IDS_SLIDER_DIFFICULTY), + app.GetString(m_iDifficultyTitleSettingA[i])); + } + m_sliderDifficulty.setAllPossibleLabels(4, difficultyLabels); + m_sliderDifficulty.init(difficultyLabels[ucValue], eControl_Difficulty, 0, + 3, ucValue); + + std::wstring wsText = + app.GetString(m_iDifficultySettingA[app.GetGameSettings( + m_iPad, eGameSetting_Difficulty)]); + EHTMLFontSize size = eHTMLSize_Normal; + if (!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) { + size = eHTMLSize_Splitscreen; + } + wchar_t startTags[64]; + swprintf(startTags, 64, L"", + app.GetHTMLColour(eHTMLColor_White)); + wsText = startTags + wsText; + + m_labelDifficultyText.init(wsText); + + // If you are in-game, only the game host can change in-game gamertags, and + // you can't change difficulty only the primary player gets to change the + // autosave and difficulty settings + bool bRemoveDifficulty = false; + bool bRemoveAutosave = false; + bool bRemoveInGameGamertags = false; + + bool bNotInGame = (Minecraft::GetInstance()->level == NULL); + bool bPrimaryPlayer = ProfileManager.GetPrimaryPad() == m_iPad; + if (!bPrimaryPlayer) { + bRemoveDifficulty = true; + bRemoveAutosave = true; + bRemoveInGameGamertags = true; + } + + if (!bNotInGame) // in the game + { + bRemoveDifficulty = true; + if (!g_NetworkManager.IsHost()) { + bRemoveAutosave = true; + bRemoveInGameGamertags = true; + } + } + if (bRemoveDifficulty) { + m_labelDifficultyText.setVisible(false); + removeControl(&m_sliderDifficulty, true); + } + + if (bRemoveAutosave) { + removeControl(&m_sliderAutosave, true); + } + + if (bRemoveInGameGamertags) { + removeControl(&m_checkboxInGameGamertags, true); + } + + // MGH - disabled the language select for the patch build, we'll re-enable + // afterwards 4J Stu - Removed it with a preprocessor def as we turn this + // off in various places +#ifdef _ENABLE_LANGUAGE_SELECT + // 4J-JEV: Changing languages in-game will produce many a bug. + if (app.GetGameStarted()) { + removeControl(&m_buttonLanguageSelect, false); + } else { + } +#else + removeControl(&m_buttonLanguageSelect, false); +#endif + + doHorizontalResizeCheck(); +} + void UIScene_SettingsOptionsMenu::handleSliderMove(F64 sliderId, F64 currentValue) { int value = (int)currentValue; @@ -245,3 +389,27 @@ void UIScene_SettingsOptionsMenu::handleSliderMove(F64 sliderId, break; } } + +void UIScene_SettingsOptionsMenu::setGameSettings() { + // check the checkboxes + app.SetGameSettings(m_iPad, eGameSetting_ViewBob, + m_checkboxViewBob.IsChecked() ? 1 : 0); + app.SetGameSettings(m_iPad, eGameSetting_GamertagsVisible, + m_checkboxInGameGamertags.IsChecked() ? 1 : 0); + app.SetGameSettings(m_iPad, eGameSetting_Hints, + m_checkboxShowHints.IsChecked() ? 1 : 0); + app.SetGameSettings(m_iPad, eGameSetting_Tooltips, + m_checkboxShowTooltips.IsChecked() ? 1 : 0); + + // the mashup option will only be shown if some worlds have been previously + // hidden + if (m_bMashUpWorldsUnhideOption && m_checkboxMashupWorlds.IsChecked()) { + // unhide all worlds + app.EnableMashupPackWorlds(m_iPad); + } + + // 4J-PB - don't action changes here or we might write to the profile on + // backing out here and then get a change in the settings all, and write + // again on backing out there + // app.CheckGameSettingsChanged(true,pInputData->UserIndex); +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.h index b22d07012..67c30660d 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.h @@ -11,6 +11,7 @@ private: eControl_InGameGamertags, eControl_ShowMashUpWorlds, eControl_Autosave, + eControl_Languages, eControl_Difficulty }; @@ -24,6 +25,8 @@ private: m_checkboxMashupWorlds; // Checkboxes UIControl_Slider m_sliderAutosave, m_sliderDifficulty; // Sliders UIControl_Label m_labelDifficultyText; // Text + UIControl_Button m_buttonLanguageSelect; + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) UI_MAP_ELEMENT(m_checkboxViewBob, "ViewBob") UI_MAP_ELEMENT(m_checkboxShowHints, "ShowHints") @@ -33,10 +36,12 @@ private: UI_MAP_ELEMENT(m_sliderAutosave, "Autosave") UI_MAP_ELEMENT(m_sliderDifficulty, "Difficulty") UI_MAP_ELEMENT(m_labelDifficultyText, "DifficultyText") + UI_MAP_ELEMENT(m_buttonLanguageSelect, "Languages") UI_END_MAP_ELEMENTS_AND_NAMES() bool m_bNotInGame; bool m_bMashUpWorldsUnhideOption; + bool m_bNavigateToLanguageSelector; public: UIScene_SettingsOptionsMenu(int iPad, void* initData, UILayer* parentLayer); @@ -44,6 +49,8 @@ public: virtual EUIScene getSceneType() { return eUIScene_SettingsOptionsMenu; } + virtual void tick(); + virtual void updateTooltips(); virtual void updateComponents(); @@ -55,6 +62,12 @@ public: // INPUT virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool& handled); + virtual void handlePress(F64 controlId, F64 childId); + + virtual void handleReload(); virtual void handleSliderMove(F64 sliderId, F64 currentValue); + +protected: + void setGameSettings(); }; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp index 5ef3d0411..5eff02e6f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp @@ -226,216 +226,7 @@ void UIScene_SkinSelectMenu::handleInput(int iPad, int key, bool repeat, case ACTION_MENU_TOUCHPAD_PRESS: #endif if (pressed) { - ui.AnimateKeyPress(iPad, key, repeat, pressed, released); - // if the profile data has been changed, then force a profile - // write It seems we're allowed to break the 5 minute rule if - // it's the result of a user action - switch (m_packIndex) { - case SKIN_SELECT_PACK_DEFAULT: - app.SetPlayerSkin(iPad, m_skinIndex); - app.SetPlayerCape(iPad, 0); - m_currentSkinPath = app.GetPlayerSkinName(iPad); - m_originalSkinId = app.GetPlayerSkinId(iPad); - setCharacterSelected(true); - ui.PlayUISFX(eSFX_Press); - break; - case SKIN_SELECT_PACK_FAVORITES: - if (app.GetPlayerFavoriteSkinsCount(iPad) > 0) { - // get the pack number from the skin id - wchar_t chars[256]; - swprintf( - chars, 256, L"dlcskin%08d.png", - app.GetPlayerFavoriteSkin(iPad, m_skinIndex)); - - DLCPack* Pack = - app.m_dlcManager.getPackContainingSkin(chars); - - if (Pack) { - DLCSkinFile* skinFile = - Pack->getSkinFile(chars); - app.SetPlayerSkin(iPad, skinFile->getPath()); - app.SetPlayerCape( - iPad, skinFile->getParameterAsString( - DLCManager::e_DLCParamType_Cape)); - setCharacterSelected(true); - m_currentSkinPath = app.GetPlayerSkinName(iPad); - m_originalSkinId = app.GetPlayerSkinId(iPad); - app.SetPlayerFavoriteSkinsPos(iPad, - m_skinIndex); - } - } - break; - default: - if (m_currentPack != NULL) { - DLCSkinFile* skinFile = - m_currentPack->getSkinFile(m_skinIndex); - - if (!skinFile->getParameterAsBool( - DLCManager::e_DLCParamType_Free) // Is this - // a free - // skin? - && - !m_currentPack->hasPurchasedFile( - DLCManager::e_DLCType_Skin, - skinFile - ->getPath()) // do we have a license? - ) { - // 4J-PB - check for a patch -#ifdef __ORBIS__ - // 4J-PB - Check if there is a patch for the - // game - int errorCode = - ProfileManager.getNPAvailability( - ProfileManager.GetPrimaryPad()); - - bool bPatchAvailable; - switch (errorCode) { - case SCE_NP_ERROR_LATEST_PATCH_PKG_EXIST: - case SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED: - bPatchAvailable = true; - break; - default: - bPatchAvailable = false; - break; - } - - if (bPatchAvailable) { - int32_t ret = sceErrorDialogInitialize(); - m_bErrorDialogRunning = true; - if (ret == SCE_OK) { - SceErrorDialogParam param; - sceErrorDialogParamInitialize(¶m); - // 4J-PB - We want to display the option - // to get the patch now - param.errorCode = - SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED; // pClass->m_errorCode; - ret = sceUserServiceGetInitialUser( - ¶m.userId); - if (ret == SCE_OK) { - ret = sceErrorDialogOpen(¶m); - break; - } - } - } -#endif - - // no - unsigned int uiIDA[1] = {IDS_OK}; -#ifdef __ORBIS__ - // Check if PSN is unavailable because of age - // restriction - int npAvailability = - ProfileManager.getNPAvailability(iPad); - if (npAvailability == - SCE_NP_ERROR_AGE_RESTRICTION) { - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad, - NULL, NULL, app.GetStringTable()); - } else -#endif - // We need to upsell the full version - if (ProfileManager.IsGuest(iPad)) { - // can't buy - ui.RequestMessageBox( - IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, - iPad, NULL, NULL, - app.GetStringTable(), NULL, 0, - false); - } - // are we online? - else if (!ProfileManager.IsSignedInLive( - iPad)) { - showNotOnlineDialog(iPad); - } else { - // upsell -#ifdef _XBOX - DLC_INFO* pDLCInfo = - app.GetDLCInfoForTrialOfferID( - m_currentPack - ->getPurchaseOfferId()); - ULONGLONG ullOfferID_Full; - - if (pDLCInfo != NULL) { - ullOfferID_Full = - pDLCInfo->ullOfferID_Full; - } else { - ullOfferID_Full = - m_currentPack - ->getPurchaseOfferId(); - } - - // tell sentient about the upsell of the - // full version of the skin pack - TelemetryManager->RecordUpsellPresented( - iPad, eSet_UpsellID_Skin_DLC, - ullOfferID_Full & 0xFFFFFFFF); -#endif - bool bContentRestricted = false; -#if defined(__PS3__) || defined(__PSVITA__) - ProfileManager - .GetChatAndContentRestrictions( - m_iPad, true, NULL, - &bContentRestricted, NULL); -#endif - if (bContentRestricted) { -#if !(defined(_XBOX) || \ - defined( \ - _WIN64)) // 4J Stu - Temp to get the win build running, but so we - // check this for other platforms you can't see the store - unsigned int uiIDA[1] = { - IDS_CONFIRM_OK}; - ui.RequestMessageBox( - IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, - 1, iPad, NULL, this, - app.GetStringTable(), NULL, 0, - false); -#endif - } else { - // 4J-PB - need to check for an - // empty store -#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__ - if (app.CheckForEmptyStore(iPad) == - false) -#endif - { - this->m_bIgnoreInput = true; - - unsigned int uiIDA[2] = { - IDS_CONFIRM_OK, - IDS_CONFIRM_CANCEL}; - ui.RequestMessageBox( - IDS_UNLOCK_DLC_TITLE, - IDS_UNLOCK_DLC_SKIN, uiIDA, - 2, iPad, - &UIScene_SkinSelectMenu:: - UnlockSkinReturned, - this, app.GetStringTable(), - NULL, 0, false); - } - } - } - } else { - app.SetPlayerSkin(iPad, skinFile->getPath()); - app.SetPlayerCape( - iPad, skinFile->getParameterAsString( - DLCManager::e_DLCParamType_Cape)); - setCharacterSelected(true); - m_currentSkinPath = app.GetPlayerSkinName(iPad); - m_originalSkinId = app.GetPlayerSkinId(iPad); - - // push this onto the favorite list - AddFavoriteSkin(iPad, - GET_DLC_SKIN_ID_FROM_BITMASK( - m_originalSkinId)); - } - } - - ui.PlayUISFX(eSFX_Press); - break; - } + InputActionOK(iPad); } break; case ACTION_MENU_UP: @@ -643,37 +434,84 @@ void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad) { // if(true) if (!m_currentPack->hasPurchasedFile( DLCManager::e_DLCType_Skin, skinFile->getPath())) { +#ifdef __ORBIS__ + // 4J-PB - Check if there is a patch for the game + int errorCode = ProfileManager.getNPAvailability( + ProfileManager.GetPrimaryPad()); + + bool bPatchAvailable; + switch (errorCode) { + case SCE_NP_ERROR_LATEST_PATCH_PKG_EXIST: + case SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED: + bPatchAvailable = true; + break; + default: + bPatchAvailable = false; + break; + } + + if (bPatchAvailable) { + int32_t ret = sceErrorDialogInitialize(); + m_bErrorDialogRunning = true; + if (ret == SCE_OK) { + SceErrorDialogParam param; + sceErrorDialogParamInitialize(¶m); + // 4J-PB - We want to display the option to get + // the patch now + param.errorCode = + SCE_NP_ERROR_LATEST_PATCH_PKG_DOWNLOADED; // pClass->m_errorCode; + ret = + sceUserServiceGetInitialUser(¶m.userId); + if (ret == SCE_OK) { + ret = sceErrorDialogOpen(¶m); + break; + } + } + } +#endif + // no unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - // We need to upsell the full version - if (ProfileManager.IsGuest(iPad)) { - // can't buy - ui.RequestMessageBox( - IDS_PRO_GUESTPROFILE_TITLE, - IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, iPad, NULL, - NULL, app.GetStringTable(), NULL, 0, false); - } -#if defined(__PS3__) || defined(__ORBIS__) - // are we online? - else if (!ProfileManager.IsSignedInLive(iPad)) { - showNotOnlineDialog(iPad); - } +#ifdef __ORBIS__ + // Check if PSN is unavailable because of age + // restriction + int npAvailability = + ProfileManager.getNPAvailability(iPad); + if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) { + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, + uiIDA, 1, iPad); + } else #endif - else { - // upsell -#ifdef _XBOX - DLC_INFO* pDLCInfo = app.GetDLCInfoForTrialOfferID( - m_currentPack->getPurchaseOfferId()); - ULONGLONG ullOfferID_Full; - - if (pDLCInfo != NULL) { - ullOfferID_Full = pDLCInfo->ullOfferID_Full; - } else { - ullOfferID_Full = - m_currentPack->getPurchaseOfferId(); + // We need to upsell the full version + if (ProfileManager.IsGuest(iPad)) { + // can't buy + ui.RequestAlertMessage( + IDS_PRO_GUESTPROFILE_TITLE, + IDS_PRO_GUESTPROFILE_TEXT, uiIDA, 1, iPad); } +#if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ + // are we online? + else if (!ProfileManager.IsSignedInLive(iPad)) { + showNotOnlineDialog(iPad); + } +#endif + else { + // upsell +#ifdef _XBOX + DLC_INFO* pDLCInfo = + app.GetDLCInfoForTrialOfferID( + m_currentPack->getPurchaseOfferId()); + ULONGLONG ullOfferID_Full; + + if (pDLCInfo != NULL) { + ullOfferID_Full = pDLCInfo->ullOfferID_Full; + } else { + ullOfferID_Full = + m_currentPack->getPurchaseOfferId(); + } // tell sentient about the upsell of the full // version of the skin pack @@ -747,7 +585,9 @@ void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad) { iPad, GET_DLC_SKIN_ID_FROM_BITMASK(m_originalSkinId)); } - if (renableInputAfterOperation) m_bIgnoreInput = false; + if (renableInputAfterOperation) { + m_bIgnoreInput = false; + } } ui.PlayUISFX(eSFX_Press); @@ -1634,7 +1474,19 @@ void UIScene_SkinSelectMenu::showNotOnlineDialog(int iPad) { SQRNetworkManager_PS3::AttemptPSNSignIn(NULL, this); #elif defined(__PSVITA__) - SQRNetworkManager_Vita::AttemptPSNSignIn(NULL, this); + if (CGameNetworkManager::usingAdhocMode() && + SQRNetworkManager_AdHoc_Vita::GetAdhocStatus()) { + // we're in adhoc mode, we really need to ask before disconnecting + UINT uiIDA[2]; + uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; + uiIDA[1] = IDS_CANCEL; + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, + uiIDA, 2, ProfileManager.GetPrimaryPad(), + &UIScene_SkinSelectMenu::MustSignInReturned, + NULL); + } else { + SQRNetworkManager_Vita::AttemptPSNSignIn(NULL, this); + } #elif defined(__ORBIS__) SQRNetworkManager_Orbis::AttemptPSNSignIn(NULL, this, false, iPad); @@ -1642,8 +1494,8 @@ void UIScene_SkinSelectMenu::showNotOnlineDialog(int iPad) { #elif defined(_DURANGO) unsigned int uiIDA[1] = {IDS_CONFIRM_OK}; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, - uiIDA, 1, iPad, NULL, NULL, app.GetStringTable()); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, + IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad); #endif } @@ -1705,10 +1557,12 @@ int UIScene_SkinSelectMenu::UnlockSkinReturned( app.Checkout(chSkuID); } } - // need to re-enable input because the user can back out of the - // store purchase, and we'll be stuck - pScene->m_bIgnoreInput = false; } + // need to re-enable input because the user can back out of the + // store purchase, and we'll be stuck + pScene->m_bIgnoreInput = + false; // MGH - moved this to outside the pSONYDLCInfo, so we + // don't get stuck #elif defined _XBOX_ONE StorageManager.InstallOffer( 1, @@ -1783,3 +1637,29 @@ void UIScene_SkinSelectMenu::HandleDLCLicenseChange() { handleSkinIndexChanged(); } #endif + +#ifdef __PSVITA__ +int UIScene_SkinSelectMenu::MustSignInReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result) { + if (result == C4JStorage::EMessage_ResultAccept) { +#ifdef __PS3__ + SQRNetworkManager_PS3::AttemptPSNSignIn( + &UIScene_SkinSelectMenu::PSNSignInReturned, pParam, true); +#elif defined __PSVITA__ + SQRNetworkManager_Vita::AttemptPSNSignIn( + &UIScene_SkinSelectMenu::PSNSignInReturned, pParam, true); +#elif defined __ORBIS__ + SQRNetworkManager_Orbis::AttemptPSNSignIn( + &UIScene_SkinSelectMenu::PSNSignInReturned, pParam, true); +#endif + } + return 0; +} + +int UIScene_SkinSelectMenu::PSNSignInReturned(void* pParam, bool bContinue, + int iPad) { + if (bContinue) { + } + return 0; +} +#endif // __PSVITA__ \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.h index 5fb1f0bf4..5f013be82 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.h @@ -189,6 +189,12 @@ private: bool m_bErrorDialogRunning; #endif +#ifdef __PSVITA__ + static int MustSignInReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result); + static int PSNSignInReturned(void* pParam, bool bContinue, int iPad); +#endif + #ifdef __PSVITA__ CRITICAL_SECTION m_DLCInstallCS; // to prevent a race condition between the // install and the mounted callback diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_Timer.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_Timer.cpp index dd36c6d00..ab10dfffb 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_Timer.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_Timer.cpp @@ -16,7 +16,7 @@ UIScene_Timer::UIScene_Timer(int iPad, void* initData, UILayer* parentLayer) std::wstring UIScene_Timer::getMoviePath() { return L"Timer"; } -void UIScene_Timer::reloadMovie() { +void UIScene_Timer::reloadMovie(bool force) { // Never needs reloaded } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_Timer.h b/Minecraft.Client/Platform/Common/UI/UIScene_Timer.h index c4f085b22..c13b389cd 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_Timer.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_Timer.h @@ -20,7 +20,7 @@ public: // Returns true if lower scenes in this scenes layer, or in any layer below // this scenes layers should be hidden virtual bool hidesLowerScenes() { return true; } - virtual void reloadMovie(); + virtual void reloadMovie(bool force); virtual bool needsReloaded(); protected: diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp index 5ce7b8b70..163ba62ed 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp @@ -121,6 +121,17 @@ void UIScene_TradingMenu::handleReload() { m_slotListInventory.addSlots(MerchantMenu::INV_SLOT_START, 27); m_slotListHotbar.addSlots(MerchantMenu::USE_ROW_SLOT_START, 9); + + updateDisplay(); + + IggyDataValue result; + IggyDataValue value[1]; + + value[0].type = IGGY_DATATYPE_number; + value[0].number = m_selectedSlot; + IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, + IggyPlayerRootPath(getMovie()), + m_funcSetActiveSlot, 1, value); } void UIScene_TradingMenu::tick() { @@ -261,3 +272,15 @@ void UIScene_TradingMenu::setOfferDescription( getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetOfferDescription, 1, value); } + +void UIScene_TradingMenu::HandleMessage(EUIMessage message, void* data) { + switch (message) { + case eUIMessage_InventoryUpdated: + handleInventoryUpdated(data); + break; + }; +} + +void UIScene_TradingMenu::handleInventoryUpdated(LPVOID data) { + HandleInventoryUpdated(); +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.h index 84d87811c..5445832e2 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.h @@ -23,7 +23,8 @@ protected: UIControl_Label m_labelRequest1, m_labelRequest2; IggyName m_funcMoveSelector, m_funcShowScrollRightArrow, - m_funcShowScrollLeftArrow, m_funcSetOfferDescription; + m_funcShowScrollLeftArrow, m_funcSetOfferDescription, + m_funcSetActiveSlot; UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) UI_MAP_ELEMENT(m_controlMainPanel, "MainPanel") @@ -48,6 +49,7 @@ protected: UI_MAP_NAME(m_funcShowScrollRightArrow, L"ShowScrollRightArrow") UI_MAP_NAME(m_funcShowScrollLeftArrow, L"ShowScrollLeftArrow") UI_MAP_NAME(m_funcSetOfferDescription, L"SetOfferDescription") + UI_MAP_NAME(m_funcSetActiveSlot, L"SetSelectorSlot") UI_END_MAP_ELEMENTS_AND_NAMES() virtual std::wstring getMoviePath(); @@ -73,9 +75,10 @@ protected: virtual void setRequest2RedBox(bool show); virtual void setTradeRedBox(int index, bool show); - virtual void setOfferDescription( - const std::wstring& name, - std::vector& unformattedStrings); + virtual void setOfferDescription(std::vector* description); + + virtual void HandleMessage(EUIMessage message, void* data); + void handleInventoryUpdated(LPVOID data); int getPad() { return m_iPad; } }; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_TrialExitUpsell.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_TrialExitUpsell.cpp index b95c7d1e1..4287246ff 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_TrialExitUpsell.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_TrialExitUpsell.cpp @@ -6,9 +6,6 @@ UIScene_TrialExitUpsell::UIScene_TrialExitUpsell(int iPad, void* initData, UILayer* parentLayer) : UIScene(iPad, parentLayer) { // Setup all the Iggy references we need for this scene - app.DebugPrintf( - "UIScene_TrialExitUpsell::UIScene_TrialExitUpsell BEFORE " - "initialiseMovie CALL\n"); initialiseMovie(); } @@ -58,10 +55,9 @@ void UIScene_TrialExitUpsell::handleInput(int iPad, int key, bool repeat, if (bContentRestricted) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, - IDS_CONTENT_RESTRICTION, uiIDA, 1, - ProfileManager.GetPrimaryPad(), NULL, - this, app.GetStringTable()); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad()); } else #endif { diff --git a/Minecraft.Client/Platform/Common/UI/UIString.cpp b/Minecraft.Client/Platform/Common/UI/UIString.cpp new file mode 100644 index 000000000..676798713 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIString.cpp @@ -0,0 +1,149 @@ +#include "../../stdafx.h" + +#include "../../../../Minecraft.World/Util/StringHelpers.h" + +#include "UIString.h" + +bool UIString::setCurrentLanguage() { + int nextLanguage, nextLocale; + nextLanguage = XGetLanguage(); + nextLocale = XGetLocale(); + + if ((nextLanguage != s_currentLanguage) || + (nextLocale != s_currentLocale)) { + s_currentLanguage = nextLanguage; + s_currentLocale = nextLocale; + return true; + } + + return false; +} + +int UIString::getCurrentLanguage() { return s_currentLanguage; } + +UIString::UIStringCore::UIStringCore(StringBuilder wstrBuilder) { + m_bIsConstant = false; + + m_lastSetLanguage = m_lastSetLocale = -1; + m_lastUpdatedLanguage = m_lastUpdatedLocale = -1; + + m_fStringBuilder = wstrBuilder; + + m_wstrCache = L""; + update(true); +} + +UIString::UIStringCore::UIStringCore(const std::wstring& str) { + m_bIsConstant = true; + + m_lastSetLanguage = m_lastSetLocale = -1; + m_lastUpdatedLanguage = m_lastUpdatedLocale = -1; + + m_wstrCache = str; +} + +std::wstring& UIString::UIStringCore::getString() { + if (hasNewString()) update(true); + return m_wstrCache; +} + +bool UIString::UIStringCore::hasNewString() { + if (m_bIsConstant) return false; + return (m_lastSetLanguage != s_currentLanguage) || + (m_lastSetLocale != s_currentLocale); +} + +bool UIString::UIStringCore::update(bool force) { + if (!m_bIsConstant && (force || hasNewString())) { + m_wstrCache = m_fStringBuilder(); + m_lastSetLanguage = s_currentLanguage; + m_lastSetLocale = s_currentLocale; + return true; + } + return false; +} + +bool UIString::UIStringCore::needsUpdating() { + if (m_bIsConstant) return false; + return (m_lastSetLanguage != s_currentLanguage) || + (m_lastUpdatedLanguage != m_lastSetLanguage) || + (m_lastSetLocale != s_currentLocale) || + (m_lastUpdatedLocale != m_lastSetLocale); +} + +void UIString::UIStringCore::setUpdated() { + m_lastUpdatedLanguage = m_lastSetLanguage; + m_lastUpdatedLocale = m_lastSetLocale; +} + +int UIString::s_currentLanguage = -1; +int UIString::s_currentLocale = -1; + +UIString::UIString() { m_core = std::shared_ptr(); } + +UIString::UIString(int ids) { +#ifdef __PS3__ + StringBuilder builder = StringBuilder(new IdsStringBuilder(ids)); +#else + StringBuilder builder = [ids]() { return app.GetString(ids); }; +#endif + UIStringCore* core = new UIStringCore(builder); + m_core = std::shared_ptr(core); +} + +UIString::UIString(StringBuilder wstrBuilder) { + UIStringCore* core = new UIStringCore(wstrBuilder); + m_core = std::shared_ptr(core); +} + +UIString::UIString(const std::string& constant) { + std::wstring wstr = convStringToWstring(constant); + UIStringCore* core = new UIStringCore(wstr); + m_core = std::shared_ptr(core); +} + +UIString::UIString(const std::wstring& constant) { + UIStringCore* core = new UIStringCore(constant); + m_core = std::shared_ptr(core); +} + +UIString::UIString(const wchar_t* constant) { + std::wstring str = std::wstring(constant); + UIStringCore* core = new UIStringCore(str); + m_core = std::shared_ptr(core); +} + +UIString::~UIString() { +#ifndef __PS3__ + m_core = nullptr; +#endif +} + +bool UIString::empty() { return m_core.get() == NULL; } + +bool UIString::compare(const UIString& uiString) { + return m_core.get() != uiString.m_core.get(); +} + +bool UIString::needsUpdating() { + if (m_core != NULL) + return m_core->needsUpdating(); + else + return false; +} + +void UIString::setUpdated() { + if (m_core != NULL) m_core->setUpdated(); +} + +std::wstring& UIString::getString() { + static std::wstring blank(L""); + if (m_core != NULL) + return m_core->getString(); + else + return blank; +} + +const wchar_t* UIString::c_str() { return getString().c_str(); } + +unsigned int UIString::length() { return getString().length(); } \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIString.h b/Minecraft.Client/Platform/Common/UI/UIString.h new file mode 100644 index 000000000..f493c07b9 --- /dev/null +++ b/Minecraft.Client/Platform/Common/UI/UIString.h @@ -0,0 +1,101 @@ +#pragma once + +#include +#include + +#ifndef __PS3__ + +typedef std::function StringBuilder; + +#else + +class StringBuilderCore { +public: + virtual std::wstring getString() = 0; +}; + +struct StringBuilder { + std::shared_ptr m_coreBuilder; + virtual std::wstring operator()() { return m_coreBuilder->getString(); } + StringBuilder() {} + StringBuilder(StringBuilderCore* core) { + m_coreBuilder = std::shared_ptr(core); + } +}; + +class IdsStringBuilder : public StringBuilderCore { + const int m_ids; + +public: + IdsStringBuilder(int ids) : m_ids(ids) {} + virtual std::wstring getString(void) { return app.GetString(m_ids); } +}; +#endif + +class UIString { +protected: + static int s_currentLanguage; + static int s_currentLocale; + +public: + static bool setCurrentLanguage(); + static int getCurrentLanguage(); + +protected: + class UIStringCore : public std::enable_shared_from_this { + private: + int m_lastSetLanguage; + int m_lastSetLocale; + + int m_lastUpdatedLanguage; + int m_lastUpdatedLocale; + + std::wstring m_wstrCache; + + bool m_bIsConstant; + + StringBuilder m_fStringBuilder; + + public: + UIStringCore(StringBuilder wstrBuilder); + UIStringCore(const std::wstring& str); + + std::wstring& getString(); + + bool hasNewString(); + bool update(bool force); + + bool needsUpdating(); + void setUpdated(); + }; + + std::shared_ptr m_core; + +public: + UIString(); + + UIString(int ids); // Create a dynamic UI std::string from a std::string id + // value. + + UIString(StringBuilder wstrBuilder); // Create a dynamic UI std::string + // with a custom update function. + + // Create a UIString with a constant value. + UIString(const std::string& constant); + UIString(const std::wstring& constant); + UIString(const wchar_t* constant); + + ~UIString(); + + bool empty(); + bool compare(const UIString& uiString); + + bool needsUpdating(); // Language has been change since the last time + // setUpdated was called. + void setUpdated(); // The new text has been used. + + std::wstring& getString(); + + const wchar_t* c_str(); + unsigned int length(); +}; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UIStructs.h b/Minecraft.Client/Platform/Common/UI/UIStructs.h index d9e214ede..b63bfc392 100644 --- a/Minecraft.Client/Platform/Common/UI/UIStructs.h +++ b/Minecraft.Client/Platform/Common/UI/UIStructs.h @@ -15,6 +15,10 @@ class SignTileEntity; class LevelGenerationOptions; class LocalPlayer; class Merchant; +class EntityHorse; +class BeaconTileEntity; +class Slot; +class AbstractContainerMenu; // 4J Stu - Structs shared by Iggy and Xui scenes. typedef struct _UIVec2D { @@ -70,6 +74,7 @@ typedef struct _EnchantingScreenInput { int z; int iPad; bool bSplitscreen; + std::wstring name; } EnchantingScreenInput; // Furnace @@ -91,6 +96,16 @@ typedef struct _CraftingPanelScreenInput { int z; } CraftingPanelScreenInput; +// Fireworks +typedef struct _FireworksScreenInput { + std::shared_ptr player; + bool bSplitscreen; + int iPad; + int x; + int y; + int z; +} FireworksScreenInput; + // Trading typedef struct _TradingScreenInput { std::shared_ptr inventory; @@ -111,6 +126,31 @@ typedef struct _AnvilScreenInput { bool bSplitscreen; } AnvilScreenInput; +// Hopper +typedef struct _HopperScreenInput { + std::shared_ptr inventory; + std::shared_ptr hopper; + int iPad; + bool bSplitscreen; +} HopperScreenInput; + +// Horse +typedef struct _HorseScreenInput { + std::shared_ptr inventory; + std::shared_ptr container; + std::shared_ptr horse; + int iPad; + bool bSplitscreen; +} HorseScreenInput; + +// Beacon +typedef struct _BeaconScreenInput { + std::shared_ptr inventory; + std::shared_ptr beacon; + int iPad; + bool bSplitscreen; +} BeaconScreenInput; + // Sign typedef struct _SignEntryScreenInput { std::shared_ptr sign; @@ -232,6 +272,8 @@ typedef struct _LaunchMoreOptionsMenuInitData { bool bOnlineSettingChangedBySystem = false; + bool bDoMobSpawning = false; + bool bDoDaylightCycle = false; int iPad = -1; std::uint32_t dwTexturePack = 0; @@ -239,6 +281,27 @@ typedef struct _LaunchMoreOptionsMenuInitData { std::wstring seed = L""; int worldSize = 3; bool bDisableSaving = false; + + EGameHostOptionWorldSize currentWorldSize; + EGameHostOptionWorldSize newWorldSize; + + _LaunchMoreOptionsMenuInitData() { + memset(this, 0, sizeof(_LaunchMoreOptionsMenuInitData)); + bOnlineGame = true; + bAllowFriendsOfFriends = true; + bPVP = true; + bFireSpreads = true; + worldSize = 3; + seed = L""; + bDisableSaving = false; + newWorldSize = e_worldSize_Unknown; + newWorldSizeOverwriteEdges = false; + bMobGriefing = true; + bDoMobLoot = true; + bDoTileDrops = true; + bNaturalRegeneration = true; + bDoDaylightCycle = true; + } } LaunchMoreOptionsMenuInitData; typedef struct _LoadingInputParams { @@ -319,13 +382,13 @@ typedef struct { // Message box typedef struct _MessageBoxInfo { - unsigned int uiTitle; - unsigned int uiText; - unsigned int* uiOptionA; - unsigned int uiOptionC; - unsigned int dwPad; - int (*Func)(void*, int, const C4JStorage::EMessageResult); - void* lpParam; + UINT uiTitle; + UINT uiText; + UINT* uiOptionA; + UINT uiOptionC; + DWORD dwPad; + int (*Func)(LPVOID, int, const C4JStorage::EMessageResult); + LPVOID lpParam; // C4JStringTable *pStringTable; // 4J Stu - We don't need this for our // internal message boxes wchar_t* pwchFormatString; @@ -359,3 +422,9 @@ typedef struct _CustomDrawData { y1; // the bounding box of the original DisplayObject, in object space float mat[16]; } CustomDrawData; + +typedef struct _ItemEditorInput { + int iPad; + Slot* slot; + AbstractContainerMenu* menu; +} ItemEditorInput; \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp b/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp index bf25c88c7..79ca80186 100644 --- a/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp +++ b/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp @@ -4,6 +4,8 @@ #include "UITTFFont.h" UITTFFont::UITTFFont(const std::string& path, S32 fallbackCharacter) { + S32 fallbackCharacter) + : m_strFontName(name) { app.DebugPrintf("UITTFFont opening %s\n", path.c_str()); pbData = NULL; @@ -41,7 +43,8 @@ UITTFFont::UITTFFont(const std::string& path, S32 fallbackCharacter) { } IggyFontInstallTruetypeUTF8((void*)pbData, IGGY_TTC_INDEX_none, - "Mojangles_TTF", -1, IGGY_FONTFLAG_none); + m_strFontName.c_str(), -1, + IGGY_FONTFLAG_none); IggyFontInstallTruetypeFallbackCodepointUTF8( "Mojangles_TTF", -1, IGGY_FONTFLAG_none, fallbackCharacter); @@ -57,3 +60,5 @@ UITTFFont::UITTFFont(const std::string& path, S32 fallbackCharacter) { } UITTFFont::~UITTFFont() {} + +std::string UITTFFont::getFontName() { return m_strFontName; } \ No newline at end of file diff --git a/Minecraft.Client/Platform/Common/UI/UITTFFont.h b/Minecraft.Client/Platform/Common/UI/UITTFFont.h index d2992c92c..9b37f9a38 100644 --- a/Minecraft.Client/Platform/Common/UI/UITTFFont.h +++ b/Minecraft.Client/Platform/Common/UI/UITTFFont.h @@ -1,13 +1,16 @@ #pragma once -#include - class UITTFFont { private: std::uint8_t* pbData; + const std::string m_strFontName; + // DWORD dwDataSize; public: - UITTFFont(const std::string& path, S32 fallbackCharacter); + UITTFFont(const std::string& name, const std::string& path, + S32 fallbackCharacter); ~UITTFFont(); + + std::string getFontName(); }; diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_LoadSettings.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_LoadSettings.cpp index df5493ddc..f24a5a12d 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_LoadSettings.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_LoadSettings.cpp @@ -983,7 +983,7 @@ void CScene_LoadGameSettings::StartGameFromSave(CScene_LoadGameSettings* pClass, LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave timer app.SetAutosaveTimerTime(); @@ -1484,7 +1484,7 @@ void CScene_LoadGameSettings::LoadLevelGen(LevelGenerationOptions *levelGen) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave timer app.SetAutosaveTimerTime(); diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_MainMenu.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_MainMenu.cpp index 2423a7a72..e1bbe9750 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_MainMenu.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_MainMenu.cpp @@ -921,7 +921,7 @@ void CScene_Main::LoadTrial(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp index dcdf3e07c..eff8717bc 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp @@ -979,7 +979,7 @@ void CScene_MultiGameCreate::CreateGame(CScene_MultiGameCreate* pClass, DWORD dw LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameJoinLoad.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameJoinLoad.cpp index 5bf3db581..07bacefab 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameJoinLoad.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameJoinLoad.cpp @@ -1928,7 +1928,7 @@ void CScene_MultiGameJoinLoad::LoadLevelGen(LevelGenerationOptions *levelGen) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -1978,7 +1978,7 @@ void CScene_MultiGameJoinLoad::LoadSaveFromDisk(File *saveFile) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; diff --git a/Minecraft.Client/Platform/Durango/Durango_App.cpp b/Minecraft.Client/Platform/Durango/Durango_App.cpp index 5a4c95e8f..833226636 100644 --- a/Minecraft.Client/Platform/Durango/Durango_App.cpp +++ b/Minecraft.Client/Platform/Durango/Durango_App.cpp @@ -304,7 +304,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); diff --git a/Minecraft.Client/Platform/Linux/Linux_App.cpp b/Minecraft.Client/Platform/Linux/Linux_App.cpp index cd462caa2..14b2cc82d 100644 --- a/Minecraft.Client/Platform/Linux/Linux_App.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_App.cpp @@ -108,7 +108,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() { LoadingInputParams* loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); diff --git a/Minecraft.Client/Platform/Orbis/Orbis_App.cpp b/Minecraft.Client/Platform/Orbis/Orbis_App.cpp index 16cd30972..cb0fae464 100644 --- a/Minecraft.Client/Platform/Orbis/Orbis_App.cpp +++ b/Minecraft.Client/Platform/Orbis/Orbis_App.cpp @@ -440,7 +440,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); diff --git a/Minecraft.Client/Platform/PS3/PS3_App.cpp b/Minecraft.Client/Platform/PS3/PS3_App.cpp index b2f8d0646..56efa6a2e 100644 --- a/Minecraft.Client/Platform/PS3/PS3_App.cpp +++ b/Minecraft.Client/Platform/PS3/PS3_App.cpp @@ -557,7 +557,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); diff --git a/Minecraft.Client/Platform/PSVita/PSVita_App.cpp b/Minecraft.Client/Platform/PSVita/PSVita_App.cpp index 888e4c854..37e5e538a 100644 --- a/Minecraft.Client/Platform/PSVita/PSVita_App.cpp +++ b/Minecraft.Client/Platform/PSVita/PSVita_App.cpp @@ -349,7 +349,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); diff --git a/Minecraft.Client/Platform/Windows64/Windows64_App.cpp b/Minecraft.Client/Platform/Windows64/Windows64_App.cpp index bc60aa486..41382f270 100644 --- a/Minecraft.Client/Platform/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Platform/Windows64/Windows64_App.cpp @@ -107,7 +107,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); diff --git a/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp index bf00975cc..1495a7b2b 100644 --- a/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp +++ b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp @@ -280,7 +280,7 @@ void CreateWorldScreen::buttonClicked(Button* button) { LoadingInputParams* loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; app.SetAutosaveTimerTime();