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.objects.RubikObject;
|
21
|
import org.distorted.helpers.TransparentImageButton;
|
22
|
|
23
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
24
|
|
25
|
public class TutorialScreen
|
26
|
{
|
27
|
private TransparentImageButton mDialogButton, mSolveButton, mScrambleButton, mBackButton;
|
28
|
private TransparentImageButton mLockButton, mEmptyButton1, mEmptyButton2, mEmptyButton3;
|
29
|
private final LockController mLockController;
|
30
|
private final MovesController mMovesController;
|
31
|
private final boolean mFree;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
private void setupLockButton(final TutorialActivity act)
|
36
|
{
|
37
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
38
|
mLockButton = new TransparentImageButton(act,R.drawable.ui_locked,params);
|
39
|
|
40
|
mLockButton.setOnClickListener( new View.OnClickListener()
|
41
|
{
|
42
|
@Override
|
43
|
public void onClick(View v)
|
44
|
{
|
45
|
//act.switchToPurchase();
|
46
|
}
|
47
|
});
|
48
|
}
|
49
|
|
50
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
51
|
|
52
|
private void setupEmptyButton1(final TutorialActivity act)
|
53
|
{
|
54
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
55
|
mEmptyButton1 = new TransparentImageButton(act, params);
|
56
|
mEmptyButton1.setClickable(false);
|
57
|
}
|
58
|
|
59
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60
|
|
61
|
private void setupEmptyButton2(final TutorialActivity act)
|
62
|
{
|
63
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
64
|
mEmptyButton2 = new TransparentImageButton(act, params);
|
65
|
mEmptyButton2.setClickable(false);
|
66
|
}
|
67
|
|
68
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69
|
|
70
|
private void setupEmptyButton3(final TutorialActivity act)
|
71
|
{
|
72
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
73
|
mEmptyButton3 = new TransparentImageButton(act, params);
|
74
|
mEmptyButton3.setClickable(false);
|
75
|
}
|
76
|
|
77
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
78
|
|
79
|
private void setupDialogButton(final TutorialActivity act)
|
80
|
{
|
81
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
82
|
mDialogButton = new TransparentImageButton(act,R.drawable.ui_menu,params);
|
83
|
|
84
|
mDialogButton.setOnClickListener( new View.OnClickListener()
|
85
|
{
|
86
|
@Override
|
87
|
public void onClick(View v)
|
88
|
{
|
89
|
act.showDialog();
|
90
|
}
|
91
|
});
|
92
|
}
|
93
|
|
94
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
95
|
|
96
|
private void setupSolveButton(final TutorialActivity act)
|
97
|
{
|
98
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
99
|
mSolveButton = new TransparentImageButton(act,R.drawable.ui_cube_solve,params);
|
100
|
|
101
|
mSolveButton.setOnClickListener( new View.OnClickListener()
|
102
|
{
|
103
|
@Override
|
104
|
public void onClick(View v)
|
105
|
{
|
106
|
act.getControl().solveObject();
|
107
|
mMovesController.clearMoves(act);
|
108
|
}
|
109
|
});
|
110
|
}
|
111
|
|
112
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
113
|
|
114
|
private void setupScrambleButton(final TutorialActivity act)
|
115
|
{
|
116
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
117
|
mScrambleButton = new TransparentImageButton(act,R.drawable.ui_cube_scramble,params);
|
118
|
|
119
|
mScrambleButton.setOnClickListener( new View.OnClickListener()
|
120
|
{
|
121
|
@Override
|
122
|
public void onClick(View v)
|
123
|
{
|
124
|
int duration = BaseEffect.Type.FAST_SCRAMBLE.getDuration();
|
125
|
act.getControl().fastScrambleObject(duration,RubikObject.FAST_SCRAMBLES);
|
126
|
}
|
127
|
});
|
128
|
}
|
129
|
|
130
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
131
|
|
132
|
private void setupBackButton(final TutorialActivity act)
|
133
|
{
|
134
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
135
|
mBackButton = new TransparentImageButton(act,R.drawable.ui_smallback,params);
|
136
|
|
137
|
mBackButton.setOnClickListener( new View.OnClickListener()
|
138
|
{
|
139
|
@Override
|
140
|
public void onClick(View v)
|
141
|
{
|
142
|
act.finish();
|
143
|
}
|
144
|
});
|
145
|
}
|
146
|
|
147
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
148
|
|
149
|
void createRightPane(final TutorialActivity act)
|
150
|
{
|
151
|
LinearLayout layout = act.findViewById(R.id.tutorialRightBar);
|
152
|
layout.removeAllViews();
|
153
|
|
154
|
if( mFree )
|
155
|
{
|
156
|
ObjectControl control = act.getControl();
|
157
|
mMovesController.setupButton(act,control);
|
158
|
mLockController.setupButton(act,control);
|
159
|
setupDialogButton(act);
|
160
|
setupSolveButton(act);
|
161
|
setupScrambleButton(act);
|
162
|
layout.addView(mDialogButton);
|
163
|
layout.addView(mSolveButton);
|
164
|
layout.addView(mScrambleButton);
|
165
|
layout.addView(mMovesController.getButton());
|
166
|
layout.addView(mLockController.getButton());
|
167
|
}
|
168
|
else
|
169
|
{
|
170
|
setupLockButton(act);
|
171
|
setupEmptyButton1(act);
|
172
|
setupEmptyButton2(act);
|
173
|
setupEmptyButton3(act);
|
174
|
layout.addView(mLockButton);
|
175
|
layout.addView(mEmptyButton1);
|
176
|
layout.addView(mEmptyButton2);
|
177
|
layout.addView(mEmptyButton3);
|
178
|
}
|
179
|
|
180
|
setupBackButton(act);
|
181
|
layout.addView(mBackButton);
|
182
|
}
|
183
|
|
184
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
185
|
|
186
|
void addMove(Activity act, int axis, int row, int angle)
|
187
|
{
|
188
|
mMovesController.addMove(act, axis,row,angle);
|
189
|
}
|
190
|
|
191
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
192
|
// PUBLIC API
|
193
|
|
194
|
public TutorialScreen(boolean free)
|
195
|
{
|
196
|
mFree = free;
|
197
|
mLockController = new LockController();
|
198
|
mMovesController = new MovesController();
|
199
|
}
|
200
|
|
201
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
202
|
|
203
|
public void reddenLock(final TutorialActivity act)
|
204
|
{
|
205
|
ObjectControl control = act.getControl();
|
206
|
mLockController.reddenLock(act,control);
|
207
|
}
|
208
|
}
|