mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Fixed that the flag on avatar image could be to big.
This commit is contained in:
parent
ad4b68dcb5
commit
f87c5bbbec
2 changed files with 17 additions and 2 deletions
|
@ -287,7 +287,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
avatar.setText(this.player.getName());
|
||||
if (!player.getUserData().getFlagName().equals(flagName)) {
|
||||
flagName = player.getUserData().getFlagName();
|
||||
this.avatar.setTopTextImage(CountryUtil.getCountryFlagIcon(flagName).getImage());
|
||||
this.avatar.setTopTextImage(CountryUtil.getCountryFlagIconSize(flagName, 11).getImage());
|
||||
}
|
||||
// TODO: Add the wins to the tooltiptext of the avatar
|
||||
String countryname = CountryUtil.getCountryName(flagName);
|
||||
|
|
|
@ -27,7 +27,6 @@ public class CountryUtil {
|
|||
public static ImageIcon getCountryFlagIcon(String countryCode) {
|
||||
ImageIcon flagIcon = FLAG_ICON_CACHE.get(countryCode);
|
||||
if (flagIcon == null) {
|
||||
// URL url = CountryUtil.class.getResource("/flags/" + countryCode + (countryCode.endsWith(".png") ? "" : ".png"));
|
||||
Image flagImage = ImageHelper.getImageFromResources("/flags/" + countryCode + (countryCode.endsWith(".png") ? "" : ".png"));
|
||||
if (flagImage != null) {
|
||||
if (GUISizeHelper.flagHeight > 11) {
|
||||
|
@ -48,6 +47,22 @@ public class CountryUtil {
|
|||
return flagIcon;
|
||||
}
|
||||
|
||||
public static ImageIcon getCountryFlagIconSize(String countryCode, int height) {
|
||||
ImageIcon flagIcon = null;
|
||||
Image flagImage = ImageHelper.getImageFromResources("/flags/" + countryCode + (countryCode.endsWith(".png") ? "" : ".png"));
|
||||
if (flagImage != null) {
|
||||
|
||||
if (height > 11) {
|
||||
int width = Math.round(height * flagImage.getWidth(null) / flagImage.getHeight(null));
|
||||
BufferedImage resized = ImageHelper.scale((BufferedImage) flagImage, BufferedImage.TYPE_4BYTE_ABGR, width, height);
|
||||
flagIcon = new ImageIcon(resized);
|
||||
} else {
|
||||
flagIcon = new ImageIcon(flagImage);
|
||||
}
|
||||
}
|
||||
return flagIcon;
|
||||
}
|
||||
|
||||
public static void changeGUISize() {
|
||||
FLAG_ICON_CACHE.clear();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue