Search in sources :

Example 1 with ItemsStash

use of delta.games.lotro.character.storage.ItemsStash in project lotro-companion by dmorcellet.

the class MainTestStashWindow method main.

/**
 * Basic main method for test.
 * @param args Not used.
 */
public static void main(String[] args) {
    LotroTestUtils utils = new LotroTestUtils();
    CharacterFile toon = utils.getMainToon();
    // Copy gear to stash
    ItemsStash stash = toon.getStash();
    CharacterData data = toon.getInfosManager().getLastCharacterDescription();
    CharacterEquipment gear = data.getEquipment();
    for (EQUIMENT_SLOT slot : EQUIMENT_SLOT.values()) {
        Item item = gear.getItemForSlot(slot);
        if (item != null) {
            Item clone = ItemFactory.clone(item);
            stash.addItem(clone);
        }
    }
    StashWindowController controller = new StashWindowController(toon);
    controller.show();
}
Also used : Item(delta.games.lotro.lore.items.Item) CharacterEquipment(delta.games.lotro.character.CharacterEquipment) ItemsStash(delta.games.lotro.character.storage.ItemsStash) CharacterData(delta.games.lotro.character.CharacterData) EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) LotroTestUtils(delta.games.lotro.character.log.LotroTestUtils) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 2 with ItemsStash

use of delta.games.lotro.character.storage.ItemsStash in project lotro-companion by dmorcellet.

the class EquipmentPanelController method handleCopyToStash.

private void handleCopyToStash(EQUIMENT_SLOT slot) {
    CharacterEquipment equipment = _toonData.getEquipment();
    SlotContents contents = equipment.getSlotContents(slot, false);
    if (contents != null) {
        Item item = contents.getItem();
        if (item != null) {
            ItemsStash stash = _toon.getStash();
            Item newItem = ItemFactory.clone(item);
            stash.addItem(newItem);
            Integer stashId = newItem.getStashIdentifier();
            item.setStashIdentifier(stashId);
            _toon.saveStash();
            // Broadcast stash update event...
            CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_STASH_UPDATED, _toon, null);
            EventsManager.invokeEvent(event);
        }
    }
}
Also used : SlotContents(delta.games.lotro.character.CharacterEquipment.SlotContents) JMenuItem(javax.swing.JMenuItem) Item(delta.games.lotro.lore.items.Item) CharacterEquipment(delta.games.lotro.character.CharacterEquipment) ItemsStash(delta.games.lotro.character.storage.ItemsStash) CharacterEvent(delta.games.lotro.character.events.CharacterEvent)

Example 3 with ItemsStash

use of delta.games.lotro.character.storage.ItemsStash in project lotro-companion by dmorcellet.

the class StashItemsTableController method buildDataProvider.

private DataProvider<Item> buildDataProvider() {
    DataProvider<Item> ret = new DataProvider<Item>() {

        @Override
        public Item getAt(int index) {
            ItemsStash stash = _toon.getStash();
            List<Item> items = stash.getItemsList();
            return items.get(index);
        }

        @Override
        public int getCount() {
            ItemsStash stash = _toon.getStash();
            List<Item> items = stash.getItemsList();
            return items.size();
        }
    };
    return ret;
}
Also used : CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) DataProvider(delta.common.ui.swing.tables.DataProvider) Item(delta.games.lotro.lore.items.Item) ItemsStash(delta.games.lotro.character.storage.ItemsStash)

Example 4 with ItemsStash

use of delta.games.lotro.character.storage.ItemsStash in project lotro-companion by dmorcellet.

the class EquipmentPanelController method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd.startsWith(SLOT_SEED)) {
        cmd = cmd.substring(SLOT_SEED.length());
        // Straight click
        EQUIMENT_SLOT slot = EQUIMENT_SLOT.valueOf(cmd);
        if (slot != null) {
            Item currentItem = getItemForSlot(slot);
            if (currentItem != null) {
                handleEditItem(slot);
            } else {
                List<Item> items = ItemsManager.getInstance().getAllItems();
                handleChooseItem(slot, items);
            }
        }
    } else {
        // From contextual menu
        Component invoker = _contextMenu.getInvoker();
        EQUIMENT_SLOT slot = findSlotForButton(invoker);
        if (slot != null) {
            if (EDIT_COMMAND.equals(cmd)) {
                handleEditItem(slot);
            } else if (CHOOSE_COMMAND.equals(cmd)) {
                List<Item> items = ItemsManager.getInstance().getAllItems();
                handleChooseItem(slot, items);
            } else if (CHOOSE_FROM_STASH_COMMAND.equals(cmd)) {
                ItemsStash stash = _toon.getStash();
                List<Item> items = stash.getAll();
                handleChooseItem(slot, items);
            } else if (REMOVE_COMMAND.equals(cmd)) {
                handleRemoveItem(slot);
            } else if (COPY_TO_STASH_COMMAND.equals(cmd)) {
                handleCopyToStash(slot);
            }
        }
    }
}
Also used : JMenuItem(javax.swing.JMenuItem) Item(delta.games.lotro.lore.items.Item) ItemsStash(delta.games.lotro.character.storage.ItemsStash) EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) List(java.util.List) Component(java.awt.Component)

Example 5 with ItemsStash

use of delta.games.lotro.character.storage.ItemsStash in project lotro-companion by dmorcellet.

the class StashWindowController method removeItem.

private void removeItem() {
    GenericTableController<Item> controller = _itemsTable.getTableController();
    Item item = controller.getSelectedItem();
    if (item != null) {
        ItemsStash stash = _toon.getStash();
        stash.removeItem(item.getStashIdentifier());
        _toon.saveStash();
        _itemsTable.getTableController().refresh();
    }
}
Also used : ToolbarIconItem(delta.common.ui.swing.toolbar.ToolbarIconItem) Item(delta.games.lotro.lore.items.Item) ItemsStash(delta.games.lotro.character.storage.ItemsStash)

Aggregations

ItemsStash (delta.games.lotro.character.storage.ItemsStash)6 Item (delta.games.lotro.lore.items.Item)6 ToolbarIconItem (delta.common.ui.swing.toolbar.ToolbarIconItem)2 CharacterEquipment (delta.games.lotro.character.CharacterEquipment)2 EQUIMENT_SLOT (delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT)2 JMenuItem (javax.swing.JMenuItem)2 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)1 DataProvider (delta.common.ui.swing.tables.DataProvider)1 CharacterData (delta.games.lotro.character.CharacterData)1 SlotContents (delta.games.lotro.character.CharacterEquipment.SlotContents)1 CharacterFile (delta.games.lotro.character.CharacterFile)1 CharacterEvent (delta.games.lotro.character.events.CharacterEvent)1 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)1 Component (java.awt.Component)1 List (java.util.List)1