| 165 | |
| 166 | |
| 167 | void cWindow::Clicked( |
| 168 | cPlayer & a_Player, |
| 169 | int a_WindowID, short a_SlotNum, eClickAction a_ClickAction, |
| 170 | const cItem & a_ClickedItem |
| 171 | ) |
| 172 | { |
| 173 | cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); |
| 174 | if (a_WindowID != m_WindowID) |
| 175 | { |
| 176 | LOGWARNING("%s: Wrong window ID (exp %d, got %d) received from \"%s\"; ignoring click.", __FUNCTION__, m_WindowID, a_WindowID, a_Player.GetName().c_str()); |
| 177 | return; |
| 178 | } |
| 179 | |
| 180 | switch (a_ClickAction) |
| 181 | { |
| 182 | case caRightClickOutside: |
| 183 | { |
| 184 | if (PlgMgr->CallHookPlayerTossingItem(a_Player)) |
| 185 | { |
| 186 | // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch) |
| 187 | return; |
| 188 | } |
| 189 | if (a_Player.IsGameModeCreative()) |
| 190 | { |
| 191 | a_Player.TossPickup(a_ClickedItem); |
| 192 | } |
| 193 | |
| 194 | // Toss one of the dragged items: |
| 195 | a_Player.TossHeldItem(); |
| 196 | return; |
| 197 | } |
| 198 | case caLeftClickOutside: |
| 199 | { |
| 200 | if (PlgMgr->CallHookPlayerTossingItem(a_Player)) |
| 201 | { |
| 202 | // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch) |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | if (a_Player.IsGameModeCreative()) |
| 207 | { |
| 208 | a_Player.TossPickup(a_ClickedItem); |
| 209 | } |
| 210 | |
| 211 | // Toss all dragged items: |
| 212 | a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount); |
| 213 | return; |
| 214 | } |
| 215 | case caLeftClickOutsideHoldNothing: |
| 216 | case caRightClickOutsideHoldNothing: |
| 217 | { |
| 218 | // Nothing needed |
| 219 | return; |
| 220 | } |
| 221 | case caLeftPaintBegin: OnPaintBegin (a_Player); return; |
| 222 | case caRightPaintBegin: OnPaintBegin (a_Player); return; |
| 223 | case caLeftPaintProgress: OnPaintProgress(a_Player, a_SlotNum); return; |
| 224 | case caRightPaintProgress: OnPaintProgress(a_Player, a_SlotNum); return; |
no test coverage detected