Project

General

Profile

« Previous | Next » 

Revision b3a907f1

Added by Leszek Koltunski over 1 year ago

Dino4 solver: progress.

View differences:

src/main/java/org/distorted/screens/RubikScreenSolver.java
48 48
public class RubikScreenSolver extends RubikScreenAbstract
49 49
  {
50 50
  private static final int RESET_DURATION = 1000;
51
  private static final int MODE_NORMAL = 0;
52
  private static final int MODE_DINO_4 = 1;
51 53

  
52 54
  private static Bitmap[] mBitmap;
53 55
  private ImageButton[] mColorButton;
54 56
  private TransparentImageButton mResetButton,mBackButton, mSolveButton;
55 57
  private boolean mSolving;
56
  private int mCurrentColor;
58
  private int mCurrentColor, mCurrentButton;
57 59
  private int[] mFaceColors;
60
  private int mColorMode;
58 61
  private int mNumColors;
59 62
  private float mBitmapSize;
60 63
  private WeakReference<RubikActivity> mWeakAct;
......
139 142

  
140 143
  public void generateFaceColors(int object)
141 144
    {
145
    mColorMode = MODE_NORMAL;
146

  
142 147
    if( object== ObjectSignatures.PYRA_3 ||
143 148
        object== ObjectSignatures.PYRA_4 ||
144 149
        object== ObjectSignatures.PYRA_5 ||
......
186 191
      {
187 192
      mNumColors  = 4;
188 193
      mFaceColors = new int[] { COLOR_YELLOW, COLOR_RED, COLOR_BLUE, COLOR_WHITE };
194
      mColorMode  = MODE_DINO_4;
189 195
      }
190 196
    else
191 197
      {
......
225 231
      }
226 232
    }
227 233

  
234
///////////////////////////////////////////////////////////////////////////////////////////////////
235

  
236
  private int translateColor(int color)
237
    {
238
    if( mColorMode==MODE_DINO_4 )
239
      {
240
      int realColor = mFaceColors[color];
241
      int[] hexColors = ShapeHexahedron.FACE_COLORS;
242

  
243
      for(int i=0; i<6; i++)
244
        if( hexColors[i]==realColor ) return i;
245
      }
246

  
247
    return color;
248
    }
249

  
228 250
///////////////////////////////////////////////////////////////////////////////////////////////////
229 251

  
230 252
  private void setupColorButtons(final RubikActivity act, final float width)
......
252 274
        @Override
253 275
        public void onClick(View view)
254 276
          {
255
          mCurrentColor = ii;
277
          mCurrentColor = translateColor(ii);
278
          mCurrentButton= ii;
256 279
          markButton(act);
257 280
          }
258 281
        });
......
330 353
      {
331 354
      Drawable d = mColorButton[b].getBackground();
332 355

  
333
      if( b==mCurrentColor )
356
      if( b==mCurrentButton )
334 357
        {
335 358
        d.setColorFilter(ContextCompat.getColor(act,R.color.red), PorterDuff.Mode.MULTIPLY);
336 359
        }
......
345 368

  
346 369
  public void savePreferences(SharedPreferences.Editor editor)
347 370
    {
348
    editor.putInt("stateSolver_color", mCurrentColor);
371
    editor.putInt("stateSolver_color" , mCurrentColor );
372
    editor.putInt("stateSolver_button", mCurrentButton);
349 373
    }
350 374

  
351 375
///////////////////////////////////////////////////////////////////////////////////////////////////
352 376

  
353 377
  public void restorePreferences(SharedPreferences preferences)
354 378
    {
355
    mCurrentColor = preferences.getInt("stateSolver_color", 0);
379
    mCurrentColor = preferences.getInt("stateSolver_color" , 0);
380
    mCurrentButton= preferences.getInt("stateSolver_button", 0);
356 381
    }
357 382

  
358 383
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff