diff options
Diffstat (limited to 'src/UI')
-rw-r--r-- | src/UI/SlotArea.cpp | 181 |
1 files changed, 91 insertions, 90 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 948a32a95..97f5ca194 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1891,127 +1891,128 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a return; } - // Result slot clicked - if (a_SlotNum == 2) + switch (a_SlotNum) { - bool bAsync = false; - if (GetSlot(a_SlotNum, a_Player) == nullptr) - { - LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum); - return; - } - - cItem Slot(*GetSlot(a_SlotNum, a_Player)); - if (!Slot.IsSameType(a_ClickedItem)) + case 1: // Fuel slot clicked { - 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 & DraggingItem = a_Player.GetDraggingItem(); + cFurnaceRecipe * FurnaceRecipes = cRoot::Get()->GetFurnaceRecipe(); - switch (a_ClickAction) - { - case caShiftLeftClick: - case caShiftRightClick: + // Do not allow non-fuels to be placed in the fuel slot: + if (!DraggingItem.IsEmpty() && !FurnaceRecipes->IsFuel(DraggingItem) && (a_ClickAction != caShiftLeftClick) && (a_ClickAction != caShiftRightClick)) { - HandleSmeltItem(Slot, a_Player); - ShiftClicked(a_Player, a_SlotNum, Slot); + LOGD("Rejecting non fuel item being placed in fuel slot."); return; } - case caMiddleClick: - { - MiddleClicked(a_Player, a_SlotNum); - return; - } - case caDropKey: - case caCtrlDropKey: - { - DropClicked(a_Player, a_SlotNum, (a_SlotNum == caCtrlDropKey)); - Slot.m_ItemCount = Slot.m_ItemCount - GetSlot(a_SlotNum, a_Player)->m_ItemCount; - HandleSmeltItem(Slot, a_Player); - return; - } - default: - { - break; - } + break; } - - cItem & DraggingItem = a_Player.GetDraggingItem(); - if (!DraggingItem.IsEmpty()) + case 2: // Result slot clicked { - if (a_ClickAction == caDblClick) + bool bAsync = false; + if (GetSlot(a_SlotNum, a_Player) == nullptr) { + LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum); return; } - if (!DraggingItem.IsEqual(Slot)) - { - return; - } - if ((DraggingItem.m_ItemCount + Slot.m_ItemCount) > Slot.GetMaxStackSize()) + + cItem Slot(*GetSlot(a_SlotNum, a_Player)); + if (!Slot.IsSameType(a_ClickedItem)) { - return; + 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; } - DraggingItem.m_ItemCount += Slot.m_ItemCount; - HandleSmeltItem(Slot, a_Player); - Slot.Empty(); - } - else - { switch (a_ClickAction) { - case caDblClick: + case caShiftLeftClick: + case caShiftRightClick: + { + HandleSmeltItem(Slot, a_Player); + ShiftClicked(a_Player, a_SlotNum, Slot); + return; + } + case caMiddleClick: { - DblClicked(a_Player, a_SlotNum); + MiddleClicked(a_Player, a_SlotNum); return; } - case caLeftClick: + case caDropKey: + case caCtrlDropKey: { - DraggingItem = Slot; + DropClicked(a_Player, a_SlotNum, (a_SlotNum == caCtrlDropKey)); + Slot.m_ItemCount = Slot.m_ItemCount - GetSlot(a_SlotNum, a_Player)->m_ItemCount; HandleSmeltItem(Slot, a_Player); - Slot.Empty(); + return; + } + default: + { break; } - case caRightClick: + } + + cItem & DraggingItem = a_Player.GetDraggingItem(); + if (!DraggingItem.IsEmpty()) + { + if (a_ClickAction == caDblClick) + { + return; + } + if (!DraggingItem.IsEqual(Slot)) { - 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; + return; + } + if ((DraggingItem.m_ItemCount + Slot.m_ItemCount) > Slot.GetMaxStackSize()) + { + return; + } - if (Slot.m_ItemCount <= 0) + DraggingItem.m_ItemCount += Slot.m_ItemCount; + HandleSmeltItem(Slot, a_Player); + Slot.Empty(); + } + else + { + switch (a_ClickAction) + { + case caDblClick: { + DblClicked(a_Player, a_SlotNum); + return; + } + case caLeftClick: + { + DraggingItem = Slot; + HandleSmeltItem(Slot, 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(); + } + HandleSmeltItem(DraggingItem, a_Player); + break; + } + default: + { + ASSERT(!"Unhandled click type!"); } - HandleSmeltItem(DraggingItem, a_Player); - break; - } - default: - { - ASSERT(!"Unhandled click type!"); } } - } - - SetSlot(a_SlotNum, a_Player, Slot); - if (bAsync) - { - m_ParentWindow.BroadcastWholeWindow(); - } - return; - } - - // Fuel slot clicked - if (a_SlotNum == 1) - { - cItem & DraggingItem = a_Player.GetDraggingItem(); - cFurnaceRecipe * FurnaceRecipes = cRoot::Get()->GetFurnaceRecipe(); - // Do not allow non-fuels to be placed in the fuel slot: - if (!DraggingItem.IsEmpty() && !FurnaceRecipes->IsFuel(DraggingItem) && (a_ClickAction != caShiftLeftClick) && (a_ClickAction != caShiftRightClick)) - { - LOGD("Rejecting non fuel item being placed in fuel slot."); + SetSlot(a_SlotNum, a_Player, Slot); + if (bAsync) + { + m_ParentWindow.BroadcastWholeWindow(); + } return; } } |