1 |
9530f6b0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
15ed3429
|
leszek
|
// Copyright 2020 Leszek Koltunski //
|
3 |
9530f6b0
|
Leszek Koltunski
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
44fec653
|
Leszek Koltunski
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8 |
9530f6b0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
7ee8337b
|
leszek
|
package org.distorted.playui;
|
11 |
9530f6b0
|
Leszek Koltunski
|
|
12 |
88b94310
|
Leszek Koltunski
|
import android.content.SharedPreferences;
|
13 |
9530f6b0
|
Leszek Koltunski
|
import android.view.View;
|
14 |
|
|
import android.widget.LinearLayout;
|
15 |
|
|
|
16 |
|
|
import org.distorted.helpers.TransparentImageButton;
|
17 |
|
|
import org.distorted.main.R;
|
18 |
15ed3429
|
leszek
|
import org.distorted.objectlib.effects.BaseEffect;
|
19 |
|
|
import org.distorted.objectlib.main.ObjectControl;
|
20 |
9530f6b0
|
Leszek Koltunski
|
|
21 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
22 |
|
|
|
23 |
15ed3429
|
leszek
|
public class ScreenFree extends ScreenBase
|
24 |
|
|
{
|
25 |
ca280c3f
|
Leszek Koltunski
|
private TransparentImageButton mBackButton, mScrambleButton, mSolveButton;
|
26 |
9530f6b0
|
Leszek Koltunski
|
|
27 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28 |
|
|
|
29 |
15ed3429
|
leszek
|
void leaveScreen(PlayActivity act)
|
30 |
9530f6b0
|
Leszek Koltunski
|
{
|
31 |
15ed3429
|
leszek
|
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35 |
|
|
|
36 |
|
|
void enterScreen(final PlayActivity act)
|
37 |
|
|
{
|
38 |
|
|
int width = act.getScreenWidthInPixels();
|
39 |
|
|
|
40 |
|
|
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
|
41 |
|
|
LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
|
42 |
|
|
LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
|
43 |
|
|
|
44 |
|
|
// TOP ////////////////////////////
|
45 |
|
|
setupSolveButton(act);
|
46 |
|
|
setupScrambleButton(act);
|
47 |
|
|
|
48 |
|
|
LinearLayout layoutUpper = act.findViewById(R.id.upperBar);
|
49 |
|
|
|
50 |
|
|
LinearLayout layoutLeftU = new LinearLayout(act);
|
51 |
|
|
layoutLeftU.setLayoutParams(paramsL);
|
52 |
|
|
LinearLayout layoutMidU = new LinearLayout(act);
|
53 |
|
|
layoutMidU.setLayoutParams(paramsM);
|
54 |
|
|
LinearLayout layoutRightU= new LinearLayout(act);
|
55 |
|
|
layoutRightU.setLayoutParams(paramsR);
|
56 |
|
|
|
57 |
|
|
layoutLeftU.addView(mSolveButton);
|
58 |
|
|
layoutRightU.addView(mScrambleButton);
|
59 |
|
|
|
60 |
|
|
layoutUpper.removeAllViews();
|
61 |
|
|
layoutUpper.addView(layoutLeftU);
|
62 |
|
|
layoutUpper.addView(layoutMidU);
|
63 |
|
|
layoutUpper.addView(layoutRightU);
|
64 |
|
|
|
65 |
|
|
// BOT ////////////////////////////
|
66 |
|
|
setupBackButton(act);
|
67 |
|
|
createBottomPane(act,mBackButton);
|
68 |
9530f6b0
|
Leszek Koltunski
|
}
|
69 |
|
|
|
70 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71 |
|
|
|
72 |
7ee8337b
|
leszek
|
private void setupBackButton(final PlayActivity act)
|
73 |
9530f6b0
|
Leszek Koltunski
|
{
|
74 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
75 |
70688a23
|
leszek
|
mBackButton = new TransparentImageButton(act,R.drawable.ui_smallback,params);
|
76 |
9530f6b0
|
Leszek Koltunski
|
|
77 |
|
|
mBackButton.setOnClickListener( new View.OnClickListener()
|
78 |
|
|
{
|
79 |
|
|
@Override
|
80 |
|
|
public void onClick(View v)
|
81 |
|
|
{
|
82 |
|
|
act.finish();
|
83 |
|
|
}
|
84 |
|
|
});
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88 |
|
|
|
89 |
7ee8337b
|
leszek
|
private void setupSolveButton(final PlayActivity act)
|
90 |
9530f6b0
|
Leszek Koltunski
|
{
|
91 |
f3563327
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
92 |
70688a23
|
leszek
|
mSolveButton = new TransparentImageButton(act,R.drawable.ui_cube_solve,params);
|
93 |
f3563327
|
Leszek Koltunski
|
|
94 |
|
|
mSolveButton.setOnClickListener( new View.OnClickListener()
|
95 |
|
|
{
|
96 |
|
|
@Override
|
97 |
|
|
public void onClick(View v)
|
98 |
|
|
{
|
99 |
b72b71a1
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
100 |
ca280c3f
|
Leszek Koltunski
|
control.solveObject();
|
101 |
f3563327
|
Leszek Koltunski
|
mMovesController.clearMoves(act);
|
102 |
|
|
}
|
103 |
|
|
});
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107 |
9530f6b0
|
Leszek Koltunski
|
|
108 |
7ee8337b
|
leszek
|
private void setupScrambleButton(final PlayActivity act)
|
109 |
f3563327
|
Leszek Koltunski
|
{
|
110 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
111 |
70688a23
|
leszek
|
mScrambleButton = new TransparentImageButton(act,R.drawable.ui_cube_scramble,params);
|
112 |
f3563327
|
Leszek Koltunski
|
|
113 |
|
|
mScrambleButton.setOnClickListener( new View.OnClickListener()
|
114 |
|
|
{
|
115 |
|
|
@Override
|
116 |
|
|
public void onClick(View v)
|
117 |
|
|
{
|
118 |
4844152a
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
119 |
5c0c4988
|
leszek
|
int duration = BaseEffect.Type.FAST_SCRAMBLE.getDuration();
|
120 |
7ee8337b
|
leszek
|
int numScrambles = act.getNumScrambles();
|
121 |
|
|
control.fastScrambleObject(duration,numScrambles);
|
122 |
ca280c3f
|
Leszek Koltunski
|
mMovesController.clearMoves(act);
|
123 |
f3563327
|
Leszek Koltunski
|
}
|
124 |
|
|
});
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128 |
|
|
|
129 |
15ed3429
|
leszek
|
public void savePreferences(SharedPreferences.Editor editor)
|
130 |
f3563327
|
Leszek Koltunski
|
{
|
131 |
9530f6b0
|
Leszek Koltunski
|
|
132 |
88b94310
|
Leszek Koltunski
|
}
|
133 |
|
|
|
134 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135 |
|
|
|
136 |
15ed3429
|
leszek
|
public void restorePreferences(SharedPreferences preferences)
|
137 |
88b94310
|
Leszek Koltunski
|
{
|
138 |
|
|
|
139 |
b72b71a1
|
Leszek Koltunski
|
}
|
140 |
15ed3429
|
leszek
|
}
|