mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
Merge pull request #2846 from kubikrubikvkube/master
Singleton object should not have map with values that can't be GCed
This commit is contained in:
commit
20b24e3360
40 changed files with 289 additions and 263 deletions
|
|
@ -1443,7 +1443,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
((MagePane) component).changeGUISize();
|
||||
}
|
||||
}
|
||||
for (ChatPanelBasic chatPanel : getChatPanels().values()) {
|
||||
for (ChatPanelBasic chatPanel : CHATS.values()) {
|
||||
chatPanel.changeGUISize(GUISizeHelper.chatFont);
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1718,8 +1718,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
|
||||
private void updateCounts() {
|
||||
deckNameAndCountLabel.setText(role.getName() + " - " + allCards.size());
|
||||
creatureCountLabel.setText("" + creatureCounter.get());
|
||||
landCountLabel.setText("" + landCounter.get());
|
||||
creatureCountLabel.setText(String.valueOf(creatureCounter.get()));
|
||||
landCountLabel.setText(String.valueOf(landCounter.get()));
|
||||
for (CardType cardType : selectByTypeButtons.keySet()) {
|
||||
AbstractButton button = selectByTypeButtons.get(cardType);
|
||||
String text = cardType.toString();
|
||||
|
|
@ -2058,7 +2058,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
if (stack.isEmpty()) {
|
||||
countLabel.setVisible(false);
|
||||
} else {
|
||||
countLabel.setText("" + stack.size());
|
||||
countLabel.setText(String.valueOf(stack.size()));
|
||||
countLabel.setLocation(GRID_PADDING + (cardWidth + GRID_PADDING) * colIndex, currentY - COUNT_LABEL_HEIGHT);
|
||||
countLabel.setSize(cardWidth, COUNT_LABEL_HEIGHT);
|
||||
countLabel.setVisible(true);
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public class ChatPanelBasic extends javax.swing.JPanel {
|
|||
if (level.equals("0")) {
|
||||
return false;
|
||||
}
|
||||
message = "." + message + ".";
|
||||
message = '.' + message + '.';
|
||||
|
||||
message = message.toLowerCase();
|
||||
message = message.replaceAll("[a@]([s5][s5]+)", "axyx");
|
||||
|
|
@ -217,7 +217,7 @@ public class ChatPanelBasic extends javax.swing.JPanel {
|
|||
|
||||
if (level.equals("2")) {
|
||||
message = message.replaceAll("\\.", "");
|
||||
message = "." + message + ".";
|
||||
message = '.' + message + '.';
|
||||
matchPattern = profanity2Pattern.matcher(message);
|
||||
if (matchPattern.find()) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ public class KeyBindButton extends JButton implements ActionListener {
|
|||
private void applyNewKeycode(int code) {
|
||||
preferences.getKeybindButtons().stream()
|
||||
.filter(b -> b != KeyBindButton.this)
|
||||
.filter(b -> b.getKeyCode() == code)
|
||||
.filter(b -> {
|
||||
return b.keyCode == code;
|
||||
})
|
||||
.forEach(b -> b.setKeyCode(0));
|
||||
|
||||
setKeyCode(code);
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
synchronized (dialogManagers) {
|
||||
if (!dialogManagers.containsKey(gameId)) {
|
||||
DialogManager dialogManager = new DialogManager();
|
||||
dialogManager.setScreenWidth(768);
|
||||
dialogManager.setScreenHeight(1024);
|
||||
dialogManager.screen_width = 768;
|
||||
dialogManager.screen_height = 1024;
|
||||
dialogManager.setBounds(0, 0, 768, 1024);
|
||||
dialogManager.setVisible(false);
|
||||
dialogManagers.put(gameId, dialogManager);
|
||||
|
|
@ -96,8 +96,8 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
public static void updateParams(int width, int height, boolean isVisible) {
|
||||
synchronized (dialogManagers) {
|
||||
for (DialogManager dialogManager : dialogManagers.values()) {
|
||||
dialogManager.setScreenWidth(width);
|
||||
dialogManager.setScreenHeight(height);
|
||||
dialogManager.screen_width = width;
|
||||
dialogManager.screen_height = height;
|
||||
dialogManager.setBounds(0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,8 +141,7 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
remove(toRemove.get(i));
|
||||
}
|
||||
|
||||
java.util.List<CardView> cardList = new ArrayList<CardView>();
|
||||
cardList.addAll(cards.values());
|
||||
java.util.List<CardView> cardList = new ArrayList<CardView>(cards.values());
|
||||
|
||||
int width = SettingsManager.getInstance().getCardSize().width;
|
||||
int height = SettingsManager.getInstance().getCardSize().height;
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
if (card.getId().equals(cardView.getId())) {
|
||||
deck.getCards().remove(card);
|
||||
deck.getSideboard().add(card);
|
||||
cardSelector.loadSideboard(new ArrayList<>(deck.getSideboard()), getBigCard());
|
||||
cardSelector.loadSideboard(new ArrayList<>(deck.getSideboard()), this.bigCard);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom());
|
||||
if (tournamentType.isCubeBooster()) {
|
||||
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
|
||||
if (!(cubeFromDeckFilename.equals(""))) {
|
||||
if (!(cubeFromDeckFilename.isEmpty())) {
|
||||
Deck cubeFromDeck = new Deck();
|
||||
try {
|
||||
cubeFromDeck = Deck.load(DeckImporterUtil.importDeck(cubeFromDeckFilename), true, true);
|
||||
|
|
@ -828,8 +828,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, "");
|
||||
if (!randomPrefs.isEmpty()) {
|
||||
txtRandomPacks.setText(randomPrefs);
|
||||
ArrayList<String> theList = new ArrayList<>();
|
||||
theList.addAll(Arrays.asList(randomPrefs.split(";")));
|
||||
ArrayList<String> theList = new ArrayList<>(Arrays.asList(randomPrefs.split(";")));
|
||||
randomPackSelector.setSelectedPacks(theList);
|
||||
} else {
|
||||
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();
|
||||
|
|
|
|||
|
|
@ -162,8 +162,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
if (s1 != s2) {
|
||||
changed = true;
|
||||
} else if (s1 > 0) {
|
||||
Set<UUID> attachmentIds = new HashSet<>();
|
||||
attachmentIds.addAll(permanent.getAttachments());
|
||||
Set<UUID> attachmentIds = new HashSet<>(permanent.getAttachments());
|
||||
for (MagePermanent magePermanent : oldMagePermanent.getLinks()) {
|
||||
if (!attachmentIds.contains(magePermanent.getOriginalPermanent().getId())) {
|
||||
// that means that the amount of attachments is the same
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
if (!SessionHandler.watchGame(gameId)) {
|
||||
removeGame();
|
||||
}
|
||||
for (PlayAreaPanel panel : getPlayers().values()) {
|
||||
for (PlayAreaPanel panel : players.values()) {
|
||||
panel.setPlayingMode(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -553,7 +553,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
if (!SessionHandler.startReplay(gameId)) {
|
||||
removeGame();
|
||||
}
|
||||
for (PlayAreaPanel panel : getPlayers().values()) {
|
||||
for (PlayAreaPanel panel : players.values()) {
|
||||
panel.setPlayingMode(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -815,7 +815,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
logger.warn(" uuid:" + player.getPlayerId());
|
||||
logger.warn(" players:");
|
||||
for (PlayAreaPanel p : players.values()) {
|
||||
logger.warn("" + p);
|
||||
logger.warn(String.valueOf(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public class ButtonColumn extends AbstractCellEditor implements TableCellRendere
|
|||
if (table.getRowCount() > 0 && table.getRowCount() >= table.getEditingRow() && table.getEditingRow() >= 0) {
|
||||
int row = table.convertRowIndexToModel(table.getEditingRow());
|
||||
fireEditingStopped();
|
||||
ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row);
|
||||
ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, String.valueOf(row));
|
||||
action.actionPerformed(event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,70 +68,70 @@ public class AudioManager {
|
|||
if (audioManager.nextPageClip == null) {
|
||||
audioManager.nextPageClip = new MageClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav", AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().nextPageClip);
|
||||
checkAndPlayClip(audioManager.nextPageClip);
|
||||
}
|
||||
|
||||
public static void playPrevPage() {
|
||||
if (audioManager.prevPageClip == null) {
|
||||
audioManager.prevPageClip = new MageClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav", AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().prevPageClip);
|
||||
checkAndPlayClip(audioManager.prevPageClip);
|
||||
}
|
||||
|
||||
public static void playAnotherTab() {
|
||||
if (audioManager.anotherTabClip == null) {
|
||||
audioManager.anotherTabClip = new MageClip(Constants.BASE_SOUND_PATH + "OnNextPage.wav", AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().anotherTabClip);
|
||||
checkAndPlayClip(audioManager.anotherTabClip);
|
||||
}
|
||||
|
||||
public static void playNextPhase() {
|
||||
if (audioManager.nextPhaseClip == null) {
|
||||
audioManager.nextPhaseClip = new MageClip(Constants.BASE_SOUND_PATH + "OnNextPhase.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().nextPhaseClip);
|
||||
checkAndPlayClip(audioManager.nextPhaseClip);
|
||||
}
|
||||
|
||||
public static void playEndTurn() {
|
||||
if (audioManager.endTurnClip == null) {
|
||||
audioManager.endTurnClip = new MageClip(Constants.BASE_SOUND_PATH + "OnEndTurn.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().endTurnClip);
|
||||
checkAndPlayClip(audioManager.endTurnClip);
|
||||
}
|
||||
|
||||
public static void playTapPermanent() {
|
||||
if (audioManager.tapPermanentClip == null) {
|
||||
audioManager.tapPermanentClip = new MageClip(Constants.BASE_SOUND_PATH + "OnTapPermanent.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().tapPermanentClip);
|
||||
checkAndPlayClip(audioManager.tapPermanentClip);
|
||||
}
|
||||
|
||||
public static void playSummon() {
|
||||
if (audioManager.summonClip == null) {
|
||||
audioManager.summonClip = new MageClip(Constants.BASE_SOUND_PATH + "OnSummon.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().summonClip);
|
||||
checkAndPlayClip(audioManager.summonClip);
|
||||
}
|
||||
|
||||
public static void playDiedCreature() {
|
||||
if (audioManager.diedCreatureClip == null) {
|
||||
audioManager.diedCreatureClip = new MageClip(Constants.BASE_SOUND_PATH + "OnSummon-.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().diedCreatureClip);
|
||||
checkAndPlayClip(audioManager.diedCreatureClip);
|
||||
}
|
||||
|
||||
public static void playDraw() {
|
||||
if (audioManager.drawClip == null) {
|
||||
audioManager.drawClip = new MageClip(Constants.BASE_SOUND_PATH + "OnDraw.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().drawClip);
|
||||
checkAndPlayClip(audioManager.drawClip);
|
||||
}
|
||||
|
||||
public static void playButtonOk() {
|
||||
if (audioManager.buttonOkClip == null) {
|
||||
audioManager.buttonOkClip = new MageClip(Constants.BASE_SOUND_PATH + "OnButtonOk.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().buttonOkClip);
|
||||
checkAndPlayClip(audioManager.buttonOkClip);
|
||||
}
|
||||
|
||||
public static void playButtonCancel() {
|
||||
|
|
@ -139,105 +139,105 @@ public class AudioManager {
|
|||
audioManager.buttonCancelClip = new MageClip(Constants.BASE_SOUND_PATH + "OnButtonCancel.wav", AudioGroup.SkipSounds);
|
||||
|
||||
}
|
||||
checkAndPlayClip(getManager().buttonCancelClip);
|
||||
checkAndPlayClip(audioManager.buttonCancelClip);
|
||||
}
|
||||
|
||||
public static void playAttack() {
|
||||
if (audioManager.attackClip == null) {
|
||||
audioManager.attackClip = new MageClip(Constants.BASE_SOUND_PATH + "OnAttack.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().attackClip);
|
||||
checkAndPlayClip(audioManager.attackClip);
|
||||
}
|
||||
|
||||
public static void playBlock() {
|
||||
if (audioManager.blockClip == null) {
|
||||
audioManager.blockClip = new MageClip(Constants.BASE_SOUND_PATH + "OnBlock.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().blockClip);
|
||||
checkAndPlayClip(audioManager.blockClip);
|
||||
}
|
||||
|
||||
public static void playAddPermanent() {
|
||||
if (audioManager.addPermanentClip == null) {
|
||||
audioManager.addPermanentClip = new MageClip(Constants.BASE_SOUND_PATH + "OnAddPermanent.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().addPermanentClip);
|
||||
checkAndPlayClip(audioManager.addPermanentClip);
|
||||
}
|
||||
|
||||
public static void playAddArtifact() {
|
||||
if (audioManager.addArtifactClip == null) {
|
||||
audioManager.addArtifactClip = new MageClip(Constants.BASE_SOUND_PATH + "OnAddArtifact.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().addArtifactClip);
|
||||
checkAndPlayClip(audioManager.addArtifactClip);
|
||||
}
|
||||
|
||||
public static void playStackNew() {
|
||||
if (audioManager.updateStackClip == null) {
|
||||
audioManager.updateStackClip = new MageClip(Constants.BASE_SOUND_PATH + "OnStackNew.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().updateStackClip);
|
||||
checkAndPlayClip(audioManager.updateStackClip);
|
||||
}
|
||||
|
||||
public static void playOnHover() {
|
||||
if (audioManager.onHover == null) {
|
||||
audioManager.onHover = new MageClip(Constants.BASE_SOUND_PATH + "OnHover.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().onHover);
|
||||
checkAndPlayClip(audioManager.onHover);
|
||||
}
|
||||
|
||||
public static void playOnCountdown1() {
|
||||
if (audioManager.onCountdown1 == null) {
|
||||
audioManager.onCountdown1 = new MageClip(Constants.BASE_SOUND_PATH + "OnCountdown1.wav", AudioGroup.DraftSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().onCountdown1);
|
||||
checkAndPlayClip(audioManager.onCountdown1);
|
||||
}
|
||||
|
||||
public static void playOnDraftSelect() {
|
||||
if (audioManager.onDraftSelect == null) {
|
||||
audioManager.onDraftSelect = new MageClip(Constants.BASE_SOUND_PATH + "OnDraftSelect.wav", AudioGroup.DraftSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().onDraftSelect);
|
||||
checkAndPlayClip(audioManager.onDraftSelect);
|
||||
}
|
||||
|
||||
public static void playOnSkipButton() {
|
||||
if (audioManager.onSkipButton == null) {
|
||||
audioManager.onSkipButton = new MageClip(Constants.BASE_SOUND_PATH + "OnSkipButton.wav", AudioGroup.SkipSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().onSkipButton);
|
||||
checkAndPlayClip(audioManager.onSkipButton);
|
||||
}
|
||||
|
||||
public static void playOnSkipButtonCancel() {
|
||||
if (audioManager.onSkipButtonCancel == null) {
|
||||
audioManager.onSkipButtonCancel = new MageClip(Constants.BASE_SOUND_PATH + "OnSkipButtonCancel.wav", AudioGroup.SkipSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().onSkipButtonCancel);
|
||||
checkAndPlayClip(audioManager.onSkipButtonCancel);
|
||||
}
|
||||
|
||||
public static void playPlayerJoinedTable() {
|
||||
if (audioManager.playerJoinedTable == null) {
|
||||
audioManager.playerJoinedTable = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerJoined.wav", AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().playerJoinedTable);
|
||||
checkAndPlayClip(audioManager.playerJoinedTable);
|
||||
}
|
||||
|
||||
public static void playYourGameStarted() {
|
||||
if (audioManager.yourGameStarted == null) {
|
||||
audioManager.yourGameStarted = new MageClip(Constants.BASE_SOUND_PATH + "OnGameStart.wav", AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().yourGameStarted);
|
||||
checkAndPlayClip(audioManager.yourGameStarted);
|
||||
}
|
||||
|
||||
public static void playTournamentStarted() {
|
||||
if (audioManager.tournamentStarted == null) {
|
||||
audioManager.tournamentStarted = new MageClip(Constants.BASE_SOUND_PATH + "OnTournamentStart.wav", AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().tournamentStarted);
|
||||
checkAndPlayClip(audioManager.tournamentStarted);
|
||||
}
|
||||
|
||||
public static void playPlayerWhispered() {
|
||||
if (audioManager.playerWhispered == null) {
|
||||
audioManager.playerWhispered = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerWhispered.wav", AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().playerWhispered);
|
||||
checkAndPlayClip(audioManager.playerWhispered);
|
||||
}
|
||||
|
||||
public static void playPlayerSubmittedDeck() {
|
||||
|
|
@ -245,14 +245,14 @@ public class AudioManager {
|
|||
audioManager.playerSubmittedDeck = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerSubmittedDeck.wav",
|
||||
AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().playerSubmittedDeck);
|
||||
checkAndPlayClip(audioManager.playerSubmittedDeck);
|
||||
}
|
||||
|
||||
public static void playPlayerLeft() {
|
||||
if (audioManager.playerLeft == null) {
|
||||
audioManager.playerLeft = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerLeft.wav", AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().playerLeft);
|
||||
checkAndPlayClip(audioManager.playerLeft);
|
||||
}
|
||||
|
||||
public static void playPlayerQuitTournament() {
|
||||
|
|
@ -260,21 +260,21 @@ public class AudioManager {
|
|||
audioManager.playerQuitTournament = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerQuitTournament.wav",
|
||||
AudioGroup.OtherSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().playerQuitTournament);
|
||||
checkAndPlayClip(audioManager.playerQuitTournament);
|
||||
}
|
||||
|
||||
public static void playPlayerLost() {
|
||||
if (audioManager.playerLost == null) {
|
||||
audioManager.playerLost = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerLost.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().playerLost);
|
||||
checkAndPlayClip(audioManager.playerLost);
|
||||
}
|
||||
|
||||
public static void playPlayerWon() {
|
||||
if (audioManager.playerWon == null) {
|
||||
audioManager.playerWon = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerWon.wav", AudioGroup.GameSounds);
|
||||
}
|
||||
checkAndPlayClip(getManager().playerWon);
|
||||
checkAndPlayClip(audioManager.playerWon);
|
||||
}
|
||||
|
||||
private static boolean audioGroupEnabled(AudioGroup audioGroup) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.client.util.gui;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
|
@ -7,7 +9,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Class for dealing with arrows in the game.
|
||||
*
|
||||
*
|
||||
* @author nantuko, noxx
|
||||
*/
|
||||
public class ArrowBuilder {
|
||||
|
|
@ -18,31 +20,25 @@ public class ArrowBuilder {
|
|||
instance = new ArrowBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores arrow panels per game
|
||||
*/
|
||||
private final Map<UUID, JPanel> arrowPanels = new HashMap<>();
|
||||
private final Map<UUID, Map<Type, List<Arrow>>> map = new MapMaker().weakKeys().weakValues().makeMap();
|
||||
/**
|
||||
* The top panel where arrow panels are added to.
|
||||
*/
|
||||
private JPanel arrowsManagerPanel;
|
||||
private int currentWidth;
|
||||
private int currentHeight;
|
||||
|
||||
public static ArrowBuilder getBuilder() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* The top panel where arrow panels are added to.
|
||||
*/
|
||||
private JPanel arrowsManagerPanel;
|
||||
|
||||
/**
|
||||
* Stores arrow panels per game
|
||||
*/
|
||||
private final Map<UUID, JPanel> arrowPanels = new HashMap<UUID, JPanel>();
|
||||
|
||||
private final Map<UUID, Map<Type, List<Arrow>>> map = new HashMap<UUID, Map<Type, java.util.List<Arrow>>>();
|
||||
|
||||
private int currentWidth;
|
||||
private int currentHeight;
|
||||
|
||||
public enum Type {
|
||||
PAIRED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the panel where all arrows are being drawn.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public JPanel getArrowsManagerPanel() {
|
||||
|
|
@ -58,7 +54,7 @@ public class ArrowBuilder {
|
|||
}
|
||||
return arrowsManagerPanel;
|
||||
}
|
||||
|
||||
|
||||
private JPanel getArrowsPanel(UUID gameId) {
|
||||
if (!arrowPanels.containsKey(gameId)) {
|
||||
JPanel arrowPanel = new JPanel();
|
||||
|
|
@ -73,20 +69,9 @@ public class ArrowBuilder {
|
|||
return arrowPanels.get(gameId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not synchronized method for arrows panel.
|
||||
* Doesn't create JPanel in case the panel doesn't exist.
|
||||
* Works faster.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/*public JPanel getPanelRef() {
|
||||
return arrowsManagerPanel;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Adds new arrow.
|
||||
*
|
||||
*
|
||||
* @param startX
|
||||
* @param startY
|
||||
* @param endX
|
||||
|
|
@ -100,18 +85,25 @@ public class ArrowBuilder {
|
|||
arrow.setColor(color);
|
||||
arrow.setArrowLocation(startX, startY, endX, endY);
|
||||
arrow.setBounds(0, 0, Math.max(startX, endX) + 40, Math.max(startY, endY) + 30); // 30 is offset for arrow heads (being cut otherwise)
|
||||
|
||||
synchronized (map) {
|
||||
p.add(arrow);
|
||||
Map<Type, java.util.List<Arrow>> innerMap = map.computeIfAbsent(gameId, k -> new HashMap<Type, List<Arrow>>());
|
||||
java.util.List<Arrow> arrows = innerMap.computeIfAbsent(type, k -> new ArrayList<Arrow>());
|
||||
arrows.add(arrow);
|
||||
}
|
||||
|
||||
p.add(arrow);
|
||||
Map<Type, List<Arrow>> innerMap = map.computeIfAbsent(gameId, k -> new HashMap<>());
|
||||
List<Arrow> arrows = innerMap.computeIfAbsent(type, k -> new ArrayList<>());
|
||||
arrows.add(arrow);
|
||||
p.revalidate();
|
||||
p.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Not synchronized method for arrows panel.
|
||||
* Doesn't create JPanel in case the panel doesn't exist.
|
||||
* Works faster.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/*public JPanel getPanelRef() {
|
||||
return arrowsManagerPanel;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Removes all arrows from the screen.
|
||||
*/
|
||||
|
|
@ -119,15 +111,13 @@ public class ArrowBuilder {
|
|||
if (map.containsKey(gameId)) {
|
||||
Map<Type, List<Arrow>> innerMap = map.get(gameId);
|
||||
JPanel p = getArrowsPanel(gameId);
|
||||
synchronized (map) {
|
||||
if (p != null && p.getComponentCount() > 0) {
|
||||
p.removeAll();
|
||||
p.revalidate();
|
||||
p.repaint();
|
||||
}
|
||||
innerMap.clear();
|
||||
map.remove(gameId);
|
||||
if (p != null && p.getComponentCount() > 0) {
|
||||
p.removeAll();
|
||||
p.revalidate();
|
||||
p.repaint();
|
||||
}
|
||||
innerMap.clear();
|
||||
map.remove(gameId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,18 +127,16 @@ public class ArrowBuilder {
|
|||
java.util.List<Arrow> arrows = innerMap.get(type);
|
||||
if (arrows != null && !arrows.isEmpty()) {
|
||||
JPanel p = getArrowsPanel(gameId);
|
||||
synchronized (map) {
|
||||
for (Arrow arrow : arrows) {
|
||||
p.remove(arrow);
|
||||
}
|
||||
innerMap.put(type, new ArrayList<Arrow>());
|
||||
for (Arrow arrow : arrows) {
|
||||
p.remove(arrow);
|
||||
}
|
||||
innerMap.put(type, new ArrayList<>());
|
||||
p.revalidate();
|
||||
p.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setSize(int width, int height) {
|
||||
this.currentWidth = width;
|
||||
this.currentHeight = height;
|
||||
|
|
@ -173,4 +161,8 @@ public class ArrowBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
PAIRED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -574,12 +574,12 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
|
||||
int cx = getCardX() - component.x;
|
||||
int cy = getCardY() - component.y;
|
||||
int cw = getCardWidth();
|
||||
int ch = getCardHeight();
|
||||
int cw = cardWidth;
|
||||
int ch = cardHeight;
|
||||
if (isTapped()) {
|
||||
cy = ch - cw + cx;
|
||||
ch = cw;
|
||||
cw = getCardHeight();
|
||||
cw = cardHeight;
|
||||
}
|
||||
|
||||
return x >= cx && x <= cx + cw && y >= cy && y <= cy + ch;
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ public abstract class CardRenderer {
|
|||
g2.setColor(Color.black);
|
||||
g2.drawPolygon(p);
|
||||
g2.setFont(new Font("Arial", Font.BOLD, 7));
|
||||
String cstr = "" + v.getCount();
|
||||
String cstr = String.valueOf(v.getCount());
|
||||
int strW = g2.getFontMetrics().stringWidth(cstr);
|
||||
g2.drawString(cstr, 5 - strW / 2, 8);
|
||||
g2.dispose();
|
||||
|
|
|
|||
|
|
@ -707,7 +707,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
if ((cardView instanceof PermanentView) && ((PermanentView) cardView).getDamage() > 0) {
|
||||
int x = cardWidth - partWidth - borderWidth;
|
||||
int y = curY - boxHeight;
|
||||
String damage = "" + ((PermanentView) cardView).getDamage();
|
||||
String damage = String.valueOf(((PermanentView) cardView).getDamage());
|
||||
g.setFont(ptTextFont);
|
||||
int txWidth = g.getFontMetrics().stringWidth(damage);
|
||||
g.setColor(Color.red);
|
||||
|
|
@ -986,7 +986,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
g.setColor(Color.black);
|
||||
g.fillOval(borderWidth + 1, totalContentInset + 1, boxHeight - 2, boxHeight - 2);
|
||||
g.setColor(Color.white);
|
||||
if (isNightCard()) {
|
||||
if (isTransformed) {
|
||||
g.fillArc(borderWidth + 3, totalContentInset + 3, boxHeight - 6, boxHeight - 6, 90, 270);
|
||||
g.setColor(Color.black);
|
||||
g.fillArc(borderWidth + 3 + 3, totalContentInset + 3, boxHeight - 6 - 3, boxHeight - 6, 90, 270);
|
||||
|
|
@ -1012,7 +1012,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
|
||||
// Determine the color of the name / type line text
|
||||
protected Color getBoxTextColor() {
|
||||
if (isNightCard()) {
|
||||
if (isTransformed) {
|
||||
return Color.white;
|
||||
} else if (cardView.isAbility()) {
|
||||
return Color.white;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class TextboxLoyaltyRule extends TextboxRule {
|
|||
} else if (loyaltyChange > 0) {
|
||||
return "+" + loyaltyChange;
|
||||
} else {
|
||||
return "" + loyaltyChange;
|
||||
return String.valueOf(loyaltyChange);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,10 +186,10 @@ public class TextboxRuleParser {
|
|||
if (levelMatch.find()) {
|
||||
try {
|
||||
levelFrom = Integer.parseInt(levelMatch.group(1));
|
||||
if (!levelMatch.group(2).equals("")) {
|
||||
if (!levelMatch.group(2).isEmpty()) {
|
||||
levelTo = Integer.parseInt(levelMatch.group(2));
|
||||
}
|
||||
if (!levelMatch.group(3).equals("")) {
|
||||
if (!levelMatch.group(3).isEmpty()) {
|
||||
levelTo = TextboxLevelRule.AND_HIGHER;
|
||||
}
|
||||
isLeveler = true;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,9 @@ public class DownloadGui extends JPanel {
|
|||
p.setBorder(BorderFactory.createTitledBorder("Progress:"));
|
||||
p.add(progress);
|
||||
JButton b = new JButton("X");
|
||||
b.addActionListener(e -> getDownloader().dispose());
|
||||
b.addActionListener(e -> {
|
||||
d.dispose();
|
||||
});
|
||||
p.add(b, BorderLayout.EAST);
|
||||
add(p, BorderLayout.NORTH);
|
||||
|
||||
|
|
@ -154,10 +156,10 @@ public class DownloadGui extends JPanel {
|
|||
add(bar = new JProgressBar(job.getProgress()));
|
||||
JButton b = new JButton("X");
|
||||
b.addActionListener(e -> {
|
||||
switch(getJob().getState()) {
|
||||
switch(this.job.getState()) {
|
||||
case NEW:
|
||||
case WORKING:
|
||||
getJob().setState(State.ABORTED);
|
||||
this.job.setState(State.ABORTED);
|
||||
}
|
||||
});
|
||||
add(b, BorderLayout.EAST);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class DownloadJob extends AbstractLaternaBean {
|
|||
public void setError(String message, Exception error) {
|
||||
if (message == null) {
|
||||
|
||||
message = "Download of " + this.getName() + "from " + this.getSource().toString() + " caused error: " + error.toString();
|
||||
message = "Download of " + name + "from " + source.toString() + " caused error: " + error.toString();
|
||||
}
|
||||
// log.warn(message, error);
|
||||
log.warn(message);
|
||||
|
|
@ -167,7 +167,7 @@ public class DownloadJob extends AbstractLaternaBean {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return proxy != null ? proxy.type().toString() + ' ' : "" + url;
|
||||
return proxy != null ? proxy.type().toString() + ' ' : url;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -196,7 +196,7 @@ public class DownloadJob extends AbstractLaternaBean {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return proxy != null ? proxy.type().toString() + ' ' : "" + url;
|
||||
return proxy != null ? proxy.type().toString() + ' ' : String.valueOf(url);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
|
||||
@Override
|
||||
public void dispose() {
|
||||
for (DownloadJob j : getJobs()) {
|
||||
for (DownloadJob j : jobs) {
|
||||
switch (j.getState()) {
|
||||
case NEW:
|
||||
case WORKING:
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class GathererSymbols implements Iterable<DownloadJob> {
|
|||
if (symIndex < symbols.length) {
|
||||
sym = symbols[symIndex++];
|
||||
} else if (numeric <= maxNumeric) {
|
||||
sym = "" + (numeric++);
|
||||
sym = String.valueOf(numeric++);
|
||||
} else {
|
||||
sizeIndex++;
|
||||
if (sizeIndex == sizes.length) {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
JDialog dlg = download.getDlg(frame);
|
||||
dlg.setVisible(true);
|
||||
dlg.dispose();
|
||||
download.setCancel(true);
|
||||
download.cancel = true;
|
||||
}
|
||||
|
||||
public JDialog getDlg(JFrame frame) {
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
private BufferedImage loadbuffer_selected() throws IOException {
|
||||
BufferedImage res;
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE, "");
|
||||
if (path != null && !path.equals("")) {
|
||||
if (path != null && !path.isEmpty()) {
|
||||
try {
|
||||
res = ImageIO.read(new File(path));
|
||||
return res;
|
||||
|
|
@ -162,7 +162,7 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
background = ImageIO.read(is);
|
||||
} else {
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE, "");
|
||||
if (path != null && !path.equals("")) {
|
||||
if (path != null && !path.isEmpty()) {
|
||||
try {
|
||||
File f = new File(path);
|
||||
if (f != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue