aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp')
-rw-r--r--Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
index 7823fb4e..0ee92eef 100644
--- a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
+++ b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
@@ -50,7 +50,10 @@ void UIScene_AbstractContainerMenu::handleDestroy()
// 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst 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) pMinecraft->localplayers[m_iPad]->closeContainer();
+ 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);
@@ -311,7 +314,7 @@ void UIScene_AbstractContainerMenu::render(S32 width, S32 height, C4JRender::eVi
if(m_needsCacheRendered)
{
- m_expectedCachedSlotCount = 0;
+ m_expectedCachedSlotCount = GetBaseSlotCount();
unsigned int count = m_menu->getSize();
for(unsigned int i = 0; i < count; ++i)
{
@@ -333,6 +336,7 @@ void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *reg
if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
shared_ptr<ItemInstance> item = nullptr;
+ int slotId = -1;
if(wcscmp((wchar_t *)region->name,L"pointerIcon")==0)
{
m_cacheSlotRenders = false;
@@ -340,7 +344,6 @@ void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *reg
}
else
{
- int slotId = -1;
swscanf((wchar_t*)region->name,L"slot_%d",&slotId);
if (slotId == -1)
{
@@ -354,7 +357,7 @@ void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *reg
}
}
- if(item != NULL) customDrawSlotControl(region,m_iPad,item,1.0f,item->isFoil(),true);
+ if(item != NULL) 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, bool pressed, bool released, bool &handled)
@@ -370,21 +373,24 @@ void UIScene_AbstractContainerMenu::handleInput(int iPad, int key, bool repeat,
}
}
-void UIScene_AbstractContainerMenu::SetPointerText(const wstring &description, vector<wstring> &unformattedStrings, bool newSlot)
+void UIScene_AbstractContainerMenu::SetPointerText(vector<HtmlString> *description, bool newSlot)
{
- //app.DebugPrintf("Setting pointer text\n");
- m_cursorPath.setLabel(description,false,newSlot);
+ m_cursorPath.setLabel(HtmlString::Compose(description), false, newSlot);
}
void UIScene_AbstractContainerMenu::setSectionFocus(ESceneSection eSection, int iPad)
{
+ UIControl *newFocus = getSection(eSection);
+ if(newFocus) newFocus->setFocus(true);
+
if(m_focusSection != eSectionNone)
{
UIControl *currentFocus = getSection(m_focusSection);
- if(currentFocus) currentFocus->setFocus(false);
+ // 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);
}
- UIControl *newFocus = getSection(eSection);
- if(newFocus) newFocus->setFocus(true);
+
m_focusSection = eSection;
}
@@ -405,6 +411,13 @@ shared_ptr<ItemInstance> UIScene_AbstractContainerMenu::getSlotItem(ESceneSectio
else 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 );