1 |
344f290c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
eaf87d1d
|
Leszek Koltunski
|
package org.distorted.tutorials;
|
21 |
344f290c
|
Leszek Koltunski
|
|
22 |
e019c70b
|
Leszek Koltunski
|
import android.app.Activity;
|
23 |
344f290c
|
Leszek Koltunski
|
import android.view.View;
|
24 |
|
|
import android.widget.ImageButton;
|
25 |
|
|
import android.widget.LinearLayout;
|
26 |
|
|
|
27 |
dd1a65c1
|
Leszek Koltunski
|
import org.distorted.helpers.MovesController;
|
28 |
2afc6754
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectControl;
|
29 |
318c0a7d
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectType;
|
30 |
3f7a4363
|
Leszek Koltunski
|
|
31 |
dd1a65c1
|
Leszek Koltunski
|
import org.distorted.helpers.LockController;
|
32 |
344f290c
|
Leszek Koltunski
|
import org.distorted.main.R;
|
33 |
|
|
import org.distorted.main.RubikActivity;
|
34 |
fcd5b990
|
Leszek Koltunski
|
import org.distorted.screens.RubikScreenPlay;
|
35 |
|
|
import org.distorted.screens.ScreenList;
|
36 |
55e6be1d
|
Leszek Koltunski
|
import org.distorted.helpers.TransparentImageButton;
|
37 |
344f290c
|
Leszek Koltunski
|
|
38 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
|
40 |
dd1a65c1
|
Leszek Koltunski
|
public class TutorialScreen
|
41 |
344f290c
|
Leszek Koltunski
|
{
|
42 |
55e6be1d
|
Leszek Koltunski
|
private ImageButton mSolveButton, mScrambleButton, mBackButton;
|
43 |
dd1a65c1
|
Leszek Koltunski
|
private final LockController mLockController;
|
44 |
|
|
private final MovesController mMovesController;
|
45 |
344f290c
|
Leszek Koltunski
|
|
46 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47 |
|
|
|
48 |
|
|
private void setupSolveButton(final TutorialActivity act, final float width)
|
49 |
|
|
{
|
50 |
|
|
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);
|
51 |
|
|
mSolveButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
52 |
|
|
|
53 |
|
|
mSolveButton.setOnClickListener( new View.OnClickListener()
|
54 |
|
|
{
|
55 |
|
|
@Override
|
56 |
|
|
public void onClick(View v)
|
57 |
|
|
{
|
58 |
2afc6754
|
Leszek Koltunski
|
act.getControl().solveObject();
|
59 |
dd1a65c1
|
Leszek Koltunski
|
mMovesController.clearMoves(act);
|
60 |
344f290c
|
Leszek Koltunski
|
}
|
61 |
|
|
});
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65 |
|
|
|
66 |
|
|
private void setupScrambleButton(final TutorialActivity act, final float width)
|
67 |
|
|
{
|
68 |
|
|
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);
|
69 |
|
|
mScrambleButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
|
70 |
|
|
|
71 |
|
|
mScrambleButton.setOnClickListener( new View.OnClickListener()
|
72 |
|
|
{
|
73 |
|
|
@Override
|
74 |
|
|
public void onClick(View v)
|
75 |
|
|
{
|
76 |
f5da732a
|
Leszek Koltunski
|
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
77 |
8ab435b9
|
Leszek Koltunski
|
int ordinal = play.getObject().ordinal();
|
78 |
|
|
int numScrambles = ObjectType.getNumScramble(ordinal);
|
79 |
2afc6754
|
Leszek Koltunski
|
act.getControl().scrambleObject(numScrambles);
|
80 |
344f290c
|
Leszek Koltunski
|
}
|
81 |
|
|
});
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
85 |
|
|
|
86 |
|
|
private void setupBackButton(final TutorialActivity act, final float width)
|
87 |
|
|
{
|
88 |
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);
|
89 |
344f290c
|
Leszek Koltunski
|
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
90 |
|
|
|
91 |
|
|
mBackButton.setOnClickListener( new View.OnClickListener()
|
92 |
|
|
{
|
93 |
|
|
@Override
|
94 |
|
|
public void onClick(View v)
|
95 |
|
|
{
|
96 |
2afc6754
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
97 |
|
|
if( control!=null ) control.unblockEverything();
|
98 |
344f290c
|
Leszek Koltunski
|
act.finish();
|
99 |
|
|
}
|
100 |
|
|
});
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
104 |
|
|
|
105 |
|
|
void createRightPane(final TutorialActivity act, float width)
|
106 |
|
|
{
|
107 |
2971588c
|
Leszek Koltunski
|
LinearLayout layout = act.findViewById(R.id.tutorialRightBar);
|
108 |
344f290c
|
Leszek Koltunski
|
layout.removeAllViews();
|
109 |
|
|
|
110 |
e019c70b
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
111 |
|
|
mMovesController.setupButton(act,control, width);
|
112 |
|
|
mLockController.setupButton(act,control,width);
|
113 |
344f290c
|
Leszek Koltunski
|
setupSolveButton(act,width);
|
114 |
|
|
setupScrambleButton(act,width);
|
115 |
|
|
setupBackButton(act,width);
|
116 |
|
|
|
117 |
|
|
layout.addView(mSolveButton);
|
118 |
dd1a65c1
|
Leszek Koltunski
|
layout.addView(mMovesController.getButton());
|
119 |
344f290c
|
Leszek Koltunski
|
layout.addView(mScrambleButton);
|
120 |
dd1a65c1
|
Leszek Koltunski
|
layout.addView(mLockController.getButton());
|
121 |
344f290c
|
Leszek Koltunski
|
layout.addView(mBackButton);
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
125 |
|
|
|
126 |
e019c70b
|
Leszek Koltunski
|
void addMove(Activity act, int axis, int row, int angle)
|
127 |
146661ec
|
Leszek Koltunski
|
{
|
128 |
dd1a65c1
|
Leszek Koltunski
|
mMovesController.addMove(act, axis,row,angle);
|
129 |
146661ec
|
Leszek Koltunski
|
}
|
130 |
|
|
|
131 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132 |
|
|
// PUBLIC API
|
133 |
|
|
|
134 |
dd1a65c1
|
Leszek Koltunski
|
public TutorialScreen()
|
135 |
344f290c
|
Leszek Koltunski
|
{
|
136 |
dd1a65c1
|
Leszek Koltunski
|
mLockController = new LockController();
|
137 |
|
|
mMovesController = new MovesController();
|
138 |
344f290c
|
Leszek Koltunski
|
}
|
139 |
cc88f2fa
|
Leszek Koltunski
|
|
140 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
141 |
|
|
|
142 |
e019c70b
|
Leszek Koltunski
|
public void reddenLock(final TutorialActivity act)
|
143 |
cc88f2fa
|
Leszek Koltunski
|
{
|
144 |
e019c70b
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
145 |
|
|
mLockController.reddenLock(act,control);
|
146 |
cc88f2fa
|
Leszek Koltunski
|
}
|
147 |
344f290c
|
Leszek Koltunski
|
}
|