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();
}
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);
}
}
}
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;
}
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);
}
}
}
}
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();
}
}
Aggregations