Revision 24cd23dd
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
57 | 57 |
|
58 | 58 |
public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Updatee |
59 | 59 |
{ |
60 |
private static final float MENU_BUTTON_HEIGHT = 0.075f; |
|
61 |
private static final float MENU_TEXT_SIZE = 0.032f; |
|
62 |
private static final float MENU_MARGIN = 0.008f; |
|
63 |
|
|
60 | 64 |
public static final int NUM_COLUMNS = 5; |
61 | 65 |
public static final int LEVELS_SHOWN = 8; |
62 | 66 |
private static final int[] mLocation = new int[2]; |
... | ... | |
72 | 76 |
private int mUpperBarHeight; |
73 | 77 |
private boolean mShouldReactToEndOfScrambling; |
74 | 78 |
private float mScreenWidth, mScreenHeight; |
79 |
private int mLevelHeight, mLevelWidth; |
|
75 | 80 |
private int mOldNumScramble; |
76 | 81 |
|
77 | 82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
90 | 95 |
mScreenHeight = act.getScreenHeightInPixels(); |
91 | 96 |
mUpperBarHeight = act.getHeightUpperBar(); |
92 | 97 |
|
93 |
mMenuButtonHeight = (int)(mScreenHeight*RubikActivity.MENU_BUTTON_HEIGHT);
|
|
94 |
mMenuTextSize = (int)(mScreenHeight*RubikActivity.MENU_TEXT_SIZE);
|
|
98 |
mMenuButtonHeight = (int)(mScreenHeight*MENU_BUTTON_HEIGHT); |
|
99 |
mMenuTextSize = (int)(mScreenHeight*MENU_TEXT_SIZE); |
|
95 | 100 |
|
96 | 101 |
mObjectPopup = null; |
97 | 102 |
mOldNumScramble = 1000; // used to remember which 'level' buttons are visible; initially all visible |
... | ... | |
102 | 107 |
|
103 | 108 |
setupSolveButton(act); |
104 | 109 |
layoutTop.addView(mSolveButton); |
105 |
setupMenuButton(act,mScreenWidth); |
|
110 |
setupMenuButton(act,mScreenWidth, mScreenHeight);
|
|
106 | 111 |
layoutTop.addView(mMenuButton); |
107 | 112 |
setupScrambleButton(act); |
108 | 113 |
layoutTop.addView(mScrambleButton); |
... | ... | |
146 | 151 |
|
147 | 152 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
148 | 153 |
|
149 |
private void setupMenuButton(final RubikActivity act, final float width) |
|
154 |
private void setupMenuButton(final RubikActivity act, final float width, final float height)
|
|
150 | 155 |
{ |
151 | 156 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_menu,R.drawable.ui_medium_menu, R.drawable.ui_big_menu, R.drawable.ui_huge_menu); |
152 | 157 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
... | ... | |
160 | 165 |
if( mMenuPopup==null ) |
161 | 166 |
{ |
162 | 167 |
float width = act.getScreenWidthInPixels(); |
163 |
setupMenuWindow(act,width); |
|
168 |
setupMenuWindow(act,width,height);
|
|
164 | 169 |
} |
165 | 170 |
|
166 | 171 |
if( act.getControl().isUINotBlocked()) |
... | ... | |
335 | 340 |
|
336 | 341 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
337 | 342 |
|
338 |
private void setupMenuWindow(final RubikActivity act, final float width) |
|
343 |
private void setupMenuWindow(final RubikActivity act, final float width, final float height)
|
|
339 | 344 |
{ |
340 | 345 |
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
341 | 346 |
final View layout = layoutInflater.inflate(R.layout.popup_menu, null); |
... | ... | |
343 | 348 |
mMenuPopup = new PopupWindow(act); |
344 | 349 |
mMenuPopup.setContentView(layout); |
345 | 350 |
mMenuPopup.setFocusable(true); |
346 |
int padding = (int)(width*RubikActivity.MEDIUM_MARGIN);
|
|
351 |
int padding = (int)(height*MENU_MARGIN);
|
|
347 | 352 |
int numButtons = USE_IAP ? 7 : 6; |
348 | 353 |
mMenuLayoutWidth = (int)(width*0.65f); |
349 |
mMenuLayoutHeight= padding + numButtons*(mMenuButtonHeight+padding) + 4*mMenuButtonHeight+6*padding; |
|
354 |
mLevelWidth = (mMenuLayoutWidth-4*padding)/3; |
|
355 |
mLevelHeight = (int)(mLevelWidth*0.75f); |
|
356 |
mMenuLayoutHeight= padding + numButtons*(mMenuButtonHeight+padding) + mLevelHeight/3 + 3*(mLevelHeight+padding); |
|
350 | 357 |
|
351 | 358 |
layout.setPadding(padding,0,padding,0); |
352 | 359 |
|
... | ... | |
462 | 469 |
|
463 | 470 |
private void setupLevelButtons(RubikActivity act, View layout, int padding) |
464 | 471 |
{ |
465 |
int sizeW = (mMenuLayoutWidth-4*padding)/3; |
|
466 |
int sizeH = (int)(sizeW*0.8f); |
|
467 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(sizeW,sizeH); |
|
472 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mLevelWidth,mLevelHeight); |
|
468 | 473 |
params.setMargins(padding/2,0,padding/2,0); |
469 | 474 |
|
470 | 475 |
mLevel = new Button[LEVELS_SHOWN+1]; |
Also available in: Unified diff
Further improvements for the UI.