Revision a42e25a6
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/magic/RubikActivity.java | ||
---|---|---|
197 | 197 |
{ |
198 | 198 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
199 | 199 |
RubikPostRender post = view.getPostRender(); |
200 |
|
|
201 |
if( post.canDrag() ) |
|
202 |
{ |
|
203 |
post.changeObject(object,size,moves); |
|
204 |
} |
|
200 |
post.changeObject(object,size,moves); |
|
205 | 201 |
} |
206 | 202 |
|
207 | 203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/magic/RubikPostRender.java | ||
---|---|---|
45 | 45 |
private boolean mFinishRotation, mRemoveRotation, mRemovePatternRotation, mAddRotation, |
46 | 46 |
mSetQuatCurrent, mSetQuatAccumulated, mChangeObject, mSolveObject, |
47 | 47 |
mScrambleObject, mInitializeObject; |
48 |
private boolean mCanRotate, mCanDrag, mCanUI;
|
|
48 |
private boolean mCanRotate, mCanPlay;
|
|
49 | 49 |
private boolean mIsSolved; |
50 | 50 |
private RubikObjectList mNextObject; |
51 | 51 |
private int mNextSize; |
... | ... | |
79 | 79 |
mSolveObject = false; |
80 | 80 |
mScrambleObject = false; |
81 | 81 |
|
82 |
mCanRotate = true; |
|
83 |
mCanDrag = true; |
|
84 |
mCanUI = true; |
|
82 |
mCanRotate = true; |
|
83 |
mCanPlay = true; |
|
85 | 84 |
|
86 | 85 |
mOldObject = null; |
87 | 86 |
mNewObject = null; |
... | ... | |
130 | 129 |
{ |
131 | 130 |
android.util.Log.e("renderer", "exception starting effect: "+ex.getMessage()); |
132 | 131 |
|
133 |
mCanUI = true;
|
|
132 |
mCanPlay = true;
|
|
134 | 133 |
mCanRotate = true; |
135 |
mCanDrag = true; |
|
136 | 134 |
} |
137 | 135 |
} |
138 | 136 |
|
... | ... | |
163 | 161 |
} |
164 | 162 |
} |
165 | 163 |
|
166 |
mCanDrag = true; |
|
167 | 164 |
mCanRotate = false; |
168 |
mCanUI = false;
|
|
165 |
mCanPlay = false;
|
|
169 | 166 |
doEffectNow( BaseEffect.Type.WIN ); |
170 | 167 |
} |
171 | 168 |
else |
172 | 169 |
{ |
173 | 170 |
mCanRotate = true; |
174 |
mCanUI = true;
|
|
171 |
mCanPlay = true;
|
|
175 | 172 |
} |
176 | 173 |
|
177 | 174 |
mIsSolved = solved; |
... | ... | |
215 | 212 |
{ |
216 | 213 |
mFinishRotation = false; |
217 | 214 |
mCanRotate = false; |
218 |
mCanUI = false;
|
|
215 |
mCanPlay = false;
|
|
219 | 216 |
mRotationFinishedID = mNewObject.finishRotationNow(this); |
220 | 217 |
|
221 | 218 |
if( mRotationFinishedID==0 ) // failed to add effect - should never happen |
222 | 219 |
{ |
223 | 220 |
mCanRotate = true; |
224 |
mCanUI = true;
|
|
221 |
mCanPlay = true;
|
|
225 | 222 |
} |
226 | 223 |
} |
227 | 224 |
|
... | ... | |
233 | 230 |
|
234 | 231 |
if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getSize()!=mNextSize) |
235 | 232 |
{ |
236 |
mCanDrag = false; |
|
237 |
mCanRotate = false; |
|
238 |
mCanUI = false; |
|
233 |
mCanRotate= false; |
|
234 |
mCanPlay = false; |
|
239 | 235 |
createObjectNow(mNextObject, mNextSize, mNextMoves); |
240 | 236 |
doEffectNow( BaseEffect.Type.SIZECHANGE ); |
241 | 237 |
} |
... | ... | |
250 | 246 |
private void scrambleObjectNow() |
251 | 247 |
{ |
252 | 248 |
mScrambleObject = false; |
253 |
mCanDrag = false; |
|
254 | 249 |
mCanRotate = false; |
255 |
mCanUI = false;
|
|
250 |
mCanPlay = false;
|
|
256 | 251 |
mIsSolved = false; |
257 | 252 |
RubikScores.getInstance().incrementNumPlays(); |
258 | 253 |
doEffectNow( BaseEffect.Type.SCRAMBLE ); |
... | ... | |
262 | 257 |
|
263 | 258 |
private void solveObjectNow() |
264 | 259 |
{ |
265 |
mSolveObject = false; |
|
266 |
mCanDrag = false; |
|
267 |
mCanRotate = false; |
|
268 |
mCanUI = false; |
|
260 |
mSolveObject = false; |
|
261 |
mCanRotate = false; |
|
262 |
mCanPlay = false; |
|
269 | 263 |
doEffectNow( BaseEffect.Type.SOLVE ); |
270 | 264 |
} |
271 | 265 |
|
... | ... | |
350 | 344 |
|
351 | 345 |
void scrambleObject(int num) |
352 | 346 |
{ |
353 |
if( mCanUI )
|
|
347 |
if( mCanPlay )
|
|
354 | 348 |
{ |
355 | 349 |
mScrambleObject = true; |
356 | 350 |
mScrambleObjectNum = num; |
... | ... | |
361 | 355 |
|
362 | 356 |
void solveObject() |
363 | 357 |
{ |
364 |
if( mCanUI )
|
|
358 |
if( mCanPlay )
|
|
365 | 359 |
{ |
366 | 360 |
mSolveObject = true; |
367 | 361 |
} |
... | ... | |
376 | 370 |
|
377 | 371 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
378 | 372 |
|
379 |
boolean canDrag()
|
|
373 |
public boolean canPlay()
|
|
380 | 374 |
{ |
381 |
return mCanDrag;
|
|
375 |
return mCanPlay;
|
|
382 | 376 |
} |
383 | 377 |
|
384 | 378 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
476 | 470 |
{ |
477 | 471 |
if( effectID == mEffectID[i] ) |
478 | 472 |
{ |
479 |
mCanRotate = true; |
|
480 |
mCanDrag = true; |
|
481 |
mCanUI = true; |
|
473 |
mCanRotate = true; |
|
474 |
mCanPlay = true; |
|
482 | 475 |
|
483 | 476 |
if( i==BaseEffect.Type.SCRAMBLE.ordinal() ) |
484 | 477 |
{ |
src/main/java/org/distorted/magic/RubikSurfaceView.java | ||
---|---|---|
190 | 190 |
} |
191 | 191 |
else |
192 | 192 |
{ |
193 |
mDragging = mPostRender.canDrag();
|
|
193 |
mDragging = true;
|
|
194 | 194 |
mBeginningRotation = false; |
195 | 195 |
mContinuingRotation = false; |
196 | 196 |
} |
... | ... | |
211 | 211 |
float len = (float)Math.sqrt(mAxisX*mAxisX + mAxisY*mAxisY); |
212 | 212 |
mAxisX /= len; |
213 | 213 |
mAxisY /= len; |
214 |
|
|
215 |
// android.util.Log.e("axis", "axis 2D: "+mAxisX+" , "+mAxisY); |
|
216 | 214 |
} |
217 | 215 |
|
218 | 216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
371 | 369 |
mPostRender.setQuatAccumulatedOnNextRender(); |
372 | 370 |
} |
373 | 371 |
} |
374 |
else if( mPostRender.canRotate() || mPostRender.canDrag() )
|
|
372 |
else |
|
375 | 373 |
{ |
376 | 374 |
setUpDragOrRotate(x,y); |
377 | 375 |
} |
src/main/java/org/distorted/uistate/RubikStatePattern.java | ||
---|---|---|
88 | 88 |
if( mPatternOrdinal<0 ) |
89 | 89 |
{ |
90 | 90 |
mPatternOrdinal = RubikObjectList.getSizeIndex(RubikStatePlay.DEF_OBJECT,RubikStatePlay.DEF_SIZE); |
91 |
act.changeObject(RubikObjectList.getObject(RubikStatePlay.DEF_OBJECT),RubikStatePlay.DEF_SIZE,null); |
|
92 | 91 |
} |
93 | 92 |
|
94 | 93 |
FragmentManager mana = act.getSupportFragmentManager(); |
src/main/java/org/distorted/uistate/RubikStatePlay.java | ||
---|---|---|
116 | 116 |
@Override |
117 | 117 |
public void onClick(View view) |
118 | 118 |
{ |
119 |
int total = RubikObjectList.getTotal(); |
|
120 |
boolean vertical = act.isVertical(); |
|
121 |
mLayout.setOrientation(vertical ? LinearLayout.VERTICAL:LinearLayout.HORIZONTAL); |
|
119 |
if( act.getPostRender().canPlay() ) |
|
120 |
{ |
|
121 |
int total = RubikObjectList.getTotal(); |
|
122 |
boolean vertical = act.isVertical(); |
|
123 |
mLayout.setOrientation(vertical ? LinearLayout.VERTICAL:LinearLayout.HORIZONTAL); |
|
122 | 124 |
|
123 |
int height = view.getHeight(); |
|
124 |
int width = view.getWidth(); |
|
125 |
int laywid = mLayoutWidth * (vertical? 1:total); |
|
126 |
int layhei = mLayoutHeight* (vertical? total:1); |
|
125 |
int height = view.getHeight();
|
|
126 |
int width = view.getWidth();
|
|
127 |
int laywid = mLayoutWidth * (vertical? 1:total);
|
|
128 |
int layhei = mLayoutHeight* (vertical? total:1);
|
|
127 | 129 |
|
128 |
mPopup.showAsDropDown(view, (width-laywid)/2, -height-layhei, Gravity.LEFT); |
|
130 |
mPopup.showAsDropDown(view, (width-laywid)/2, -height-layhei, Gravity.LEFT); |
|
131 |
} |
|
129 | 132 |
} |
130 | 133 |
}); |
131 | 134 |
} |
... | ... | |
146 | 149 |
@Override |
147 | 150 |
public void onClick(View v) |
148 | 151 |
{ |
149 |
RubikState.goBack(act); |
|
152 |
if( act.getPostRender().canPlay() ) RubikState.goBack(act);
|
|
150 | 153 |
} |
151 | 154 |
}); |
152 | 155 |
} |
... | ... | |
195 | 198 |
@Override |
196 | 199 |
public void onClick(View v) |
197 | 200 |
{ |
198 |
mObject = obj; |
|
199 |
mSize = sizes[size]; |
|
200 |
act.changeObject(list,sizes[size],null); |
|
201 |
if( act.getPostRender().canPlay() && RubikState.getCurrentState()==RubikState.PLAY ) |
|
202 |
{ |
|
203 |
mObject = obj; |
|
204 |
mSize = sizes[size]; |
|
205 |
act.changeObject(list,sizes[size],null); |
|
206 |
} |
|
201 | 207 |
mPopup.dismiss(); |
202 | 208 |
} |
203 | 209 |
}); |
Also available in: Unified diff
Bugfixes.