示例#1
0
 def __init__(self, net_plugin, send_click):
     self._net = net_plugin
     self.send_click = send_click
     self.active_slot_nr = 0
     # the slot that moves with the mouse when clicking a slot
     self.cursor_slot = windows.SlotCursor()
     self.window = windows.PlayerWindow()
     self.async = InventoryAsync(self)
示例#2
0
    def set_slot(self, window_id, slot_nr, slot_data):
        inv = self.inventory
        if window_id != inv.window.window_id \
                and window_id == constants.INV_WINID_PLAYER:
            # server did not close the open window
            # before adressing the player inventory
            self.handle_close_window(None, None) #--> this updates the player inventory with the items added by actions in the currently open window, this should be done to maintain consistency with player inventory 
        elif window_id > inv.window.window_id: #what does greater than mean? 
            # server did not send the Open Window packet yet
            return  # assume window will be empty TODO defer the set_slot?

        if window_id == constants.INV_WINID_CURSOR \
                and slot_nr == constants.INV_SLOT_NR_CURSOR:
            slot = inv.cursor_slot = windows.SlotCursor(**slot_data)
        elif window_id == inv.window.window_id:
            slot = inv.window.slots[slot_nr] = windows.Slot(
                inv.window, slot_nr, **slot_data)
        else:
            raise ValueError(
                'Unexpected slot_nr (%i) or window ID (%i instead of %i)'
                % (slot_nr, window_id, inv.window.window_id))

        self.emit_set_slot(slot,self.inventory.window)
示例#3
0
    def set_slot(self, window_id, slot_nr, slot_data):
        inv = self.inventory
        if window_id != inv.window.window_id \
                and window_id == constants.INV_WINID_PLAYER:
            # server did not close the open window
            # before adressing the player inventory
            self.handle_close_window(None, None)
        elif window_id > inv.window.window_id:
            # server did not send the Open Window packet yet
            return  # assume window will be empty TODO defer the set_slot?

        if window_id == constants.INV_WINID_CURSOR \
                and slot_nr == constants.INV_SLOT_NR_CURSOR:
            slot = inv.cursor_slot = windows.SlotCursor(**slot_data)
        elif window_id == inv.window.window_id:
            slot = inv.window.slots[slot_nr] = windows.Slot(
                inv.window, slot_nr, **slot_data)
        else:
            raise ValueError(
                'Unexpected slot_nr (%i) or window ID (%i instead of %i)' %
                (slot_nr, window_id, inv.window.window_id))

        self.emit_set_slot(slot)