]> git.zerfleddert.de Git - FreeShisen/blob - src/de/cwde/shisensho/ShisenSho.java
rename, add hdpi icons, cleanup some warnings
[FreeShisen] / src / de / cwde / shisensho / ShisenSho.java
1 package de.cwde.shisensho;
2
3 import android.app.Application;
4 import android.os.Bundle;
5 import android.util.Log;
6
7 public class ShisenSho extends Application {
8 private static ShisenSho instance = null;
9 private ShisenShoView view = null;
10 public ShisenShoActivity activity = null;
11
12 public Board board;
13 public int[] boardSize=new int[2];
14 public int difficulty=1; // 1=Hard, 2=Easy
15 public int size=3; // 1=Small, 2=Medium, 3=Big
16 public boolean gravity=true;
17 public boolean timeCounter=true;
18
19 public static void log(String msg) {
20 Log.w("ShisenSho", msg);
21 }
22
23 public void newPlay() {
24 board = new Board();
25 board.buildRandomBoard(boardSize[0],boardSize[1],difficulty,gravity);
26 }
27
28 public void setSize(int s) {
29 switch (s) {
30 case 1:
31 size=1;
32 boardSize[0]=6+2;
33 boardSize[1]=8+2;
34 break;
35 case 2:
36 size=2;
37 boardSize[0]=6+2;
38 boardSize[1]=12+2;
39 break;
40 case 3:
41 default:
42 size=3;
43 boardSize[0]=6+2;
44 boardSize[1]=16+2;
45 break;
46 }
47 }
48
49 public void sleep(int deciSeconds) {
50 try {
51 Thread.sleep(deciSeconds*100);
52 } catch (InterruptedException e) { }
53 }
54
55 public ShisenSho() {
56 instance = this;
57 setSize(size);
58 }
59
60 public static synchronized ShisenSho app() {
61 return instance;
62 }
63
64 public ShisenShoView getView() {
65 if (view == null) view = new ShisenShoView(this);
66 return view;
67 }
68
69 /** Called when the activity is first created. */
70 @Override
71 public void onCreate() {
72 super.onCreate();
73 }
74
75 public Bundle getOptions() {
76 Bundle options = new Bundle();
77 options.putInt("size", size);
78 options.putInt("difficulty", difficulty);
79 options.putBoolean("gravity", gravity);
80 options.putBoolean("timeCounter", timeCounter);
81 return options;
82 }
83
84 public void setOptions(Bundle options) {
85 int size = options.getInt("size");
86 int difficulty = options.getInt("difficulty");
87 boolean gravity = options.getBoolean("gravity");
88 boolean timeCounter = options.getBoolean("timeCounter");
89
90 boolean needsReset = false;
91
92 if (size != this.size) {
93 setSize(size);
94 needsReset = true;
95 }
96
97 if (difficulty != this.difficulty) {
98 this.difficulty = difficulty;
99 needsReset = true;
100 }
101
102 if (gravity != this.gravity) {
103 this.gravity = gravity;
104 needsReset = true;
105 }
106
107 if (timeCounter != this.timeCounter) {
108 this.timeCounter = timeCounter;
109 view.onTimeCounterActivate();
110 }
111
112 if (needsReset) {
113 view.reset();
114 }
115 }
116
117 }
Impressum, Datenschutz