1 |
a8576d91
|
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 |
fcd5b990
|
Leszek Koltunski
|
package org.distorted.screens;
|
21 |
a8576d91
|
Leszek Koltunski
|
|
22 |
e019c70b
|
Leszek Koltunski
|
import android.app.Activity;
|
23 |
a8576d91
|
Leszek Koltunski
|
import android.widget.ImageButton;
|
24 |
|
|
import android.widget.LinearLayout;
|
25 |
|
|
|
26 |
e019c70b
|
Leszek Koltunski
|
import org.distorted.main.RubikActivity;
|
27 |
9523ae28
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectControl;
|
28 |
|
|
|
29 |
dd1a65c1
|
Leszek Koltunski
|
import org.distorted.helpers.LockController;
|
30 |
|
|
import org.distorted.helpers.MovesController;
|
31 |
a8576d91
|
Leszek Koltunski
|
import org.distorted.main.R;
|
32 |
|
|
|
33 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34 |
|
|
|
35 |
55e6be1d
|
Leszek Koltunski
|
abstract class RubikScreenBase extends RubikScreenAbstract
|
36 |
a8576d91
|
Leszek Koltunski
|
{
|
37 |
dd1a65c1
|
Leszek Koltunski
|
private final LockController mLockController;
|
38 |
|
|
protected MovesController mMovesController;
|
39 |
a8576d91
|
Leszek Koltunski
|
|
40 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41 |
|
|
|
42 |
e019c70b
|
Leszek Koltunski
|
void createBottomPane(final RubikActivity act, float width, ImageButton button)
|
43 |
a8576d91
|
Leszek Koltunski
|
{
|
44 |
dd1a65c1
|
Leszek Koltunski
|
mMovesController.clearMoves(act);
|
45 |
9f006481
|
Leszek Koltunski
|
|
46 |
a8576d91
|
Leszek Koltunski
|
LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
|
47 |
|
|
layoutBot.removeAllViews();
|
48 |
|
|
|
49 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
|
50 |
|
|
|
51 |
|
|
LinearLayout layoutLeft = new LinearLayout(act);
|
52 |
|
|
layoutLeft.setLayoutParams(params);
|
53 |
|
|
LinearLayout layoutMid = new LinearLayout(act);
|
54 |
|
|
layoutMid.setLayoutParams(params);
|
55 |
|
|
LinearLayout layoutRight = new LinearLayout(act);
|
56 |
|
|
layoutRight.setLayoutParams(params);
|
57 |
|
|
|
58 |
e019c70b
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
59 |
|
|
mMovesController.setupButton(act,control,width);
|
60 |
dd1a65c1
|
Leszek Koltunski
|
layoutLeft.addView(mMovesController.getButton());
|
61 |
e019c70b
|
Leszek Koltunski
|
mLockController.setupButton(act,control,width);
|
62 |
dd1a65c1
|
Leszek Koltunski
|
layoutMid.addView(mLockController.getButton());
|
63 |
a8576d91
|
Leszek Koltunski
|
layoutRight.addView(button);
|
64 |
|
|
|
65 |
|
|
layoutBot.addView(layoutLeft);
|
66 |
|
|
layoutBot.addView(layoutMid);
|
67 |
|
|
layoutBot.addView(layoutRight);
|
68 |
|
|
}
|
69 |
|
|
|
70 |
8badfe2a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71 |
|
|
|
72 |
e019c70b
|
Leszek Koltunski
|
public void setLockState(final RubikActivity act)
|
73 |
8badfe2a
|
Leszek Koltunski
|
{
|
74 |
9523ae28
|
Leszek Koltunski
|
boolean locked = act.getControl().retLocked();
|
75 |
|
|
mLockController.setState(act,locked);
|
76 |
8badfe2a
|
Leszek Koltunski
|
}
|
77 |
|
|
|
78 |
146661ec
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79 |
|
|
// PUBLIC API
|
80 |
|
|
|
81 |
|
|
public RubikScreenBase()
|
82 |
|
|
{
|
83 |
dd1a65c1
|
Leszek Koltunski
|
mLockController = new LockController();
|
84 |
|
|
mMovesController= new MovesController();
|
85 |
146661ec
|
Leszek Koltunski
|
}
|
86 |
|
|
|
87 |
a8576d91
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88 |
|
|
|
89 |
e019c70b
|
Leszek Koltunski
|
public void addMove(Activity act, int axis, int row, int angle)
|
90 |
a8576d91
|
Leszek Koltunski
|
{
|
91 |
dd1a65c1
|
Leszek Koltunski
|
mMovesController.addMove(act,axis,row,angle);
|
92 |
a8576d91
|
Leszek Koltunski
|
}
|
93 |
cc88f2fa
|
Leszek Koltunski
|
|
94 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
95 |
|
|
|
96 |
e019c70b
|
Leszek Koltunski
|
public void reddenLock(final RubikActivity act)
|
97 |
cc88f2fa
|
Leszek Koltunski
|
{
|
98 |
9523ae28
|
Leszek Koltunski
|
ObjectControl control = act.getControl();
|
99 |
|
|
mLockController.reddenLock(act,control);
|
100 |
cc88f2fa
|
Leszek Koltunski
|
}
|
101 |
a8576d91
|
Leszek Koltunski
|
}
|