mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
* UI: added new skill level column with star icons instead text;
This commit is contained in:
parent
ed7c32f9e8
commit
92d1b5c51a
6 changed files with 1817 additions and 1750 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,3 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.mage.card.arcane;
|
||||
|
||||
import java.awt.*;
|
||||
|
@ -63,26 +58,26 @@ public final class CardRendererUtils {
|
|||
int plus_b = (int) ((255 - b) / 2);
|
||||
|
||||
return new Color(r + plus_r,
|
||||
g + plus_g,
|
||||
b + plus_b,
|
||||
alpha);
|
||||
g + plus_g,
|
||||
b + plus_b,
|
||||
alpha);
|
||||
}
|
||||
|
||||
|
||||
public static Color abitdarker(Color c) {
|
||||
int r = c.getRed();
|
||||
int g = c.getGreen();
|
||||
int b = c.getBlue();
|
||||
int alpha = c.getAlpha();
|
||||
|
||||
int plus_r = (int) (Math.min (255 - r, r) / 2);
|
||||
int plus_g = (int) (Math.min (255 - g, g) / 2);
|
||||
int plus_b = (int) (Math.min (255 - b, b) / 2);
|
||||
int plus_r = (int) (Math.min(255 - r, r) / 2);
|
||||
int plus_g = (int) (Math.min(255 - g, g) / 2);
|
||||
int plus_b = (int) (Math.min(255 - b, b) / 2);
|
||||
|
||||
return new Color(r - plus_r,
|
||||
g - plus_g,
|
||||
b - plus_b,
|
||||
alpha);
|
||||
}
|
||||
g - plus_g,
|
||||
b - plus_b,
|
||||
alpha);
|
||||
}
|
||||
|
||||
// Draw a rounded box with a 2-pixel border
|
||||
// Used on various card parts.
|
||||
|
@ -192,4 +187,12 @@ public final class CardRendererUtils {
|
|||
.replaceAll("<i>", "")
|
||||
.replaceAll("</i>", "");
|
||||
}
|
||||
|
||||
public static Color copyColor(Color color) {
|
||||
if (color != null) {
|
||||
return new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,13 @@ import java.awt.*;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public final class ManaSymbolsCellRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
// base panel to render
|
||||
private JPanel manaPanel = new JPanel();
|
||||
private JPanel renderPanel = new JPanel();
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||
|
@ -20,47 +23,47 @@ public final class ManaSymbolsCellRenderer extends DefaultTableCellRenderer {
|
|||
|
||||
// get table text cell settings
|
||||
DefaultTableCellRenderer baseRenderer = (DefaultTableCellRenderer) table.getDefaultRenderer(String.class);
|
||||
JLabel baseLabel = (JLabel)baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JLabel baseComp = (JLabel) baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
// apply settings to mana panel from parent
|
||||
manaPanel.setOpaque(baseLabel.isOpaque());
|
||||
manaPanel.setForeground(baseLabel.getForeground());
|
||||
manaPanel.setBackground(baseLabel.getBackground());
|
||||
renderPanel.setOpaque(baseComp.isOpaque());
|
||||
renderPanel.setForeground(CardRendererUtils.copyColor(baseComp.getForeground()));
|
||||
renderPanel.setBackground(CardRendererUtils.copyColor(baseComp.getBackground()));
|
||||
renderPanel.setBorder(baseComp.getBorder());
|
||||
|
||||
// icons size with margin
|
||||
int symbolWidth = GUISizeHelper.symbolTableSize;
|
||||
int symbolHorizontalMargin = 2;
|
||||
|
||||
// create each mana symbol as child label
|
||||
String manaCost = (String)value;
|
||||
manaPanel.removeAll();
|
||||
manaPanel.setLayout(new BoxLayout(manaPanel, BoxLayout.X_AXIS));
|
||||
if(manaCost != null){
|
||||
String manaCost = (String) value;
|
||||
renderPanel.removeAll();
|
||||
renderPanel.setLayout(new BoxLayout(renderPanel, BoxLayout.X_AXIS));
|
||||
if (manaCost != null) {
|
||||
StringTokenizer tok = new StringTokenizer(manaCost, " ");
|
||||
while (tok.hasMoreTokens()) {
|
||||
String symbol = tok.nextToken();
|
||||
|
||||
JLabel symbolLabel = new JLabel();
|
||||
//symbolLabel.setBorder(new LineBorder(new Color(150, 150, 150))); // debug
|
||||
symbolLabel.setBorder(new EmptyBorder(0, symbolHorizontalMargin,0, 0));
|
||||
symbolLabel.setBorder(new EmptyBorder(0, symbolHorizontalMargin, 0, 0));
|
||||
|
||||
BufferedImage image = ManaSymbols.getSizedManaSymbol(symbol, symbolWidth);
|
||||
if (image != null){
|
||||
if (image != null) {
|
||||
// icon
|
||||
symbolLabel.setIcon(new ImageIcon(image));
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
// text
|
||||
symbolLabel.setText("{" + symbol + "}");
|
||||
symbolLabel.setOpaque(baseLabel.isOpaque());
|
||||
symbolLabel.setForeground(baseLabel.getForeground());
|
||||
symbolLabel.setBackground(baseLabel.getBackground());
|
||||
symbolLabel.setOpaque(baseComp.isOpaque());
|
||||
symbolLabel.setForeground(baseComp.getForeground());
|
||||
symbolLabel.setBackground(baseComp.getBackground());
|
||||
}
|
||||
|
||||
manaPanel.add(symbolLabel);
|
||||
renderPanel.add(symbolLabel);
|
||||
}
|
||||
}
|
||||
|
||||
return manaPanel;
|
||||
return renderPanel;
|
||||
}
|
||||
}
|
||||
|
|
BIN
Mage.Client/src/main/resources/info/yellow_star_16.png
Normal file
BIN
Mage.Client/src/main/resources/info/yellow_star_16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 478 B |
BIN
Mage.Client/src/main/resources/info/yellow_star_24.png
Normal file
BIN
Mage.Client/src/main/resources/info/yellow_star_24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 658 B |
BIN
Mage.Client/src/main/resources/info/yellow_star_32.png
Normal file
BIN
Mage.Client/src/main/resources/info/yellow_star_32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 931 B |
Loading…
Reference in a new issue