1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// 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
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
7
|
|
8
|
package org.distorted.tutorials;
|
9
|
|
10
|
import android.app.Activity;
|
11
|
import android.view.View;
|
12
|
import android.widget.LinearLayout;
|
13
|
|
14
|
import org.distorted.helpers.MovesController;
|
15
|
import org.distorted.objectlib.effects.BaseEffect;
|
16
|
import org.distorted.objectlib.main.ObjectControl;
|
17
|
|
18
|
import org.distorted.helpers.LockController;
|
19
|
import org.distorted.main.R;
|
20
|
import org.distorted.main.RubikActivity;
|
21
|
import org.distorted.objects.RubikObject;
|
22
|
import org.distorted.helpers.TransparentImageButton;
|
23
|
|
24
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25
|
|
26
|
public class TutorialScreen
|
27
|
{
|
28
|
private TransparentImageButton mSolveButton, mScrambleButton, mBackButton;
|
29
|
private final LockController mLockController;
|
30
|
private final MovesController mMovesController;
|
31
|
|
32
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33
|
|
34
|
private void setupSolveButton(final TutorialActivity act)
|
35
|
{
|
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
|
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
|
|
40
|
mSolveButton.setOnClickListener( new View.OnClickListener()
|
41
|
{
|
42
|
@Override
|
43
|
public void onClick(View v)
|
44
|
{
|
45
|
act.getControl().solveObject();
|
46
|
mMovesController.clearMoves(act);
|
47
|
}
|
48
|
});
|
49
|
}
|
50
|
|
51
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
52
|
|
53
|
private void setupScrambleButton(final TutorialActivity act)
|
54
|
{
|
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
|
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
|
|
59
|
mScrambleButton.setOnClickListener( new View.OnClickListener()
|
60
|
{
|
61
|
@Override
|
62
|
public void onClick(View v)
|
63
|
{
|
64
|
int duration = BaseEffect.Type.FAST_SCRAMBLE.getDuration();
|
65
|
act.getControl().fastScrambleObject(duration,RubikObject.FAST_SCRAMBLES);
|
66
|
}
|
67
|
});
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71
|
|
72
|
private void setupBackButton(final TutorialActivity act)
|
73
|
{
|
74
|
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
|
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
|
|
78
|
mBackButton.setOnClickListener( new View.OnClickListener()
|
79
|
{
|
80
|
@Override
|
81
|
public void onClick(View v)
|
82
|
{
|
83
|
ObjectControl control = act.getControl();
|
84
|
if( control!=null ) control.unblockEverything();
|
85
|
act.finish();
|
86
|
}
|
87
|
});
|
88
|
}
|
89
|
|
90
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91
|
|
92
|
void createRightPane(final TutorialActivity act)
|
93
|
{
|
94
|
LinearLayout layout = act.findViewById(R.id.tutorialRightBar);
|
95
|
layout.removeAllViews();
|
96
|
|
97
|
ObjectControl control = act.getControl();
|
98
|
mMovesController.setupButton(act,control);
|
99
|
mLockController.setupButton(act,control);
|
100
|
setupSolveButton(act);
|
101
|
setupScrambleButton(act);
|
102
|
setupBackButton(act);
|
103
|
|
104
|
layout.addView(mSolveButton);
|
105
|
layout.addView(mScrambleButton);
|
106
|
layout.addView(mMovesController.getButton());
|
107
|
layout.addView(mLockController.getButton());
|
108
|
layout.addView(mBackButton);
|
109
|
}
|
110
|
|
111
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112
|
|
113
|
void addMove(Activity act, int axis, int row, int angle)
|
114
|
{
|
115
|
mMovesController.addMove(act, axis,row,angle);
|
116
|
}
|
117
|
|
118
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
119
|
// PUBLIC API
|
120
|
|
121
|
public TutorialScreen()
|
122
|
{
|
123
|
mLockController = new LockController();
|
124
|
mMovesController = new MovesController();
|
125
|
}
|
126
|
|
127
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128
|
|
129
|
public void reddenLock(final TutorialActivity act)
|
130
|
{
|
131
|
ObjectControl control = act.getControl();
|
132
|
mLockController.reddenLock(act,control);
|
133
|
}
|
134
|
}
|