Skip to content

Commit cf09d6c

Browse files
committed
New client style AubergineStyle.
1 parent 292db21 commit cf09d6c

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed

data/gui/border_violet_001.png

159 Bytes
Loading

data/gui/panel_aubergine_001.png

51.8 KB
Loading
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/***************************************************************************
2+
* (C) Copyright 2003-2012 - Stendhal *
3+
***************************************************************************
4+
***************************************************************************
5+
* *
6+
* This program is free software; you can redistribute it and/or modify *
7+
* it under the terms of the GNU General Public License as published by *
8+
* the Free Software Foundation; either version 2 of the License, or *
9+
* (at your option) any later version. *
10+
* *
11+
***************************************************************************/
12+
package games.stendhal.client.gui.styled;
13+
14+
15+
import games.stendhal.client.gui.wt.core.SettingChangeAdapter;
16+
import games.stendhal.client.gui.wt.core.WtWindowManager;
17+
import games.stendhal.client.sprite.Sprite;
18+
import games.stendhal.client.sprite.SpriteStore;
19+
import games.stendhal.common.MathHelper;
20+
21+
import java.awt.Color;
22+
import java.awt.Font;
23+
24+
import javax.swing.border.Border;
25+
26+
/**
27+
* The style.
28+
*/
29+
public class AubergineStyle implements Style {
30+
private static final int DEFAULT_FONT_SIZE = 12;
31+
32+
private static final Color highLightColor = new Color(184, 149, 193); // Violet
33+
private static final Color shadowColor = new Color(42, 7, 51); // Dark violet
34+
private static final Color plainColor = new Color(255, 255, 255); // White
35+
36+
/**
37+
* A shared instance.
38+
*/
39+
private static Style sharedInstance;
40+
41+
/**
42+
* The background texture.
43+
*/
44+
private Sprite background;
45+
46+
/**
47+
* The border.
48+
*/
49+
private Sprite borderSprite;
50+
private Border border;
51+
/**
52+
* Downwards border (for buttons etc).
53+
*/
54+
private Border borderDown;
55+
56+
/**
57+
* The default font.
58+
*/
59+
private Font font;
60+
61+
/**
62+
* Create new style.
63+
*/
64+
public AubergineStyle() {
65+
/*
66+
* Load the texture
67+
*/
68+
final SpriteStore st = SpriteStore.get();
69+
background = st.getSprite("data/gui/panel_aubergine_001.png");
70+
71+
borderSprite = st.getSprite("data/gui/border_violet_001.png");
72+
border = new PixmapBorder(borderSprite, true);
73+
borderDown = new PixmapBorder(background, false);
74+
75+
WtWindowManager.getInstance().registerSettingChangeListener("ui.font_size",
76+
new SettingChangeAdapter("ui.font_size", Integer.toString(DEFAULT_FONT_SIZE)) {
77+
@Override
78+
public void changed(String newValue) {
79+
int size = MathHelper.parseIntDefault(newValue, DEFAULT_FONT_SIZE);
80+
font = new Font("Dialog", Font.PLAIN, size);
81+
}
82+
});
83+
}
84+
85+
//
86+
// Style
87+
//
88+
89+
/**
90+
* Get a shared instance.
91+
*
92+
* @return A shared instance.
93+
*/
94+
public static synchronized Style getInstance() {
95+
if (sharedInstance == null) {
96+
sharedInstance = new AubergineStyle();
97+
}
98+
99+
return sharedInstance;
100+
}
101+
102+
//
103+
// Style
104+
//
105+
106+
/**
107+
* Get the background texture.
108+
*
109+
* @return A texture sprite.
110+
*/
111+
@Override
112+
public Sprite getBackground() {
113+
return background;
114+
}
115+
116+
/**
117+
* Get component border.
118+
*
119+
* @return A border, or <code>null</code> to use default.
120+
*/
121+
@Override
122+
public Border getBorder() {
123+
return border;
124+
}
125+
126+
/**
127+
* Get lowered component border.
128+
*
129+
* @return A border, or <code>null</code> to use default.
130+
*/
131+
@Override
132+
public Border getBorderDown() {
133+
return borderDown;
134+
}
135+
136+
/**
137+
* Get the normal font.
138+
*
139+
* @return A font.
140+
*/
141+
@Override
142+
public Font getFont() {
143+
return font;
144+
}
145+
146+
/**
147+
* Get the foreground color appropriate for the background texture.
148+
*
149+
* @return A color.
150+
*/
151+
@Override
152+
public Color getForeground() {
153+
return Color.white;
154+
}
155+
156+
@Override
157+
public Color getHighLightColor() {
158+
return highLightColor;
159+
}
160+
161+
@Override
162+
public Color getShadowColor() {
163+
return shadowColor;
164+
}
165+
166+
/**
167+
* Get a color that roughly represents the background.
168+
*
169+
* @return plain color
170+
*/
171+
@Override
172+
public Color getPlainColor() {
173+
return plainColor;
174+
}
175+
}

src/games/stendhal/client/stendhal.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ public static StyledLookAndFeel setStyle(int id) {
248248
styles.add(WoodStyle.getInstance());
249249
styles.add(TileAquaStyle.getInstance());
250250
styles.add(BrickBrownStyle.getInstance());
251+
styles.add(AubergineStyle.getInstance());
251252

252253
try {
253254
return new StyledLookAndFeel(styles.get(id));

0 commit comments

Comments
 (0)