Revision ce0c7ca8
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/magic/RubikSettingsEnum.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.magic; |
21 | 21 |
|
22 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
22 |
import android.content.SharedPreferences;
|
|
23 | 23 |
|
24 | 24 |
import org.distorted.effect.ScrambleEffect; |
25 | 25 |
import org.distorted.effect.SizeChangeEffect; |
26 | 26 |
import org.distorted.effect.SolveEffect; |
27 | 27 |
|
28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
29 |
|
|
28 | 30 |
enum RubikSettingsEnum |
29 | 31 |
{ |
30 |
SIZECHANGE ( 20, 1, R.string.sizechange_effect ),
|
|
32 |
SIZECHANGE ( 20, 1, R.string.sizechange_effect), |
|
31 | 33 |
SOLVE ( 20, 1, R.string.solve_effect ), |
32 |
SCRAMBLE ( 100, 0, R.string.scramble_effect );
|
|
34 |
SCRAMBLE ( 100, 1, R.string.scramble_effect );
|
|
33 | 35 |
|
34 | 36 |
public static final int LENGTH = values().length; |
35 |
private int mDefaultPos, mDefaultType; |
|
37 |
private final int mDefaultPos, mDefaultType; |
|
38 |
private int mCurrentPos, mCurrentType; |
|
36 | 39 |
private int mText; |
37 | 40 |
|
38 | 41 |
private static final RubikSettingsEnum[] enums; // copy the values() to a local variable so that we |
... | ... | |
54 | 57 |
|
55 | 58 |
RubikSettingsEnum( int dPos, int dType, int text ) |
56 | 59 |
{ |
57 |
mDefaultPos = dPos; |
|
58 |
mDefaultType = dType; |
|
60 |
mDefaultPos = mCurrentPos = dPos;
|
|
61 |
mDefaultType = mCurrentType= dType;
|
|
59 | 62 |
mText = text; |
60 | 63 |
} |
61 | 64 |
|
62 | 65 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 66 |
|
64 |
int getDefaultPos()
|
|
67 |
int getText()
|
|
65 | 68 |
{ |
66 |
return mDefaultPos;
|
|
69 |
return mText;
|
|
67 | 70 |
} |
68 | 71 |
|
69 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
70 | 73 |
|
71 |
int getDefaultType()
|
|
74 |
int getCurrentPos()
|
|
72 | 75 |
{ |
73 |
return mDefaultType;
|
|
76 |
return mCurrentPos;
|
|
74 | 77 |
} |
75 | 78 |
|
76 | 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 | 80 |
|
78 |
int getText()
|
|
81 |
int getCurrentType()
|
|
79 | 82 |
{ |
80 |
return mText; |
|
83 |
return mCurrentType; |
|
84 |
} |
|
85 |
|
|
86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
87 |
|
|
88 |
void setCurrentPos(int pos) |
|
89 |
{ |
|
90 |
mCurrentPos = pos; |
|
91 |
} |
|
92 |
|
|
93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
94 |
|
|
95 |
void setCurrentType(int type) |
|
96 |
{ |
|
97 |
mCurrentType = type; |
|
98 |
} |
|
99 |
|
|
100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
101 |
|
|
102 |
void savePreferences(SharedPreferences.Editor editor) |
|
103 |
{ |
|
104 |
String name = name(); |
|
105 |
|
|
106 |
editor.putInt(name+"_Pos" , mCurrentPos ); |
|
107 |
editor.putInt(name+"_Type", mCurrentType); |
|
108 |
} |
|
109 |
|
|
110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
111 |
|
|
112 |
void restorePreferences(SharedPreferences preferences) |
|
113 |
{ |
|
114 |
String name = name(); |
|
115 |
|
|
116 |
mCurrentPos = preferences.getInt(name+"_Pos" , mDefaultPos ); |
|
117 |
mCurrentType = preferences.getInt(name+"_Type", mDefaultType); |
|
81 | 118 |
} |
82 | 119 |
|
83 | 120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
100 | 137 |
|
101 | 138 |
return null; |
102 | 139 |
} |
140 |
|
|
141 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
142 |
|
|
143 |
static int translatePos(int pos) |
|
144 |
{ |
|
145 |
return (pos/2)*100; |
|
146 |
} |
|
103 | 147 |
} |
Also available in: Unified diff
RubikCube: major progress with a separate RubikSettingsEnum enum - almost finished.