Project

General

Profile

Download (5.66 KB) Statistics
| Branch: | Revision:

examples / src / main / java / org / distorted / examples / girl / GirlActivity.java @ 107e4b72

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted 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
// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.examples.girl;
21

    
22
import org.distorted.library.main.Distorted;
23
import org.distorted.examples.R;
24

    
25
import android.app.Activity;
26
import android.opengl.GLSurfaceView;
27
import android.os.Bundle;
28
import android.widget.SeekBar;
29
import android.widget.TextView;
30
import android.widget.SeekBar.OnSeekBarChangeListener;
31

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

    
34
public class GirlActivity extends Activity  implements OnSeekBarChangeListener
35
{
36
    private TextView textSwing, textSize, textHips;
37
   
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
    
40
    @Override
41
    protected void onCreate(Bundle icicle) 
42
      {
43
      super.onCreate(icicle);
44
      
45
      setContentView(R.layout.girllayout);
46
           
47
      textSwing = (TextView)findViewById(R.id.girlTextSwing);
48
      textSize  = (TextView)findViewById(R.id.girlTextSize);
49
      textHips  = (TextView)findViewById(R.id.girlTextHips);
50

    
51
      SeekBar barSwing = (SeekBar)findViewById(R.id.girlSeekSwing);
52
      SeekBar barSize  = (SeekBar)findViewById(R.id.girlSeekSize);
53
      SeekBar barHips  = (SeekBar)findViewById(R.id.girlSeekHips);
54
      
55
      barSwing.setOnSeekBarChangeListener(this); 
56
      barSize.setOnSeekBarChangeListener(this); 
57
      barHips.setOnSeekBarChangeListener(this); 
58
  
59
      barSwing.setProgress(0);
60
      barSize.setProgress(50);
61
      barHips.setProgress(0);
62

    
63
      textSwing.setText(getString(R.string.swing_placeholder,0));
64
      textSize.setText(getString(R.string.size_placeholder,1.0f));
65
      textHips.setText(getString(R.string.hips_placeholder,0));
66
      }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69
    
70
    @Override
71
    protected void onPause() 
72
      {
73
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.girlSurfaceView);
74
      view.onPause();
75

    
76
      Distorted.onPause();
77
      super.onPause();
78
      }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81
    
82
    @Override
83
    protected void onResume() 
84
      {
85
      super.onResume();
86
      
87
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.girlSurfaceView);
88
      view.onResume();
89
      }
90
 
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92
    
93
    @Override
94
    protected void onDestroy() 
95
      {
96
      Distorted.onDestroy();  
97
      super.onDestroy();
98
      }
99
   
100
///////////////////////////////////////////////////////////////////
101
    
102
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
103
      {
104
      int v;
105
      float s;
106
      GirlSurfaceView view = (GirlSurfaceView) this.findViewById(R.id.girlSurfaceView);
107

    
108
      switch (bar.getId()) 
109
        {
110
        case R.id.girlSeekSwing: v = progress/5;
111
                                 view.getRenderer().setSwing(v);
112
                                 textSwing.setText(getString(R.string.swing_placeholder,v));
113
                                 break;
114
        case R.id.girlSeekSize : if( progress> 50) s = (progress-50)/16.0f + 1.0f;
115
                                 else              s = 0.015f*progress + 0.25f;
116
                                 view.getRenderer().setSize(s);
117
                                 textSize.setText(getString(R.string.size_placeholder,(((int)(s*10))/10.0f)));
118
                                 break;
119
        case R.id.girlSeekHips : v = progress/5;
120
                                 view.getRenderer().setHips(v);
121
                                 textHips.setText(getString(R.string.hips_placeholder,v));
122
                                 break;
123
        }
124
      }
125

    
126
///////////////////////////////////////////////////////////////////
127

    
128
    public void onStartTrackingTouch(SeekBar bar) { }
129
    
130
///////////////////////////////////////////////////////////////////
131

    
132
    public void onStopTrackingTouch(SeekBar bar)  { }
133
     
134
}
(1-1/3)