changed architecture so puzzles can run in dialog etc
A => android/assets/uiskin/default.fnt +101 -0
@@ 0,0 1,101 @@ 
+info face="Droid Sans" size=17 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
+common lineHeight=20 base=18 scaleW=256 scaleH=128 pages=1 packed=0
+page id=0 file="default.png"
+chars count=96
+char id=32   x=0     y=0     width=0     height=0     xoffset=0     yoffset=16    xadvance=4     page=0  chnl=0 
+char id=124   x=0     y=0     width=6     height=20     xoffset=1     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=106   x=6     y=0     width=9     height=20     xoffset=-4     yoffset=3    xadvance=4     page=0  chnl=0 
+char id=81   x=15     y=0     width=15     height=19     xoffset=-2     yoffset=3    xadvance=12     page=0  chnl=0 
+char id=74   x=30     y=0     width=11     height=19     xoffset=-5     yoffset=3    xadvance=4     page=0  chnl=0 
+char id=125   x=41     y=0     width=10     height=18     xoffset=-3     yoffset=3    xadvance=6     page=0  chnl=0 
+char id=123   x=51     y=0     width=10     height=18     xoffset=-3     yoffset=3    xadvance=6     page=0  chnl=0 
+char id=93   x=61     y=0     width=8     height=18     xoffset=-3     yoffset=3    xadvance=5     page=0  chnl=0 
+char id=91   x=69     y=0     width=8     height=18     xoffset=-2     yoffset=3    xadvance=5     page=0  chnl=0 
+char id=41   x=77     y=0     width=9     height=18     xoffset=-3     yoffset=3    xadvance=5     page=0  chnl=0 
+char id=40   x=86     y=0     width=9     height=18     xoffset=-3     yoffset=3    xadvance=5     page=0  chnl=0 
+char id=64   x=95     y=0     width=18     height=17     xoffset=-3     yoffset=3    xadvance=14     page=0  chnl=0 
+char id=121   x=113     y=0     width=13     height=17     xoffset=-3     yoffset=6    xadvance=8     page=0  chnl=0 
+char id=113   x=126     y=0     width=13     height=17     xoffset=-3     yoffset=6    xadvance=9     page=0  chnl=0 
+char id=112   x=139     y=0     width=13     height=17     xoffset=-2     yoffset=6    xadvance=9     page=0  chnl=0 
+char id=103   x=152     y=0     width=13     height=17     xoffset=-3     yoffset=6    xadvance=8     page=0  chnl=0 
+char id=38   x=165     y=0     width=16     height=16     xoffset=-3     yoffset=3    xadvance=11     page=0  chnl=0 
+char id=37   x=181     y=0     width=18     height=16     xoffset=-3     yoffset=3    xadvance=14     page=0  chnl=0 
+char id=36   x=199     y=0     width=12     height=16     xoffset=-2     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=63   x=211     y=0     width=11     height=16     xoffset=-3     yoffset=3    xadvance=7     page=0  chnl=0 
+char id=33   x=222     y=0     width=7     height=16     xoffset=-2     yoffset=3    xadvance=4     page=0  chnl=0 
+char id=48   x=229     y=0     width=13     height=16     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=57   x=242     y=0     width=13     height=16     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=56   x=0     y=20     width=13     height=16     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=54   x=13     y=20     width=13     height=16     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=53   x=26     y=20     width=12     height=16     xoffset=-2     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=51   x=38     y=20     width=13     height=16     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=100   x=51     y=20     width=13     height=16     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=98   x=64     y=20     width=13     height=16     xoffset=-2     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=85   x=77     y=20     width=14     height=16     xoffset=-2     yoffset=3    xadvance=11     page=0  chnl=0 
+char id=83   x=91     y=20     width=13     height=16     xoffset=-3     yoffset=3    xadvance=8     page=0  chnl=0 
+char id=79   x=104     y=20     width=15     height=16     xoffset=-2     yoffset=3    xadvance=12     page=0  chnl=0 
+char id=71   x=119     y=20     width=14     height=16     xoffset=-2     yoffset=3    xadvance=11     page=0  chnl=0 
+char id=67   x=133     y=20     width=13     height=16     xoffset=-2     yoffset=3    xadvance=10     page=0  chnl=0 
+char id=127   x=146     y=20     width=12     height=15     xoffset=-2     yoffset=3    xadvance=10     page=0  chnl=0 
+char id=35   x=158     y=20     width=15     height=15     xoffset=-3     yoffset=3    xadvance=10     page=0  chnl=0 
+char id=92   x=173     y=20     width=11     height=15     xoffset=-3     yoffset=3    xadvance=6     page=0  chnl=0 
+char id=47   x=184     y=20     width=11     height=15     xoffset=-3     yoffset=3    xadvance=6     page=0  chnl=0 
+char id=59   x=195     y=20     width=8     height=15     xoffset=-3     yoffset=6    xadvance=4     page=0  chnl=0 
+char id=55   x=203     y=20     width=13     height=15     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=52   x=216     y=20     width=14     height=15     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=50   x=230     y=20     width=13     height=15     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=49   x=243     y=20     width=9     height=15     xoffset=-2     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=116   x=0     y=36     width=10     height=15     xoffset=-3     yoffset=4    xadvance=5     page=0  chnl=0 
+char id=108   x=10     y=36     width=6     height=15     xoffset=-2     yoffset=3    xadvance=4     page=0  chnl=0 
+char id=107   x=16     y=36     width=12     height=15     xoffset=-2     yoffset=3    xadvance=8     page=0  chnl=0 
+char id=105   x=28     y=36     width=7     height=15     xoffset=-2     yoffset=3    xadvance=4     page=0  chnl=0 
+char id=104   x=35     y=36     width=12     height=15     xoffset=-2     yoffset=3    xadvance=10     page=0  chnl=0 
+char id=102   x=47     y=36     width=11     height=15     xoffset=-3     yoffset=3    xadvance=5     page=0  chnl=0 
+char id=90   x=58     y=36     width=13     height=15     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=89   x=71     y=36     width=13     height=15     xoffset=-3     yoffset=3    xadvance=8     page=0  chnl=0 
+char id=88   x=84     y=36     width=14     height=15     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=87   x=98     y=36     width=19     height=15     xoffset=-3     yoffset=3    xadvance=15     page=0  chnl=0 
+char id=86   x=117     y=36     width=14     height=15     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=84   x=131     y=36     width=13     height=15     xoffset=-3     yoffset=3    xadvance=8     page=0  chnl=0 
+char id=82   x=144     y=36     width=13     height=15     xoffset=-2     yoffset=3    xadvance=10     page=0  chnl=0 
+char id=80   x=157     y=36     width=12     height=15     xoffset=-2     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=78   x=169     y=36     width=14     height=15     xoffset=-2     yoffset=3    xadvance=12     page=0  chnl=0 
+char id=77   x=183     y=36     width=17     height=15     xoffset=-2     yoffset=3    xadvance=14     page=0  chnl=0 
+char id=76   x=200     y=36     width=11     height=15     xoffset=-2     yoffset=3    xadvance=8     page=0  chnl=0 
+char id=75   x=211     y=36     width=13     height=15     xoffset=-2     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=73   x=224     y=36     width=10     height=15     xoffset=-3     yoffset=3    xadvance=5     page=0  chnl=0 
+char id=72   x=234     y=36     width=14     height=15     xoffset=-2     yoffset=3    xadvance=11     page=0  chnl=0 
+char id=70   x=0     y=51     width=11     height=15     xoffset=-2     yoffset=3    xadvance=8     page=0  chnl=0 
+char id=69   x=11     y=51     width=11     height=15     xoffset=-2     yoffset=3    xadvance=8     page=0  chnl=0 
+char id=68   x=22     y=51     width=14     height=15     xoffset=-2     yoffset=3    xadvance=11     page=0  chnl=0 
+char id=66   x=36     y=51     width=13     height=15     xoffset=-2     yoffset=3    xadvance=10     page=0  chnl=0 
+char id=65   x=49     y=51     width=15     height=15     xoffset=-3     yoffset=3    xadvance=10     page=0  chnl=0 
+char id=58   x=64     y=51     width=7     height=13     xoffset=-2     yoffset=6    xadvance=4     page=0  chnl=0 
+char id=117   x=71     y=51     width=12     height=13     xoffset=-2     yoffset=6    xadvance=10     page=0  chnl=0 
+char id=115   x=83     y=51     width=11     height=13     xoffset=-3     yoffset=6    xadvance=7     page=0  chnl=0 
+char id=111   x=94     y=51     width=13     height=13     xoffset=-3     yoffset=6    xadvance=9     page=0  chnl=0 
+char id=101   x=107     y=51     width=13     height=13     xoffset=-3     yoffset=6    xadvance=9     page=0  chnl=0 
+char id=99   x=120     y=51     width=12     height=13     xoffset=-3     yoffset=6    xadvance=7     page=0  chnl=0 
+char id=97   x=132     y=51     width=12     height=13     xoffset=-3     yoffset=6    xadvance=9     page=0  chnl=0 
+char id=60   x=144     y=51     width=13     height=12     xoffset=-3     yoffset=5    xadvance=9     page=0  chnl=0 
+char id=122   x=157     y=51     width=11     height=12     xoffset=-3     yoffset=6    xadvance=7     page=0  chnl=0 
+char id=120   x=168     y=51     width=13     height=12     xoffset=-3     yoffset=6    xadvance=8     page=0  chnl=0 
+char id=119   x=181     y=51     width=17     height=12     xoffset=-3     yoffset=6    xadvance=12     page=0  chnl=0 
+char id=118   x=198     y=51     width=13     height=12     xoffset=-3     yoffset=6    xadvance=8     page=0  chnl=0 
+char id=114   x=211     y=51     width=10     height=12     xoffset=-2     yoffset=6    xadvance=6     page=0  chnl=0 
+char id=110   x=221     y=51     width=12     height=12     xoffset=-2     yoffset=6    xadvance=10     page=0  chnl=0 
+char id=109   x=233     y=51     width=17     height=12     xoffset=-2     yoffset=6    xadvance=15     page=0  chnl=0 
+char id=94   x=0     y=66     width=13     height=11     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=62   x=13     y=66     width=13     height=11     xoffset=-3     yoffset=5    xadvance=9     page=0  chnl=0 
+char id=42   x=26     y=66     width=13     height=10     xoffset=-3     yoffset=3    xadvance=9     page=0  chnl=0 
+char id=43   x=39     y=66     width=13     height=10     xoffset=-3     yoffset=6    xadvance=9     page=0  chnl=0 
+char id=61   x=52     y=66     width=13     height=8     xoffset=-3     yoffset=7    xadvance=9     page=0  chnl=0 
+char id=39   x=65     y=66     width=6     height=8     xoffset=-2     yoffset=3    xadvance=3     page=0  chnl=0 
+char id=34   x=71     y=66     width=9     height=8     xoffset=-2     yoffset=3    xadvance=6     page=0  chnl=0 
+char id=44   x=80     y=66     width=8     height=7     xoffset=-3     yoffset=14    xadvance=4     page=0  chnl=0 
+char id=126   x=88     y=66     width=13     height=6     xoffset=-3     yoffset=8    xadvance=9     page=0  chnl=0 
+char id=46   x=101     y=66     width=7     height=6     xoffset=-2     yoffset=13    xadvance=4     page=0  chnl=0 
+char id=96   x=108     y=66     width=8     height=6     xoffset=0     yoffset=2    xadvance=9     page=0  chnl=0 
+char id=45   x=116     y=66     width=9     height=5     xoffset=-3     yoffset=10    xadvance=5     page=0  chnl=0 
+char id=95   x=125     y=66     width=13     height=4     xoffset=-4     yoffset=17    xadvance=6     page=0  chnl=0 
+kernings count=-1

          
A => android/assets/uiskin/default.png +0 -0

        
A => android/assets/uiskin/uiskin.atlas +200 -0
@@ 0,0 1,200 @@ 
+
+uiskin.png
+size: 266,109
+format: RGBA8888
+filter: Nearest,Nearest
+repeat: none
+check-off
+  rotate: false
+  xy: 125, 16
+  size: 14, 14
+  orig: 14, 14
+  offset: 0, 0
+  index: -1
+textfield
+  rotate: false
+  xy: 125, 16
+  size: 14, 14
+  split: 3, 3, 3, 3
+  orig: 14, 14
+  offset: 0, 0
+  index: -1
+check-on
+  rotate: false
+  xy: 125, 1
+  size: 14, 14
+  orig: 14, 14
+  offset: 0, 0
+  index: -1
+cursor
+  rotate: false
+  xy: 155, 23
+  size: 3, 3
+  split: 1, 1, 1, 1
+  orig: 3, 3
+  offset: 0, 0
+  index: -1
+default
+  rotate: false
+  xy: 1, 31
+  size: 254, 77
+  orig: 254, 77
+  offset: 0, 0
+  index: -1
+default-pane
+  rotate: false
+  xy: 155, 27
+  size: 5, 3
+  split: 1, 1, 1, 1
+  orig: 5, 3
+  offset: 0, 0
+  index: -1
+default-rect-pad
+  rotate: false
+  xy: 155, 27
+  size: 5, 3
+  split: 1, 1, 1, 1
+  orig: 5, 3
+  offset: 0, 0
+  index: -1
+default-pane-noborder
+  rotate: false
+  xy: 44, 8
+  size: 1, 1
+  split: 0, 0, 0, 0
+  orig: 1, 1
+  offset: 0, 0
+  index: -1
+default-rect
+  rotate: false
+  xy: 256, 80
+  size: 3, 3
+  split: 1, 1, 1, 1
+  orig: 3, 3
+  offset: 0, 0
+  index: -1
+default-rect-down
+  rotate: false
+  xy: 161, 27
+  size: 3, 3
+  split: 1, 1, 1, 1
+  orig: 3, 3
+  offset: 0, 0
+  index: -1
+default-round
+  rotate: false
+  xy: 112, 10
+  size: 12, 20
+  split: 5, 5, 5, 4
+  pad: 4, 4, 1, 1
+  orig: 12, 20
+  offset: 0, 0
+  index: -1
+default-round-down
+  rotate: false
+  xy: 99, 10
+  size: 12, 20
+  split: 5, 5, 5, 4
+  pad: 4, 4, 1, 1
+  orig: 12, 20
+  offset: 0, 0
+  index: -1
+default-round-large
+  rotate: false
+  xy: 57, 10
+  size: 20, 20
+  split: 5, 5, 5, 4
+  orig: 20, 20
+  offset: 0, 0
+  index: -1
+default-scroll
+  rotate: false
+  xy: 78, 10
+  size: 20, 20
+  split: 2, 2, 2, 2
+  orig: 20, 20
+  offset: 0, 0
+  index: -1
+default-select
+  rotate: false
+  xy: 29, 10
+  size: 27, 20
+  split: 4, 14, 4, 4
+  orig: 27, 20
+  offset: 0, 0
+  index: -1
+default-select-selection
+  rotate: false
+  xy: 260, 86
+  size: 3, 3
+  split: 1, 1, 1, 1
+  orig: 3, 3
+  offset: 0, 0
+  index: -1
+default-slider
+  rotate: false
+  xy: 29, 1
+  size: 8, 8
+  split: 2, 2, 2, 2
+  orig: 8, 8
+  offset: 0, 0
+  index: -1
+default-slider-knob
+  rotate: false
+  xy: 256, 90
+  size: 9, 18
+  orig: 9, 18
+  offset: 0, 0
+  index: -1
+default-splitpane
+  rotate: false
+  xy: 38, 6
+  size: 5, 3
+  split: 0, 5, 0, 0
+  orig: 5, 3
+  offset: 0, 0
+  index: -1
+default-splitpane-vertical
+  rotate: false
+  xy: 256, 84
+  size: 3, 5
+  split: 0, 0, 0, 5
+  orig: 3, 5
+  offset: 0, 0
+  index: -1
+default-window
+  rotate: false
+  xy: 1, 1
+  size: 27, 29
+  split: 4, 3, 20, 3
+  orig: 27, 29
+  offset: 0, 0
+  index: -1
+selection
+  rotate: false
+  xy: 155, 21
+  size: 1, 1
+  orig: 1, 1
+  offset: 0, 0
+  index: -1
+tree-minus
+  rotate: false
+  xy: 140, 16
+  size: 14, 14
+  orig: 14, 14
+  offset: 0, 0
+  index: -1
+tree-plus
+  rotate: false
+  xy: 140, 1
+  size: 14, 14
+  orig: 14, 14
+  offset: 0, 0
+  index: -1
+white
+  rotate: false
+  xy: 38, 2
+  size: 3, 3
+  orig: 3, 3
+  offset: 0, 0
+  index: -1

          
A => android/assets/uiskin/uiskin.json +177 -0
@@ 0,0 1,177 @@ 
+{
+	"com.badlogic.gdx.graphics.g2d.BitmapFont": {
+		"default-font": {
+			"file": "default.fnt"
+		}
+	},
+	"com.badlogic.gdx.graphics.Color": {
+		"green": {
+			"a": 1,
+			"b": 0,
+			"g": 1,
+			"r": 0
+		},
+		"white": {
+			"a": 1,
+			"b": 1,
+			"g": 1,
+			"r": 1
+		},
+		"red": {
+			"a": 1,
+			"b": 0,
+			"g": 0,
+			"r": 1
+		},
+		"black": {
+			"a": 1,
+			"b": 0,
+			"g": 0,
+			"r": 0
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable": {
+		"dialogDim": {
+			"name": "white",
+			"color": {
+				"r": 0,
+				"g": 0,
+				"b": 0,
+				"a": 0.45
+			}
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle": {
+		"default": {
+			"down": "default-round-down",
+			"up": "default-round"
+		},
+		"toggle": {
+			"down": "default-round-down",
+			"checked": "default-round-down",
+			"up": "default-round"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": {
+		"default": {
+			"down": "default-round-down",
+			"up": "default-round",
+			"font": "default-font",
+			"fontColor": "white"
+		},
+		"toggle": {
+			"down": "default-round-down",
+			"up": "default-round",
+			"checked": "default-round-down",
+			"font": "default-font",
+			"fontColor": "white",
+			"downFontColor": "red"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle": {
+		"default": {
+			"vScroll": "default-scroll",
+			"hScrollKnob": "default-round-large",
+			"background": "default-rect",
+			"hScroll": "default-scroll",
+			"vScrollKnob": "default-round-large"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxStyle": {
+		"default": {
+			"font": "default-font",
+			"fontColor": "white",
+			"background": "default-select",
+			"scrollStyle": "default",
+			"listStyle": {
+				"font": "default-font",
+				"selection": "default-select-selection"
+			}
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.SplitPane$SplitPaneStyle": {
+		"default-vertical": {
+			"handle": "default-splitpane-vertical"
+		},
+		"default-horizontal": {
+			"handle": "default-splitpane"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle": {
+		"default": {
+			"titleFont": "default-font",
+			"background": "default-window",
+			"titleFontColor": "white"
+		},
+		"dialog": {
+			"titleFont": "default-font",
+			"background": "default-window",
+			"titleFontColor": "white",
+			"stageBackground": "dialogDim"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.ProgressBar$ProgressBarStyle": {
+		"default-horizontal": {
+			"background": "default-slider",
+			"knob": "default-slider-knob"
+		},
+		"default-vertical": {
+			"background": "default-slider",
+			"knob": "default-round-large"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle": {
+		"default-horizontal": {
+			"background": "default-slider",
+			"knob": "default-slider-knob"
+		},
+		"default-vertical": {
+			"background": "default-slider",
+			"knob": "default-round-large"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle": {
+		"default": {
+			"font": "default-font",
+			"fontColor": "white"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle": {
+		"default": {
+			"selection": "selection",
+			"background": "textfield",
+			"font": "default-font",
+			"fontColor": "white",
+			"cursor": "cursor"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.CheckBox$CheckBoxStyle": {
+		"default": {
+			"checkboxOn": "check-on",
+			"checkboxOff": "check-off",
+			"font": "default-font",
+			"fontColor": "white"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle": {
+		"default": {
+			"fontColorUnselected": "white",
+			"selection": "selection",
+			"fontColorSelected": "white",
+			"font": "default-font"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle": {
+		"default": {
+			"background": "default-pane",
+			"knob": "default-round-large"
+		}
+	},
+	"com.badlogic.gdx.scenes.scene2d.ui.Tree$TreeStyle": {
+		"default": {
+			"minus": "tree-minus",
+			"plus": "tree-plus",
+			"selection": "default-select-selection"
+		}
+	}
+}

          
A => android/assets/uiskin/uiskin.png +0 -0

        
M android/project.properties +1 -1
@@ 11,4 11,4 @@ 
 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
 
 # Project target.
-target=android-19
+target=android-21

          
M core/src/net/dermetfan/jigsawPuzzle/Assets.java +2 -0
@@ 29,6 29,8 @@ public abstract class Assets {
 	/** the parent of the level directories */
 	public static final FileHandle puzzlesDir = Gdx.files.internal("puzzles");
 
+	public static final String uiskin = "uiskin/uiskin.json";
+
 	/** loads all psh files in subdirectories of {@link #puzzlesDir} */
 	public static void loadAllLevels() {
 		for(FileHandle puzzleDir : puzzlesDir.list())

          
M core/src/net/dermetfan/jigsawPuzzle/Constants.java +2 -2
@@ 17,8 17,8 @@ package net.dermetfan.jigsawPuzzle;
 /** @author dermetfan */
 public class Constants {
 
-	public static final boolean debug = false;
+	public static final boolean debug = true;
 
-	public static final float tolerance = 10, puzzleCheckTolerance = .9f, moveBackDuration = .5f;
+	public static final float tolerance = 10, moveBackDuration = .5f;
 
 }

          
M core/src/net/dermetfan/jigsawPuzzle/JigsawPuzzle.java +2 -0
@@ 17,6 17,7 @@ package net.dermetfan.jigsawPuzzle;
 import com.badlogic.gdx.Game;
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.GL20;
+import com.badlogic.gdx.scenes.scene2d.ui.Skin;
 import net.dermetfan.jigsawPuzzle.screens.PlayScreen;
 
 /** entry-point / the actual game

          
@@ 27,6 28,7 @@ public class JigsawPuzzle extends Game {
 	@Override
 	public void create() {
 		Assets.loadAllLevels();
+		Assets.manager.load(Assets.uiskin, Skin.class);
 		Assets.manager.finishLoading();
 		setScreen(new PlayScreen());
 	}

          
A => core/src/net/dermetfan/jigsawPuzzle/puzzle/JigsawPuzzle.java +284 -0
@@ 0,0 1,284 @@ 
+/** Copyright 2014 Robin Stumm (serverkorken@gmail.com, http://dermetfan.net)
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License. */
+
+package net.dermetfan.jigsawPuzzle.puzzle;
+
+import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.scenes.scene2d.Actor;
+import com.badlogic.gdx.scenes.scene2d.Group;
+import com.badlogic.gdx.scenes.scene2d.InputEvent;
+import com.badlogic.gdx.scenes.scene2d.actions.Actions;
+import com.badlogic.gdx.scenes.scene2d.ui.Image;
+import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop;
+import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Payload;
+import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Source;
+import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Target;
+import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
+import com.badlogic.gdx.utils.Pools;
+import com.badlogic.gdx.utils.SnapshotArray;
+import net.dermetfan.jigsawPuzzle.Constants;
+import net.dermetfan.jigsawPuzzle.utils.PolygonRegionDrawable;
+import net.dermetfan.utils.libgdx.math.GeometryUtils;
+import net.dermetfan.utils.libgdx.scene2d.Scene2DUtils;
+
+/** represents a puzzle and manages {@link Piece Pieces}
+ *  @author dermetfan */
+public class JigsawPuzzle {
+
+	private final SnapshotArray<Piece> placedPieces, remainingPieces;
+
+	public JigsawPuzzle() {
+		remainingPieces = new SnapshotArray<Piece>();
+		placedPieces = new SnapshotArray<Piece>();
+	}
+
+	/** @param pieces the amount of pieces that will probably be in this puzzle */
+	public JigsawPuzzle(int pieces) {
+		remainingPieces = new SnapshotArray<Piece>(pieces);
+		placedPieces = new SnapshotArray<Piece>(pieces);
+	}
+
+	/** @param pieces the {@link #remainingPieces remaining pieces} */
+	public JigsawPuzzle(Piece... pieces) {
+		remainingPieces = new SnapshotArray<Piece>(pieces);
+		placedPieces = new SnapshotArray<Piece>(pieces.length);
+	}
+
+	/** Solves the puzzle by {@link #place(Piece) placing} all {@link #remainingPieces remaining pieces}.
+	 *  @param relativeTo the piece relative to which the puzzle should be solved */
+	public void solve(Piece relativeTo) {
+		if(placedPieces.contains(relativeTo, true) || remainingPieces.contains(relativeTo, true))
+			for(Piece piece : remainingPieces) {
+				if(piece == relativeTo)
+					continue;
+				place(piece);
+			}
+		else
+			throw new IllegalArgumentException("the reference piece is not part of the puzzle");
+	}
+
+	/** moves all {@link #placedPieces} to {@link #remainingPieces} */
+	public void unsolve() {
+		remainingPieces.addAll(placedPieces);
+		placedPieces.clear();
+		placedPieces.ensureCapacity(remainingPieces.size); // just for performance
+	}
+
+	/** Places the given piece in its spot on the puzzle. If no piece was {@link #placedPieces placed} yet, it's position is assumed to be correct (hence it will simply be moved to {@link #placedPieces})
+	 *  @param piece the piece to automatically place in its spot on the puzzle */
+	public void place(Piece piece) {
+		if(!remainingPieces.removeValue(piece, true))
+			throw new IllegalArgumentException("the given piece is not remaining and hence cannot be automatically placed");
+		Piece ref = placedPieces.size > 0 ? placedPieces.first() : piece;
+		piece.snap(ref);
+		placedPieces.add(piece);
+	}
+
+	/** @param piece the piece to add to {@link #remainingPieces} */
+	public void addRemaining(Piece piece) {
+		placedPieces.removeValue(piece, true);
+		remainingPieces.add(piece);
+	}
+
+	/** @return if the puzzle is solved */
+	public boolean isSolved() {
+		return remainingPieces.size == 0;
+	}
+
+	/** Checks if the given piece is correctly positioned. Always returns true if no piece was placed yet.
+	 *  @param piece the piece which position to check
+	 *  @param tolerance the distance by which the piece is allowed to be off
+	 *  @return if the given piece is correctly placed in relation to {@link #placedPieces} */
+	public boolean isCorrectlyPlaced(Piece piece, float tolerance) {
+		return placedPieces.size <= 0 || piece.inRelationTo(placedPieces.first(), tolerance);
+	}
+
+	/** usually not necessary, {@link #isSolved()} should return the right result
+	 *  @param tolerance the distance by which each piece is allowed to be off
+	 * 	@return if the {@link #placedPieces} are really correctly placed */
+	public boolean checkPlaced(float tolerance) {
+		Piece reference = placedPieces.first();
+		for(Piece piece : placedPieces)
+			if(!piece.inRelationTo(reference, tolerance))
+				return false;
+		return true;
+	}
+
+	/** @return the {@link #placedPieces} */
+	public Piece[] getPlacedPieces() {
+		placedPieces.end();
+		return placedPieces.begin();
+	}
+
+	/** @return the {@link #remainingPieces} */
+	public Piece[] getRemainingPieces() {
+		remainingPieces.end();
+		return remainingPieces.begin();
+	}
+
+	public void setUp(final Listener listener, final Group bank, final Group board) {
+		final DragAndDrop dnd = new DragAndDrop();
+
+		dnd.addSource(new Source(bank) {
+			Payload payload = new Payload(); // the Payload object we're gonna use (to avoid having to create new ones all the time/GC)
+			Vector2 tmp = new Vector2();
+
+			@Override
+			public Payload dragStart(InputEvent event, float x, float y, int pointer) {
+				Actor actor = getActor().hit(x, y, true); // select actor under the mouse
+				if(actor == bank) // don't drag the board itself
+					return null;
+
+				payload.setDragActor(actor);
+
+				// put the actor in the right position under the mouse
+				bank.localToDescendantCoordinates(actor, tmp.set(x, y));
+				dnd.setDragActorPosition(-tmp.x, -tmp.y + actor.getHeight());
+
+				tmp.set(actor.getX(), actor.getY()); // set tmp for dragStop (the current position, to return to it if it wasn't dragged on the  correctly)
+				return payload;
+			}
+
+			@Override
+			public void dragStop(InputEvent event, float x, float y, int pointer, Payload payload, Target target) {
+				final Actor actor = payload.getDragActor();
+				if(actor.getParent() == null) { // move back to where the piece was dragged from
+					// put it on the stage in the correct position
+					bank.getStage().addActor(actor); // (could use something else instead of bank's stage)
+					bank.localToStageCoordinates(tmp);
+					// move back
+					actor.addAction(Actions.sequence(Actions.moveTo(tmp.x, tmp.y, Constants.moveBackDuration), Actions.run(new Runnable() {
+						@Override
+						public void run() {
+							bank.addActor(actor);
+							// set position correctly on bank
+							bank.stageToLocalCoordinates(tmp);
+							actor.setPosition(tmp.x, tmp.y);
+						}
+					})));
+				}
+			}
+		});
+
+		final Vector2 tmp = new Vector2();
+
+		dnd.addTarget(new Target(bank) { // add bank as target to be able to move pieces on it
+			@Override
+			public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
+				return true; // return if the actor should be shown as accepted while dragging it over the bank
+			}
+
+			@Override
+			public void drop(Source source, Payload payload, float x, float y, int pointer) {
+				Actor dragged = payload.getDragActor();
+				bank.addActor(dragged); // add to bank again
+				// set to new coordinates
+				tmp.set(dragged.getX(), dragged.getY());
+				bank.stageToLocalCoordinates(tmp);
+				dragged.setPosition(tmp.x, tmp.y);
+			}
+		});
+
+		dnd.addTarget(new Target(board) { // add board as target to be able to actually solve the puzzle
+			@Override
+			public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
+				Actor dragged = payload.getDragActor();
+				if(dragged instanceof Piece) {
+					Piece piece = (Piece) dragged;
+					if(isCorrectlyPlaced(piece, Constants.tolerance)) // if the piece is in correct relation to some (in this case the last) piece of the already places pieces, show it would be okay to place it here
+						return true;
+				}
+				return false;
+			}
+
+			@Override
+			public void drop(Source source, Payload payload, float x, float y, int pointer) {
+				Actor dragged = payload.getDragActor();
+				Scene2DUtils.addAtStageCoordinates(dragged, board);
+				if(dragged instanceof Piece) {
+					Piece piece = (Piece) dragged;
+					place(piece); // snap it into its perfect position in relation to some already placed piece
+					if(isSolved() && listener != null)
+						listener.solved(JigsawPuzzle.this);
+				}
+			}
+		});
+	}
+
+	/** a piece on a {@link JigsawPuzzle}
+	 *  @author dermetfan */
+	public static class Piece extends Image {
+
+		/** the position of the piece on the puzzle (the minX and minY of its vertices) */
+		private float slotX, slotY;
+
+		public Piece(PolygonRegionDrawable drawable) {
+			super(drawable);
+		}
+
+		@Override
+		public void setDrawable(Drawable drawable) {
+			super.setDrawable(drawable);
+			if(drawable instanceof PolygonRegionDrawable) {
+				float[] vertices = ((PolygonRegionDrawable) drawable).getRegion().getVertices();
+				slotX = GeometryUtils.minX(vertices);
+				slotY = GeometryUtils.minY(vertices);
+			} else
+				slotX = slotY = 0;
+		}
+
+		/** @param ref the piece in relation to which to snap into this piece's spot */
+		public void snap(Piece ref) {
+			Vector2 refPuzzlePoint = Pools.obtain(Vector2.class).set(ref.getX(), ref.getY()).sub(ref.slotX, ref.slotY);
+			setPosition(refPuzzlePoint.x + slotX, refPuzzlePoint.y + slotY);
+			Pools.free(refPuzzlePoint);
+		}
+
+		/** @param ref the piece in which relation this piece should be
+		 *  @param tolerance the tolerance in the x and y axis
+		 *  @return if this piece is in relation to the given piece with the given tolerance */
+		public boolean inRelationTo(Piece ref, float tolerance) {
+			// get puzzle points (bottom left corner of the puzzle)
+			Vector2 puzzlePoint = Pools.obtain(Vector2.class).set(-slotX, -slotY), refPuzzlePoint = Pools.obtain(Vector2.class).set(-ref.slotX, -ref.slotY);
+			localToStageCoordinates(puzzlePoint);
+			ref.localToStageCoordinates(refPuzzlePoint);
+
+			// see if they're the same
+			boolean rel = puzzlePoint.epsilonEquals(refPuzzlePoint, tolerance);
+
+			Pools.free(puzzlePoint);
+			Pools.free(refPuzzlePoint);
+
+			return rel;
+		}
+
+		/** @return the {@link #slotX} */
+		public float getSlotX() {
+			return slotX;
+		}
+
+		/** @return the {@link #slotY} */
+		public float getSlotY() {
+			return slotY;
+		}
+
+	}
+
+	public static interface Listener {
+
+		void solved(JigsawPuzzle puzzle);
+
+	}
+
+}

          
R core/src/net/dermetfan/jigsawPuzzle/puzzle/Puzzle.java =>  +0 -177
@@ 1,177 0,0 @@ 
-/** Copyright 2014 Robin Stumm (serverkorken@gmail.com, http://dermetfan.net)
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License. */
-
-package net.dermetfan.jigsawPuzzle.puzzle;
-
-import com.badlogic.gdx.math.Vector2;
-import com.badlogic.gdx.scenes.scene2d.ui.Image;
-import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
-import com.badlogic.gdx.utils.Pools;
-import com.badlogic.gdx.utils.SnapshotArray;
-import net.dermetfan.jigsawPuzzle.Constants;
-import net.dermetfan.jigsawPuzzle.utils.PolygonRegionDrawable;
-import net.dermetfan.utils.libgdx.math.GeometryUtils;
-
-/** represents a puzzle and manages {@link Piece Pieces}
- * 	@author dermetfan */
-public class Puzzle {
-
-	/** a piece on a {@link Puzzle}
-	 *  @author dermetfan */
-	public static class Piece extends Image {
-
-		/** the position of the piece on the puzzle (the minX and minY of its vertices) */
-		private float slotX, slotY;
-
-		public Piece(PolygonRegionDrawable drawable) {
-			super(drawable);
-		}
-
-		@Override
-		public void setDrawable(Drawable drawable) {
-			super.setDrawable(drawable);
-			if(drawable instanceof PolygonRegionDrawable) {
-				float[] vertices = ((PolygonRegionDrawable) drawable).getRegion().getVertices();
-				slotX = GeometryUtils.minX(vertices);
-				slotY = GeometryUtils.minY(vertices);
-			} else
-				slotX = slotY = 0;
-		}
-
-		/** @param ref the piece in relation to which to snap into this piece's spot */
-		public void snap(Piece ref) {
-			Vector2 refPuzzlePoint = Pools.obtain(Vector2.class).set(ref.getX(), ref.getY()).sub(ref.slotX, ref.slotY);
-			setPosition(refPuzzlePoint.x + slotX, refPuzzlePoint.y + slotY);
-			Pools.free(refPuzzlePoint);
-		}
-
-		/** @param ref the piece in which relation this piece should be
-		 *  @param tolerance the tolerance in the x and y axis
-		 *  @return if this piece is in relation to the given piece with the given tolerance */
-		public boolean inRelationTo(Piece ref, float tolerance) {
-			// get puzzle points (bottom left corner of the puzzle)
-			Vector2 puzzlePoint = Pools.obtain(Vector2.class).set(getX(), getY()).sub(slotX, slotY), refPuzzlePoint = Pools.obtain(Vector2.class).set(ref.getX(), ref.getY()).sub(ref.slotX, ref.slotY);
-
-			// see if they're the same
-			boolean rel = puzzlePoint.epsilonEquals(refPuzzlePoint, tolerance);
-
-			Pools.free(puzzlePoint);
-			Pools.free(refPuzzlePoint);
-
-			return rel;
-		}
-
-		/** @return the {@link #slotX} */
-		public float getSlotX() {
-			return slotX;
-		}
-
-		/** @return the {@link #slotY} */
-		public float getSlotY() {
-			return slotY;
-		}
-
-	}
-
-	private final SnapshotArray<Piece> placedPieces, remainingPieces;
-
-	public Puzzle() {
-		remainingPieces = new SnapshotArray<Piece>();
-		placedPieces = new SnapshotArray<Piece>();
-	}
-
-	/** @param pieces the amount of pieces that will probably be in this puzzle */
-	public Puzzle(int pieces) {
-		remainingPieces = new SnapshotArray<Piece>(pieces);
-		placedPieces = new SnapshotArray<Piece>(pieces);
-	}
-
-	/** @param pieces the {@link #remainingPieces remaining pieces} */
-	public Puzzle(Piece... pieces) {
-		remainingPieces = new SnapshotArray<Piece>(pieces);
-		placedPieces = new SnapshotArray<Piece>(pieces.length);
-	}
-
-	/** Solves the puzzle by {@link #place(Piece) placing} all {@link #remainingPieces remaining pieces}.
-	 * 	@param relativeTo the piece relative to which the puzzle should be solved */
-	public void solve(Piece relativeTo) {
-		if(placedPieces.contains(relativeTo, true) || remainingPieces.contains(relativeTo, true))
-			for(Piece piece : remainingPieces) {
-				if(piece == relativeTo)
-					continue;
-				place(piece);
-			}
-		else
-			throw new IllegalArgumentException("the reference piece is not part of the puzzle");
-	}
-
-	/** moves all {@link #placedPieces} to {@link #remainingPieces} */
-	public void unsolve() {
-		remainingPieces.addAll(placedPieces);
-		placedPieces.clear();
-		placedPieces.ensureCapacity(remainingPieces.size); // just for performance
-	}
-
-	/** Places the given piece in its spot on the puzzle. If no piece was {@link #placedPieces placed} yet, it's position is assumed to be correct (hence it will simply be moved to {@link #placedPieces})
-	 * 	@param piece the piece to automatically place in its spot on the puzzle */
-	public void place(Piece piece) {
-		if(!remainingPieces.removeValue(piece, true))
-			throw new IllegalArgumentException("the given piece is not remaining and hence cannot be automatically placed");
-		Piece ref = placedPieces.size > 0 ? placedPieces.first() : piece;
-		piece.snap(ref);
-		placedPieces.add(piece);
-	}
-
-	/** @param piece the piece to add to {@link #remainingPieces} */
-	public void addRemaining(Piece piece) {
-		placedPieces.removeValue(piece, true);
-		remainingPieces.add(piece);
-	}
-
-	/** @return if the puzzle is solved */
-	public boolean isSolved() {
-		return remainingPieces.size == 0;
-	}
-
-	/** Checks if the given piece is correctly positioned. Always returns true if no piece was placed yet.
-	 *  @param piece the piece which position to check
-	 *  @param tolerance the distance the piece is allowed to be off
-	 *  @return if the given piece is correctly placed in relation to {@link #placedPieces} */
-	public boolean isCorrectlyPlaced(Piece piece, float tolerance) {
-		return placedPieces.size <= 0 || piece.inRelationTo(placedPieces.first(), tolerance);
-	}
-
-	/** usually not necessary, {@link #isSolved()} should return the right result
-	 * 	@return if the {@link #placedPieces} are really correctly placed */
-	public boolean checkPlaced() {
-		Piece reference = placedPieces.first();
-		for(Piece piece : placedPieces)
-			if(!piece.inRelationTo(reference, Constants.puzzleCheckTolerance))
-				return false;
-		return true;
-	}
-
-	/** @return the {@link #placedPieces} */
-	public Piece[] getPlacedPieces() {
-		placedPieces.end();
-		return placedPieces.begin();
-	}
-
-	/** @return the {@link #remainingPieces} */
-	public Piece[] getRemainingPieces() {
-		remainingPieces.end();
-		return remainingPieces.begin();
-	}
-
-}

          
M core/src/net/dermetfan/jigsawPuzzle/screens/PlayScreen.java +34 -127
@@ 24,26 24,20 @@ import com.badlogic.gdx.files.FileHandle
 import com.badlogic.gdx.graphics.g2d.Batch;
 import com.badlogic.gdx.graphics.g2d.PolygonRegion;
 import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
-import com.badlogic.gdx.math.Vector2;
-import com.badlogic.gdx.scenes.scene2d.Actor;
-import com.badlogic.gdx.scenes.scene2d.InputEvent;
 import com.badlogic.gdx.scenes.scene2d.Stage;
-import com.badlogic.gdx.scenes.scene2d.actions.Actions;
+import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
+import com.badlogic.gdx.scenes.scene2d.ui.Skin;
 import com.badlogic.gdx.scenes.scene2d.ui.Table;
-import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop;
-import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Payload;
-import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Source;
-import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Target;
 import com.badlogic.gdx.utils.viewport.ScreenViewport;
 import net.dermetfan.jigsawPuzzle.Assets;
 import net.dermetfan.jigsawPuzzle.Constants;
-import net.dermetfan.jigsawPuzzle.puzzle.Puzzle;
-import net.dermetfan.jigsawPuzzle.puzzle.Puzzle.Piece;
+import net.dermetfan.jigsawPuzzle.puzzle.JigsawPuzzle;
+import net.dermetfan.jigsawPuzzle.puzzle.JigsawPuzzle.Listener;
+import net.dermetfan.jigsawPuzzle.puzzle.JigsawPuzzle.Piece;
 import net.dermetfan.jigsawPuzzle.utils.Board;
 import net.dermetfan.jigsawPuzzle.utils.PolygonRegionDrawable;
-import net.dermetfan.utils.libgdx.scene2d.Scene2DUtils;
 
-/**	a UI for a {@link Puzzle}
+/**	a UI for a {@link JigsawPuzzle}
  * 	@author dermetfan */
 public class PlayScreen extends ScreenAdapter {
 

          
@@ 104,132 98,45 @@ public class PlayScreen extends ScreenAd
 		table.setFillParent(true); // make table fill the whole stage
 		stage.addActor(table);
 
-		{ // all the puzzle stuff
-			final Puzzle puzzle = new Puzzle();
-
-			final Board dragBoard = new Board(); // the board that pieces will be dragged from
-			for(FileHandle psh : Assets.puzzlePSHs(level)) { // set up the pieces on the drag board
-				Piece piece = new Piece(new PolygonRegionDrawable(Assets.manager.get(psh.path(), PolygonRegion.class)));
-				dragBoard.addActor(piece);
-				piece.setY(dragBoard.getHeight());
-				dragBoard.pack();
-				puzzle.addRemaining(piece);
-			}
+		// dialog to contain the puzzle
+		final Dialog dialog = new Dialog(level, Assets.manager.get(Assets.uiskin, Skin.class));
+		dialog.setModal(false);
+		dialog.setResizable(true);
 
-			final Board dropBoard = new Board(); // the board pieces will be dropped on
-
-			table.add(dropBoard).expand().fill().left();
-			table.add(dragBoard).expandY().fill().right();
+		final JigsawPuzzle puzzle = new JigsawPuzzle();
+		final Board bank = new Board(); // the board that pieces will be dragged from
+		final Board board = new Board(); // the board pieces will be dropped on
+		for(FileHandle psh : Assets.puzzlePSHs(level)) { // set up the pieces on the bank
+			Piece piece = new Piece(new PolygonRegionDrawable(Assets.manager.get(psh.path(), PolygonRegion.class)));
+			bank.addActor(piece);
+			piece.setX(bank.getWidth());
+			bank.pack();
+			puzzle.addRemaining(piece);
+		}
 
-			{ // drag and drop
-				final DragAndDrop dnd = new DragAndDrop();
-
-				dnd.addSource(new Source(dragBoard) {
-
-					Payload payload = new Payload(); // the Payload object we're gonna use (to avoid having to create new ones all the time/GC)
-					Vector2 tmp = new Vector2();
+		puzzle.setUp(new Listener() {
+			@Override
+			public void solved(JigsawPuzzle puzzle) {
+				Gdx.input.getTextInput(new TextInputListener() { // temporary solution
 
 					@Override
-					public Payload dragStart(InputEvent event, float x, float y, int pointer) {
-						Actor actor = getActor().hit(x, y, true); // select actor under the mouse
-						if(actor == dragBoard) // don't drag the board itself
-							return null;
-
-						payload.setDragActor(actor);
-
-						// put the actor in the right position under the mouse
-						dragBoard.localToDescendantCoordinates(actor, tmp.set(x, y));
-						dnd.setDragActorPosition(-tmp.x, -tmp.y + actor.getHeight());
-
-						tmp.set(actor.getX(), actor.getY()); // set tmp for dragStop (the current position, to return to it if it wasn't dragged on the dropBoard correctly)
-						return payload;
+					public void input(String level) {
+						initUI(level);
 					}
 
 					@Override
-					public void dragStop(InputEvent event, float x, float y, int pointer, Payload payload, Target target) {
-						final Actor actor = payload.getDragActor();
-						if(actor.getParent() == null) { // move back to where the piece was dragged from
-							// put it on the stage in the correct position
-							stage.addActor(actor);
-							dragBoard.localToStageCoordinates(tmp);
-							// move back
-							actor.addAction(Actions.sequence(Actions.moveTo(tmp.x, tmp.y, Constants.moveBackDuration), Actions.run(new Runnable() {
-
-								@Override
-								public void run() {
-									dragBoard.addActor(actor);
-									// set position correctly on dragBoard
-									dragBoard.stageToLocalCoordinates(tmp);
-									actor.setPosition(tmp.x, tmp.y);
-								}
-
-							})));
-						}
-					}
-
-				});
-
-				final Vector2 tmp = new Vector2();
-
-				dnd.addTarget(new Target(dragBoard) { // add dragBoard as target to be able to move pieces on it
-
-					@Override
-					public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
-						return true; // return if the actor should be shown as accepted while dragging it over the dragBoard
-					}
-
-					@Override
-					public void drop(Source source, Payload payload, float x, float y, int pointer) {
-						Actor dragged = payload.getDragActor();
-						dragBoard.addActor(dragged); // add to dragBoard again
-						// set to new coordinates
-						tmp.set(dragged.getX(), dragged.getY());
-						dragBoard.stageToLocalCoordinates(tmp);
-						dragged.setPosition(tmp.x, tmp.y);
+					public void canceled() {
+						Gdx.app.exit();
 					}
 
-				});
-
-				dnd.addTarget(new Target(dropBoard) { // add dropBoard as target to be able to actually solve the puzzle
-
-					@Override
-					public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
-						Actor dragged = payload.getDragActor();
-						if(dragged instanceof Piece) {
-							Piece piece = (Piece) dragged;
-							if(puzzle.isCorrectlyPlaced(piece, Constants.tolerance)) // if the piece is in correct relation to some (in this case the last) piece of the already places pieces, show it would be okay to place it here
-								return true;
-						}
-						return false;
-					}
+				}, "Puzzle solved!", "Play again? Enter level name");
+			}
+		}, bank, board);
 
-					@Override
-					public void drop(Source source, Payload payload, float x, float y, int pointer) {
-						Actor dragged = payload.getDragActor();
-						Scene2DUtils.addAtStageCoordinates(dragged, dropBoard);
-						if(dragged instanceof Piece) {
-							Piece piece = (Piece) dragged;
-							puzzle.place(piece); // snap it into it's perfect position in relation to some already placed piece
-							if(puzzle.isSolved())
-								Gdx.input.getTextInput(new TextInputListener() { // temporary solution
+		dialog.getContentTable().add(board).expand().fill().minSize(bank.getWidth(), bank.getHeight()).row();
+		dialog.getContentTable().add(bank).expand().fill();
 
-									@Override
-									public void input(String level) {
-										initUI(level);
-									}
-
-									@Override
-									public void canceled() {
-										Gdx.app.exit();
-									}
-
-								}, "Puzzle solved!", "Play again? Enter level name");
-						}
-					}
-
-				});
-			}
-		}
+		dialog.show(stage);
 	}
 
 	@Override