1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2023 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.playui;
|
11
|
|
12
|
import android.content.SharedPreferences;
|
13
|
import android.widget.LinearLayout;
|
14
|
|
15
|
import org.distorted.helpers.LockController;
|
16
|
import org.distorted.helpers.MovesController;
|
17
|
import org.distorted.helpers.TransparentImageButton;
|
18
|
import org.distorted.main.R;
|
19
|
import org.distorted.objectlib.main.ObjectControl;
|
20
|
|
21
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
22
|
|
23
|
abstract class ScreenBase extends ScreenAbstract
|
24
|
{
|
25
|
private final LockController mLockController;
|
26
|
protected MovesController mMovesController;
|
27
|
|
28
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
29
|
|
30
|
void createBottomPane(final PlayActivity act, TransparentImageButton butt)
|
31
|
{
|
32
|
mMovesController.clearMoves(act);
|
33
|
|
34
|
LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
|
35
|
layoutBot.removeAllViews();
|
36
|
|
37
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
|
38
|
|
39
|
LinearLayout layoutLeft = new LinearLayout(act);
|
40
|
layoutLeft.setLayoutParams(params);
|
41
|
LinearLayout layoutMid = new LinearLayout(act);
|
42
|
layoutMid.setLayoutParams(params);
|
43
|
LinearLayout layoutRight = new LinearLayout(act);
|
44
|
layoutRight.setLayoutParams(params);
|
45
|
|
46
|
ObjectControl control = act.getControl();
|
47
|
mMovesController.setupButton(act,control);
|
48
|
layoutLeft.addView(mMovesController.getButton());
|
49
|
mLockController.setupButton(act,control);
|
50
|
layoutMid.addView(mLockController.getButton());
|
51
|
|
52
|
if( butt !=null ) layoutRight.addView(butt);
|
53
|
|
54
|
layoutBot.addView(layoutLeft);
|
55
|
layoutBot.addView(layoutMid);
|
56
|
layoutBot.addView(layoutRight);
|
57
|
}
|
58
|
|
59
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60
|
|
61
|
public void setLockState(final PlayActivity act)
|
62
|
{
|
63
|
boolean locked = act.getControl().retLocked();
|
64
|
mLockController.setState(act,locked);
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
// PUBLIC API
|
69
|
|
70
|
public ScreenBase()
|
71
|
{
|
72
|
mLockController = new LockController();
|
73
|
mMovesController= new MovesController();
|
74
|
}
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
|
78
|
public void addMove(PlayActivity act, int axis, int row, int angle)
|
79
|
{
|
80
|
mMovesController.addMove(act,axis,row,angle);
|
81
|
}
|
82
|
|
83
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
84
|
|
85
|
public void reddenLock(final PlayActivity act)
|
86
|
{
|
87
|
ObjectControl control = act.getControl();
|
88
|
mLockController.reddenLock(act,control);
|
89
|
}
|
90
|
|
91
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
92
|
|
93
|
public void saveMovePreferences(String key,SharedPreferences.Editor editor)
|
94
|
{
|
95
|
mMovesController.savePreferences(key,editor);
|
96
|
}
|
97
|
|
98
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99
|
|
100
|
public void restoreMovePreferences(PlayActivity act, String key, SharedPreferences preferences)
|
101
|
{
|
102
|
mMovesController.restorePreferences(act,key,preferences);
|
103
|
}
|
104
|
}
|