Revision 473611ee
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/states/RubikStateSolver.java | ||
---|---|---|
24 | 24 |
import android.graphics.Bitmap; |
25 | 25 |
import android.graphics.Canvas; |
26 | 26 |
import android.graphics.Paint; |
27 |
import android.graphics.PorterDuff; |
|
28 |
import android.graphics.drawable.Drawable; |
|
29 |
import android.support.v4.content.ContextCompat; |
|
27 | 30 |
import android.util.DisplayMetrics; |
28 | 31 |
import android.view.View; |
29 | 32 |
import android.widget.Button; |
... | ... | |
32 | 35 |
|
33 | 36 |
import org.distorted.main.R; |
34 | 37 |
import org.distorted.main.RubikActivity; |
35 |
import org.distorted.objects.RubikObject;
|
|
38 |
import org.distorted.main.RubikPostRender;
|
|
36 | 39 |
import org.distorted.objects.RubikObjectList; |
37 | 40 |
|
38 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
123 | 126 |
|
124 | 127 |
void leaveState(RubikActivity act) |
125 | 128 |
{ |
126 |
RubikObject object = act.getObject();
|
|
127 |
object.resetAllTextureMaps();
|
|
129 |
RubikPostRender post = act.getPostRender();
|
|
130 |
post.resetAllTextureMaps();
|
|
128 | 131 |
} |
129 | 132 |
|
130 | 133 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
134 | 137 |
mSolving = false; |
135 | 138 |
|
136 | 139 |
act.changeObject(RubikObjectList.CUBE,3,null); |
140 |
RubikStatePlay play = (RubikStatePlay)RubikState.PLAY.getStateClass(); |
|
141 |
play.setObjectAndSize(RubikObjectList.CUBE,3); |
|
137 | 142 |
|
138 | 143 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
139 | 144 |
final float scale = metrics.density; |
... | ... | |
145 | 150 |
if( mBitmap ==null ) setupBitmaps(scale); |
146 | 151 |
if( mColorButton==null ) setupColorButtons(act,scale); |
147 | 152 |
|
153 |
markButton(act); |
|
154 |
|
|
148 | 155 |
for(ImageButton button: mColorButton) layoutTop.addView(button); |
149 | 156 |
|
150 | 157 |
// BOT //////////////////////////// |
... | ... | |
222 | 229 |
@Override |
223 | 230 |
public void onClick(View view) |
224 | 231 |
{ |
225 |
android.util.Log.e("solver", "button "+FACE_COLORS[ii]+" clicked"); |
|
232 |
mCurrentColor = ii; |
|
233 |
markButton(act); |
|
226 | 234 |
} |
227 | 235 |
}); |
228 | 236 |
} |
... | ... | |
276 | 284 |
}); |
277 | 285 |
} |
278 | 286 |
|
287 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
288 |
|
|
289 |
private void markButton(RubikActivity act) |
|
290 |
{ |
|
291 |
for(int b=0; b<NUM_FACES; b++) |
|
292 |
{ |
|
293 |
Drawable d = mColorButton[b].getBackground(); |
|
294 |
|
|
295 |
if( b==mCurrentColor ) |
|
296 |
{ |
|
297 |
d.setColorFilter(ContextCompat.getColor(act,R.color.red), PorterDuff.Mode.MULTIPLY); |
|
298 |
} |
|
299 |
else |
|
300 |
{ |
|
301 |
d.clearColorFilter(); |
|
302 |
} |
|
303 |
} |
|
304 |
} |
|
305 |
|
|
279 | 306 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
280 | 307 |
|
281 | 308 |
public void savePreferences(SharedPreferences.Editor editor) |
... | ... | |
293 | 320 |
{ |
294 | 321 |
mCurrentColor = preferences.getInt("stateSolver_color", 0); |
295 | 322 |
} |
323 |
|
|
324 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
325 |
|
|
326 |
public int getCurrentColor() |
|
327 |
{ |
|
328 |
return mCurrentColor; |
|
329 |
} |
|
296 | 330 |
} |
Also available in: Unified diff
Progress with the 3x3x3 Solver.