| 41 |
41 |
import org.distorted.dialogs.RubikDialogUpdates;
|
| 42 |
42 |
import org.distorted.external.RubikNetwork;
|
| 43 |
43 |
import org.distorted.external.RubikUpdates;
|
| 44 |
|
import org.distorted.objectlib.main.ObjectControl;
|
| 45 |
44 |
|
| 46 |
45 |
import org.distorted.main.R;
|
| 47 |
46 |
import org.distorted.main.RubikActivity;
|
| ... | ... | |
| 49 |
48 |
import org.distorted.dialogs.RubikDialogPattern;
|
| 50 |
49 |
import org.distorted.dialogs.RubikDialogScores;
|
| 51 |
50 |
import org.distorted.dialogs.RubikDialogTutorial;
|
| 52 |
|
import org.distorted.helpers.TransparentButton;
|
| 53 |
51 |
import org.distorted.helpers.TransparentImageButton;
|
| 54 |
|
import org.distorted.external.RubikScores;
|
| 55 |
52 |
import org.distorted.objects.MainEntry;
|
| 56 |
53 |
import org.distorted.objects.MainEntryList;
|
| 57 |
54 |
import org.distorted.objects.RubikObject;
|
| ... | ... | |
| 65 |
62 |
{
|
| 66 |
63 |
public static final int NUM_COLUMNS = 5;
|
| 67 |
64 |
public static final int LEVELS_SHOWN = 8;
|
|
65 |
private static final int NUM_BUTTONS = 5;
|
| 68 |
66 |
|
| 69 |
|
private static final int[] BUTTON_LABELS = { R.string.scores,
|
| 70 |
|
R.string.patterns,
|
| 71 |
|
R.string.solver,
|
| 72 |
|
R.string.tutorials,
|
| 73 |
|
R.string.about };
|
| 74 |
|
private static final int NUM_BUTTONS = BUTTON_LABELS.length;
|
| 75 |
|
|
| 76 |
|
private static final float BIG_BUTTON = 1.5f;
|
| 77 |
67 |
private static final int[] mLocation = new int[2];
|
| 78 |
68 |
|
| 79 |
69 |
private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton;
|
| 80 |
|
private TransparentButton mPlayButton;
|
| 81 |
70 |
private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup;
|
| 82 |
|
private LinearLayout mPlayLayout;
|
|
71 |
|
| 83 |
72 |
private TextView mBubbleUpdates;
|
| 84 |
|
private int mObjectSize, mMenuLayoutWidth, mMenuLayoutHeight, mPlayLayoutWidth;
|
|
73 |
private int mObjectSize, mMenuLayoutWidth, mMenuLayoutHeight, mMenuButtonHeight;
|
| 85 |
74 |
private int mLevelValue;
|
| 86 |
|
private float mButtonSize, mMenuItemSize, mMenuTextSize;
|
| 87 |
75 |
private int mColCount, mRowCount, mMaxRowCount;
|
| 88 |
76 |
private int mUpperBarHeight;
|
| 89 |
77 |
private boolean mShouldReactToEndOfScrambling;
|
| ... | ... | |
| 107 |
95 |
mScreenWidth = act.getScreenWidthInPixels();
|
| 108 |
96 |
mUpperBarHeight = act.getHeightUpperBar();
|
| 109 |
97 |
|
| 110 |
|
mMenuTextSize = mScreenWidth*RubikActivity.MENU_MED_TEXT_SIZE;
|
| 111 |
|
mButtonSize = mScreenWidth*RubikActivity.BUTTON_TEXT_SIZE;
|
| 112 |
|
mMenuItemSize = mScreenWidth*RubikActivity.MENU_ITEM_SIZE;
|
|
98 |
mMenuButtonHeight = (int)(mScreenWidth*RubikActivity.MENU_BUTTON_HEIGHT);
|
| 113 |
99 |
|
| 114 |
100 |
mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS;
|
| 115 |
101 |
mColCount = NUM_COLUMNS;
|
| ... | ... | |
| 162 |
148 |
});
|
| 163 |
149 |
}
|
| 164 |
150 |
|
| 165 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 166 |
|
|
| 167 |
|
private void setupPlayButton(final RubikActivity act, final float width)
|
| 168 |
|
{
|
| 169 |
|
final int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
| 170 |
|
|
| 171 |
|
mPlayButton = new TransparentButton(act, R.string.play, mButtonSize);
|
| 172 |
|
|
| 173 |
|
mPlayButton.setOnClickListener( new View.OnClickListener()
|
| 174 |
|
{
|
| 175 |
|
@Override
|
| 176 |
|
public void onClick(View view)
|
| 177 |
|
{
|
| 178 |
|
if( mPlayPopup==null )
|
| 179 |
|
{
|
| 180 |
|
float width = act.getScreenWidthInPixels();
|
| 181 |
|
setupPlayWindow(act,width);
|
| 182 |
|
}
|
| 183 |
|
|
| 184 |
|
if( act.getControl().isUINotBlocked())
|
| 185 |
|
{
|
| 186 |
|
adjustSolvedIcons();
|
| 187 |
|
float height= act.getScreenHeightInPixels();
|
| 188 |
|
final int maxHeight= (int)(0.9f*(height-mUpperBarHeight) );
|
| 189 |
|
View popupView = mPlayPopup.getContentView();
|
| 190 |
|
popupView.setSystemUiVisibility(RubikActivity.FLAGS);
|
| 191 |
|
final int object = RubikObjectList.getCurrObject();
|
| 192 |
|
final int dbLevel = RubikObjectList.getDBLevel(object);
|
| 193 |
|
final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN)+1;
|
| 194 |
|
final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+4*margin+2*mMenuItemSize*(BIG_BUTTON-1.0f));
|
| 195 |
|
final int realHeight = Math.min(popupHeight,maxHeight);
|
| 196 |
|
displayPopup(act,view,mPlayPopup,mPlayLayoutWidth,realHeight,margin,margin);
|
| 197 |
|
}
|
| 198 |
|
}
|
| 199 |
|
});
|
| 200 |
|
}
|
| 201 |
|
|
| 202 |
151 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 203 |
152 |
|
| 204 |
153 |
private void setupMenuButton(final RubikActivity act, final float width)
|
| ... | ... | |
| 223 |
172 |
{
|
| 224 |
173 |
View popupView = mMenuPopup.getContentView();
|
| 225 |
174 |
popupView.setSystemUiVisibility(RubikActivity.FLAGS);
|
| 226 |
|
displayPopup(act,view,mMenuPopup,mMenuLayoutWidth,mMenuLayoutHeight,(int)(-width/12),margin);
|
|
175 |
displayPopup(act,view,mMenuPopup,mMenuLayoutWidth,mMenuLayoutHeight,(int)(-mMenuLayoutWidth/2 + width/6),margin);
|
| 227 |
176 |
}
|
| 228 |
177 |
}
|
| 229 |
178 |
});
|
| ... | ... | |
| 290 |
239 |
int ordinal = mainEntry.getOrdinal();
|
| 291 |
240 |
RubikObjectList.setCurrObject(act,ordinal);
|
| 292 |
241 |
act.changeObject(ordinal,true);
|
| 293 |
|
if( mPlayLayout!=null ) adjustLevels(act);
|
|
242 |
if( mMenuPopup!=null ) adjustLevels(act);
|
| 294 |
243 |
mMovesController.clearMoves(act);
|
| 295 |
244 |
}
|
| 296 |
245 |
else if( type==MainEntry.TYPE_CREATOR )
|
| ... | ... | |
| 427 |
376 |
{
|
| 428 |
377 |
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
| 429 |
378 |
final View layout = layoutInflater.inflate(R.layout.popup_menu, null);
|
| 430 |
|
LinearLayout menuLayout = layout.findViewById(R.id.menuGrid);
|
| 431 |
379 |
|
| 432 |
380 |
mMenuPopup = new PopupWindow(act);
|
| 433 |
381 |
mMenuPopup.setContentView(layout);
|
| 434 |
382 |
mMenuPopup.setFocusable(true);
|
| 435 |
383 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
| 436 |
|
int padding = (int)(width*RubikActivity.PADDING);
|
| 437 |
|
|
| 438 |
|
mMenuLayoutWidth = (int)(width/2);
|
| 439 |
|
mMenuLayoutHeight= (int)(2*margin + NUM_BUTTONS*(mMenuItemSize+margin));
|
|
384 |
int padding = (int)(width*RubikActivity.MEDIUM_MARGIN);
|
| 440 |
385 |
|
| 441 |
|
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( mMenuLayoutWidth - 2*padding, (int)mMenuItemSize);
|
|
386 |
mMenuLayoutWidth = (int)(width*0.6f);
|
|
387 |
mMenuLayoutHeight= (int)(2*padding + NUM_BUTTONS*(mMenuButtonHeight+margin));
|
| 442 |
388 |
|
| 443 |
|
for(int i=0; i<NUM_BUTTONS; i++)
|
| 444 |
|
{
|
| 445 |
|
final int but = i;
|
| 446 |
|
Button button = new Button(act);
|
| 447 |
|
button.setLayoutParams(p);
|
| 448 |
|
button.setText(BUTTON_LABELS[i]);
|
| 449 |
|
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
|
389 |
layout.setPadding(padding,0,padding,0);
|
| 450 |
390 |
|
| 451 |
|
button.setOnClickListener( new View.OnClickListener()
|
|
391 |
Button highScores = layout.findViewById(R.id.menuHighScores);
|
|
392 |
highScores.setOnClickListener( new View.OnClickListener()
|
| 452 |
393 |
{
|
| 453 |
394 |
@Override
|
| 454 |
395 |
public void onClick(View v)
|
| 455 |
396 |
{
|
| 456 |
397 |
mMenuPopup.dismiss();
|
| 457 |
|
MenuAction(act,but);
|
|
398 |
Bundle sBundle = new Bundle();
|
|
399 |
int currObject = RubikObjectList.getCurrObject();
|
|
400 |
sBundle.putInt("tab", currObject );
|
|
401 |
sBundle.putBoolean("submitting", false);
|
|
402 |
RubikDialogScores scores = new RubikDialogScores();
|
|
403 |
scores.setArguments(sBundle);
|
|
404 |
scores.show(act.getSupportFragmentManager(), null);
|
| 458 |
405 |
}
|
| 459 |
406 |
});
|
| 460 |
407 |
|
| 461 |
|
menuLayout.addView(button);
|
| 462 |
|
}
|
| 463 |
|
}
|
| 464 |
|
|
| 465 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 466 |
|
|
| 467 |
|
private void setupPlayWindow(final RubikActivity act, final float width)
|
| 468 |
|
{
|
| 469 |
|
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
| 470 |
|
final View layout = layoutInflater.inflate(R.layout.popup_play, null);
|
| 471 |
|
mPlayLayout = layout.findViewById(R.id.playGrid);
|
| 472 |
|
|
| 473 |
|
mPlayLayoutWidth = (int)(width*0.4f);
|
| 474 |
|
|
| 475 |
|
mPlayPopup = new PopupWindow(act);
|
| 476 |
|
mPlayPopup.setContentView(layout);
|
| 477 |
|
mPlayPopup.setFocusable(true);
|
|
408 |
Button prettyPatterns = layout.findViewById(R.id.menuPrettyPatterns);
|
|
409 |
prettyPatterns.setOnClickListener( new View.OnClickListener()
|
|
410 |
{
|
|
411 |
@Override
|
|
412 |
public void onClick(View v)
|
|
413 |
{
|
|
414 |
mMenuPopup.dismiss();
|
|
415 |
RubikDialogPattern pDiag = new RubikDialogPattern();
|
|
416 |
pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() );
|
|
417 |
}
|
|
418 |
});
|
| 478 |
419 |
|
| 479 |
|
adjustLevels(act);
|
| 480 |
|
}
|
|
420 |
Button solver = layout.findViewById(R.id.menuSolver);
|
|
421 |
solver.setOnClickListener( new View.OnClickListener()
|
|
422 |
{
|
|
423 |
@Override
|
|
424 |
public void onClick(View v)
|
|
425 |
{
|
|
426 |
mMenuPopup.dismiss();
|
|
427 |
ScreenList.switchScreen(act, ScreenList.SVER);
|
|
428 |
}
|
|
429 |
});
|
| 481 |
430 |
|
| 482 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
431 |
Button tutorials = layout.findViewById(R.id.menuTutorials);
|
|
432 |
tutorials.setOnClickListener( new View.OnClickListener()
|
|
433 |
{
|
|
434 |
@Override
|
|
435 |
public void onClick(View v)
|
|
436 |
{
|
|
437 |
mMenuPopup.dismiss();
|
|
438 |
RubikDialogTutorial tDiag = new RubikDialogTutorial();
|
|
439 |
tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() );
|
|
440 |
}
|
|
441 |
});
|
| 483 |
442 |
|
| 484 |
|
private void MenuAction(RubikActivity act, int button)
|
| 485 |
|
{
|
| 486 |
|
switch(button)
|
| 487 |
|
{
|
| 488 |
|
case 0: Bundle sBundle = new Bundle();
|
| 489 |
|
int currObject = RubikObjectList.getCurrObject();
|
| 490 |
|
sBundle.putInt("tab", currObject );
|
| 491 |
|
sBundle.putBoolean("submitting", false);
|
| 492 |
|
RubikDialogScores scores = new RubikDialogScores();
|
| 493 |
|
scores.setArguments(sBundle);
|
| 494 |
|
scores.show(act.getSupportFragmentManager(), null);
|
| 495 |
|
break;
|
| 496 |
|
case 1: RubikDialogPattern pDiag = new RubikDialogPattern();
|
| 497 |
|
pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() );
|
| 498 |
|
break;
|
| 499 |
|
case 2: ScreenList.switchScreen(act, ScreenList.SVER);
|
| 500 |
|
break;
|
| 501 |
|
case 3: RubikDialogTutorial tDiag = new RubikDialogTutorial();
|
| 502 |
|
tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() );
|
| 503 |
|
break;
|
| 504 |
|
case 4: RubikDialogAbout aDiag = new RubikDialogAbout();
|
| 505 |
|
aDiag.show(act.getSupportFragmentManager(), null);
|
| 506 |
|
break;
|
| 507 |
|
}
|
|
443 |
Button about = layout.findViewById(R.id.menuAbout);
|
|
444 |
about.setOnClickListener( new View.OnClickListener()
|
|
445 |
{
|
|
446 |
@Override
|
|
447 |
public void onClick(View v)
|
|
448 |
{
|
|
449 |
mMenuPopup.dismiss();
|
|
450 |
RubikDialogAbout aDiag = new RubikDialogAbout();
|
|
451 |
aDiag.show(act.getSupportFragmentManager(), null);
|
|
452 |
}
|
|
453 |
});
|
| 508 |
454 |
}
|
| 509 |
455 |
|
| 510 |
456 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 565 |
511 |
|
| 566 |
512 |
public void setCurrObject(RubikActivity act)
|
| 567 |
513 |
{
|
| 568 |
|
if( mPlayLayout!=null ) adjustLevels(act);
|
|
514 |
if( mMenuPopup!=null ) adjustLevels(act);
|
| 569 |
515 |
}
|
| 570 |
516 |
|
| 571 |
517 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 614 |
560 |
}
|
| 615 |
561 |
|
| 616 |
562 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 617 |
|
|
|
563 |
/*
|
| 618 |
564 |
private void adjustSolvedIcons()
|
| 619 |
565 |
{
|
| 620 |
566 |
if( mPlayLayout!=null )
|
| ... | ... | |
| 634 |
580 |
}
|
| 635 |
581 |
}
|
| 636 |
582 |
}
|
| 637 |
|
|
|
583 |
*/
|
| 638 |
584 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 639 |
585 |
|
| 640 |
586 |
private void adjustLevels(final RubikActivity act)
|
| 641 |
587 |
{
|
|
588 |
/*
|
| 642 |
589 |
int currObject = RubikObjectList.getCurrObject();
|
| 643 |
590 |
int dbLevel = RubikObjectList.getDBLevel(currObject);
|
| 644 |
591 |
RubikObject object = RubikObjectList.getObject(currObject);
|
| ... | ... | |
| 656 |
603 |
float width = act.getScreenWidthInPixels();
|
| 657 |
604 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
| 658 |
605 |
int padding = (int)(width*RubikActivity.PADDING);
|
| 659 |
|
int butWidth = mPlayLayoutWidth - 2*padding;
|
|
606 |
int butWidth = 0;//mPlayLayoutWidth - 2*padding;
|
| 660 |
607 |
int butHeight= (int)mMenuItemSize;
|
| 661 |
608 |
int bigButH = (int)(mMenuItemSize*BIG_BUTTON) ;
|
| 662 |
609 |
|
| ... | ... | |
| 705 |
652 |
|
| 706 |
653 |
mPlayLayout.addView(button);
|
| 707 |
654 |
}
|
|
655 |
|
|
656 |
*/
|
| 708 |
657 |
}
|
| 709 |
658 |
|
| 710 |
659 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
Progress with central menu popup.