Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedPlayScreen.java @ f802924b

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.bandaged;
21

    
22
import android.view.View;
23
import android.widget.LinearLayout;
24

    
25
import org.distorted.helpers.LockController;
26
import org.distorted.helpers.MovesController;
27
import org.distorted.helpers.TransparentImageButton;
28
import org.distorted.main.R;
29
import org.distorted.main.RubikActivity;
30
import org.distorted.objectlib.main.ObjectControl;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
public class BandagedPlayScreen
35
{
36
  private TransparentImageButton mBackButton, mScrambleButton, mSolveButton;
37
  private final LockController mLockController;
38
  protected MovesController mMovesController;
39
  private int mObjectOrdinal;
40
  private int mBarHeight;
41
  private float mButtonSize;
42

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

    
45
  public BandagedPlayScreen()
46
    {
47
    mLockController = new LockController();
48
    mMovesController= new MovesController();
49
    }
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
  private void setupBackButton(final BandagedPlayActivity act)
54
    {
55
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback);
56
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
57
    mBackButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
58

    
59
    mBackButton.setOnClickListener( new View.OnClickListener()
60
      {
61
      @Override
62
      public void onClick(View v)
63
        {
64
        ObjectControl control = act.getControl();
65
        if( control!=null ) control.unblockEverything();
66
        act.finish();
67
        }
68
      });
69
    }
70

    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

    
73
  void onAttachedToWindow(final BandagedPlayActivity act, final int objectOrdinal)
74
    {
75
    int width = act.getScreenWidthInPixels();
76
    mBarHeight = act.getHeightBar();
77
    mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
78

    
79
    mObjectOrdinal = objectOrdinal;
80

    
81
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
82
    LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
83
    LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
84

    
85
    LinearLayout layoutLeft = new LinearLayout(act);
86
    layoutLeft.setLayoutParams(paramsL);
87
    LinearLayout layoutMid  = new LinearLayout(act);
88
    layoutMid.setLayoutParams(paramsM);
89
    LinearLayout layoutRight= new LinearLayout(act);
90
    layoutRight.setLayoutParams(paramsR);
91

    
92
    setupBackButton(act);
93
    ObjectControl control = act.getControl();
94
    mMovesController.setupButton(act,control);
95
    layoutLeft.addView(mMovesController.getButton());
96
    mLockController.setupButton(act,control);
97
    layoutMid.addView(mLockController.getButton());
98

    
99
    layoutRight.addView(mBackButton);
100

    
101
    LinearLayout layout = act.findViewById(R.id.lowerBar);
102
    layout.removeAllViews();
103
    layout.addView(layoutLeft);
104
    layout.addView(layoutMid);
105
    layout.addView(layoutRight);
106

    
107
    }
108

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

    
111
  public void setLockState(final RubikActivity act)
112
    {
113
    boolean locked = act.getControl().retLocked();
114
    mLockController.setState(act,locked);
115
    }
116

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

    
119
  public void reddenLock(final RubikActivity act)
120
    {
121
    ObjectControl control = act.getControl();
122
    mLockController.reddenLock(act,control);
123
    }
124
}
(8-8/9)