1 | |
package net.cscott.sdr.anim; |
2 | |
|
3 | |
import com.jme.image.Texture; |
4 | |
import com.jme.scene.state.TextureState; |
5 | |
import com.jme.system.DisplaySystem; |
6 | |
import com.jme.util.TextureManager; |
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
public class MenuArrow extends GradientTriangle { |
15 | |
final TextureState textureState; |
16 | |
public MenuArrow(String name, BaseState st, boolean isLeft) { |
17 | 0 | super(name, st.x(0), st.y(-22), st.x(isLeft?-24:24), st.y(0), st.x(0), st.y(22)); |
18 | 0 | textureState = DisplaySystem.getDisplaySystem() |
19 | |
.getRenderer().createTextureState(); |
20 | 0 | textureState.setEnabled(true); |
21 | 0 | this.setRenderState(textureState); |
22 | 0 | this.setRenderState(BaseState.mkAlpha()); |
23 | 0 | setSelected(false); |
24 | 0 | } |
25 | |
public void setSelected(boolean isSelected) { |
26 | 0 | textureState.setTexture(getTexture(isSelected)); |
27 | 0 | this.updateRenderState(); |
28 | 0 | } |
29 | |
|
30 | 0 | private static Texture[] texture = new Texture[2]; |
31 | |
private static Texture getTexture(boolean isSelected) { |
32 | 0 | int which = isSelected ? 1 : 0; |
33 | 0 | if (texture[which]==null) { |
34 | 0 | texture[which] = TextureManager.loadTexture( |
35 | |
MenuArrow.class.getClassLoader().getResource( |
36 | |
"net/cscott/sdr/anim/menu-arrow"+ |
37 | |
(isSelected?"-sel":"")+ |
38 | |
".png"), |
39 | |
Texture.MM_NONE, |
40 | |
Texture.FM_LINEAR); |
41 | |
} |
42 | 0 | return texture[which]; |
43 | |
} |
44 | |
} |