mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
Made a hack for Nimbus LAF to add transparency to JInternalFrames. Updated CombatDialog. Updated Mage-Theme-Plugin (jar) with background. Fixed "Games played:" title length, so game count can be seen for big numbers.
This commit is contained in:
parent
c6ff81e619
commit
a731fba667
7 changed files with 161 additions and 3 deletions
Binary file not shown.
|
@ -54,9 +54,11 @@ import javax.swing.JOptionPane;
|
|||
import javax.swing.JToolBar.Separator;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.synth.SynthLookAndFeel;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.client.components.MageSynthStyleFactory;
|
||||
import mage.client.dialog.AboutDialog;
|
||||
import mage.client.dialog.CombatDialog;
|
||||
import mage.client.dialog.ConnectDialog;
|
||||
|
@ -111,6 +113,8 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
MageSynthStyleFactory f = new MageSynthStyleFactory(SynthLookAndFeel.getStyleFactory());
|
||||
SynthLookAndFeel.setStyleFactory(f);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
@ -152,11 +156,11 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
|
||||
if (Plugins.getInstance().isCounterPluginLoaded()) {
|
||||
int i = Plugins.getInstance().getGamesPlayed();
|
||||
JLabel label = new JLabel(" Games played: " + String.valueOf(i));
|
||||
JLabel label = new JLabel(" Games played: " + String.valueOf(i));
|
||||
desktopPane.add(label);
|
||||
label.setVisible(true);
|
||||
label.setForeground(Color.white);
|
||||
label.setBounds(0, 0, 100, 30);
|
||||
label.setBounds(0, 0, 180, 30);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package mage.client.components;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.synth.Region;
|
||||
import javax.swing.plaf.synth.SynthStyle;
|
||||
import javax.swing.plaf.synth.SynthStyleFactory;
|
||||
|
||||
/**
|
||||
* Class makes {@link JInternalFrame} translucent background possible.
|
||||
* This class provides fix that makes setOpaque(false) and setBackgroundColor(any color) working,
|
||||
* especially for Nimbus LAF that has great problems with it.
|
||||
*
|
||||
* @version 0.1 16.11.2010
|
||||
* @author nantuko
|
||||
*/
|
||||
public class MageSynthStyleFactory extends SynthStyleFactory {
|
||||
private SynthStyleFactory wrappedFactory;
|
||||
|
||||
public MageSynthStyleFactory(SynthStyleFactory factory) {
|
||||
this.wrappedFactory = factory;
|
||||
}
|
||||
|
||||
public SynthStyle getStyle(JComponent c, Region id) {
|
||||
SynthStyle s = wrappedFactory.getStyle(c, id);
|
||||
if (id == Region.INTERNAL_FRAME) {
|
||||
s = new TranslucentSynthSytle(s);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package mage.client.components;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.plaf.synth.ColorType;
|
||||
import javax.swing.plaf.synth.Region;
|
||||
import javax.swing.plaf.synth.SynthContext;
|
||||
import javax.swing.plaf.synth.SynthGraphicsUtils;
|
||||
import javax.swing.plaf.synth.SynthPainter;
|
||||
import javax.swing.plaf.synth.SynthStyle;
|
||||
|
||||
class TranslucentSynthSytle extends SynthStyle {
|
||||
private final SynthStyle style;
|
||||
|
||||
public TranslucentSynthSytle(SynthStyle s) {
|
||||
style = s;
|
||||
}
|
||||
|
||||
public Object get(SynthContext context, Object key) {
|
||||
return style.get(context, key);
|
||||
}
|
||||
|
||||
public boolean getBoolean(SynthContext context, Object key,
|
||||
boolean defaultValue) {
|
||||
return style.getBoolean(context, key, defaultValue);
|
||||
}
|
||||
|
||||
public Color getColor(SynthContext context, ColorType type) {
|
||||
return style.getColor(context, type);
|
||||
}
|
||||
|
||||
public Font getFont(SynthContext context) {
|
||||
return style.getFont(context);
|
||||
}
|
||||
|
||||
public SynthGraphicsUtils getGraphicsUtils(SynthContext context) {
|
||||
return style.getGraphicsUtils(context);
|
||||
}
|
||||
|
||||
public Icon getIcon(SynthContext context, Object key) {
|
||||
return style.getIcon(context, key);
|
||||
}
|
||||
|
||||
public Insets getInsets(SynthContext context, Insets insets) {
|
||||
return style.getInsets(context, insets);
|
||||
}
|
||||
|
||||
public int getInt(SynthContext context, Object key, int defaultValue) {
|
||||
return style.getInt(context, key, defaultValue);
|
||||
}
|
||||
|
||||
public SynthPainter getPainter(final SynthContext context) {
|
||||
return new SynthPainter() {
|
||||
public void paintInternalFrameBackground(SynthContext context,
|
||||
Graphics g, int x, int y, int w, int h) {
|
||||
g.setColor(new Color(50, 50, 50, 100));
|
||||
g.fillRoundRect(x, y, w, h, 5, 5);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String getString(SynthContext context, Object key,
|
||||
String defaultValue) {
|
||||
return style.getString(context, key, defaultValue);
|
||||
}
|
||||
|
||||
public void installDefaults(SynthContext context) {
|
||||
style.installDefaults(context);
|
||||
}
|
||||
|
||||
public void uninstallDefaults(SynthContext context) {
|
||||
style.uninstallDefaults(context);
|
||||
}
|
||||
|
||||
public boolean isOpaque(SynthContext context) {
|
||||
if (context.getRegion() == Region.INTERNAL_FRAME) {
|
||||
return false;
|
||||
} else {
|
||||
return style.isOpaque(context);
|
||||
}
|
||||
}
|
||||
|
||||
public Color getColorForState(SynthContext context, ColorType type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Font getFontForState(SynthContext context) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -34,11 +34,16 @@
|
|||
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.game.CombatGroup;
|
||||
import mage.view.CombatGroupView;
|
||||
|
@ -56,8 +61,23 @@ public class CombatDialog extends MageDialog {
|
|||
|
||||
/** Creates new form CombatDialog */
|
||||
public CombatDialog() {
|
||||
|
||||
JPanel contentPane = new JPanel() {
|
||||
private static final long serialVersionUID = -8283955788355547309L;
|
||||
public void paintComponent(Graphics g) {
|
||||
g.setColor(new Color(50, 50, 50, 100));
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
};
|
||||
setContentPane(contentPane);
|
||||
|
||||
initComponents();
|
||||
this.setModal(false);
|
||||
|
||||
combatArea.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
getRootPane().setOpaque(false);
|
||||
}
|
||||
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
|
|
|
@ -17,6 +17,7 @@ public interface MagePlugins {
|
|||
void loadPlugins();
|
||||
void shutdown();
|
||||
void updateGamePanel(Map<String, JComponent> ui);
|
||||
void updateOnTable(Map<String, JComponent> ui);
|
||||
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId);
|
||||
boolean isCardPluginLoaded();
|
||||
boolean isCounterPluginLoaded();
|
||||
|
|
|
@ -65,7 +65,16 @@ public class Plugins implements MagePlugins {
|
|||
PluginManagerUtil pmu = new PluginManagerUtil(pm);
|
||||
|
||||
for (ThemePlugin pl : pmu.getPlugins(ThemePlugin.class)) {
|
||||
pl.apply(ui);
|
||||
pl.applyInGame(ui);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOnTable(Map<String, JComponent> ui) {
|
||||
PluginManagerUtil pmu = new PluginManagerUtil(pm);
|
||||
|
||||
for (ThemePlugin pl : pmu.getPlugins(ThemePlugin.class)) {
|
||||
pl.applyOnTable(ui);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue