Revision 53f23b64
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/magic/RubikActivity.java | ||
---|---|---|
26 | 26 |
import android.view.View; |
27 | 27 |
|
28 | 28 |
import org.distorted.dialog.RubikDialogAbout; |
29 |
import org.distorted.dialog.RubikDialogPattern; |
|
30 | 29 |
import org.distorted.dialog.RubikDialogScores; |
31 | 30 |
import org.distorted.dialog.RubikDialogEffects; |
32 | 31 |
import org.distorted.effect.BaseEffect; |
... | ... | |
88 | 87 |
scores.setCountry(this); |
89 | 88 |
} |
90 | 89 |
|
90 |
boolean success = false; |
|
91 | 91 |
RubikStatePlay play = (RubikStatePlay)RubikState.PLAY.getStateClass(); |
92 | 92 |
int object = play.getObject(); |
93 | 93 |
int size = play.getSize(); |
... | ... | |
96 | 96 |
{ |
97 | 97 |
RubikObjectList obj = RubikObjectList.getObject(object); |
98 | 98 |
int[] sizes = obj.getSizes(); |
99 |
int sizeIndex = RubikObjectList.getSizeIndex(object,size); |
|
99 | 100 |
|
100 |
if( size>=0 && size<sizes.length )
|
|
101 |
if( sizeIndex>=0 && sizeIndex<sizes.length )
|
|
101 | 102 |
{ |
102 |
view.getRenderer().createObject( obj, sizes[size] ); |
|
103 |
success = true; |
|
104 |
view.getRenderer().createObject( obj, size ); |
|
103 | 105 |
} |
106 |
|
|
107 |
} |
|
108 |
|
|
109 |
if( !success ) |
|
110 |
{ |
|
111 |
RubikObjectList obj = RubikObjectList.getObject(RubikStatePlay.DEF_OBJECT); |
|
112 |
int s = RubikStatePlay.DEF_SIZE; |
|
113 |
|
|
114 |
play.setObjectAndSize(obj,s); |
|
115 |
view.getRenderer().createObject(obj,s); |
|
104 | 116 |
} |
105 | 117 |
} |
106 | 118 |
|
... | ... | |
163 | 175 |
// PUBLIC API |
164 | 176 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
165 | 177 |
|
166 |
public void setCanRotate(boolean can)
|
|
178 |
public void changeObject(RubikObjectList object, int size)
|
|
167 | 179 |
{ |
168 | 180 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
169 | 181 |
RubikRenderer renderer = view.getRenderer(); |
170 | 182 |
|
171 |
renderer.setCanRotate(can); |
|
172 |
} |
|
173 |
|
|
174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
175 |
|
|
176 |
public void changeObject(int object, int size) |
|
177 |
{ |
|
178 |
RubikObjectList obj = RubikObjectList.getObject(object); |
|
179 |
int objectSize = obj.getSizes()[size]; |
|
180 |
|
|
181 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
182 |
RubikRenderer renderer = view.getRenderer(); |
|
183 |
|
|
184 | 183 |
if( renderer.canDrag() ) |
185 | 184 |
{ |
186 |
renderer.createObject(obj,objectSize);
|
|
185 |
renderer.createObject(object,size);
|
|
187 | 186 |
} |
188 | 187 |
} |
189 | 188 |
|
... | ... | |
217 | 216 |
RubikStatePlay play = (RubikStatePlay) RubikState.PLAY.getStateClass(); |
218 | 217 |
int object = play.getObject(); |
219 | 218 |
int size = play.getSize(); |
219 |
int sizeIndex = RubikObjectList.getSizeIndex(object,size); |
|
220 | 220 |
|
221 | 221 |
Bundle bundle = new Bundle(); |
222 |
bundle.putInt("tab", RubikObjectList.pack(object,size) ); |
|
222 |
bundle.putInt("tab", RubikObjectList.pack(object,sizeIndex) );
|
|
223 | 223 |
bundle.putBoolean("submitting", false); |
224 | 224 |
|
225 | 225 |
RubikDialogScores scores = new RubikDialogScores(); |
... | ... | |
231 | 231 |
|
232 | 232 |
public void Patterns(View v) |
233 | 233 |
{ |
234 |
RubikDialogPattern diag = new RubikDialogPattern(); |
|
235 |
diag.show(getSupportFragmentManager(), null); |
|
234 |
RubikState.switchState(this,RubikState.PATT); |
|
236 | 235 |
} |
237 | 236 |
|
238 | 237 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Progress with Pretty Patterns - do away with the tabbed dialog!