1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 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.view.View;
|
14
|
import android.widget.LinearLayout;
|
15
|
|
16
|
import org.distorted.helpers.TransparentImageButton;
|
17
|
import org.distorted.main.R;
|
18
|
import org.distorted.objectlib.effects.BaseEffect;
|
19
|
import org.distorted.objectlib.main.ObjectControl;
|
20
|
|
21
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
22
|
|
23
|
public class ScreenFree extends ScreenBase
|
24
|
{
|
25
|
private TransparentImageButton mBackButton, mScrambleButton, mSolveButton;
|
26
|
|
27
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28
|
|
29
|
void leaveScreen(PlayActivity act)
|
30
|
{
|
31
|
|
32
|
}
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35
|
|
36
|
void enterScreen(final PlayActivity act)
|
37
|
{
|
38
|
int width = act.getScreenWidthInPixels();
|
39
|
|
40
|
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
|
41
|
LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
|
42
|
LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
|
43
|
|
44
|
// TOP ////////////////////////////
|
45
|
setupSolveButton(act);
|
46
|
setupScrambleButton(act);
|
47
|
|
48
|
LinearLayout layoutUpper = act.findViewById(R.id.upperBar);
|
49
|
|
50
|
LinearLayout layoutLeftU = new LinearLayout(act);
|
51
|
layoutLeftU.setLayoutParams(paramsL);
|
52
|
LinearLayout layoutMidU = new LinearLayout(act);
|
53
|
layoutMidU.setLayoutParams(paramsM);
|
54
|
LinearLayout layoutRightU= new LinearLayout(act);
|
55
|
layoutRightU.setLayoutParams(paramsR);
|
56
|
|
57
|
layoutLeftU.addView(mSolveButton);
|
58
|
layoutRightU.addView(mScrambleButton);
|
59
|
|
60
|
layoutUpper.removeAllViews();
|
61
|
layoutUpper.addView(layoutLeftU);
|
62
|
layoutUpper.addView(layoutMidU);
|
63
|
layoutUpper.addView(layoutRightU);
|
64
|
|
65
|
// BOT ////////////////////////////
|
66
|
setupBackButton(act);
|
67
|
createBottomPane(act,mBackButton);
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71
|
|
72
|
private void setupBackButton(final PlayActivity act)
|
73
|
{
|
74
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
75
|
mBackButton = new TransparentImageButton(act,R.drawable.ui_smallback,params);
|
76
|
|
77
|
mBackButton.setOnClickListener( new View.OnClickListener()
|
78
|
{
|
79
|
@Override
|
80
|
public void onClick(View v)
|
81
|
{
|
82
|
act.finish();
|
83
|
}
|
84
|
});
|
85
|
}
|
86
|
|
87
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88
|
|
89
|
private void setupSolveButton(final PlayActivity act)
|
90
|
{
|
91
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
92
|
mSolveButton = new TransparentImageButton(act,R.drawable.ui_cube_solve,params);
|
93
|
|
94
|
mSolveButton.setOnClickListener( new View.OnClickListener()
|
95
|
{
|
96
|
@Override
|
97
|
public void onClick(View v)
|
98
|
{
|
99
|
ObjectControl control = act.getControl();
|
100
|
control.solveObject();
|
101
|
mMovesController.clearMoves(act);
|
102
|
}
|
103
|
});
|
104
|
}
|
105
|
|
106
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107
|
|
108
|
private void setupScrambleButton(final PlayActivity act)
|
109
|
{
|
110
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
111
|
mScrambleButton = new TransparentImageButton(act,R.drawable.ui_cube_scramble,params);
|
112
|
|
113
|
mScrambleButton.setOnClickListener( new View.OnClickListener()
|
114
|
{
|
115
|
@Override
|
116
|
public void onClick(View v)
|
117
|
{
|
118
|
ObjectControl control = act.getControl();
|
119
|
int duration = BaseEffect.Type.FAST_SCRAMBLE.getDuration();
|
120
|
int numScrambles = act.getNumScrambles();
|
121
|
control.fastScrambleObject(duration,numScrambles);
|
122
|
mMovesController.clearMoves(act);
|
123
|
}
|
124
|
});
|
125
|
}
|
126
|
|
127
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128
|
|
129
|
public void savePreferences(SharedPreferences.Editor editor)
|
130
|
{
|
131
|
|
132
|
}
|
133
|
|
134
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135
|
|
136
|
public void restorePreferences(SharedPreferences preferences)
|
137
|
{
|
138
|
|
139
|
}
|
140
|
}
|