mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
removed some (not all) slowdonws in quest card shop when owner of a big collection purchases a fatpack. (there were N redraws of owned card list instead of just one)
This commit is contained in:
@@ -364,7 +364,6 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
|
|||||||
if (item instanceof PaperCard) {
|
if (item instanceof PaperCard) {
|
||||||
final PaperCard card = (PaperCard) item;
|
final PaperCard card = (PaperCard) item;
|
||||||
this.getDeckManager().addItem(card, qty);
|
this.getDeckManager().addItem(card, qty);
|
||||||
this.getCatalogManager().removeItem(item, qty);
|
|
||||||
this.questData.getCards().buyCard(card, qty, value);
|
this.questData.getCards().buyCard(card, qty, value);
|
||||||
|
|
||||||
} else if (item instanceof OpenablePack) {
|
} else if (item instanceof OpenablePack) {
|
||||||
@@ -379,13 +378,13 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
|
|||||||
}
|
}
|
||||||
this.questData.getCards().buyPack(booster, value);
|
this.questData.getCards().buyPack(booster, value);
|
||||||
final List<PaperCard> newCards = booster.getCards();
|
final List<PaperCard> newCards = booster.getCards();
|
||||||
final List<InventoryItem> newInventory = new LinkedList<InventoryItem>(newCards);
|
|
||||||
|
ItemPool<InventoryItem> newInventory = new ItemPool<InventoryItem>(InventoryItem.class);
|
||||||
|
newInventory.addAllFlat(newCards);
|
||||||
getDeckManager().addItems(newInventory);
|
getDeckManager().addItems(newInventory);
|
||||||
final CardListViewer c = new CardListViewer(booster.getName(),
|
final CardListViewer c = new CardListViewer(booster.getName(), "You have found the following cards inside:", newCards);
|
||||||
"You have found the following cards inside:", newCards);
|
|
||||||
c.show();
|
c.show();
|
||||||
}
|
}
|
||||||
this.getCatalogManager().removeItem(item, qty);
|
|
||||||
} else if (item instanceof PreconDeck) {
|
} else if (item instanceof PreconDeck) {
|
||||||
final PreconDeck deck = (PreconDeck) item;
|
final PreconDeck deck = (PreconDeck) item;
|
||||||
this.questData.getCards().buyPreconDeck(deck, value);
|
this.questData.getCards().buyPreconDeck(deck, value);
|
||||||
@@ -400,8 +399,8 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
|
|||||||
one ? "Deck" : String.format("%d copies of deck", qty),
|
one ? "Deck" : String.format("%d copies of deck", qty),
|
||||||
deck.getName(), one ? "was" : "were", one ? "Its" : "Their"),
|
deck.getName(), one ? "was" : "were", one ? "Its" : "Their"),
|
||||||
"Thanks for purchasing!", JOptionPane.INFORMATION_MESSAGE);
|
"Thanks for purchasing!", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
} else return;
|
||||||
this.getCatalogManager().removeItem(item, qty);
|
this.getCatalogManager().removeItem(item, qty);
|
||||||
}
|
|
||||||
|
|
||||||
this.creditsLabel.setText("Credits: " + this.questData.getAssets().getCredits());
|
this.creditsLabel.setText("Credits: " + this.questData.getAssets().getCredits());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,29 +280,9 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
|
|||||||
*/
|
*/
|
||||||
public void addItems(Iterable<Map.Entry<T, Integer>> itemsToAdd) {
|
public void addItems(Iterable<Map.Entry<T, Integer>> itemsToAdd) {
|
||||||
final int n = this.table.getSelectedRow();
|
final int n = this.table.getSelectedRow();
|
||||||
for (Map.Entry<T, Integer> item : itemsToAdd) {
|
this.pool.addAll(itemsToAdd);
|
||||||
this.pool.add(item.getKey(), item.getValue());
|
|
||||||
if (this.isUnfiltered()) {
|
if (this.isUnfiltered()) {
|
||||||
this.model.addItem(item.getKey(), item.getValue());
|
this.model.addItems(itemsToAdd);
|
||||||
}
|
|
||||||
}
|
|
||||||
this.updateView(false);
|
|
||||||
this.table.fixSelection(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* addItems.
|
|
||||||
*
|
|
||||||
* @param itemsToAdd
|
|
||||||
*/
|
|
||||||
public void addItems(Collection<T> itemsToAdd) {
|
|
||||||
final int n = this.table.getSelectedRow();
|
|
||||||
for (T item : itemsToAdd) {
|
|
||||||
this.pool.add(item, 1);
|
|
||||||
if (this.isUnfiltered()) {
|
|
||||||
this.model.addItem(item, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.updateView(false);
|
this.updateView(false);
|
||||||
this.table.fixSelection(n);
|
this.table.fixSelection(n);
|
||||||
|
|||||||
Reference in New Issue
Block a user