summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/BrewingstandWindow.cpp8
-rw-r--r--src/UI/SlotArea.cpp147
-rw-r--r--src/UI/SlotArea.h2
3 files changed, 80 insertions, 77 deletions
diff --git a/src/UI/BrewingstandWindow.cpp b/src/UI/BrewingstandWindow.cpp
index 2f1f3c97d..11a5990f2 100644
--- a/src/UI/BrewingstandWindow.cpp
+++ b/src/UI/BrewingstandWindow.cpp
@@ -31,17 +31,15 @@ void cBrewingstandWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlay
if (a_ClickedArea == m_SlotAreas[0])
{
- // Brewing stand Area
- if ((a_Slot >= 0) && (a_Slot < 3))
+ if ((a_Slot >= 0) && (a_Slot <= 4))
{
- // Bottle slots
+ // Brewing stand Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
- // Ingredient slot
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
@@ -50,7 +48,7 @@ void cBrewingstandWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlay
else
{
cBrewingRecipes * BR = cRoot::Get()->GetBrewingRecipes();
- if ((BR->IsBottle(a_ItemStack)) || (BR->IsIngredient(a_ItemStack)))
+ if ((BR->IsBottle(a_ItemStack)) || (BR->IsIngredient(a_ItemStack)) || BR->IsFuel(a_ItemStack))
{
AreasInOrder.push_back(m_SlotAreas[0]); /* brewing stand Area */
}
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 3a01d78ef..71a43e01d 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -1947,7 +1947,7 @@ void cSlotAreaFurnace::HandleSmeltItem(const cItem & a_Result, cPlayer & a_Playe
////////////////////////////////////////////////////////////////////////////////
// cSlotAreaBrewingstand:
cSlotAreaBrewingstand::cSlotAreaBrewingstand(cBrewingstandEntity * a_Brewingstand, cWindow & a_ParentWindow) :
- cSlotArea(4, a_ParentWindow),
+ cSlotArea(5, a_ParentWindow),
m_Brewingstand(a_Brewingstand)
{
m_Brewingstand->GetContents().AddListener(*this);
@@ -1975,100 +1975,101 @@ void cSlotAreaBrewingstand::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAct
return;
}
- if ((a_SlotNum >= 0) && (a_SlotNum < 3))
+ if (GetSlot(a_SlotNum, a_Player) == nullptr)
{
- bool bAsync = false;
- if (GetSlot(a_SlotNum, a_Player) == nullptr)
- {
- LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
- return;
- }
+ LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
+ return;
+ }
- cItem Slot(*GetSlot(a_SlotNum, a_Player));
- if (!Slot.IsSameType(a_ClickedItem))
- {
- LOGWARNING("*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum, m_NumSlots);
- LOGWARNING("My item: %s", ItemToFullString(Slot).c_str());
- LOGWARNING("Their item: %s", ItemToFullString(a_ClickedItem).c_str());
- bAsync = true;
- }
+ cItem Slot(*GetSlot(a_SlotNum, a_Player));
+ cItem & DraggingItem = a_Player.GetDraggingItem();
+ cBrewingRecipes * BR = cRoot::Get()->GetBrewingRecipes();
+ if ((a_SlotNum >= 0) && (a_SlotNum <= 2))
+ {
+ // Bottle slots
switch (a_ClickAction)
{
+ case caLeftClick:
+ case caRightClick:
+ {
+ if (BR->IsBottle(Slot))
+ {
+ HandleBrewedItem(a_Player, Slot);
+ }
+ if (!DraggingItem.IsEmpty() && !BR->IsBottle(DraggingItem))
+ {
+ // Deny placing a invalid item into the bottle slot
+ return;
+ }
+ break;
+ }
case caShiftLeftClick:
case caShiftRightClick:
{
- HandleBrewedItem(a_Player);
- ShiftClicked(a_Player, a_SlotNum, Slot);
- return;
+ if (BR->IsBottle(Slot))
+ {
+ HandleBrewedItem(a_Player, Slot);
+ }
+ super::ShiftClicked(a_Player, a_SlotNum, Slot);
+ break;
}
- case caMiddleClick:
+ default:
{
- MiddleClicked(a_Player, a_SlotNum);
- return;
+ if (!DraggingItem.IsEmpty() && !BR->IsBottle(DraggingItem))
+ {
+ // Deny placing a invalid item into the bottle slot
+ return;
+ }
+ break;
}
- case caDropKey:
- case caCtrlDropKey:
+ }
+ }
+
+ if ((a_SlotNum == 3) && !DraggingItem.IsEmpty())
+ {
+ // Ingredient slot
+ switch (a_ClickAction)
+ {
+ case caShiftLeftClick:
+ case caShiftRightClick:
{
- DropClicked(a_Player, a_SlotNum, (a_SlotNum == caCtrlDropKey));
- Slot.m_ItemCount = Slot.m_ItemCount - GetSlot(a_SlotNum, a_Player)->m_ItemCount;
- HandleBrewedItem(a_Player);
- return;
+ super::ShiftClicked(a_Player, a_SlotNum, Slot);
+ break;
}
default:
{
+ if (!BR->IsIngredient(DraggingItem))
+ {
+ // Deny placing a invalid item into the ingredient slot
+ return;
+ }
break;
}
}
+ }
- cItem & DraggingItem = a_Player.GetDraggingItem();
- if (!DraggingItem.IsEmpty())
- {
- super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
- return;
- }
- else
+ if ((a_SlotNum == 4) && !DraggingItem.IsEmpty())
+ {
+ // Fuel slot
+ switch (a_ClickAction)
{
- switch (a_ClickAction)
+ case caShiftLeftClick:
+ case caShiftRightClick:
{
- case caDblClick:
+ super::ShiftClicked(a_Player, a_SlotNum, Slot);
+ break;
+ }
+ default:
+ {
+ if (!BR->IsFuel(DraggingItem))
{
- DblClicked(a_Player, a_SlotNum);
+ // Deny placing a invalid item into the fuel slot
return;
}
- case caLeftClick:
- {
- DraggingItem = Slot;
- HandleBrewedItem(a_Player);
- Slot.Empty();
- break;
- }
- case caRightClick:
- {
- DraggingItem = Slot.CopyOne();
- DraggingItem.m_ItemCount = static_cast<char>(static_cast<float>(Slot.m_ItemCount) / 2.f + 0.5f);
- Slot.m_ItemCount -= DraggingItem.m_ItemCount;
-
- if (Slot.m_ItemCount <= 0)
- {
- Slot.Empty();
- }
- HandleBrewedItem(a_Player);
- break;
- }
- default:
- {
- ASSERT(!"Unhandled click type!");
- }
+ break;
}
}
-
- SetSlot(a_SlotNum, a_Player, Slot);
- if (bAsync)
- {
- m_ParentWindow.BroadcastWholeWindow();
- }
- return;
}
super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
@@ -2078,9 +2079,13 @@ void cSlotAreaBrewingstand::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAct
-void cSlotAreaBrewingstand::HandleBrewedItem(cPlayer & a_Player)
+void cSlotAreaBrewingstand::HandleBrewedItem(cPlayer & a_Player, const cItem & a_ClickedItem)
{
- a_Player.AwardAchievement(achBrewPotion);
+ // Award an achievement if the item is not a water bottle (is a real brewed potion)
+ if (a_ClickedItem.m_ItemDamage > 0)
+ {
+ a_Player.AwardAchievement(achBrewPotion);
+ }
}
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index f613df9af..a25de0319 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -479,7 +479,7 @@ protected:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
/** Called after an item has been brewed to handle statistics etc. */
- void HandleBrewedItem(cPlayer & a_Player);
+ void HandleBrewedItem(cPlayer & a_Player, const cItem & a_ClickedItem);
} ;