From b25b91b3254641531c9eb9614667afa1e1eb6c60 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Wed, 5 Jun 2013 10:39:48 +0400 Subject: [PATCH] Issue#232: Avatar pictures sometimes missing --- .../src/main/java/mage/client/game/PlayerPanelExt.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index 13ee1a8ce5..24d97a1b96 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -43,6 +43,7 @@ import mage.client.cards.BigCard; import mage.client.components.HoverButton; import mage.client.components.MageRoundPane; import mage.client.components.ext.dlg.DialogManager; +import mage.client.dialog.PreferencesDialog; import mage.client.plugins.adapters.MageActionCallback; import mage.client.plugins.impl.Plugins; import mage.client.util.CardsViewUtil; @@ -86,6 +87,8 @@ public class PlayerPanelExt extends javax.swing.JPanel { private static final int AVATAR_COUNT = 77; + private static final String DEFAULT_AVATAR_PATH = "/avatars/51.jpg"; + private static final int PANEL_WIDTH = 94; private static final int PANEL_HEIGHT = 242; private static final int PANEL_HEIGHT_SMALL = 190; @@ -160,7 +163,10 @@ public class PlayerPanelExt extends javax.swing.JPanel { if (!MageFrame.isLite()) { int id = player.getUserData().getAvatarId(); - if (id > 0 && id != avatarId) { + if (id <= 0) { + id = PreferencesDialog.DEFAULT_AVATAR_ID; + } + if (id != avatarId) { avatarId = id; String path = "/avatars/" + String.valueOf(avatarId) + ".jpg"; if (avatarId == 64) { @@ -241,7 +247,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { panelBackground.setVisible(true); // Avatar - Image image = ImageHelper.getImageFromResources("/avatars/unknown.jpg"); + Image image = ImageHelper.getImageFromResources(DEFAULT_AVATAR_PATH); topCardPanel = Plugins.getInstance().getMageCard(new CardView(CardRepository.instance.findCard("Forest").getCard()), bigCard, topCardDimension, gameId, true); topCardPanel.setVisible(false);