Skip to content

Commit

Permalink
New client style AubergineStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Mar 23, 2013
1 parent 292db21 commit cf09d6c
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 0 deletions.
Binary file added data/gui/border_violet_001.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/gui/panel_aubergine_001.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
175 changes: 175 additions & 0 deletions src/games/stendhal/client/gui/styled/AubergineStyle.java
@@ -0,0 +1,175 @@
/***************************************************************************
* (C) Copyright 2003-2012 - Stendhal *
***************************************************************************
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
package games.stendhal.client.gui.styled;


import games.stendhal.client.gui.wt.core.SettingChangeAdapter;
import games.stendhal.client.gui.wt.core.WtWindowManager;
import games.stendhal.client.sprite.Sprite;
import games.stendhal.client.sprite.SpriteStore;
import games.stendhal.common.MathHelper;

import java.awt.Color;
import java.awt.Font;

import javax.swing.border.Border;

/**
* The style.
*/
public class AubergineStyle implements Style {
private static final int DEFAULT_FONT_SIZE = 12;

private static final Color highLightColor = new Color(184, 149, 193); // Violet
private static final Color shadowColor = new Color(42, 7, 51); // Dark violet
private static final Color plainColor = new Color(255, 255, 255); // White

/**
* A shared instance.
*/
private static Style sharedInstance;

/**
* The background texture.
*/
private Sprite background;

/**
* The border.
*/
private Sprite borderSprite;
private Border border;
/**
* Downwards border (for buttons etc).
*/
private Border borderDown;

/**
* The default font.
*/
private Font font;

/**
* Create new style.
*/
public AubergineStyle() {
/*
* Load the texture
*/
final SpriteStore st = SpriteStore.get();
background = st.getSprite("data/gui/panel_aubergine_001.png");

borderSprite = st.getSprite("data/gui/border_violet_001.png");
border = new PixmapBorder(borderSprite, true);
borderDown = new PixmapBorder(background, false);

WtWindowManager.getInstance().registerSettingChangeListener("ui.font_size",
new SettingChangeAdapter("ui.font_size", Integer.toString(DEFAULT_FONT_SIZE)) {
@Override
public void changed(String newValue) {
int size = MathHelper.parseIntDefault(newValue, DEFAULT_FONT_SIZE);
font = new Font("Dialog", Font.PLAIN, size);
}
});
}

//
// Style
//

/**
* Get a shared instance.
*
* @return A shared instance.
*/
public static synchronized Style getInstance() {
if (sharedInstance == null) {
sharedInstance = new AubergineStyle();
}

return sharedInstance;
}

//
// Style
//

/**
* Get the background texture.
*
* @return A texture sprite.
*/
@Override
public Sprite getBackground() {
return background;
}

/**
* Get component border.
*
* @return A border, or <code>null</code> to use default.
*/
@Override
public Border getBorder() {
return border;
}

/**
* Get lowered component border.
*
* @return A border, or <code>null</code> to use default.
*/
@Override
public Border getBorderDown() {
return borderDown;
}

/**
* Get the normal font.
*
* @return A font.
*/
@Override
public Font getFont() {
return font;
}

/**
* Get the foreground color appropriate for the background texture.
*
* @return A color.
*/
@Override
public Color getForeground() {
return Color.white;
}

@Override
public Color getHighLightColor() {
return highLightColor;
}

@Override
public Color getShadowColor() {
return shadowColor;
}

/**
* Get a color that roughly represents the background.
*
* @return plain color
*/
@Override
public Color getPlainColor() {
return plainColor;
}
}
1 change: 1 addition & 0 deletions src/games/stendhal/client/stendhal.java
Expand Up @@ -248,6 +248,7 @@ public static StyledLookAndFeel setStyle(int id) {
styles.add(WoodStyle.getInstance());
styles.add(TileAquaStyle.getInstance());
styles.add(BrickBrownStyle.getInstance());
styles.add(AubergineStyle.getInstance());

try {
return new StyledLookAndFeel(styles.get(id));
Expand Down

0 comments on commit cf09d6c

Please sign in to comment.