@@ -24,6 +24,11 @@ public class SettingsState extends State {
2424 private Plane tutorialButton ;
2525 private Plane volumeButton ;
2626 private Plane editorButton ;
27+ private Plane colorsExample ;
28+ private Plane colorsButton ;
29+
30+ private int numberOfColorschemes ;
31+ private GLRenderer glRenderer ;
2732
2833 private SettingsState () {
2934
@@ -37,7 +42,11 @@ public static SettingsState getInstance() {
3742 }
3843
3944 @ Override
40- protected void initialize (GLRenderer glRenderer ) {
45+ protected void initialize (GLRenderer glRendererIn ) {
46+ glRenderer = glRendererIn ;
47+
48+ numberOfColorschemes = glRenderer .numberOfColorschemes ;
49+
4150 float menuEntriesWidth = glRenderer .getWidth () * 0.75f ;
4251 float menuEntriesHeight = menuEntriesWidth / 6 ;
4352 float menuEntriesAvailableSpace = getScreenHeight ();
@@ -47,24 +56,35 @@ protected void initialize(GLRenderer glRenderer) {
4756 volumeButton = new Plane (-menuEntriesWidth , menuEntriesStartY , menuEntriesWidth , menuEntriesHeight , coordinatesVolume );
4857 glRenderer .addDrawable (volumeButton );
4958
59+ TextureCoordinates coordinatesColors = TextureCoordinates .getFromBlocks (0 , 15 , 6 , 16 );
60+ colorsButton = new Plane (-menuEntriesWidth , volumeButton .getY () - 2 * menuEntriesHeight , menuEntriesWidth , menuEntriesHeight , coordinatesColors );
61+ glRenderer .addDrawable (colorsButton );
62+
5063 TextureCoordinates coordinatesTutorial = TextureCoordinates .getFromBlocks (6 , 12 , 12 , 13 );
51- tutorialButton = new Plane (-menuEntriesWidth , volumeButton .getY () - 2 * menuEntriesHeight , menuEntriesWidth , menuEntriesHeight , coordinatesTutorial );
64+ tutorialButton = new Plane (-menuEntriesWidth , colorsButton .getY () - 2 * menuEntriesHeight , menuEntriesWidth , menuEntriesHeight , coordinatesTutorial );
5265 glRenderer .addDrawable (tutorialButton );
5366
5467 TextureCoordinates coordinatesEditor = TextureCoordinates .getFromBlocks (6 , 15 , 12 , 16 );
5568 editorButton = new Plane (-menuEntriesWidth , tutorialButton .getY () - 2 * menuEntriesHeight , menuEntriesWidth , menuEntriesHeight , coordinatesEditor );
5669 glRenderer .addDrawable (editorButton );
5770
58- volumeOn = ObjectFactory .createSingleBox (0 , 15 , menuEntriesHeight );
71+ volumeOn = ObjectFactory .createSingleBox (12 , 12 , menuEntriesHeight );
5972 volumeOn .setVisible (false );
6073 volumeOn .setX (menuEntriesWidth );
6174 volumeOn .setY (volumeButton .getY ());
6275 glRenderer .addDrawable (volumeOn );
63- volumeOff = ObjectFactory .createSingleBox (1 , 15 , menuEntriesHeight );
76+ volumeOff = ObjectFactory .createSingleBox (13 , 12 , menuEntriesHeight );
6477 volumeOff .setVisible (false );
6578 volumeOff .setX (menuEntriesWidth );
6679 volumeOff .setY (volumeButton .getY ());
6780 glRenderer .addDrawable (volumeOff );
81+
82+ TextureCoordinates coordinatesColorsExample = TextureCoordinates .getFromBlocks (14 , 1 , 16 , 2 );
83+ colorsExample = new Plane (-menuEntriesWidth /2 , menuEntriesStartY , menuEntriesHeight *2 , menuEntriesHeight , coordinatesColorsExample );
84+ colorsExample .setVisible (false );
85+ colorsExample .setX (menuEntriesWidth );
86+ colorsExample .setY (colorsButton .getY ());
87+ glRenderer .addDrawable (colorsExample );
6888 }
6989
7090 @ Override
@@ -79,9 +99,17 @@ public void entry() {
7999 scaleAnimation .setTo (1 );
80100 scaleAnimation .start ();
81101
102+ colorsExample .setVisible (true );
103+ colorsExample .setScale (0 );
104+ ScaleAnimation colorsScaleAnimation = new ScaleAnimation (colorsExample ,
105+ Animation .DURATION_LONG , Animation .DURATION_LONG + (int ) 1.0f * Animation .DURATION_SHORT );
106+ colorsScaleAnimation .setTo (1 );
107+ colorsScaleAnimation .start ();
108+
82109 AnimationFactory .startMenuAnimationEnter (volumeButton , (int ) (2.0f * Animation .DURATION_SHORT ));
83- AnimationFactory .startMenuAnimationEnter (tutorialButton , (int ) (2.5f * Animation .DURATION_SHORT ));
84- AnimationFactory .startMenuAnimationEnter (editorButton , (int ) (3.0f * Animation .DURATION_SHORT ));
110+ AnimationFactory .startMenuAnimationEnter (colorsButton , (int ) (2.5f * Animation .DURATION_SHORT ));
111+ AnimationFactory .startMenuAnimationEnter (tutorialButton , (int ) (3.0f * Animation .DURATION_SHORT ));
112+ AnimationFactory .startMenuAnimationEnter (editorButton , (int ) (3.5f * Animation .DURATION_SHORT ));
85113 }
86114
87115 @ Override
@@ -93,13 +121,20 @@ public void exit() {
93121 scaleAnimation .setHideAfter (true );
94122 scaleAnimation .start ();
95123
124+ ScaleAnimation colorsScaleAnimation = new ScaleAnimation (colorsExample ,
125+ Animation .DURATION_LONG , 0 );
126+ colorsScaleAnimation .setTo (0 );
127+ colorsScaleAnimation .setHideAfter (true );
128+ colorsScaleAnimation .start ();
129+
96130 if (nextState == TutorialState .getInstance ()) {
97131 AnimationFactory .startMenuAnimationOutPressed (tutorialButton );
98132 } else {
99133 AnimationFactory .startMenuAnimationOut (tutorialButton );
100134 }
101135
102136 AnimationFactory .startMenuAnimationOut (volumeButton );
137+ AnimationFactory .startMenuAnimationOut (colorsButton );
103138 AnimationFactory .startMenuAnimationOut (editorButton );
104139 }
105140
@@ -123,6 +158,11 @@ public void onTouchEvent(MotionEvent event) {
123158 getPreferences ().edit ().putBoolean ("volumeOn" , newVolume ).apply ();
124159 volumeOff .setVisible (!newVolume );
125160 volumeOn .setVisible (newVolume );
161+ } else if (colorsExample .collides (event , getScreenHeight ()) || colorsButton .collides (event , getScreenHeight ())) {
162+ playSound (R .raw .click );
163+ int newColorschemeIndex = (getPreferences ().getInt ("colorschemeIndex" , 0 ) + 1 ) % numberOfColorschemes ;
164+ getPreferences ().edit ().putInt ("colorschemeIndex" , newColorschemeIndex ).apply ();
165+ glRenderer .setColorscheme (newColorschemeIndex );
126166 } else if (tutorialButton .collides (event , getScreenHeight ())) {
127167 nextState = TutorialState .getInstance ();
128168 playSound (R .raw .click );
0 commit comments