Project

General

Profile

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

magiccube / src / main / java / org / distorted / tutorials / TutorialScreen.java @ 1ba56d95

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.main.ObjectControl;
16

    
17
import org.distorted.helpers.LockController;
18
import org.distorted.main.R;
19
import org.distorted.main.RubikActivity;
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 final LockController mLockController;
29
  private final MovesController mMovesController;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
  private void setupSolveButton(final TutorialActivity act)
34
    {
35
    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);
36
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
37
    mSolveButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
38

    
39
    mSolveButton.setOnClickListener( new View.OnClickListener()
40
      {
41
      @Override
42
      public void onClick(View v)
43
        {
44
        act.getControl().solveObject();
45
        mMovesController.clearMoves(act);
46
        }
47
      });
48
    }
49

    
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51

    
52
  private void setupScrambleButton(final TutorialActivity act)
53
    {
54
    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);
55
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
56
    mScrambleButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
57

    
58
    mScrambleButton.setOnClickListener( new View.OnClickListener()
59
      {
60
      @Override
61
      public void onClick(View v)
62
        {
63
        act.getControl().fastScrambleObject(RubikObject.FAST_SCRAMBLES);
64
        }
65
      });
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
  private void setupBackButton(final TutorialActivity act)
71
    {
72
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback);
73
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
74
    mBackButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
75

    
76
    mBackButton.setOnClickListener( new View.OnClickListener()
77
      {
78
      @Override
79
      public void onClick(View v)
80
        {
81
        ObjectControl control = act.getControl();
82
        if( control!=null ) control.unblockEverything();
83
        act.finish();
84
        }
85
      });
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

    
90
  void createRightPane(final TutorialActivity act)
91
    {
92
    LinearLayout layout = act.findViewById(R.id.tutorialRightBar);
93
    layout.removeAllViews();
94

    
95
    ObjectControl control = act.getControl();
96
    mMovesController.setupButton(act,control);
97
    mLockController.setupButton(act,control);
98
    setupSolveButton(act);
99
    setupScrambleButton(act);
100
    setupBackButton(act);
101

    
102
    layout.addView(mSolveButton);
103
    layout.addView(mScrambleButton);
104
    layout.addView(mMovesController.getButton());
105
    layout.addView(mLockController.getButton());
106
    layout.addView(mBackButton);
107
    }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

    
111
  void addMove(Activity act, int axis, int row, int angle)
112
    {
113
    mMovesController.addMove(act, axis,row,angle);
114
    }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117
// PUBLIC API
118

    
119
  public TutorialScreen()
120
    {
121
    mLockController = new LockController();
122
    mMovesController = new MovesController();
123
    }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

    
127
  public void reddenLock(final TutorialActivity act)
128
    {
129
    ObjectControl control = act.getControl();
130
    mLockController.reddenLock(act,control);
131
    }
132
}
(4-4/6)