26 |
26 |
import android.opengl.GLSurfaceView;
|
27 |
27 |
import android.os.Bundle;
|
28 |
28 |
import android.view.View;
|
29 |
|
import android.widget.Button;
|
30 |
29 |
import android.widget.CheckBox;
|
31 |
30 |
import android.widget.TextView;
|
32 |
31 |
|
... | ... | |
35 |
34 |
public class OlimpicActivity extends Activity
|
36 |
35 |
{
|
37 |
36 |
private TextView mText;
|
|
37 |
private boolean[] mBlue, mBlack, mRed, mYellow, mGreen;
|
38 |
38 |
|
39 |
39 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40 |
40 |
|
41 |
|
void setText(String text)
|
|
41 |
@Override
|
|
42 |
protected void onCreate(Bundle savedState)
|
42 |
43 |
{
|
43 |
|
mText.setText(text);
|
|
44 |
super.onCreate(savedState);
|
|
45 |
setContentView(R.layout.olimpiclayout);
|
|
46 |
mText = (TextView)findViewById(R.id.olimpicText);
|
|
47 |
|
|
48 |
int num = OlimpicRenderer.NUM_LEAVES+1;
|
|
49 |
|
|
50 |
mBlue = new boolean[num];
|
|
51 |
mBlack = new boolean[num];
|
|
52 |
mRed = new boolean[num];
|
|
53 |
mYellow = new boolean[num];
|
|
54 |
mGreen = new boolean[num];
|
|
55 |
|
|
56 |
if( savedState==null )
|
|
57 |
{
|
|
58 |
for (int i = 0; i < num; i++)
|
|
59 |
{
|
|
60 |
mBlue[i] = true;
|
|
61 |
mBlack[i] = true;
|
|
62 |
mRed[i] = true;
|
|
63 |
mYellow[i] = true;
|
|
64 |
mGreen[i] = true;
|
|
65 |
}
|
|
66 |
}
|
44 |
67 |
}
|
45 |
68 |
|
46 |
69 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47 |
70 |
|
48 |
|
public void onClick(View view)
|
49 |
|
{
|
50 |
|
CheckBox box = (CheckBox)view;
|
51 |
|
int id = box.getId();
|
52 |
|
boolean checked = box.isChecked();
|
53 |
|
OlimpicSurfaceView sView = (OlimpicSurfaceView) this.findViewById(R.id.olimpicSurfaceView);
|
54 |
|
|
55 |
|
switch(id)
|
|
71 |
void setText(String text)
|
56 |
72 |
{
|
57 |
|
case R.id.olimpicCheckBoxBlue0 : sView.getRenderer().pressed(0,0,checked); break;
|
58 |
|
case R.id.olimpicCheckBoxBlue1 : sView.getRenderer().pressed(0,1,checked); break;
|
59 |
|
case R.id.olimpicCheckBoxBlue2 : sView.getRenderer().pressed(0,2,checked); break;
|
60 |
|
case R.id.olimpicCheckBoxBlue3 : sView.getRenderer().pressed(0,3,checked); break;
|
61 |
|
case R.id.olimpicCheckBoxBlue4 : sView.getRenderer().pressed(0,4,checked); break;
|
62 |
|
case R.id.olimpicCheckBoxBlue5 : sView.getRenderer().pressed(0,5,checked); break;
|
63 |
|
case R.id.olimpicCheckBoxBlue6 : sView.getRenderer().pressed(0,6,checked); break;
|
64 |
|
case R.id.olimpicCheckBoxBlue7 : sView.getRenderer().pressed(0,7,checked); break;
|
65 |
|
case R.id.olimpicCheckBoxBlue8 : sView.getRenderer().pressed(0,8,checked); break;
|
66 |
|
|
67 |
|
case R.id.olimpicCheckBoxBlack0 : sView.getRenderer().pressed(1,0,checked); break;
|
68 |
|
case R.id.olimpicCheckBoxBlack1 : sView.getRenderer().pressed(1,1,checked); break;
|
69 |
|
case R.id.olimpicCheckBoxBlack2 : sView.getRenderer().pressed(1,2,checked); break;
|
70 |
|
case R.id.olimpicCheckBoxBlack3 : sView.getRenderer().pressed(1,3,checked); break;
|
71 |
|
case R.id.olimpicCheckBoxBlack4 : sView.getRenderer().pressed(1,4,checked); break;
|
72 |
|
case R.id.olimpicCheckBoxBlack5 : sView.getRenderer().pressed(1,5,checked); break;
|
73 |
|
case R.id.olimpicCheckBoxBlack6 : sView.getRenderer().pressed(1,6,checked); break;
|
74 |
|
case R.id.olimpicCheckBoxBlack7 : sView.getRenderer().pressed(1,7,checked); break;
|
75 |
|
case R.id.olimpicCheckBoxBlack8 : sView.getRenderer().pressed(1,8,checked); break;
|
76 |
|
|
77 |
|
case R.id.olimpicCheckBoxRed0 : sView.getRenderer().pressed(2,0,checked); break;
|
78 |
|
case R.id.olimpicCheckBoxRed1 : sView.getRenderer().pressed(2,1,checked); break;
|
79 |
|
case R.id.olimpicCheckBoxRed2 : sView.getRenderer().pressed(2,2,checked); break;
|
80 |
|
case R.id.olimpicCheckBoxRed3 : sView.getRenderer().pressed(2,3,checked); break;
|
81 |
|
case R.id.olimpicCheckBoxRed4 : sView.getRenderer().pressed(2,4,checked); break;
|
82 |
|
case R.id.olimpicCheckBoxRed5 : sView.getRenderer().pressed(2,5,checked); break;
|
83 |
|
case R.id.olimpicCheckBoxRed6 : sView.getRenderer().pressed(2,6,checked); break;
|
84 |
|
case R.id.olimpicCheckBoxRed7 : sView.getRenderer().pressed(2,7,checked); break;
|
85 |
|
case R.id.olimpicCheckBoxRed8 : sView.getRenderer().pressed(2,8,checked); break;
|
86 |
|
|
87 |
|
case R.id.olimpicCheckBoxYellow0: sView.getRenderer().pressed(3,0,checked); break;
|
88 |
|
case R.id.olimpicCheckBoxYellow1: sView.getRenderer().pressed(3,1,checked); break;
|
89 |
|
case R.id.olimpicCheckBoxYellow2: sView.getRenderer().pressed(3,2,checked); break;
|
90 |
|
case R.id.olimpicCheckBoxYellow3: sView.getRenderer().pressed(3,3,checked); break;
|
91 |
|
case R.id.olimpicCheckBoxYellow4: sView.getRenderer().pressed(3,4,checked); break;
|
92 |
|
case R.id.olimpicCheckBoxYellow5: sView.getRenderer().pressed(3,5,checked); break;
|
93 |
|
case R.id.olimpicCheckBoxYellow6: sView.getRenderer().pressed(3,6,checked); break;
|
94 |
|
case R.id.olimpicCheckBoxYellow7: sView.getRenderer().pressed(3,7,checked); break;
|
95 |
|
case R.id.olimpicCheckBoxYellow8: sView.getRenderer().pressed(3,8,checked); break;
|
96 |
|
|
97 |
|
case R.id.olimpicCheckBoxGreen0 : sView.getRenderer().pressed(4,0,checked); break;
|
98 |
|
case R.id.olimpicCheckBoxGreen1 : sView.getRenderer().pressed(4,1,checked); break;
|
99 |
|
case R.id.olimpicCheckBoxGreen2 : sView.getRenderer().pressed(4,2,checked); break;
|
100 |
|
case R.id.olimpicCheckBoxGreen3 : sView.getRenderer().pressed(4,3,checked); break;
|
101 |
|
case R.id.olimpicCheckBoxGreen4 : sView.getRenderer().pressed(4,4,checked); break;
|
102 |
|
case R.id.olimpicCheckBoxGreen5 : sView.getRenderer().pressed(4,5,checked); break;
|
103 |
|
case R.id.olimpicCheckBoxGreen6 : sView.getRenderer().pressed(4,6,checked); break;
|
104 |
|
case R.id.olimpicCheckBoxGreen7 : sView.getRenderer().pressed(4,7,checked); break;
|
105 |
|
case R.id.olimpicCheckBoxGreen8 : sView.getRenderer().pressed(4,8,checked); break;
|
|
73 |
mText.setText(text);
|
106 |
74 |
}
|
107 |
|
}
|
108 |
75 |
|
109 |
76 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110 |
77 |
|
111 |
|
@Override
|
112 |
|
protected void onCreate(Bundle icicle)
|
|
78 |
public void onClick(View view)
|
113 |
79 |
{
|
114 |
|
super.onCreate(icicle);
|
115 |
|
setContentView(R.layout.olimpiclayout);
|
116 |
|
mText = (TextView)findViewById(R.id.olimpicText);
|
|
80 |
CheckBox box = (CheckBox)view;
|
|
81 |
int id = box.getId();
|
|
82 |
boolean checked = box.isChecked();
|
|
83 |
OlimpicSurfaceView sView = (OlimpicSurfaceView) this.findViewById(R.id.olimpicSurfaceView);
|
|
84 |
|
|
85 |
switch(id)
|
|
86 |
{
|
|
87 |
case R.id.olimpicCheckBoxBlue0 : sView.getRenderer().pressed(0,0,checked); mBlue[0] =checked; break;
|
|
88 |
case R.id.olimpicCheckBoxBlue1 : sView.getRenderer().pressed(0,1,checked); mBlue[1] =checked; break;
|
|
89 |
case R.id.olimpicCheckBoxBlue2 : sView.getRenderer().pressed(0,2,checked); mBlue[2] =checked; break;
|
|
90 |
case R.id.olimpicCheckBoxBlue3 : sView.getRenderer().pressed(0,3,checked); mBlue[3] =checked; break;
|
|
91 |
case R.id.olimpicCheckBoxBlue4 : sView.getRenderer().pressed(0,4,checked); mBlue[4] =checked; break;
|
|
92 |
case R.id.olimpicCheckBoxBlue5 : sView.getRenderer().pressed(0,5,checked); mBlue[5] =checked; break;
|
|
93 |
case R.id.olimpicCheckBoxBlue6 : sView.getRenderer().pressed(0,6,checked); mBlue[6] =checked; break;
|
|
94 |
case R.id.olimpicCheckBoxBlue7 : sView.getRenderer().pressed(0,7,checked); mBlue[7] =checked; break;
|
|
95 |
case R.id.olimpicCheckBoxBlue8 : sView.getRenderer().pressed(0,8,checked); mBlue[8] =checked; break;
|
|
96 |
|
|
97 |
case R.id.olimpicCheckBoxBlack0 : sView.getRenderer().pressed(1,0,checked); mBlack[0] =checked; break;
|
|
98 |
case R.id.olimpicCheckBoxBlack1 : sView.getRenderer().pressed(1,1,checked); mBlack[1] =checked; break;
|
|
99 |
case R.id.olimpicCheckBoxBlack2 : sView.getRenderer().pressed(1,2,checked); mBlack[2] =checked; break;
|
|
100 |
case R.id.olimpicCheckBoxBlack3 : sView.getRenderer().pressed(1,3,checked); mBlack[3] =checked; break;
|
|
101 |
case R.id.olimpicCheckBoxBlack4 : sView.getRenderer().pressed(1,4,checked); mBlack[4] =checked; break;
|
|
102 |
case R.id.olimpicCheckBoxBlack5 : sView.getRenderer().pressed(1,5,checked); mBlack[5] =checked; break;
|
|
103 |
case R.id.olimpicCheckBoxBlack6 : sView.getRenderer().pressed(1,6,checked); mBlack[6] =checked; break;
|
|
104 |
case R.id.olimpicCheckBoxBlack7 : sView.getRenderer().pressed(1,7,checked); mBlack[7] =checked; break;
|
|
105 |
case R.id.olimpicCheckBoxBlack8 : sView.getRenderer().pressed(1,8,checked); mBlack[8] =checked; break;
|
|
106 |
|
|
107 |
case R.id.olimpicCheckBoxRed0 : sView.getRenderer().pressed(2,0,checked); mRed[0] =checked; break;
|
|
108 |
case R.id.olimpicCheckBoxRed1 : sView.getRenderer().pressed(2,1,checked); mRed[1] =checked; break;
|
|
109 |
case R.id.olimpicCheckBoxRed2 : sView.getRenderer().pressed(2,2,checked); mRed[2] =checked; break;
|
|
110 |
case R.id.olimpicCheckBoxRed3 : sView.getRenderer().pressed(2,3,checked); mRed[3] =checked; break;
|
|
111 |
case R.id.olimpicCheckBoxRed4 : sView.getRenderer().pressed(2,4,checked); mRed[4] =checked; break;
|
|
112 |
case R.id.olimpicCheckBoxRed5 : sView.getRenderer().pressed(2,5,checked); mRed[5] =checked; break;
|
|
113 |
case R.id.olimpicCheckBoxRed6 : sView.getRenderer().pressed(2,6,checked); mRed[6] =checked; break;
|
|
114 |
case R.id.olimpicCheckBoxRed7 : sView.getRenderer().pressed(2,7,checked); mRed[7] =checked; break;
|
|
115 |
case R.id.olimpicCheckBoxRed8 : sView.getRenderer().pressed(2,8,checked); mRed[8] =checked; break;
|
|
116 |
|
|
117 |
case R.id.olimpicCheckBoxYellow0: sView.getRenderer().pressed(3,0,checked); mYellow[0]=checked; break;
|
|
118 |
case R.id.olimpicCheckBoxYellow1: sView.getRenderer().pressed(3,1,checked); mYellow[1]=checked; break;
|
|
119 |
case R.id.olimpicCheckBoxYellow2: sView.getRenderer().pressed(3,2,checked); mYellow[2]=checked; break;
|
|
120 |
case R.id.olimpicCheckBoxYellow3: sView.getRenderer().pressed(3,3,checked); mYellow[3]=checked; break;
|
|
121 |
case R.id.olimpicCheckBoxYellow4: sView.getRenderer().pressed(3,4,checked); mYellow[4]=checked; break;
|
|
122 |
case R.id.olimpicCheckBoxYellow5: sView.getRenderer().pressed(3,5,checked); mYellow[5]=checked; break;
|
|
123 |
case R.id.olimpicCheckBoxYellow6: sView.getRenderer().pressed(3,6,checked); mYellow[6]=checked; break;
|
|
124 |
case R.id.olimpicCheckBoxYellow7: sView.getRenderer().pressed(3,7,checked); mYellow[7]=checked; break;
|
|
125 |
case R.id.olimpicCheckBoxYellow8: sView.getRenderer().pressed(3,8,checked); mYellow[8]=checked; break;
|
|
126 |
|
|
127 |
case R.id.olimpicCheckBoxGreen0 : sView.getRenderer().pressed(4,0,checked); mGreen[0] =checked; break;
|
|
128 |
case R.id.olimpicCheckBoxGreen1 : sView.getRenderer().pressed(4,1,checked); mGreen[1] =checked; break;
|
|
129 |
case R.id.olimpicCheckBoxGreen2 : sView.getRenderer().pressed(4,2,checked); mGreen[2] =checked; break;
|
|
130 |
case R.id.olimpicCheckBoxGreen3 : sView.getRenderer().pressed(4,3,checked); mGreen[3] =checked; break;
|
|
131 |
case R.id.olimpicCheckBoxGreen4 : sView.getRenderer().pressed(4,4,checked); mGreen[4] =checked; break;
|
|
132 |
case R.id.olimpicCheckBoxGreen5 : sView.getRenderer().pressed(4,5,checked); mGreen[5] =checked; break;
|
|
133 |
case R.id.olimpicCheckBoxGreen6 : sView.getRenderer().pressed(4,6,checked); mGreen[6] =checked; break;
|
|
134 |
case R.id.olimpicCheckBoxGreen7 : sView.getRenderer().pressed(4,7,checked); mGreen[7] =checked; break;
|
|
135 |
case R.id.olimpicCheckBoxGreen8 : sView.getRenderer().pressed(4,8,checked); mGreen[8] =checked; break;
|
|
136 |
}
|
117 |
137 |
}
|
118 |
138 |
|
119 |
139 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
143 |
163 |
{
|
144 |
164 |
Distorted.onDestroy();
|
145 |
165 |
super.onDestroy();
|
146 |
|
}
|
|
166 |
}
|
|
167 |
|
|
168 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
169 |
|
|
170 |
@Override
|
|
171 |
public void onSaveInstanceState(Bundle savedInstanceState)
|
|
172 |
{
|
|
173 |
super.onSaveInstanceState(savedInstanceState);
|
|
174 |
|
|
175 |
savedInstanceState.putBooleanArray("blue" , mBlue );
|
|
176 |
savedInstanceState.putBooleanArray("black" , mBlack );
|
|
177 |
savedInstanceState.putBooleanArray("red" , mRed );
|
|
178 |
savedInstanceState.putBooleanArray("yellow", mYellow);
|
|
179 |
savedInstanceState.putBooleanArray("green" , mGreen );
|
|
180 |
}
|
|
181 |
|
|
182 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
183 |
|
|
184 |
@Override
|
|
185 |
public void onRestoreInstanceState(Bundle savedInstanceState)
|
|
186 |
{
|
|
187 |
super.onRestoreInstanceState(savedInstanceState);
|
|
188 |
|
|
189 |
mBlue = savedInstanceState.getBooleanArray("blue" );
|
|
190 |
mBlack = savedInstanceState.getBooleanArray("black" );
|
|
191 |
mRed = savedInstanceState.getBooleanArray("red" );
|
|
192 |
mYellow = savedInstanceState.getBooleanArray("yellow");
|
|
193 |
mGreen = savedInstanceState.getBooleanArray("green" );
|
|
194 |
|
|
195 |
OlimpicSurfaceView view = (OlimpicSurfaceView) this.findViewById(R.id.olimpicSurfaceView);
|
|
196 |
OlimpicRenderer renderer = view.getRenderer();
|
|
197 |
|
|
198 |
int num = OlimpicRenderer.NUM_LEAVES + 1;
|
|
199 |
|
|
200 |
for(int i=0; i<num; i++)
|
|
201 |
{
|
|
202 |
renderer.pressed(0, i, mBlue[i] );
|
|
203 |
renderer.pressed(1, i, mBlack[i] );
|
|
204 |
renderer.pressed(2, i, mRed[i] );
|
|
205 |
renderer.pressed(3, i, mYellow[i]);
|
|
206 |
renderer.pressed(4, i, mGreen[i] );
|
|
207 |
}
|
|
208 |
}
|
|
209 |
|
147 |
210 |
}
|
Improve Olimpic (still buggy!)