1 package org
.proofofconcept
.shisensho
;
3 import java
.util
.Observable
;
4 import java
.util
.Observer
;
6 import android
.app
.Application
;
7 import android
.os
.Bundle
;
8 import android
.util
.Log
;
10 public class ShisenSho
extends Application
{
11 private static ShisenSho instance
= null;
12 private ShisenShoView view
= null;
13 public ShisenShoActivity activity
= null;
16 public int[] boardSize
=new int[2];
17 public int difficulty
=1; // 1=Hard, 2=Easy
18 public int size
=3; // 1=Small, 2=Medium, 3=Big
19 public boolean gravity
=true;
20 public boolean timeCounter
=true;
22 public static void log(String msg
) {
23 Log
.w("ShisenSho", msg
);
26 public void newPlay() {
28 board
.buildRandomBoard(boardSize
[0],boardSize
[1],difficulty
,gravity
);
31 public void setSize(int s
) {
52 public void sleep(int deciSeconds
) {
54 Thread
.sleep(deciSeconds
*100);
55 } catch (InterruptedException e
) { }
63 public static synchronized ShisenSho
app() {
67 public ShisenShoView
getView() {
68 if (view
== null) view
= new ShisenShoView(this);
72 /** Called when the activity is first created. */
74 public void onCreate() {
78 public Bundle
getOptions() {
79 Bundle options
= new Bundle();
80 options
.putInt("size", size
);
81 options
.putInt("difficulty", difficulty
);
82 options
.putBoolean("gravity", gravity
);
83 options
.putBoolean("timeCounter", timeCounter
);
87 public void setOptions(Bundle options
) {
88 int size
= options
.getInt("size");
89 int difficulty
= options
.getInt("difficulty");
90 boolean gravity
= options
.getBoolean("gravity");
91 boolean timeCounter
= options
.getBoolean("timeCounter");
93 boolean needsReset
= false;
95 if (size
!= this.size
) {
100 if (difficulty
!= this.difficulty
) {
101 this.difficulty
= difficulty
;
105 if (gravity
!= this.gravity
) {
106 this.gravity
= gravity
;
110 if (timeCounter
!= this.timeCounter
) {
111 this.timeCounter
= timeCounter
;
112 view
.onTimeCounterActivate();