PageRenderTime 209ms CodeModel.GetById 60ms app.highlight 108ms RepoModel.GetById 33ms app.codeStats 0ms

/TheElements/src/sand/falling/opengl/custom/CustomMaker.java

http://thelements.googlecode.com/
Java | 819 lines | 729 code | 63 blank | 27 comment | 198 complexity | 58eb3055fa69decc00395837199653a5 MD5 | raw file
  1package sand.falling.opengl.custom;
  2
  3import java.io.DataInputStream;
  4import java.io.DataOutputStream;
  5import java.io.EOFException;
  6import java.io.File;
  7import java.io.FileInputStream;
  8import java.io.FileOutputStream;
  9import java.io.IOException;
 10
 11import sand.falling.opengl.MainActivity;
 12import sand.falling.opengl.R;
 13import android.app.Activity;
 14import android.os.Bundle;
 15import android.view.View;
 16import android.widget.AdapterView;
 17import android.widget.ArrayAdapter;
 18import android.widget.SeekBar;
 19import android.widget.Spinner;
 20import android.widget.AdapterView.OnItemSelectedListener;
 21
 22public class CustomMaker extends Activity
 23{
 24	private static final int TSpinner = 20;
 25	private static final int TSeekBar = 5;
 26
 27	ArrayAdapter<CharSequence> sandcoladp = null;
 28	ArrayAdapter<CharSequence> adapter = null;
 29	Spinner sandcollis = null;
 30	Spinner watercollis = null;
 31	Spinner wallcollis = null;
 32	Spinner plantcollis = null;
 33	Spinner firecollis = null;
 34	Spinner oilcollis = null;
 35	Spinner icecollis = null;
 36	Spinner magmacollis = null;
 37	Spinner stonecollis = null;
 38	Spinner C4collis = null;
 39	Spinner C4pluscollis = null;
 40	Spinner fusecollis = null;
 41	Spinner destwallcollis = null;
 42	Spinner acidcollis = null;
 43	Spinner steamcollis = null;
 44	Spinner saltcollis = null;
 45	Spinner saltwatercollis = null;
 46	Spinner glasscollis = null;
 47	Spinner mudcollis = null;
 48	Spinner customelecollis = null;
 49
 50	private SeekBar explo_slider;
 51	private SeekBar red_1_slider;
 52	private SeekBar blue_1_slider;
 53	private SeekBar green_1_slider;
 54	private SeekBar density_slider;
 55
 56	//private int[] incustom = new int[TSpinner + TSeekBar];
 57	int[] inFile = new int[TSpinner + TSeekBar];
 58
 59	@Override
 60	public void onCreate(Bundle savedInstanceState)
 61	{
 62
 63		FileInputStream fis;
 64		DataInputStream dis;
 65
 66		try
 67		{
 68			File file = new File("/sdcard/elementworks/customproperties.txt");
 69			if(!file.exists())
 70			{
 71				file.createNewFile();
 72			}
 73			
 74			fis = new FileInputStream(file);
 75			dis = new DataInputStream(fis);
 76			for (int i = 0; i < (TSpinner + TSeekBar); ++i)
 77			{
 78
 79				try
 80				{
 81					inFile[i] = dis.readInt();
 82				}
 83				catch (EOFException e)
 84				{
 85					e.printStackTrace();
 86					inFile[i] = 0;
 87				}
 88
 89			}
 90
 91		}
 92		catch (IOException e)
 93		{
 94			if(!(new File("/sdcard/elementworks")).mkdir())
 95			{
 96				e.printStackTrace();
 97			}
 98			
 99			for (int i = 0; i < (TSpinner + TSeekBar); ++i)
100			{
101				inFile[i] = 0;
102			}
103		}
104
105
106		super.onCreate(savedInstanceState);
107		setContentView(R.layout.custom);
108
109		explo_slider = (SeekBar) findViewById(R.id.explo_slider);
110		red_1_slider = (SeekBar) findViewById(R.id.red_1_slider);
111		blue_1_slider = (SeekBar) findViewById(R.id.blue_1_slider);
112		green_1_slider = (SeekBar) findViewById(R.id.green_1_slider);
113		density_slider = (SeekBar) findViewById(R.id.density_slider);
114
115		// set up the Spinners
116		sandcollis = (Spinner) findViewById(R.id.sandcol);
117		sandcoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
118		sandcoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
119		sandcollis.setAdapter(sandcoladp);
120		sandcollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
121		sandcollis.setSelection(inFile[5]);
122
123		watercollis = (Spinner) findViewById(R.id.watercol);
124		ArrayAdapter<CharSequence> watercoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
125		watercoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
126		watercollis.setAdapter(watercoladp);
127		watercollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
128		watercollis.setSelection(inFile[6]);
129
130		wallcollis = (Spinner) findViewById(R.id.wallcol);
131		ArrayAdapter<CharSequence> wallcoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
132		wallcoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
133		wallcollis.setAdapter(wallcoladp);
134		wallcollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
135		wallcollis.setSelection(inFile[7]);
136
137		plantcollis = (Spinner) findViewById(R.id.plantcol);
138		ArrayAdapter<CharSequence> plantcoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
139		plantcoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
140		plantcollis.setAdapter(plantcoladp);
141		plantcollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
142		plantcollis.setSelection(inFile[8]);
143
144		firecollis = (Spinner) findViewById(R.id.firecol);
145		ArrayAdapter<CharSequence> firecoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
146		firecoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
147		firecollis.setAdapter(firecoladp);
148		firecollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
149		firecollis.setSelection(inFile[9]);
150
151		icecollis = (Spinner) findViewById(R.id.icecol);
152		ArrayAdapter<CharSequence> icecoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
153		icecoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
154		icecollis.setAdapter(icecoladp);
155		icecollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
156		icecollis.setSelection(inFile[10]);
157
158		oilcollis = (Spinner) findViewById(R.id.oilcol);
159		ArrayAdapter<CharSequence> oilcoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
160		oilcoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
161		oilcollis.setAdapter(oilcoladp);
162		oilcollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
163		oilcollis.setSelection(inFile[11]);
164
165		magmacollis = (Spinner) findViewById(R.id.magmacol);
166		ArrayAdapter<CharSequence> magmacoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
167		magmacoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
168		magmacollis.setAdapter(magmacoladp);
169		magmacollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
170		magmacollis.setSelection(inFile[12]);
171
172		stonecollis = (Spinner) findViewById(R.id.stonecol);
173		ArrayAdapter<CharSequence> stonecoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
174		stonecoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
175		stonecollis.setAdapter(stonecoladp);
176		stonecollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
177		stonecollis.setSelection(inFile[13]);
178
179		C4collis = (Spinner) findViewById(R.id.C4col);
180		ArrayAdapter<CharSequence> C4coladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
181		C4coladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
182		C4collis.setAdapter(C4coladp);
183		C4collis.setOnItemSelectedListener(new MyOnItemSelectedListener());
184		C4collis.setSelection(inFile[14]);
185
186		C4pluscollis = (Spinner) findViewById(R.id.C4pluscol);
187		ArrayAdapter<CharSequence> C4pluscoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
188		C4pluscoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
189		C4pluscollis.setAdapter(C4pluscoladp);
190		C4pluscollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
191		C4pluscollis.setSelection(inFile[15]);
192
193		fusecollis = (Spinner) findViewById(R.id.fusecol);
194		ArrayAdapter<CharSequence> fusecoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
195		fusecoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
196		fusecollis.setAdapter(fusecoladp);
197		fusecollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
198		fusecollis.setSelection(inFile[16]);
199
200		destwallcollis = (Spinner) findViewById(R.id.destructablewallcol);
201		ArrayAdapter<CharSequence> destwallcoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
202		destwallcoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
203		destwallcollis.setAdapter(destwallcoladp);
204		destwallcollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
205		destwallcollis.setSelection(inFile[17]);
206
207		acidcollis = (Spinner) findViewById(R.id.acidcol);
208		ArrayAdapter<CharSequence> acidcoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
209		acidcoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
210		acidcollis.setAdapter(acidcoladp);
211		acidcollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
212		acidcollis.setSelection(inFile[18]);
213
214		steamcollis = (Spinner) findViewById(R.id.steamcol);
215		ArrayAdapter<CharSequence> steamcoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
216		steamcoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
217		steamcollis.setAdapter(steamcoladp);
218		steamcollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
219		steamcollis.setSelection(inFile[19]);
220
221		saltcollis = (Spinner) findViewById(R.id.saltcol);
222		ArrayAdapter<CharSequence> saltcoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
223		saltcoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
224		saltcollis.setAdapter(saltcoladp);
225		saltcollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
226		saltcollis.setSelection(inFile[20]);
227
228		saltwatercollis = (Spinner) findViewById(R.id.saltwatercol);
229		ArrayAdapter<CharSequence> saltwatercoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
230		saltwatercoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
231		saltwatercollis.setAdapter(saltwatercoladp);
232		saltwatercollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
233		saltwatercollis.setSelection(inFile[21]);
234
235		glasscollis = (Spinner) findViewById(R.id.glasscol);
236		ArrayAdapter<CharSequence> glasscoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
237		glasscoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
238		glasscollis.setAdapter(glasscoladp);
239		glasscollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
240		glasscollis.setSelection(inFile[22]);
241		
242		customelecollis = (Spinner) findViewById(R.id.customelecol);
243		ArrayAdapter<CharSequence> customelecoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
244		customelecoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
245		customelecollis.setAdapter(customelecoladp);
246		customelecollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
247		customelecollis.setSelection(inFile[23]);
248
249		mudcollis = (Spinner) findViewById(R.id.mudcol);
250		ArrayAdapter<CharSequence> mudcoladp = ArrayAdapter.createFromResource(this, R.array.reaction_array, android.R.layout.simple_spinner_item);
251		mudcoladp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
252		mudcollis.setAdapter(mudcoladp);
253		mudcollis.setOnItemSelectedListener(new MyOnItemSelectedListener());
254		mudcollis.setSelection(inFile[24]);
255
256		explo_slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
257		{
258			public void onProgressChanged(SeekBar seekbar, int progress, boolean fromTouch)
259			{
260				// When it is dragged, set the explosion value to 100 * the fraction of the bar dragged
261				int p = 100 * progress / seekbar.getMax();
262				MainActivity.setExplosiveness(p);
263				inFile[0] = progress;
264				savecustomdata();
265			}
266
267			// These aren't needed for now
268			public void onStartTrackingTouch(SeekBar seekbar)
269			{
270			}
271
272			public void onStopTrackingTouch(SeekBar seekbar)
273			{
274			}
275		});
276		// Start off the progress bar at the value in the file
277		explo_slider.setProgress(inFile[0]);
278		red_1_slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
279		{
280			public void onProgressChanged(SeekBar seekbar, int progress, boolean fromTouch)
281			{
282				// When it is dragged, set the red value to 255 * the fraction of the bar dragged
283				int p = 255 * progress / seekbar.getMax();
284				MainActivity.setRed(p);
285				inFile[1] = progress;
286				savecustomdata();
287			}
288
289			// These aren't needed for now
290			public void onStartTrackingTouch(SeekBar seekbar)
291			{
292			}
293
294			public void onStopTrackingTouch(SeekBar seekbar)
295			{
296			}
297		});
298		// Start off the progress bar at the saved value
299		red_1_slider.setProgress(inFile[1]);
300
301		green_1_slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
302		{
303			public void onProgressChanged(SeekBar seekbar, int progress, boolean fromTouch)
304			{
305				// When it is dragged, set the green value to 255 * the fraction of the bar dragged
306				int p = 255 * progress / seekbar.getMax();
307				MainActivity.setGreen(p);
308				inFile[2] = progress;
309				savecustomdata();
310			}
311
312			// These aren't needed for now
313			public void onStartTrackingTouch(SeekBar seekbar)
314			{
315			}
316
317			public void onStopTrackingTouch(SeekBar seekbar)
318			{
319			}
320		});
321		// Start off the progress bar at the value in the file
322		green_1_slider.setProgress(inFile[2]);
323		blue_1_slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
324		{
325			public void onProgressChanged(SeekBar seekbar, int progress, boolean fromTouch)
326			{
327				// When it is dragged, set the blue value to 255 * the fraction of the bar dragged
328				int p = 255 * progress / seekbar.getMax();
329				MainActivity.setBlue(p);
330				inFile[3] = progress;
331				savecustomdata();
332			}
333
334			// These aren't needed for now
335			public void onStartTrackingTouch(SeekBar seekbar)
336			{
337			}
338
339			public void onStopTrackingTouch(SeekBar seekbar)
340			{
341			}
342		});
343		// Start off the progress bar at the value in the file
344		blue_1_slider.setProgress(inFile[3]);
345		density_slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
346		{
347			public void onProgressChanged(SeekBar seekbar, int progress, boolean fromTouch)
348			{
349				// When it is dragged, set the blue value to 255 * the fraction of the bar dragged
350				int p = 100 * progress / seekbar.getMax();
351				MainActivity.setDensity(p);
352				inFile[4] = progress;
353				savecustomdata();
354			}
355
356			// These aren't needed for now
357			public void onStartTrackingTouch(SeekBar seekbar)
358			{
359			}
360
361			public void onStopTrackingTouch(SeekBar seekbar)
362			{
363			}
364		});
365		// Start off the progress bar at the value in the file
366		density_slider.setProgress(inFile[4]);
367	}
368
369	public class MyOnItemSelectedListener implements OnItemSelectedListener
370	{
371		public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
372		{
373			int ffileindex = 5; // temp var, initialized to 5 to start b.c
374			// that's where the first collis is in array
375			int rfileindex = 0; // one we'll actually use
376			// pos starts at 0
377			if (parent.equals(sandcollis))
378			{
379				rfileindex = ffileindex;
380				collisioner(0, pos);
381			}
382			ffileindex++;
383			if (parent.equals(watercollis))
384			{
385				rfileindex = ffileindex;
386				collisioner(1, pos);
387			}
388			ffileindex++;
389			if (parent.equals(wallcollis))
390			{
391				rfileindex = ffileindex;
392				collisioner(2, pos);
393			}
394			ffileindex++;
395			if (parent.equals(plantcollis))
396			{
397				rfileindex = ffileindex;
398				collisioner(4, pos);
399			}
400			ffileindex++;
401			if (parent.equals(firecollis))
402			{
403				rfileindex = ffileindex;
404				collisioner(5, pos);
405			}
406			ffileindex++;
407			if (parent.equals(icecollis))
408			{
409				rfileindex = ffileindex;
410				collisioner(6, pos);
411			}
412			ffileindex++;
413			if (parent.equals(oilcollis))
414			{
415				rfileindex = ffileindex;
416				collisioner(9, pos);
417			}
418			ffileindex++;
419			if (parent.equals(magmacollis))
420			{
421				rfileindex = ffileindex;
422				collisioner(10, pos);
423			}
424			ffileindex++;
425			if (parent.equals(stonecollis))
426			{
427				rfileindex = ffileindex;
428				collisioner(11, pos);
429			}
430			ffileindex++;
431			if (parent.equals(C4collis))
432			{
433				rfileindex = ffileindex;
434				collisioner(12, pos);
435			}
436			ffileindex++;
437			if (parent.equals(C4pluscollis))
438			{
439				rfileindex = ffileindex;
440				collisioner(13, pos);
441			}
442			ffileindex++;
443			if (parent.equals(fusecollis))
444			{
445				rfileindex = ffileindex;
446				collisioner(14, pos);
447			}
448			ffileindex++;
449			if (parent.equals(destwallcollis))
450			{
451				rfileindex = ffileindex;
452				collisioner(15, pos);
453			}
454			ffileindex++;
455			if (parent.equals(acidcollis))
456			{
457				rfileindex = ffileindex;
458				collisioner(17, pos);
459			}
460			ffileindex++;
461			if (parent.equals(steamcollis))
462			{
463				rfileindex = ffileindex;
464				collisioner(18, pos);
465			}
466			ffileindex++;
467			if (parent.equals(saltcollis))
468			{
469				rfileindex = ffileindex;
470				collisioner(19, pos);
471			}
472			ffileindex++;
473			if (parent.equals(saltwatercollis))
474			{
475				rfileindex = ffileindex;
476				collisioner(20, pos);
477			}
478			ffileindex++;
479			if (parent.equals(glasscollis))
480			{
481				rfileindex = ffileindex;
482				collisioner(21, pos);
483			}
484			ffileindex++;
485			if (parent.equals(customelecollis))
486			{
487				rfileindex = ffileindex;
488				collisioner(22, pos);
489			}
490			ffileindex++;
491			if (parent.equals(mudcollis))
492			{
493				rfileindex = ffileindex;
494				collisioner(23, pos);
495			}
496			ffileindex++;
497
498			inFile[rfileindex] = pos;
499			savecustomdata();
500		}
501
502		public void onNothingSelected(AdapterView<?> parent)
503		{
504			// Do nothing.
505		}
506
507
508	}
509
510	public void savecustomdata()
511	{
512		// Saves the custom element properties (set by the sliders) to a file
513		FileOutputStream fos;
514		DataOutputStream dos;
515
516		try
517		{
518			File file = new File("/sdcard/elementworks/customproperties.txt");
519			if(!file.exists())
520			{
521				file.createNewFile();
522			}
523			fos = new FileOutputStream(file);
524			dos = new DataOutputStream(fos);
525			for (int i = 0; i < (TSpinner + TSeekBar); i++)
526			{
527				dos.writeInt(inFile[i]);
528			}
529		}
530		catch (IOException e)
531		{
532			if(!(new File("/sdcard/elementworks")).mkdir())
533			{
534				e.printStackTrace();
535			}
536		}
537	}
538	
539	public static void collisioner(int elent, int pos)
540	{ //TODO: change this massive thing to a switch statement
541
542		// setcollision(int custnumber, int elementnumb, int collisionspot,
543		// int collisionnumber);
544		// which custom element, the element the custom should be like, the
545		// element colliding with, collision type
546		if (pos == 0)
547		{
548			MainActivity.setCollision(1, 0, elent, 0);
549		}
550		else if (pos == 1)
551		{
552			MainActivity.setCollision(1, 0, elent, 1);
553		}
554		else if (pos == 2)
555		{
556			MainActivity.setCollision(1, 24, elent, 1);
557		}
558		else if (pos == 3)
559		{
560			MainActivity.setCollision(1, 24, elent, 3);
561		}
562		else if (pos == 4)
563		{
564			MainActivity.setCollision(1, 1, elent, 4);
565		}
566		else if (pos == 5)
567		{
568			MainActivity.setCollision(1, 4, elent, 4);
569		}
570		else if (pos == 6)
571		{
572			MainActivity.setCollision(1, 5, elent, 5);
573		}
574		else if (pos == 7)
575		{
576			MainActivity.setCollision(1, 0, elent, 5);
577		}
578		else if (pos == 8)
579		{
580			MainActivity.setCollision(1, 5, elent, 7);
581		}
582		else if (pos == 9)
583		{
584			MainActivity.setCollision(1, 1, elent, 8);
585		}
586		else if (pos == 10)
587		{
588			MainActivity.setCollision(1, 6, elent, 8);
589		}
590		else if (pos == 11)
591		{
592			MainActivity.setCollision(1, 5, elent, 9);
593		}
594		else if (pos == 12)
595		{
596			MainActivity.setCollision(1, 6, elent, 9);
597		}
598		else if (pos == 13)
599		{
600			MainActivity.setCollision(1, 10, elent, 10);
601		}
602		else if (pos == 14)
603		{
604			MainActivity.setCollision(1, 6, elent, 10);
605		}
606		else if (pos == 15)
607		{
608			MainActivity.setCollision(1, 9, elent, 11);
609		}
610		else if (pos == 16)
611		{
612			MainActivity.setCollision(1, 10, elent, 11);
613		}
614		else if (pos == 17)
615		{
616			MainActivity.setCollision(1, 10, elent, 12);
617		}
618		else if (pos == 18)
619		{
620			MainActivity.setCollision(1, 1, elent, 12);
621		}
622		else if (pos == 19)
623		{
624			MainActivity.setCollision(1, 11, elent, 13);
625		}
626		else if (pos == 20)
627		{
628			MainActivity.setCollision(1, 10, elent, 13);
629		}
630		else if (pos == 21)
631		{
632			MainActivity.setCollision(1, 11, elent, 14);
633		}
634		else if (pos == 22)
635		{
636			MainActivity.setCollision(1, 10, elent, 15);
637		}
638		else if (pos == 23)
639		{
640			MainActivity.setCollision(1, 12, elent, 15);
641		}
642		else if (pos == 24)
643		{
644			MainActivity.setCollision(1, 10, elent, 17);
645		}
646		else if (pos == 25)
647		{
648			MainActivity.setCollision(1, 15, elent, 17);
649		}
650		else if (pos == 26)
651		{
652			MainActivity.setCollision(1, 17, elent, 18);
653		}
654		else if (pos == 27)
655		{
656			MainActivity.setCollision(1, 0, elent, 18);
657		}
658		else if (pos == 28)
659		{
660			MainActivity.setCollision(1, 17, elent, 19);
661		}
662		else if (pos == 29)
663		{
664			MainActivity.setCollision(1, 1, elent, 19);
665		}
666		else if (pos == 30)
667		{
668			MainActivity.setCollision(1, 18, elent, 20);
669		}
670		else if (pos == 31)
671		{
672			MainActivity.setCollision(1, 1, elent, 20);
673		}
674		else if (pos == 32)
675		{
676			MainActivity.setCollision(1, 18, elent, 21);
677		}
678		else if (pos == 33)
679		{
680			MainActivity.setCollision(1, 18, elent, 22);
681		}
682		else if (pos == 34)
683		{
684			MainActivity.setCollision(1, 0, elent, 22);
685		}
686		else if (pos == 35)
687		{
688			MainActivity.setCollision(1, 1, elent, 23);
689		}
690		else if (pos == 36)
691		{
692			MainActivity.setCollision(1, 5, elent, 23);
693		}
694		else if (pos == 37)
695		{
696			MainActivity.setCollision(1, 19, elent, 24);
697		}
698		else if (pos == 38)
699		{
700			MainActivity.setCollision(1, 1, elent, 24);
701		}
702		else if (pos == 39)
703		{
704			MainActivity.setCollision(1, 19, elent, 25);
705		}
706		else if (pos == 40)
707		{
708			MainActivity.setCollision(1, 6, elent, 25);
709		}
710		else if (pos == 41)
711		{
712			MainActivity.setCollision(1, 20, elent, 26);
713		}
714		else if (pos == 42)
715		{
716			MainActivity.setCollision(1, 4, elent, 26);
717		}
718		else if (pos == 43)
719		{
720			MainActivity.setCollision(1, 0, elent, 27);
721		}
722		else if (pos == 44)
723		{
724			MainActivity.setCollision(1, 10, elent, 27);
725		}
726		else if (pos == 45)
727		{
728			MainActivity.setCollision(1, 4, elent, 6);
729		}
730		else if (pos == 46)
731		{
732			MainActivity.setCollision(1, 5, elent, 6);
733		}
734		else if (pos == 47)
735		{
736			MainActivity.setCollision(1, 1, elent, 28);
737		}
738		else if (pos == 48)
739		{
740			MainActivity.setCollision(1, 0, elent, 28);
741		}
742		else if (pos == 49)
743		{
744			MainActivity.setCollision(1, 23, elent, 29);
745		}
746		else if (pos == 50)
747		{
748			MainActivity.setCollision(1, 5, elent, 29);
749		}
750		else if (pos == 51)
751		{
752			MainActivity.setCollision(1, 23, elent, 30);
753		}
754		else if (pos == 52)
755		{
756			MainActivity.setCollision(1, 10, elent, 30);
757		}
758	}
759	
760	//Call this function to initialize custom data from the file
761	public static void loadCustom()
762	{
763		int inFile[] = new int[TSpinner + TSeekBar];
764		FileInputStream fis;
765		DataInputStream dis;
766
767		try
768		{
769			File file = new File("/sdcard/elementworks/customproperties.txt");
770			if(!file.exists())
771			{
772				file.createNewFile();
773			}
774			
775			fis = new FileInputStream(file);
776			dis = new DataInputStream(fis);
777			for (int i = 0; i < (TSpinner + TSeekBar); ++i)
778			{
779				try
780				{
781					inFile[i] = dis.readInt();
782				}
783				catch (EOFException e)
784				{
785					e.printStackTrace();
786					inFile[i] = 0;
787				}
788			}
789		}
790		catch (IOException e)
791		{
792			if(!(new File("/sdcard/elementworks")).mkdir())
793			{
794				e.printStackTrace();
795			}
796			
797			for (int i = 0; i < (TSpinner + TSeekBar); i++)
798			{
799				inFile[i] = 0;
800			}
801		}
802		
803		//Loop through and set the stuff now
804		MainActivity.setExplosiveness(inFile[0]);
805		MainActivity.setRed(inFile[1]);
806		MainActivity.setGreen(inFile[2]);
807		MainActivity.setBlue(inFile[3]);
808		MainActivity.setDensity(inFile[4]);
809		for(int i = 0, j = 5; i < MainActivity.elementslist.length + 2; i++)
810		{
811			if(i == 3 || i == 7 || i == 8 || i == 16)
812			{
813				continue;
814			}
815			collisioner(i, inFile[j]);
816			j++;
817		}
818	}
819}