Project

General

Profile

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

magiccube / src / main / java / org / distorted / screens / RubikScreenBase.java @ 3f287c05

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
package org.distorted.screens;
21

    
22
import android.app.Activity;
23
import android.widget.ImageButton;
24
import android.widget.LinearLayout;
25

    
26
import org.distorted.main.RubikActivity;
27
import org.distorted.objectlib.main.ObjectControl;
28

    
29
import org.distorted.helpers.LockController;
30
import org.distorted.helpers.MovesController;
31
import org.distorted.main.R;
32

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

    
35
abstract class RubikScreenBase extends RubikScreenAbstract
36
  {
37
  private final LockController mLockController;
38
  protected MovesController mMovesController;
39

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

    
42
  void createBottomPane(final RubikActivity act, float width, ImageButton button)
43
    {
44
    mMovesController.clearMoves(act);
45

    
46
    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
    ObjectControl control = act.getControl();
59
    mMovesController.setupButton(act,control,width);
60
    layoutLeft.addView(mMovesController.getButton());
61
    mLockController.setupButton(act,control,width);
62
    layoutMid.addView(mLockController.getButton());
63
    layoutRight.addView(button);
64

    
65
    layoutBot.addView(layoutLeft);
66
    layoutBot.addView(layoutMid);
67
    layoutBot.addView(layoutRight);
68
    }
69

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

    
72
  public void setLockState(final RubikActivity act)
73
    {
74
    boolean locked = act.getControl().retLocked();
75
    mLockController.setState(act,locked);
76
    }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79
// PUBLIC API
80

    
81
  public RubikScreenBase()
82
    {
83
    mLockController = new LockController();
84
    mMovesController= new MovesController();
85
    }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
  public void addMove(Activity act, int axis, int row, int angle)
90
    {
91
    mMovesController.addMove(act,axis,row,angle);
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
  public void reddenLock(final RubikActivity act)
97
    {
98
    ObjectControl control = act.getControl();
99
    mLockController.reddenLock(act,control);
100
    }
101
  }
(2-2/10)