1 package de
.cwde
.shisensho
;
3 import android
.app
.Application
;
4 import android
.os
.Bundle
;
5 import android
.util
.Log
;
7 public class ShisenSho
extends Application
{
8 private static ShisenSho instance
= null;
9 private ShisenShoView view
= null;
10 public ShisenShoActivity activity
= null;
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;
19 public static void log(String msg
) {
20 Log
.w("ShisenSho", msg
);
23 public void newPlay() {
25 board
.buildRandomBoard(boardSize
[0],boardSize
[1],difficulty
,gravity
);
28 public void setSize(int s
) {
49 public void sleep(int deciSeconds
) {
51 Thread
.sleep(deciSeconds
*100);
52 } catch (InterruptedException e
) { }
60 public static synchronized ShisenSho
app() {
64 public ShisenShoView
getView() {
65 if (view
== null) view
= new ShisenShoView(this);
69 /** Called when the activity is first created. */
71 public void onCreate() {
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
);
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");
90 boolean needsReset
= false;
92 if (size
!= this.size
) {
97 if (difficulty
!= this.difficulty
) {
98 this.difficulty
= difficulty
;
102 if (gravity
!= this.gravity
) {
103 this.gravity
= gravity
;
107 if (timeCounter
!= this.timeCounter
) {
108 this.timeCounter
= timeCounter
;
109 view
.onTimeCounterActivate();