1 |
344f290c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
bb62ca3f
|
Leszek Koltunski
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
5 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
6 |
344f290c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
7 |
|
|
|
8 |
eaf87d1d
|
Leszek Koltunski
|
package org.distorted.tutorials;
|
9 |
344f290c
|
Leszek Koltunski
|
|
10 |
e019c70b
|
Leszek Koltunski
|
import android.app.Activity;
|
11 |
344f290c
|
Leszek Koltunski
|
import android.view.View;
|
12 |
|
|
import android.widget.LinearLayout;
|
13 |
|
|
|
14 |
dd1a65c1
|
Leszek Koltunski
|
import org.distorted.helpers.MovesController;
|
15 |
b1629e16
|
Leszek Koltunski
|
import org.distorted.objectlib.effects.BaseEffect;
|
16 |
2afc6754
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectControl;
|
17 |
3f7a4363
|
Leszek Koltunski
|
|
18 |
dd1a65c1
|
Leszek Koltunski
|
import org.distorted.helpers.LockController;
|
19 |
344f290c
|
Leszek Koltunski
|
import org.distorted.main.R;
|
20 |
|
|
import org.distorted.main.RubikActivity;
|
21 |
d433b50e
|
Leszek Koltunski
|
import org.distorted.objects.RubikObject;
|
22 |
55e6be1d
|
Leszek Koltunski
|
import org.distorted.helpers.TransparentImageButton;
|
23 |
344f290c
|
Leszek Koltunski
|
|
24 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25 |
|
|
|
26 |
dd1a65c1
|
Leszek Koltunski
|
public class TutorialScreen
|
27 |
344f290c
|
Leszek Koltunski
|
{
|
28 |
dd874ae8
|
Leszek Koltunski
|
private TransparentImageButton mSolveButton, mScrambleButton, mBackButton;
|
29 |
dd1a65c1
|
Leszek Koltunski
|
private final LockController mLockController;
|
30 |
|
|
private final MovesController mMovesController;
|
31 |
344f290c
|
Leszek Koltunski
|
|
32 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33 |
|
|
|
34 |
dd874ae8
|
Leszek Koltunski
|
private void setupSolveButton(final TutorialActivity act)
|
35 |
344f290c
|
Leszek Koltunski
|
{
|
36 |
|
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve,R.drawable.ui_medium_cube_solve, R.drawable.ui_big_cube_solve, R.drawable.ui_huge_cube_solve);
|
37 |
b600ccd9
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
38 |
|
|
mSolveButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
|
39 |
344f290c
|
Leszek Koltunski
|
|
40 |
|
|
mSolveButton.setOnClickListener( new View.OnClickListener()
|
41 |
|
|
{
|
42 |
|
|
@Override
|
43 |
|
|
public void onClick(View v)
|
44 |
|
|
{
|
45 |
2afc6754
|
Leszek Koltunski
|
act.getControl().solveObject();
|
46 |
dd1a65c1
|
Leszek Koltunski
|
mMovesController.clearMoves(act);
|
47 |
344f290c
|
Leszek Koltunski
|
}
|
48 |
|
|
});
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
52 |
|
|
|
53 |
dd874ae8
|
Leszek Koltunski
|
private void setupScrambleButton(final TutorialActivity act)
|
54 |
344f290c
|
Leszek Koltunski
|
{
|
55 |
|
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_scramble,R.drawable.ui_medium_cube_scramble, R.drawable.ui_big_cube_scramble, R.drawable.ui_huge_cube_scramble);
|
56 |
b600ccd9
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
57 |
|
|
mScrambleButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
|
58 |
344f290c
|
Leszek Koltunski
|
|
59 |
|
|
mScrambleButton.setOnClickListener( new View.OnClickListener()
|
60 |
|
|
{
|
61 |
|
|
@Override
|
62 |
|
|
public void onClick(View v)
|
63 |
|
|
{
|
64 |
b1629e16
|
Leszek Koltunski
|
int duration = BaseEffect.Type.FAST_SCRAMBLE.getDuration();
|
65 |
|
|
act.getControl().fastScrambleObject(duration,RubikObject.FAST_SCRAMBLES);
|
66 |
344f290c
|
Leszek Koltunski
|
}
|
67 |
|
|
});
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71 |
|
|
|
72 |
dd874ae8
|
Leszek Koltunski
|
private void setupBackButton(final TutorialActivity act)
|
73 |
344f290c
|
Leszek Koltunski
|
{
|
74 |
e314f6ae
|
Leszek Koltunski
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback);
|
75 |
b600ccd9
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
76 |
|
|
mBackButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
|
77 |
344f290c
|
Leszek Koltunski
|
|
78 |
|
|
mBackButton.setOnClickListener( new View.OnClickListener()
|
79 |
|
|
{
|
80 |
|
|
@Override
|
81 |
|
|
public void onClick(View v)
|
82 |
|
|
{
|
83 |
2afc6754
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
84 |
|
|
if( control!=null ) control.unblockEverything();
|
85 |
344f290c
|
Leszek Koltunski
|
act.finish();
|
86 |
|
|
}
|
87 |
|
|
});
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91 |
|
|
|
92 |
dd874ae8
|
Leszek Koltunski
|
void createRightPane(final TutorialActivity act)
|
93 |
344f290c
|
Leszek Koltunski
|
{
|
94 |
2971588c
|
Leszek Koltunski
|
LinearLayout layout = act.findViewById(R.id.tutorialRightBar);
|
95 |
344f290c
|
Leszek Koltunski
|
layout.removeAllViews();
|
96 |
|
|
|
97 |
e019c70b
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
98 |
dd874ae8
|
Leszek Koltunski
|
mMovesController.setupButton(act,control);
|
99 |
|
|
mLockController.setupButton(act,control);
|
100 |
|
|
setupSolveButton(act);
|
101 |
|
|
setupScrambleButton(act);
|
102 |
|
|
setupBackButton(act);
|
103 |
344f290c
|
Leszek Koltunski
|
|
104 |
|
|
layout.addView(mSolveButton);
|
105 |
|
|
layout.addView(mScrambleButton);
|
106 |
dd874ae8
|
Leszek Koltunski
|
layout.addView(mMovesController.getButton());
|
107 |
dd1a65c1
|
Leszek Koltunski
|
layout.addView(mLockController.getButton());
|
108 |
344f290c
|
Leszek Koltunski
|
layout.addView(mBackButton);
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112 |
|
|
|
113 |
e019c70b
|
Leszek Koltunski
|
void addMove(Activity act, int axis, int row, int angle)
|
114 |
146661ec
|
Leszek Koltunski
|
{
|
115 |
dd1a65c1
|
Leszek Koltunski
|
mMovesController.addMove(act, axis,row,angle);
|
116 |
146661ec
|
Leszek Koltunski
|
}
|
117 |
|
|
|
118 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
119 |
|
|
// PUBLIC API
|
120 |
|
|
|
121 |
dd1a65c1
|
Leszek Koltunski
|
public TutorialScreen()
|
122 |
344f290c
|
Leszek Koltunski
|
{
|
123 |
dd1a65c1
|
Leszek Koltunski
|
mLockController = new LockController();
|
124 |
|
|
mMovesController = new MovesController();
|
125 |
344f290c
|
Leszek Koltunski
|
}
|
126 |
cc88f2fa
|
Leszek Koltunski
|
|
127 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128 |
|
|
|
129 |
e019c70b
|
Leszek Koltunski
|
public void reddenLock(final TutorialActivity act)
|
130 |
cc88f2fa
|
Leszek Koltunski
|
{
|
131 |
e019c70b
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
132 |
|
|
mLockController.reddenLock(act,control);
|
133 |
cc88f2fa
|
Leszek Koltunski
|
}
|
134 |
344f290c
|
Leszek Koltunski
|
}
|