Project

General

Profile

Download (6.93 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / tutorials / TutorialScreen.java @ b710a574

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 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 setupSolveButton(final TutorialActivity act)
80
    {
81
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
82
    mSolveButton = new TransparentImageButton(act,R.drawable.ui_cube_solve,params);
83

    
84
    mSolveButton.setOnClickListener( new View.OnClickListener()
85
      {
86
      @Override
87
      public void onClick(View v)
88
        {
89
        act.getControl().solveObject();
90
        mMovesController.clearMoves(act);
91
        }
92
      });
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

    
97
  private void setupScrambleButton(final TutorialActivity act)
98
    {
99
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
100
    mScrambleButton = new TransparentImageButton(act,R.drawable.ui_cube_scramble,params);
101

    
102
    mScrambleButton.setOnClickListener( new View.OnClickListener()
103
      {
104
      @Override
105
      public void onClick(View v)
106
        {
107
        int duration = BaseEffect.Type.FAST_SCRAMBLE.getDuration();
108
        act.getControl().fastScrambleObject(duration,RubikObject.FAST_SCRAMBLES);
109
        }
110
      });
111
    }
112

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

    
115
  private void setupBackButton(final TutorialActivity act)
116
    {
117
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
118
    mBackButton = new TransparentImageButton(act,R.drawable.ui_smallback,params);
119

    
120
    mBackButton.setOnClickListener( new View.OnClickListener()
121
      {
122
      @Override
123
      public void onClick(View v)
124
        {
125
        act.finish();
126
        }
127
      });
128
    }
129

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

    
132
  void createRightPane(final TutorialActivity act)
133
    {
134
    LinearLayout layout = act.findViewById(R.id.tutorialRightBar);
135
    layout.removeAllViews();
136

    
137
    if( mFree )
138
      {
139
      ObjectControl control = act.getControl();
140
      mMovesController.setupButton(act,control);
141
      mLockController.setupButton(act,control);
142
      setupSolveButton(act);
143
      setupScrambleButton(act);
144
      layout.addView(mSolveButton);
145
      layout.addView(mScrambleButton);
146
      layout.addView(mMovesController.getButton());
147
      layout.addView(mLockController.getButton());
148
      }
149
    else
150
      {
151
      setupLockButton(act);
152
      setupEmptyButton1(act);
153
      setupEmptyButton2(act);
154
      setupEmptyButton3(act);
155
      layout.addView(mLockButton);
156
      layout.addView(mEmptyButton1);
157
      layout.addView(mEmptyButton2);
158
      layout.addView(mEmptyButton3);
159
      }
160

    
161
    setupBackButton(act);
162
    layout.addView(mBackButton);
163
    }
164

    
165
///////////////////////////////////////////////////////////////////////////////////////////////////
166

    
167
  void addMove(Activity act, int axis, int row, int angle)
168
    {
169
    mMovesController.addMove(act, axis,row,angle);
170
    }
171

    
172
///////////////////////////////////////////////////////////////////////////////////////////////////
173
// PUBLIC API
174

    
175
  public TutorialScreen(boolean free)
176
    {
177
    mFree = free;
178
    mLockController = new LockController();
179
    mMovesController = new MovesController();
180
    }
181

    
182
///////////////////////////////////////////////////////////////////////////////////////////////////
183

    
184
  public void reddenLock(final TutorialActivity act)
185
    {
186
    ObjectControl control = act.getControl();
187
    mLockController.reddenLock(act,control);
188
    }
189
}
(4-4/6)