Project

General

Profile

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

magiccube / src / main / java / org / distorted / screens / RubikScreenBase.java @ 5f3801d3

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.LinearLayout;
24
25 dd874ae8 Leszek Koltunski
import org.distorted.helpers.TransparentImageButton;
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 dd874ae8 Leszek Koltunski
  void createBottomPane(final RubikActivity act, TransparentImageButton left, TransparentImageButton right)
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 dd874ae8 Leszek Koltunski
    mMovesController.setupButton(act,control);
60 dd1a65c1 Leszek Koltunski
    layoutLeft.addView(mMovesController.getButton());
61 dd874ae8 Leszek Koltunski
    mLockController.setupButton(act,control);
62 dd1a65c1 Leszek Koltunski
    layoutMid.addView(mLockController.getButton());
63 dd874ae8 Leszek Koltunski
64
    if( left !=null ) layoutRight.addView(left);
65
    if( right!=null ) layoutRight.addView(right);
66 a8576d91 Leszek Koltunski
67
    layoutBot.addView(layoutLeft);
68
    layoutBot.addView(layoutMid);
69
    layoutBot.addView(layoutRight);
70
    }
71
72 8badfe2a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
73
74 e019c70b Leszek Koltunski
  public void setLockState(final RubikActivity act)
75 8badfe2a Leszek Koltunski
    {
76 9523ae28 Leszek Koltunski
    boolean locked = act.getControl().retLocked();
77
    mLockController.setState(act,locked);
78 8badfe2a Leszek Koltunski
    }
79
80 146661ec Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
81
// PUBLIC API
82
83
  public RubikScreenBase()
84
    {
85 dd1a65c1 Leszek Koltunski
    mLockController = new LockController();
86
    mMovesController= new MovesController();
87 146661ec Leszek Koltunski
    }
88
89 a8576d91 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
90
91 e019c70b Leszek Koltunski
  public void addMove(Activity act, int axis, int row, int angle)
92 a8576d91 Leszek Koltunski
    {
93 dd1a65c1 Leszek Koltunski
    mMovesController.addMove(act,axis,row,angle);
94 a8576d91 Leszek Koltunski
    }
95 cc88f2fa Leszek Koltunski
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97
98 e019c70b Leszek Koltunski
  public void reddenLock(final RubikActivity act)
99 cc88f2fa Leszek Koltunski
    {
100 9523ae28 Leszek Koltunski
    ObjectControl control = act.getControl();
101
    mLockController.reddenLock(act,control);
102 cc88f2fa Leszek Koltunski
    }
103 a8576d91 Leszek Koltunski
  }