def PlaceAction(slotId):
    """This places the cursor action in the action slot, and the
       action that was in the slot in the cursor.  If the cursor was
       empty, we do not do anything here."""
    global _actions
    if MarsCursor._cursorItem is None and MarsCursor._cursorAbility is None:
        return
    oldAction = None
    if _actions.has_key(slotId):
        # store this, because we will want to put it in the cursor later
        oldAction = _actions[slotId]
    if MarsCursor._cursorItem is not None:
        action = ActionEntry()
        action.item = MarsCursor._cursorItem
        _actions[slotId] = action
    elif MarsCursor._cursorAbility is not None:
        action = ActionEntry()
        action.ability = MarsCursor._cursorAbility
        _actions[slotId] = action
    if oldAction is not None:
        MarsCursor._cursorItem = oldAction.item
        MarsCursor._cursorAbility = oldAction.ability
        MarsCursor._UpdateCursor()
    else:
        MarsCursor._cursorItem = None
        MarsCursor._cursorAbility = None
        MarsCursor._UpdateCursor()
def PickupAction(slotId):
    """This places the action that was in the slot in the cursor, and the action
       item that was in the cursor in the action slot.  If the slot is empty, we
       do not do anything here."""
    global _actions
    if not _actions.has_key(slotId):
        return
    action = _actions[slotId]
    if action.item is None and action.ability is None:
        ClientAPI.Log("Shouldn't have gotten here.  Action entry where item and ability are None.")
        return
    oldAction = None
    if MarsCursor._cursorItem is not None and MarsCursor._cursorAbility is not None:
        oldAction = ActionEntry()
        oldAction.item = MarsCursor._cursorItem
        oldAction.ability = MarsCursor._cursorAbility
    MarsCursor._cursorItem = action.item
    MarsCursor._cursorAbility = action.ability
    MarsCursor._UpdateCursor()
    if oldAction is not None:
        # we had an action in the cursor - put it in the action bar
        _actions[slotId] = oldAction
    elif _actions.has_key(slotId):
        # clear the action bar slot
        _actions.pop(slotId)
def PickupAbility(slotId):
    """This places the ability that was in the slot in the cursor.  If the
       slot is empty, we do not do anything here."""
    global _abilities
    if not _abilities.has_key(slotId):
        return
    ability = _abilities[slotId]
    MarsCursor._cursorItem = None
    MarsCursor._cursorAbility = ability
    MarsCursor._UpdateCursor()
def ClickTradeButton(slotId):
    global _tradeOffers
    cursorItem = None
    for slot in _tradeOffers[2].keys():
        item = _tradeOffers[2][slot]
    if MarsCursor.CursorHasItem():
        cursorItem = MarsCursor._cursorItem
    if _tradeOffers[2].has_key(slotId):
        MarsCursor._cursorItem = _tradeOffers[2][slotId]
        del(_tradeOffers[2][slotId])
    else:
        MarsCursor._cursorItem = None
    if cursorItem:
        _tradeOffers[2][slotId] = cursorItem
    for slot in _tradeOffers[2].keys():
        item = _tradeOffers[2][slot]
    MarsCursor._UpdateCursor()
def PickupContainerItem(containerId, slotId):
    ClientAPI.Log("Checking container " + str(containerId) + " and slot " + str(slotId))
    item = _GetContainerItem(containerId, slotId)
    if MarsCursor.CursorHasItem():
        # Place the item in the slot (possibly taking the item that was in the slot)
        ClientAPI.Log("Drop item to: %d, %d" % (containerId, slotId))
        ClientAPI.Log("Old item: %s" % str(MarsCursor._cursorItem))
        _SetContainerItem(containerId, slotId, MarsCursor._cursorItem, item)
        MarsCursor._cursorItem = None
        MarsCursor._UpdateCursor()
    elif MarsCursor.CursorHasAbility():
        ClientAPI.Log("Cannot currently use abilities on items")
    else:
         #Cursor is empty
        MarsCursor._cursorItem = item
        MarsCursor._cursorAbility = None
        MarsCursor._UpdateCursor()
        ClientAPI.Log("Pickup item: %s, %s" % (str(item), item.icon))